From 69949eef319e1f919a32eb366c8f95aaea719b97 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Mon, 21 Sep 2015 09:21:29 -0700 Subject: [PATCH 1/7] Compute app name based on productName & channel --- build/Gruntfile.coffee | 13 +++++++------ build/tasks/install-task.coffee | 10 ++++++---- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/build/Gruntfile.coffee b/build/Gruntfile.coffee index abbb433ca..b841bcdbb 100644 --- a/build/Gruntfile.coffee +++ b/build/Gruntfile.coffee @@ -31,16 +31,17 @@ module.exports = (grunt) -> # This allows all subsequent paths to the relative to the root of the repo grunt.file.setBase(path.resolve('..')) - tmpDir = os.tmpdir() - appName = if process.platform is 'darwin' then 'Atom.app' else 'Atom' - buildDir = grunt.option('build-dir') ? path.join(tmpDir, 'atom-build') - buildDir = path.resolve(buildDir) - installDir = grunt.option('install-dir') - channel = grunt.option('channel') channel ?= process.env.JANKY_BRANCH if process.env.JANKY_BRANCH in ['stable', 'beta'] channel ?= 'dev' + appName = packageJson.productName + appName += ' Beta' if channel is 'beta' + appName += '.app' if process.platform is 'darwin' + buildDir = grunt.option('build-dir') ? path.join(os.tmpdir(), 'atom-build') + buildDir = path.resolve(buildDir) + installDir = grunt.option('install-dir') + home = if process.platform is 'win32' then process.env.USERPROFILE else process.env.HOME electronDownloadDir = path.join(home, '.atom', 'electron') diff --git a/build/tasks/install-task.coffee b/build/tasks/install-task.coffee index 86a827a1b..a84eb58fb 100644 --- a/build/tasks/install-task.coffee +++ b/build/tasks/install-task.coffee @@ -10,6 +10,7 @@ module.exports = (grunt) -> grunt.registerTask 'install', 'Install the built application', -> installDir = grunt.config.get('atom.installDir') shellAppDir = grunt.config.get('atom.shellAppDir') + appName = grunt.config.get('atom.appName') if process.platform is 'win32' runas ?= require 'runas' @@ -18,7 +19,7 @@ module.exports = (grunt) -> grunt.log.error("Failed to copy #{shellAppDir} to #{installDir}") createShortcut = path.resolve 'script', 'create-shortcut.cmd' - runas('cmd', ['/c', createShortcut, path.join(installDir, 'atom.exe'), 'Atom']) + runas('cmd', ['/c', createShortcut, path.join(installDir, 'atom.exe'), appName]) else if process.platform is 'darwin' rm installDir mkdir path.dirname(installDir) @@ -29,7 +30,8 @@ module.exports = (grunt) -> fs.renameSync(tempFolder, installDir) else binDir = path.join(installDir, 'bin') - shareDir = path.join(installDir, 'share', 'atom') + appDirName = appName.toLowerCase().replace(/\s+/g, '-') + shareDir = path.join(installDir, 'share', appDirName) mkdir binDir cp 'atom.sh', path.join(binDir, 'atom') @@ -41,7 +43,7 @@ module.exports = (grunt) -> tmpDir = if process.env.TMPDIR? then process.env.TMPDIR else '/tmp' if installDir.indexOf(tmpDir) isnt 0 desktopFile = path.join('resources', 'linux', 'atom.desktop.in') - desktopInstallFile = path.join(installDir, 'share', 'applications', 'atom.desktop') + desktopInstallFile = path.join(installDir, 'share', 'applications', appDirName + '.desktop') {description} = grunt.file.readJSON('package.json') iconName = path.join(shareDir, 'resources', 'app.asar.unpacked', 'resources', 'atom.png') @@ -54,6 +56,6 @@ module.exports = (grunt) -> # Create relative symbol link for apm. process.chdir(binDir) rm('apm') - fs.symlinkSync(path.join('..', 'share', 'atom', 'resources', 'app', 'apm', 'node_modules', '.bin', 'apm'), 'apm') + fs.symlinkSync(path.join('..', 'share', appDirName, 'resources', 'app', 'apm', 'node_modules', '.bin', 'apm'), 'apm') fs.chmodSync(path.join(shareDir, 'atom'), "755") From a9531fc4dd051ed51310877d28bef26714f541b6 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Mon, 21 Sep 2015 10:04:01 -0700 Subject: [PATCH 2/7] Install atom command as 'atom-beta' when using beta version --- spec/command-installer-spec.coffee | 78 +++++++++++++++++++++--------- src/atom.coffee | 6 ++- src/command-installer.coffee | 22 ++++++--- src/workspace.coffee | 4 +- 4 files changed, 78 insertions(+), 32 deletions(-) diff --git a/spec/command-installer-spec.coffee b/spec/command-installer-spec.coffee index b87a08edc..e63bfb82c 100644 --- a/spec/command-installer-spec.coffee +++ b/spec/command-installer-spec.coffee @@ -1,34 +1,66 @@ path = require 'path' fs = require 'fs-plus' temp = require 'temp' -installer = require '../src/command-installer' +CommandInstaller = require '../src/command-installer' -describe "install(commandPath, callback)", -> - commandFilePath = temp.openSync("atom-command").path - commandName = path.basename(commandFilePath) - installationPath = temp.mkdirSync("atom-bin") - installationFilePath = path.join(installationPath, commandName) +describe "CommandInstaller on #darwin", -> + [resourcesPath, installationPath, atomBinPath, apmBinPath] = [] beforeEach -> - fs.chmodSync(commandFilePath, '755') - spyOn(installer, 'getInstallDirectory').andReturn installationPath + installationPath = temp.mkdirSync("atom-bin") - describe "on #darwin", -> - it "symlinks the command and makes it executable", -> - expect(fs.isFileSync(commandFilePath)).toBeTruthy() - expect(fs.isFileSync(installationFilePath)).toBeFalsy() + resourcesPath = temp.mkdirSync('atom-app') + atomBinPath = path.join(resourcesPath, 'app', 'atom.sh') + apmBinPath = path.join(resourcesPath, 'app', 'apm', 'node_modules', '.bin', 'apm') + fs.writeFileSync(atomBinPath, "") + fs.writeFileSync(apmBinPath, "") + fs.chmodSync(atomBinPath, '755') + fs.chmodSync(apmBinPath, '755') - installDone = false - installError = null - installer.createSymlink commandFilePath, false, (error) -> - installDone = true - installError = error + spyOn(CommandInstaller::, 'getResourcesDirectory').andReturn(resourcesPath) + spyOn(CommandInstaller::, 'getInstallDirectory').andReturn(installationPath) - waitsFor -> - installDone + describe "installApmCommand(callback)", -> + it "symlinks the apm command and makes it executable", -> + installer = new CommandInstaller("2.0.2") + installedApmPath = path.join(installationPath, 'apm') + + expect(fs.isFileSync(installedApmPath)).toBeFalsy() + + waitsFor (done) -> + installer.installApmCommand(false, done) runs -> - expect(installError).toBeNull() - expect(fs.isFileSync(installationFilePath)).toBeTruthy() - expect(fs.realpathSync(installationFilePath)).toBe fs.realpathSync(commandFilePath) - expect(fs.isExecutableSync(installationFilePath)).toBeTruthy() + expect(fs.realpathSync(installedApmPath)).toBe fs.realpathSync(apmBinPath) + expect(fs.isExecutableSync(installedApmPath)).toBeTruthy() + + describe "installAtomCommand(askForPrivilege, callback)", -> + describe "when using a stable version of atom", -> + it "installs the atom command as 'atom'", -> + installer = new CommandInstaller("2.0.2") + installedAtomPath = path.join(installationPath, 'atom') + + expect(fs.isFileSync(installedAtomPath)).toBeFalsy() + + waitsFor (done) -> + installer.installAtomCommand(false, done) + + runs -> + expect(fs.realpathSync(installedAtomPath)).toBe fs.realpathSync(atomBinPath) + expect(fs.isExecutableSync(installedAtomPath)).toBe true + expect(fs.isFileSync(path.join(installationPath, 'atom-beta'))).toBe false + + describe "when using a beta version of atom", -> + it "installs the atom command as 'atom-beta'", -> + installer = new CommandInstaller("2.2.0-beta.0") + installedAtomPath = path.join(installationPath, 'atom-beta') + + expect(fs.isFileSync(installedAtomPath)).toBeFalsy() + + waitsFor (done) -> + installer.installAtomCommand(false, done) + + runs -> + expect(fs.realpathSync(installedAtomPath)).toBe fs.realpathSync(atomBinPath) + expect(fs.isExecutableSync(installedAtomPath)).toBe true + expect(fs.isFileSync(path.join(installationPath, 'atom'))).toBe false diff --git a/src/atom.coffee b/src/atom.coffee index 23c9c2cec..59d7765ac 100644 --- a/src/atom.coffee +++ b/src/atom.coffee @@ -573,9 +573,11 @@ class Atom extends Model {safeMode} = @getLoadSettings() CommandInstaller = require './command-installer' - CommandInstaller.installAtomCommand false, (error) -> + + commandInstaller = new CommandInstaller(@getVersion()) + commandInstaller.installAtomCommand false, (error) -> console.warn error.message if error? - CommandInstaller.installApmCommand false, (error) -> + commandInstaller.installApmCommand false, (error) -> console.warn error.message if error? @loadConfig() diff --git a/src/command-installer.coffee b/src/command-installer.coffee index 4a0e52bd8..3b4775fe1 100644 --- a/src/command-installer.coffee +++ b/src/command-installer.coffee @@ -25,9 +25,15 @@ symlinkCommandWithPrivilegeSync = (sourcePath, destinationPath) -> throw new Error("Failed to symlink '#{sourcePath}' to '#{destinationPath}'") module.exports = +class CommandInstaller + constructor: (@appVersion) -> + getInstallDirectory: -> "/usr/local/bin" + getResourcesDirectory: -> + process.resourcesPath + installShellCommandsInteractively: -> showErrorDialog = (error) -> atom.confirm @@ -47,17 +53,21 @@ module.exports = detailedMessage: "The shell commands `atom` and `apm` are installed." installAtomCommand: (askForPrivilege, callback) -> - commandPath = path.join(process.resourcesPath, 'app', 'atom.sh') - @createSymlink commandPath, askForPrivilege, callback + launcherName = if @appVersion.includes("beta") + "atom-beta" + else + "atom" + + commandPath = path.join(@getResourcesDirectory(), 'app', 'atom.sh') + @createSymlink commandPath, launcherName, askForPrivilege, callback installApmCommand: (askForPrivilege, callback) -> - commandPath = path.join(process.resourcesPath, 'app', 'apm', 'node_modules', '.bin', 'apm') - @createSymlink commandPath, askForPrivilege, callback + commandPath = path.join(@getResourcesDirectory(), 'app', 'apm', 'node_modules', '.bin', 'apm') + @createSymlink commandPath, 'apm', askForPrivilege, callback - createSymlink: (commandPath, askForPrivilege, callback) -> + createSymlink: (commandPath, commandName, askForPrivilege, callback) -> return unless process.platform is 'darwin' - commandName = path.basename(commandPath, path.extname(commandPath)) destinationPath = path.join(@getInstallDirectory(), commandName) fs.readlink destinationPath, (error, realpath) -> diff --git a/src/workspace.coffee b/src/workspace.coffee index 8e15a950e..bda6e9b45 100644 --- a/src/workspace.coffee +++ b/src/workspace.coffee @@ -119,7 +119,9 @@ class Workspace extends Model editorAdded: (editor) -> installShellCommands: -> - require('./command-installer').installShellCommandsInteractively() + CommandInstaller = require('./command-installer') + commandInstaller = new CommandInstaller(atom.getVersion()) + commandInstaller.installShellCommandsInteractively() subscribeToActiveItem: -> @updateWindowTitle() From b944061eb6cf833e4aee71af9d079a0915aaff10 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Mon, 21 Sep 2015 10:38:36 -0700 Subject: [PATCH 3/7] Use beta version when shell script is launched as 'atom-beta' --- atom.sh | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/atom.sh b/atom.sh index ecd7da052..6976cd649 100755 --- a/atom.sh +++ b/atom.sh @@ -11,6 +11,12 @@ else exit 1 fi +if [ "$(basename $0)" == 'atom-beta' ]; then + BETA_VERSION=true +else + BETA_VERSION= +fi + while getopts ":wtfvh-:" opt; do case "$opt" in -) @@ -45,7 +51,11 @@ if [ $REDIRECT_STDERR ]; then fi if [ $OS == 'Mac' ]; then - ATOM_APP_NAME=Atom.app + if [ -n "$BETA_VERSION" ]; then + ATOM_APP_NAME="Atom Beta.app" + else + ATOM_APP_NAME="Atom.app" + fi if [ -z "${ATOM_PATH}" ]; then # If ATOM_PATH isnt set, check /Applications and then ~/Applications for Atom.app @@ -74,9 +84,14 @@ if [ $OS == 'Mac' ]; then elif [ $OS == 'Linux' ]; then SCRIPT=$(readlink -f "$0") USR_DIRECTORY=$(readlink -f $(dirname $SCRIPT)/..) - ATOM_PATH="$USR_DIRECTORY/share/atom/atom" - ATOM_HOME="${ATOM_HOME:-$HOME/.atom}" + if [ -n "$BETA_VERSION" ]; then + ATOM_PATH="$USR_DIRECTORY/share/atom-beta/atom" + else + ATOM_PATH="$USR_DIRECTORY/share/atom/atom " + fi + + ATOM_HOME="${ATOM_HOME:-$HOME/.atom}" mkdir -p "$ATOM_HOME" : ${TMPDIR:=/tmp} From 1102a9687b25185508afd8f2c895e34c0c9fad0f Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Mon, 21 Sep 2015 10:59:36 -0700 Subject: [PATCH 4/7] Install beta atom shell script as /bin/atom-beta on linux --- build/tasks/install-task.coffee | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/build/tasks/install-task.coffee b/build/tasks/install-task.coffee index a84eb58fb..93bb04e66 100644 --- a/build/tasks/install-task.coffee +++ b/build/tasks/install-task.coffee @@ -30,11 +30,11 @@ module.exports = (grunt) -> fs.renameSync(tempFolder, installDir) else binDir = path.join(installDir, 'bin') - appDirName = appName.toLowerCase().replace(/\s+/g, '-') - shareDir = path.join(installDir, 'share', appDirName) + appFileName = appName.toLowerCase().replace(/\s+/g, '-') + shareDir = path.join(installDir, 'share', appFileName) mkdir binDir - cp 'atom.sh', path.join(binDir, 'atom') + cp 'atom.sh', path.join(binDir, appFileName) rm shareDir mkdir path.dirname(shareDir) cp shellAppDir, shareDir @@ -43,7 +43,7 @@ module.exports = (grunt) -> tmpDir = if process.env.TMPDIR? then process.env.TMPDIR else '/tmp' if installDir.indexOf(tmpDir) isnt 0 desktopFile = path.join('resources', 'linux', 'atom.desktop.in') - desktopInstallFile = path.join(installDir, 'share', 'applications', appDirName + '.desktop') + desktopInstallFile = path.join(installDir, 'share', 'applications', appFileName + '.desktop') {description} = grunt.file.readJSON('package.json') iconName = path.join(shareDir, 'resources', 'app.asar.unpacked', 'resources', 'atom.png') @@ -56,6 +56,6 @@ module.exports = (grunt) -> # Create relative symbol link for apm. process.chdir(binDir) rm('apm') - fs.symlinkSync(path.join('..', 'share', appDirName, 'resources', 'app', 'apm', 'node_modules', '.bin', 'apm'), 'apm') + fs.symlinkSync(path.join('..', 'share', appFileName, 'resources', 'app', 'apm', 'node_modules', '.bin', 'apm'), 'apm') fs.chmodSync(path.join(shareDir, 'atom'), "755") From cd31f9506a94deb9f642567fa71be1686e3494f6 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Mon, 21 Sep 2015 15:32:14 -0700 Subject: [PATCH 5/7] Install apm as apm-beta in beta version --- spec/command-installer-spec.coffee | 67 ++++++++++++++++++------------ src/command-installer.coffee | 11 +++-- 2 files changed, 49 insertions(+), 29 deletions(-) diff --git a/spec/command-installer-spec.coffee b/spec/command-installer-spec.coffee index e63bfb82c..972494ec3 100644 --- a/spec/command-installer-spec.coffee +++ b/spec/command-installer-spec.coffee @@ -4,7 +4,7 @@ temp = require 'temp' CommandInstaller = require '../src/command-installer' describe "CommandInstaller on #darwin", -> - [resourcesPath, installationPath, atomBinPath, apmBinPath] = [] + [installer, resourcesPath, installationPath, atomBinPath, apmBinPath] = [] beforeEach -> installationPath = temp.mkdirSync("atom-bin") @@ -20,9 +20,24 @@ describe "CommandInstaller on #darwin", -> spyOn(CommandInstaller::, 'getResourcesDirectory').andReturn(resourcesPath) spyOn(CommandInstaller::, 'getInstallDirectory').andReturn(installationPath) - describe "installApmCommand(callback)", -> - it "symlinks the apm command and makes it executable", -> + describe "when using a stable version of atom", -> + beforeEach -> installer = new CommandInstaller("2.0.2") + + it "symlinks the atom command as 'atom'", -> + installedAtomPath = path.join(installationPath, 'atom') + + expect(fs.isFileSync(installedAtomPath)).toBeFalsy() + + waitsFor (done) -> + installer.installAtomCommand(false, done) + + runs -> + expect(fs.realpathSync(installedAtomPath)).toBe fs.realpathSync(atomBinPath) + expect(fs.isExecutableSync(installedAtomPath)).toBe true + expect(fs.isFileSync(path.join(installationPath, 'atom-beta'))).toBe false + + it "symlinks the apm command as 'apm'", -> installedApmPath = path.join(installationPath, 'apm') expect(fs.isFileSync(installedApmPath)).toBeFalsy() @@ -33,34 +48,34 @@ describe "CommandInstaller on #darwin", -> runs -> expect(fs.realpathSync(installedApmPath)).toBe fs.realpathSync(apmBinPath) expect(fs.isExecutableSync(installedApmPath)).toBeTruthy() + expect(fs.isFileSync(path.join(installationPath, 'apm-beta'))).toBe false - describe "installAtomCommand(askForPrivilege, callback)", -> - describe "when using a stable version of atom", -> - it "installs the atom command as 'atom'", -> - installer = new CommandInstaller("2.0.2") - installedAtomPath = path.join(installationPath, 'atom') + describe "when using a beta version of atom", -> + beforeEach -> + installer = new CommandInstaller("2.2.0-beta.0") - expect(fs.isFileSync(installedAtomPath)).toBeFalsy() + it "symlinks the atom command as 'atom-beta'", -> + installedAtomPath = path.join(installationPath, 'atom-beta') - waitsFor (done) -> - installer.installAtomCommand(false, done) + expect(fs.isFileSync(installedAtomPath)).toBeFalsy() - runs -> - expect(fs.realpathSync(installedAtomPath)).toBe fs.realpathSync(atomBinPath) - expect(fs.isExecutableSync(installedAtomPath)).toBe true - expect(fs.isFileSync(path.join(installationPath, 'atom-beta'))).toBe false + waitsFor (done) -> + installer.installAtomCommand(false, done) - describe "when using a beta version of atom", -> - it "installs the atom command as 'atom-beta'", -> - installer = new CommandInstaller("2.2.0-beta.0") - installedAtomPath = path.join(installationPath, 'atom-beta') + runs -> + expect(fs.realpathSync(installedAtomPath)).toBe fs.realpathSync(atomBinPath) + expect(fs.isExecutableSync(installedAtomPath)).toBe true + expect(fs.isFileSync(path.join(installationPath, 'atom'))).toBe false - expect(fs.isFileSync(installedAtomPath)).toBeFalsy() + it "symlinks the apm command as 'apm-beta'", -> + installedApmPath = path.join(installationPath, 'apm-beta') - waitsFor (done) -> - installer.installAtomCommand(false, done) + expect(fs.isFileSync(installedApmPath)).toBeFalsy() - runs -> - expect(fs.realpathSync(installedAtomPath)).toBe fs.realpathSync(atomBinPath) - expect(fs.isExecutableSync(installedAtomPath)).toBe true - expect(fs.isFileSync(path.join(installationPath, 'atom'))).toBe false + waitsFor (done) -> + installer.installApmCommand(false, done) + + runs -> + expect(fs.realpathSync(installedApmPath)).toBe fs.realpathSync(apmBinPath) + expect(fs.isExecutableSync(installedApmPath)).toBeTruthy() + expect(fs.isFileSync(path.join(installationPath, 'apm'))).toBe false diff --git a/src/command-installer.coffee b/src/command-installer.coffee index 3b4775fe1..729aef84c 100644 --- a/src/command-installer.coffee +++ b/src/command-installer.coffee @@ -53,17 +53,22 @@ class CommandInstaller detailedMessage: "The shell commands `atom` and `apm` are installed." installAtomCommand: (askForPrivilege, callback) -> - launcherName = if @appVersion.includes("beta") + programName = if @appVersion.includes("beta") "atom-beta" else "atom" commandPath = path.join(@getResourcesDirectory(), 'app', 'atom.sh') - @createSymlink commandPath, launcherName, askForPrivilege, callback + @createSymlink commandPath, programName, askForPrivilege, callback installApmCommand: (askForPrivilege, callback) -> + programName = if @appVersion.includes("beta") + "apm-beta" + else + "apm" + commandPath = path.join(@getResourcesDirectory(), 'app', 'apm', 'node_modules', '.bin', 'apm') - @createSymlink commandPath, 'apm', askForPrivilege, callback + @createSymlink commandPath, programName, askForPrivilege, callback createSymlink: (commandPath, commandName, askForPrivilege, callback) -> return unless process.platform is 'darwin' From 3c48af049d2b1f8fede123166beb319eb701e14e Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Mon, 21 Sep 2015 17:48:16 -0700 Subject: [PATCH 6/7] Name files correctly for beta in debian and rpm packages --- build/Gruntfile.coffee | 39 +++++++++++------ build/tasks/install-task.coffee | 47 ++++++++++---------- build/tasks/mkdeb-task.coffee | 67 ++++++++++++++++------------- build/tasks/mkrpm-task.coffee | 44 +++++++++---------- build/tasks/task-helpers.coffee | 5 +++ resources/linux/atom.desktop.in | 6 +-- resources/linux/debian/control.in | 6 +-- resources/linux/redhat/atom.spec.in | 34 +++++++-------- script/mkdeb | 30 +++++++------ script/mkrpm | 24 ++++++----- 10 files changed, 163 insertions(+), 139 deletions(-) diff --git a/build/Gruntfile.coffee b/build/Gruntfile.coffee index b841bcdbb..630d05815 100644 --- a/build/Gruntfile.coffee +++ b/build/Gruntfile.coffee @@ -31,39 +31,50 @@ module.exports = (grunt) -> # This allows all subsequent paths to the relative to the root of the repo grunt.file.setBase(path.resolve('..')) + # Options + installDir = grunt.option('install-dir') + buildDir = grunt.option('build-dir') + buildDir ?= path.join(os.tmpdir(), 'atom-build') + buildDir = path.resolve(buildDir) channel = grunt.option('channel') channel ?= process.env.JANKY_BRANCH if process.env.JANKY_BRANCH in ['stable', 'beta'] channel ?= 'dev' + metadata = packageJson appName = packageJson.productName - appName += ' Beta' if channel is 'beta' - appName += '.app' if process.platform is 'darwin' - buildDir = grunt.option('build-dir') ? path.join(os.tmpdir(), 'atom-build') - buildDir = path.resolve(buildDir) - installDir = grunt.option('install-dir') + appFileName = packageJson.name + apmFileName = 'apm' - home = if process.platform is 'win32' then process.env.USERPROFILE else process.env.HOME - electronDownloadDir = path.join(home, '.atom', 'electron') + if channel is 'beta' + appName += ' Beta' + appFileName += '-beta' + apmFileName += '-beta' - symbolsDir = path.join(buildDir, 'Atom.breakpad.syms') shellAppDir = path.join(buildDir, appName) + symbolsDir = path.join(buildDir, 'Atom.breakpad.syms') + if process.platform is 'win32' + homeDir = process.env.USERPROFILE contentsDir = shellAppDir appDir = path.join(shellAppDir, 'resources', 'app') installDir ?= path.join(process.env.ProgramFiles, appName) killCommand = 'taskkill /F /IM atom.exe' else if process.platform is 'darwin' + homeDir = process.env.HOME + appName += '.app' contentsDir = path.join(shellAppDir, 'Contents') appDir = path.join(contentsDir, 'Resources', 'app') installDir ?= path.join('/Applications', appName) killCommand = 'pkill -9 Atom' else + homeDir = process.env.HOME contentsDir = shellAppDir appDir = path.join(shellAppDir, 'resources', 'app') installDir ?= process.env.INSTALL_PREFIX ? '/usr/local' killCommand ='pkill -9 atom' installDir = path.resolve(installDir) + electronDownloadDir = path.join(homeDir, '.atom', 'electron') coffeeConfig = glob_to_multiple: @@ -105,7 +116,7 @@ module.exports = (grunt) -> csonConfig = options: rootObject: true - cachePath: path.join(home, '.atom', 'compile-cache', 'grunt-cson') + cachePath: path.join(homeDir, '.atom', 'compile-cache', 'grunt-cson') glob_to_multiple: expand: true @@ -156,7 +167,11 @@ module.exports = (grunt) -> grunt.initConfig pkg: grunt.file.readJSON('package.json') - atom: {appDir, appName, symbolsDir, buildDir, contentsDir, installDir, shellAppDir, channel} + atom: { + appName, channel, metadata, + appFileName, apmFileName, + appDir, buildDir, contentsDir, installDir, shellAppDir, symbolsDir, + } docsOutputDir: 'docs/output' @@ -237,8 +252,8 @@ module.exports = (grunt) -> outputDirectory: path.join(buildDir, 'installer') authors: 'GitHub Inc.' loadingGif: path.resolve(__dirname, '..', 'resources', 'win', 'loading.gif') - iconUrl: 'https://raw.githubusercontent.com/atom/atom/master/resources/app-icons/stable/atom.ico' - setupIcon: path.resolve(__dirname, '..', 'resources', 'app-icons', 'stable', 'atom.ico') + iconUrl: "https://raw.githubusercontent.com/atom/atom/master/resources/app-icons/#{channel}/atom.ico" + setupIcon: path.resolve(__dirname, '..', 'resources', 'app-icons', channel, 'atom.ico') remoteReleases: 'https://atom.io/api/updates' shell: diff --git a/build/tasks/install-task.coffee b/build/tasks/install-task.coffee index 93bb04e66..54fd06022 100644 --- a/build/tasks/install-task.coffee +++ b/build/tasks/install-task.coffee @@ -1,16 +1,19 @@ path = require 'path' -_ = require 'underscore-plus' fs = require 'fs-plus' runas = null temp = require 'temp' module.exports = (grunt) -> - {cp, mkdir, rm} = require('./task-helpers')(grunt) + {cp, fillTemplate, mkdir, rm} = require('./task-helpers')(grunt) grunt.registerTask 'install', 'Install the built application', -> + appName = grunt.config.get('atom.appName') + appFileName = grunt.config.get('atom.appFileName') + apmFileName = grunt.config.get('atom.apmFileName') + buildDir = grunt.config.get('atom.buildDir') installDir = grunt.config.get('atom.installDir') shellAppDir = grunt.config.get('atom.shellAppDir') - appName = grunt.config.get('atom.appName') + {description} = grunt.config.get('atom.metadata') if process.platform is 'win32' runas ?= require 'runas' @@ -29,33 +32,29 @@ module.exports = (grunt) -> cp shellAppDir, tempFolder fs.renameSync(tempFolder, installDir) else - binDir = path.join(installDir, 'bin') - appFileName = appName.toLowerCase().replace(/\s+/g, '-') shareDir = path.join(installDir, 'share', appFileName) - - mkdir binDir - cp 'atom.sh', path.join(binDir, appFileName) rm shareDir mkdir path.dirname(shareDir) cp shellAppDir, shareDir - # Create atom.desktop if installation not in temporary folder - tmpDir = if process.env.TMPDIR? then process.env.TMPDIR else '/tmp' - if installDir.indexOf(tmpDir) isnt 0 - desktopFile = path.join('resources', 'linux', 'atom.desktop.in') - desktopInstallFile = path.join(installDir, 'share', 'applications', appFileName + '.desktop') + unless installDir.indexOf(process.env.TMPDIR ? '/tmp') is 0 + iconPath = path.join(shareDir, 'resources', 'app.asar.unpacked', 'resources', 'atom.png') - {description} = grunt.file.readJSON('package.json') - iconName = path.join(shareDir, 'resources', 'app.asar.unpacked', 'resources', 'atom.png') - executable = path.join(shareDir, 'atom') - template = _.template(String(fs.readFileSync(desktopFile))) - filled = template({description, iconName, executable}) + mkdir path.join(installDir, 'share', 'applications') + fillTemplate( + path.join('resources', 'linux', 'atom.desktop.in'), + path.join(installDir, 'share', 'applications', appFileName + '.desktop'), + {appName, appFileName, description, iconPath, installDir} + ) - grunt.file.write(desktopInstallFile, filled) + binDir = path.join(installDir, 'bin') + mkdir binDir + cp 'atom.sh', path.join(binDir, appFileName) - # Create relative symbol link for apm. - process.chdir(binDir) - rm('apm') - fs.symlinkSync(path.join('..', 'share', appFileName, 'resources', 'app', 'apm', 'node_modules', '.bin', 'apm'), 'apm') + rm(path.join(binDir, apmFileName)) + fs.symlinkSync( + path.join('..', 'share', appFileName, 'resources', 'app', 'apm', 'node_modules', '.bin', 'apm'), + path.join(binDir, apmFileName) + ) - fs.chmodSync(path.join(shareDir, 'atom'), "755") + fs.chmodSync(path.join(shareDir, 'atom'), '755') diff --git a/build/tasks/mkdeb-task.coffee b/build/tasks/mkdeb-task.coffee index e448bb91e..5f50122f8 100644 --- a/build/tasks/mkdeb-task.coffee +++ b/build/tasks/mkdeb-task.coffee @@ -1,28 +1,18 @@ -fs = require 'fs' path = require 'path' -_ = require 'underscore-plus' module.exports = (grunt) -> - {spawn} = require('./task-helpers')(grunt) - - fillTemplate = (filePath, data) -> - template = _.template(String(fs.readFileSync("#{filePath}.in"))) - filled = template(data) - - outputPath = path.join(grunt.config.get('atom.buildDir'), path.basename(filePath)) - grunt.file.write(outputPath, filled) - outputPath - - getInstalledSize = (buildDir, callback) -> - cmd = 'du' - args = ['-sk', path.join(buildDir, 'Atom')] - spawn {cmd, args}, (error, {stdout}) -> - installedSize = stdout.split(/\s+/)?[0] or '200000' # default to 200MB - callback(null, installedSize) + {spawn, fillTemplate} = require('./task-helpers')(grunt) grunt.registerTask 'mkdeb', 'Create debian package', -> done = @async() + + appName = grunt.config.get('atom.appName') + appFileName = grunt.config.get('atom.appFileName') + apmFileName = grunt.config.get('atom.apmFileName') buildDir = grunt.config.get('atom.buildDir') + installDir = '/usr' + shellAppDir = grunt.config.get('atom.shellAppDir') + {version, description} = grunt.config.get('atom.metadata') channel = grunt.config.get('atom.channel') if process.arch is 'ia32' @@ -32,23 +22,38 @@ module.exports = (grunt) -> else return done("Unsupported arch #{process.arch}") - {name, version, description} = grunt.file.readJSON('package.json') - section = 'devel' - maintainer = 'GitHub ' - installDir = '/usr' - iconName = 'atom' - executable = path.join(installDir, 'share', 'atom', 'atom') - getInstalledSize buildDir, (error, installedSize) -> - data = {name, version, description, section, arch, maintainer, installDir, iconName, installedSize, executable} - controlFilePath = fillTemplate(path.join('resources', 'linux', 'debian', 'control'), data) - desktopFilePath = fillTemplate(path.join('resources', 'linux', 'atom.desktop'), data) - iconPath = path.join('resources', 'app-icons', channel, 'png', '1024.png') + desktopFilePath = path.join(buildDir, appFileName + '.desktop') + fillTemplate( + path.join('resources', 'linux', 'atom.desktop.in'), + desktopFilePath, + {appName, appFileName, description, installDir, iconPath: appFileName} + ) + + getInstalledSize shellAppDir, (error, installedSize) -> + if error? + return done(error) + + controlFilePath = path.join(buildDir, 'control') + fillTemplate( + path.join('resources', 'linux', 'debian', 'control.in'), + controlFilePath, + {appFileName, version, arch, installedSize, description} + ) + + iconPath = path.join(shellAppDir, 'resources', 'app.asar.unpacked', 'resources', 'atom.png') cmd = path.join('script', 'mkdeb') - args = [version, arch, controlFilePath, desktopFilePath, iconPath, buildDir] + args = [appFileName, version, channel, arch, controlFilePath, desktopFilePath, iconPath, buildDir] spawn {cmd, args}, (error) -> if error? done(error) else - grunt.log.ok "Created #{buildDir}/atom-#{version}-#{arch}.deb" + grunt.log.ok "Created #{buildDir}/#{appFileName}-#{version}-#{arch}.deb" done() + + getInstalledSize = (directory, callback) -> + cmd = 'du' + args = ['-sk', directory] + spawn {cmd, args}, (error, {stdout}) -> + installedSize = stdout.split(/\s+/)?[0] or '200000' # default to 200MB + callback(null, installedSize) diff --git a/build/tasks/mkrpm-task.coffee b/build/tasks/mkrpm-task.coffee index eb4fd5847..641127857 100644 --- a/build/tasks/mkrpm-task.coffee +++ b/build/tasks/mkrpm-task.coffee @@ -1,21 +1,18 @@ -fs = require 'fs' path = require 'path' -_ = require 'underscore-plus' module.exports = (grunt) -> - {spawn, rm, mkdir} = require('./task-helpers')(grunt) - - fillTemplate = (filePath, data) -> - template = _.template(String(fs.readFileSync("#{filePath}.in"))) - filled = template(data) - - outputPath = path.join(grunt.config.get('atom.buildDir'), path.basename(filePath)) - grunt.file.write(outputPath, filled) - outputPath + {spawn, fillTemplate, rm, mkdir} = require('./task-helpers')(grunt) grunt.registerTask 'mkrpm', 'Create rpm package', -> done = @async() + appName = grunt.config.get('atom.appName') + appFileName = grunt.config.get('atom.appFileName') + apmFileName = grunt.config.get('atom.apmFileName') + buildDir = grunt.config.get('atom.buildDir') + installDir = '/usr' + {version, description} = grunt.config.get('atom.metadata') + if process.arch is 'ia32' arch = 'i386' else if process.arch is 'x64' @@ -23,7 +20,12 @@ module.exports = (grunt) -> else return done("Unsupported arch #{process.arch}") - {name, version, description} = grunt.file.readJSON('package.json') + desktopFilePath = path.join(buildDir, appFileName + '.desktop') + fillTemplate( + path.join('resources', 'linux', 'atom.desktop.in'), + desktopFilePath, + {appName, appFileName, description, installDir, iconPath: appFileName} + ) # RPM versions can't have dashes in them. # * http://www.rpm.org/max-rpm/ch-rpm-file-format.html @@ -31,23 +33,19 @@ module.exports = (grunt) -> version = version.replace(/-beta/, "~beta") version = version.replace(/-dev/, "~dev") - buildDir = grunt.config.get('atom.buildDir') + specFilePath = path.join(buildDir, appFileName + '.spec') + fillTemplate( + path.join('resources', 'linux', 'redhat', 'atom.spec.in'), + specFilePath, + {appName, appFileName, apmFileName, installDir, version, description} + ) rpmDir = path.join(buildDir, 'rpm') rm rpmDir mkdir rpmDir - installDir = grunt.config.get('atom.installDir') - shareDir = path.join(installDir, 'share', 'atom') - iconName = 'atom' - executable = path.join(shareDir, 'atom') - - data = {name, version, description, installDir, iconName, executable} - specFilePath = fillTemplate(path.join('resources', 'linux', 'redhat', 'atom.spec'), data) - desktopFilePath = fillTemplate(path.join('resources', 'linux', 'atom.desktop'), data) - cmd = path.join('script', 'mkrpm') - args = [specFilePath, desktopFilePath, buildDir] + args = [appName, appFileName, specFilePath, desktopFilePath, buildDir] spawn {cmd, args}, (error) -> if error? done(error) diff --git a/build/tasks/task-helpers.coffee b/build/tasks/task-helpers.coffee index 2819c952a..d24cdec77 100644 --- a/build/tasks/task-helpers.coffee +++ b/build/tasks/task-helpers.coffee @@ -1,5 +1,6 @@ fs = require 'fs-plus' path = require 'path' +_ = require 'underscore-plus' module.exports = (grunt) -> cp: (source, destination, {filter}={}) -> @@ -66,3 +67,7 @@ module.exports = (grunt) -> engines?.atom? catch error false + + fillTemplate: (templatePath, outputPath, data) -> + content = _.template(String(fs.readFileSync(templatePath)))(data) + grunt.file.write(outputPath, content) diff --git a/resources/linux/atom.desktop.in b/resources/linux/atom.desktop.in index 1969e3f26..290d368d2 100644 --- a/resources/linux/atom.desktop.in +++ b/resources/linux/atom.desktop.in @@ -1,9 +1,9 @@ [Desktop Entry] -Name=Atom +Name=<%= appName %> Comment=<%= description %> GenericName=Text Editor -Exec=<%= executable %> %U -Icon=<%= iconName %> +Exec=<%= installDir %>/share/<%= appFileName %>/atom %U +Icon=<%= iconPath %> Type=Application StartupNotify=true Categories=GNOME;GTK;Utility;TextEditor;Development; diff --git a/resources/linux/debian/control.in b/resources/linux/debian/control.in index 7e47f27c6..d06095f4b 100644 --- a/resources/linux/debian/control.in +++ b/resources/linux/debian/control.in @@ -1,12 +1,12 @@ -Package: <%= name %> +Package: <%= appFileName %> Version: <%= version %> Depends: git, gconf2, gconf-service, libgtk2.0-0, libudev0 | libudev1, libgcrypt11 | libgcrypt20, libnotify4, libxtst6, libnss3, python, gvfs-bin, xdg-utils, libcap2 Recommends: lsb-release Suggests: libgnome-keyring0, gir1.2-gnomekeyring-1.0 -Section: <%= section %> +Section: devel Priority: optional Architecture: <%= arch %> Installed-Size: <%= installedSize %> -Maintainer: <%= maintainer %> +Maintainer: GitHub Description: <%= description %> Atom is a free and open source text editor that is modern, approachable, and hackable to the core. diff --git a/resources/linux/redhat/atom.spec.in b/resources/linux/redhat/atom.spec.in index 8ef886e31..3397135bd 100644 --- a/resources/linux/redhat/atom.spec.in +++ b/resources/linux/redhat/atom.spec.in @@ -1,4 +1,4 @@ -Name: <%= name %> +Name: <%= appFileName %> Version: <%= version %> Release: 0.1%{?dist} Summary: <%= description %> @@ -13,25 +13,23 @@ Requires: lsb-core-noarch <%= description %> %install -mkdir -p %{buildroot}/<%= installDir %>/share/atom/ -cp -r Atom/* %{buildroot}/<%= installDir %>/share/atom/ -mkdir -p %{buildroot}/<%= installDir %>/bin/ -ln -sf ../share/atom/resources/app/apm/node_modules/.bin/apm %{buildroot}/<%= installDir %>/bin/apm -cp atom.sh %{buildroot}/<%= installDir %>/bin/atom -chmod 755 %{buildroot}/<%= installDir %>/bin/atom -mkdir -p %{buildroot}/<%= installDir %>/share/applications/ -cp atom.desktop %{buildroot}/<%= installDir %>/share/applications/ +mkdir -p "%{buildroot}/<%= installDir %>/share/<%= appFileName %>/" +cp -r "<%= appName %>"/* "%{buildroot}/<%= installDir %>/share/<%= appFileName %>/" +mkdir -p "%{buildroot}/<%= installDir %>/bin/" +ln -sf "../share/<%= appFileName %>/resources/app/apm/node_modules/.bin/apm" "%{buildroot}/<%= installDir %>/bin/<%= apmFileName %>" +cp atom.sh "%{buildroot}/<%= installDir %>/bin/<%= appFileName %>" +chmod 755 "%{buildroot}/<%= installDir %>/bin/<%= appFileName %>" +mkdir -p "%{buildroot}/<%= installDir %>/share/applications/" +cp "<%= appFileName %>.desktop" "%{buildroot}/<%= installDir %>/share/applications/" -# copy over icons in sizes that most desktop environments like -for i in 1024 512 256 128 64 48 32 24 16 -do - mkdir -p %{buildroot}/<%= installDir %>/share/icons/hicolor/${i}x${i}/apps - cp icons/${i}.png %{buildroot}/<%= installDir %>/share/icons/hicolor/${i}x${i}/apps/atom.png +for i in 1024 512 256 128 64 48 32 24 16; do + mkdir -p "%{buildroot}/<%= installDir %>/share/icons/hicolor/${i}x${i}/apps" + cp "icons/${i}.png" "%{buildroot}/<%= installDir %>/share/icons/hicolor/${i}x${i}/apps/<%= appFileName %>.png" done %files -<%= installDir %>/bin/atom -<%= installDir %>/bin/apm -<%= installDir %>/share/atom/ -<%= installDir %>/share/applications/atom.desktop +<%= installDir %>/bin/<%= appFileName %> +<%= installDir %>/bin/<%= apmFileName %> +<%= installDir %>/share/<%= appFileName %>/ +<%= installDir %>/share/applications/<%= appFileName %>.desktop <%= installDir %>/share/icons/hicolor/ diff --git a/script/mkdeb b/script/mkdeb index c39b6d649..22d2c5124 100755 --- a/script/mkdeb +++ b/script/mkdeb @@ -1,5 +1,5 @@ #!/bin/bash -# mkdeb version control-file-path deb-file-path +# mkdeb name version channel arch control-file-path desktop-file-path icon-path deb-file-path set -e @@ -7,20 +7,22 @@ SCRIPT=`readlink -f "$0"` ROOT=`readlink -f $(dirname $SCRIPT)/..` cd $ROOT -VERSION="$1" -ARCH="$2" -CONTROL_FILE="$3" -DESKTOP_FILE="$4" -ICON_FILE="$5" -DEB_PATH="$6" +NAME="$1" +VERSION="$2" +CHANNEL="$3" +ARCH="$4" +CONTROL_FILE="$5" +DESKTOP_FILE="$6" +ICON_FILE="$7" +DEB_PATH="$8" FILE_MODE=755 TARGET_ROOT="`mktemp -d`" chmod $FILE_MODE "$TARGET_ROOT" -TARGET="$TARGET_ROOT/atom-$VERSION-$ARCH" +TARGET="$TARGET_ROOT/$NAME-$VERSION-$ARCH" mkdir -m $FILE_MODE -p "$TARGET/usr" -env INSTALL_PREFIX="$TARGET/usr" script/grunt install +env INSTALL_PREFIX="$TARGET/usr" script/grunt install --channel $CHANNEL mkdir -m $FILE_MODE -p "$TARGET/DEBIAN" cp "$CONTROL_FILE" "$TARGET/DEBIAN/control" @@ -29,19 +31,19 @@ mkdir -m $FILE_MODE -p "$TARGET/usr/share/applications" cp "$DESKTOP_FILE" "$TARGET/usr/share/applications" mkdir -m $FILE_MODE -p "$TARGET/usr/share/pixmaps" -cp "$ICON_FILE" "$TARGET/usr/share/pixmaps" +cp "$ICON_FILE" "$TARGET/usr/share/pixmaps/$NAME.png" # Copy generated LICENSE.md to /usr/share/doc/atom/copyright -mkdir -m $FILE_MODE -p "$TARGET/usr/share/doc/atom" -cp "$TARGET/usr/share/atom/resources/LICENSE.md" "$TARGET/usr/share/doc/atom/copyright" +mkdir -m $FILE_MODE -p "$TARGET/usr/share/doc/$NAME" +cp "$TARGET/usr/share/$NAME/resources/LICENSE.md" "$TARGET/usr/share/doc/$NAME/copyright" # Add lintian overrides mkdir -m $FILE_MODE -p "$TARGET/usr/share/lintian/overrides" -cp "$ROOT/resources/linux/debian/lintian-overrides" "$TARGET/usr/share/lintian/overrides/atom" +cp "$ROOT/resources/linux/debian/lintian-overrides" "$TARGET/usr/share/lintian/overrides/$NAME" # Remove executable bit from .node files find "$TARGET" -type f -name "*.node" -exec chmod a-x {} \; fakeroot dpkg-deb -b "$TARGET" -mv "$TARGET_ROOT/atom-$VERSION-$ARCH.deb" "$DEB_PATH" +mv "$TARGET_ROOT/$NAME-$VERSION-$ARCH.deb" "$DEB_PATH" rm -rf "$TARGET_ROOT" diff --git a/script/mkrpm b/script/mkrpm index c9ba2d7f7..0be8cb981 100755 --- a/script/mkrpm +++ b/script/mkrpm @@ -2,22 +2,24 @@ set -e -SPEC_FILE="$1" -DESKTOP_FILE="$2" -BUILD_DIRECTORY="$3" +APP_NAME="$1" +APP_FILE_NAME="$2" +SPEC_FILE="$3" +DESKTOP_FILE="$4" +BUILD_DIRECTORY="$5" RPM_BUILD_ROOT=~/rpmbuild ARCH=`uname -m` rpmdev-setuptree -cp -r $BUILD_DIRECTORY/Atom $RPM_BUILD_ROOT/BUILD -cp -r $BUILD_DIRECTORY/icons $RPM_BUILD_ROOT/BUILD -cp $SPEC_FILE $RPM_BUILD_ROOT/SPECS -cp ./atom.sh $RPM_BUILD_ROOT/BUILD -cp $DESKTOP_FILE $RPM_BUILD_ROOT/BUILD +cp -r "$BUILD_DIRECTORY/$APP_NAME" "$RPM_BUILD_ROOT/BUILD" +cp -r "$BUILD_DIRECTORY/icons" "$RPM_BUILD_ROOT/BUILD" +cp "$SPEC_FILE" "$RPM_BUILD_ROOT/SPECS" +cp ./atom.sh "$RPM_BUILD_ROOT/BUILD" +cp "$DESKTOP_FILE" "$RPM_BUILD_ROOT/BUILD" -rpmbuild -ba $SPEC_FILE -cp $RPM_BUILD_ROOT/RPMS/$ARCH/atom-*.rpm $BUILD_DIRECTORY/rpm +rpmbuild -ba "$SPEC_FILE" +cp $RPM_BUILD_ROOT/RPMS/$ARCH/$APP_FILE_NAME-*.rpm "$BUILD_DIRECTORY/rpm" -rm -rf $RPM_BUILD_ROOT +rm -rf "$RPM_BUILD_ROOT" From feb4bd619fcc05ce82fc9128471d86d7410fac97 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Wed, 23 Sep 2015 17:32:38 -0700 Subject: [PATCH 7/7] Remove extra space --- atom.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/atom.sh b/atom.sh index 6976cd649..fcabc0e52 100755 --- a/atom.sh +++ b/atom.sh @@ -88,7 +88,7 @@ elif [ $OS == 'Linux' ]; then if [ -n "$BETA_VERSION" ]; then ATOM_PATH="$USR_DIRECTORY/share/atom-beta/atom" else - ATOM_PATH="$USR_DIRECTORY/share/atom/atom " + ATOM_PATH="$USR_DIRECTORY/share/atom/atom" fi ATOM_HOME="${ATOM_HOME:-$HOME/.atom}"