From eb1bed118feed93aa8fec0395d67048334a2dda6 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 20 Mar 2014 21:27:27 +0800 Subject: [PATCH 01/11] No need to parse args before passing to nslog. --- src/browser/main.coffee | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/browser/main.coffee b/src/browser/main.coffee index cd3483dd0..5cff80f4f 100644 --- a/src/browser/main.coffee +++ b/src/browser/main.coffee @@ -9,12 +9,7 @@ optimist = require 'optimist' nslog = require 'nslog' dialog = require 'dialog' -console.log = (args...) -> - # TODO: Make NSLog work as expected - output = args.map((arg) -> JSON.stringify(arg)).join(" ") - nslog(output) - if process.platform isnt 'darwin' - fs.writeFileSync('debug.log', output, flag: 'a') +console.log = nslog process.on 'uncaughtException', (error={}) -> nslog(error.message) if error.message? From 5151faea3daa778c44ce12dc871dda18a57edf09 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 20 Mar 2014 21:44:03 +0800 Subject: [PATCH 02/11] Use unix style install. --- atom.sh | 4 ++-- build/Gruntfile.coffee | 10 ++++------ build/tasks/install-task.coffee | 9 ++++++++- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/atom.sh b/atom.sh index cd1137051..03bb758c8 100755 --- a/atom.sh +++ b/atom.sh @@ -66,8 +66,8 @@ if [ $OS == 'Mac' ]; then open -a "$ATOM_PATH/$ATOM_APP_NAME" -n --args --executed-from="$(pwd)" --pid=$$ "$@" fi elif [ $OS == 'Linux' ]; then - ATOM_PATH='/opt/Atom/atom' - [ -x "$ATOM_PATH" ] || ATOM_PATH='/tmp/atom-build/Atom/atom' + ATOM_PATH='/opt/atom/atom' + [ -x "$ATOM_PATH" ] || ATOM_PATH='/tmp/atom-build/atom/atom' if [ $EXPECT_OUTPUT ]; then "$ATOM_PATH" --executed-from="$(pwd)" --pid=$$ "$@" diff --git a/build/Gruntfile.coffee b/build/Gruntfile.coffee index 118824f1f..ef8352b20 100644 --- a/build/Gruntfile.coffee +++ b/build/Gruntfile.coffee @@ -39,35 +39,33 @@ module.exports = (grunt) -> if process.platform is 'win32' appName = 'Atom' tmpDir = os.tmpdir() - installRoot = process.env.ProgramFiles buildDir = grunt.option('build-dir') ? path.join(tmpDir, 'atom-build') symbolsDir = path.join(buildDir, 'Atom.breakpad.syms') shellAppDir = path.join(buildDir, appName) contentsDir = shellAppDir appDir = path.join(shellAppDir, 'resources', 'app') atomShellDownloadDir = path.join(os.tmpdir(), 'atom-cached-atom-shells') + installDir = path.join(process.env.ProgramFiles, appName) else if process.platform is 'darwin' appName = 'Atom.app' tmpDir = '/tmp' - installRoot = '/Applications' buildDir = grunt.option('build-dir') ? path.join(tmpDir, 'atom-build') symbolsDir = path.join(buildDir, 'Atom.breakpad.syms') shellAppDir = path.join(buildDir, appName) contentsDir = path.join(shellAppDir, 'Contents') appDir = path.join(contentsDir, 'Resources', 'app') atomShellDownloadDir = '/tmp/atom-cached-atom-shells' + installDir = path.join('/Applications', appName) else - appName = 'Atom' + appName = 'atom' tmpDir = '/tmp' - installRoot = '/opt' buildDir = grunt.option('build-dir') ? path.join(tmpDir, 'atom-build') symbolsDir = path.join(buildDir, 'Atom.breakpad.syms') shellAppDir = path.join(buildDir, appName) contentsDir = shellAppDir appDir = path.join(shellAppDir, 'resources', 'app') atomShellDownloadDir = '/tmp/atom-cached-atom-shells' - - installDir = path.join(installRoot, appName) + installDir = process.env.INSTALL_PREFIX ? '/usr/local' coffeeConfig = options: diff --git a/build/tasks/install-task.coffee b/build/tasks/install-task.coffee index 273e1b5ef..cc98f1e8c 100644 --- a/build/tasks/install-task.coffee +++ b/build/tasks/install-task.coffee @@ -15,7 +15,14 @@ module.exports = (grunt) -> createShortcut = path.resolve 'script', 'create-shortcut.cmd' runas('cmd', ['/c', createShortcut, path.join(installDir, 'atom.exe'), 'Atom']) - else + else if process.platform is 'darwin' rm installDir mkdir path.dirname(installDir) cp shellAppDir, installDir + else + binDir = path.join(installDir, 'bin') + shareDir = path.join(installDir, 'share') + + mkdir binDir + cp 'atom.sh', path.join(binDir, 'atom') + cp shellAppDir, shareDir From 627a839779800550bba80af03a22c1a6abb9cceb Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 20 Mar 2014 22:01:14 +0800 Subject: [PATCH 03/11] Fix grunt install. --- build/Gruntfile.coffee | 2 +- build/tasks/install-task.coffee | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/build/Gruntfile.coffee b/build/Gruntfile.coffee index ef8352b20..307dfb1a5 100644 --- a/build/Gruntfile.coffee +++ b/build/Gruntfile.coffee @@ -57,7 +57,7 @@ module.exports = (grunt) -> atomShellDownloadDir = '/tmp/atom-cached-atom-shells' installDir = path.join('/Applications', appName) else - appName = 'atom' + appName = 'Atom' tmpDir = '/tmp' buildDir = grunt.option('build-dir') ? path.join(tmpDir, 'atom-build') symbolsDir = path.join(buildDir, 'Atom.breakpad.syms') diff --git a/build/tasks/install-task.coffee b/build/tasks/install-task.coffee index cc98f1e8c..6ad119b83 100644 --- a/build/tasks/install-task.coffee +++ b/build/tasks/install-task.coffee @@ -21,8 +21,10 @@ module.exports = (grunt) -> cp shellAppDir, installDir else binDir = path.join(installDir, 'bin') - shareDir = path.join(installDir, 'share') + shareDir = path.join(installDir, 'share', 'atom') mkdir binDir cp 'atom.sh', path.join(binDir, 'atom') + rm shareDir + mkdir path.dirname(shareDir) cp shellAppDir, shareDir From ae1d3b1e8025d799a018c3e2b1466db615470b86 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 20 Mar 2014 22:01:23 +0800 Subject: [PATCH 04/11] :penguin: Search atom from installed position. --- atom.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/atom.sh b/atom.sh index 03bb758c8..80e186fd4 100755 --- a/atom.sh +++ b/atom.sh @@ -66,14 +66,17 @@ if [ $OS == 'Mac' ]; then open -a "$ATOM_PATH/$ATOM_APP_NAME" -n --args --executed-from="$(pwd)" --pid=$$ "$@" fi elif [ $OS == 'Linux' ]; then - ATOM_PATH='/opt/atom/atom' - [ -x "$ATOM_PATH" ] || ATOM_PATH='/tmp/atom-build/atom/atom' + SCRIPT=`readlink -f "$0"` + USR_DIRECTORY=`readlink -f $(dirname $SCRIPT)/..` + ATOM_PATH="$USR_DIRECTORY/share/atom/atom" + + [ -x "$ATOM_PATH" ] || ATOM_PATH='/tmp/atom-build/Atom/atom' if [ $EXPECT_OUTPUT ]; then "$ATOM_PATH" --executed-from="$(pwd)" --pid=$$ "$@" exit $? else - nohup "$ATOM_PATH" --executed-from="$(pwd)" --pid=$$ "$@" > /dev/null & + nohup "$ATOM_PATH" --executed-from="$(pwd)" --pid=$$ "$@" > /dev/null 2>&1 & fi fi From 645fc1511a502623d45100f87afacf557f814b98 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 20 Mar 2014 22:10:11 +0800 Subject: [PATCH 05/11] Do not add parameter in shebang string. On Linux "#!/usr/bin/env node --harmony_collections" is unfortunately not recognized by system. --- script/bootstrap | 2 +- script/build | 2 +- script/cibuild | 2 +- script/clean | 2 +- script/grunt | 2 +- script/test | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/script/bootstrap b/script/bootstrap index a747b0e50..5fbd39981 100755 --- a/script/bootstrap +++ b/script/bootstrap @@ -1,4 +1,4 @@ -#!/usr/bin/env node --harmony_collections +#!/usr/bin/env node var nodeMinorVersion = process.versions.node.split('.')[1] if (nodeMinorVersion !== '10') { diff --git a/script/build b/script/build index 5130d385a..1f0f123ce 100755 --- a/script/build +++ b/script/build @@ -1,4 +1,4 @@ -#!/usr/bin/env node --harmony_collections +#!/usr/bin/env node var cp = require('./utils/child-process-wrapper.js'); var path = require('path'); diff --git a/script/cibuild b/script/cibuild index 6c7cb8ef5..4191500ad 100755 --- a/script/cibuild +++ b/script/cibuild @@ -1,4 +1,4 @@ -#!/usr/bin/env node --harmony_collections +#!/usr/bin/env node var cp = require('./utils/child-process-wrapper.js'); var fs = require('fs'); var path = require('path'); diff --git a/script/clean b/script/clean index db1e5c578..499477833 100755 --- a/script/clean +++ b/script/clean @@ -1,4 +1,4 @@ -#!/usr/bin/env node --harmony_collections +#!/usr/bin/env node var cp = require('./utils/child-process-wrapper.js'); var path = require('path'); var os = require('os'); diff --git a/script/grunt b/script/grunt index 1523b2fed..851cad0b1 100755 --- a/script/grunt +++ b/script/grunt @@ -1,4 +1,4 @@ -#!/usr/bin/env node --harmony_collections +#!/usr/bin/env node var cp = require('./utils/child-process-wrapper.js'); var path = require('path'); diff --git a/script/test b/script/test index cb32a470b..2c3b37147 100755 --- a/script/test +++ b/script/test @@ -1,4 +1,4 @@ -#!/usr/bin/env node --harmony_collections +#!/usr/bin/env node var safeExec = require('./utils/child-process-wrapper.js').safeExec; var path = require('path'); From 03b9a25897b97280dcedfdb0afce26922a71f4ff Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 20 Mar 2014 22:27:11 +0800 Subject: [PATCH 06/11] Add description field to package.json. It would be used when generating packages. --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 9f4782340..d3ecefcad 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,7 @@ "name": "atom", "productName": "Atom", "version": "0.77.0", + "description": "A hackable text editor for the 21st Century.", "main": "./src/browser/main.js", "repository": { "type": "git", From 67d8db8b9a773b474a219ac6fa126b04180ae265 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 24 Mar 2014 18:44:44 +0800 Subject: [PATCH 07/11] :penguin: Add mkdeb task to create debian package. --- build/tasks/mkdeb-task.coffee | 24 ++++++++++++++++++++++++ resources/linux/debian/control.in | 8 ++++++++ script/mkdeb | 21 +++++++++++++++++++++ 3 files changed, 53 insertions(+) create mode 100644 build/tasks/mkdeb-task.coffee create mode 100644 resources/linux/debian/control.in create mode 100755 script/mkdeb diff --git a/build/tasks/mkdeb-task.coffee b/build/tasks/mkdeb-task.coffee new file mode 100644 index 000000000..118d424d4 --- /dev/null +++ b/build/tasks/mkdeb-task.coffee @@ -0,0 +1,24 @@ +fs = require 'fs' +path = require 'path' +_ = require 'underscore-plus' + +module.exports = (grunt) -> + {spawn} = require('./task-helpers')(grunt) + + grunt.registerTask 'mkdeb', 'Create debian package', -> + done = @async() + control = path.join('resources', 'linux', 'debian', 'control') + controlTemplate = control + '.in' + + {name, version, description} = grunt.file.readJSON('package.json') + section = 'devel' + arch = 'amd64' + maintainer = 'GitHub ' + + template = _.template(String(fs.readFileSync(controlTemplate))) + filled = template({name, version, description, section, arch, maintainer}) + fs.writeFileSync(control, filled) + + cmd = path.join('script', 'mkdeb') + args = [version, control] + spawn({cmd, args}, done) diff --git a/resources/linux/debian/control.in b/resources/linux/debian/control.in new file mode 100644 index 000000000..cf670e62b --- /dev/null +++ b/resources/linux/debian/control.in @@ -0,0 +1,8 @@ +Package: <%= name %> +Version: <%= version %> +Section: <%= section %> +Priority: optional +Architecture: <%= arch %> +Installed-Size: `du -ks usr|cut -f 1` +Maintainer: <%= maintainer %> +Description: <%= description %> diff --git a/script/mkdeb b/script/mkdeb new file mode 100755 index 000000000..7ceff41c5 --- /dev/null +++ b/script/mkdeb @@ -0,0 +1,21 @@ +#!/bin/bash +# mkdeb version control-file-path + +SCRIPT=`readlink -f "$0"` +ROOT=`readlink -f $(dirname $SCRIPT)/..` +cd $ROOT + +VERSION="$1" +CONTROL_FILE="$2" +TARGET_ROOT="`mktemp -d`" +TARGET="$TARGET_ROOT/atom-$VERSION" + +mkdir -p "$TARGET/usr" +env INSTALL_PREFIX="$TARGET/usr" script/grunt install + +mkdir -p "$TARGET/DEBIAN" +mv "$CONTROL_FILE" "$TARGET/DEBIAN/control" + +dpkg-deb -b "$TARGET" +mv "$TARGET_ROOT/atom-$VERSION.deb" /tmp/atom-build/ +rm -rf $TARGET_ROOT From 6f068f14fd1d5d9d7ddea9616877970bc6862a26 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 24 Mar 2014 18:50:58 +0800 Subject: [PATCH 08/11] Do not hard code build dir. --- build/tasks/mkdeb-task.coffee | 2 +- script/mkdeb | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/build/tasks/mkdeb-task.coffee b/build/tasks/mkdeb-task.coffee index 118d424d4..e7f3218c8 100644 --- a/build/tasks/mkdeb-task.coffee +++ b/build/tasks/mkdeb-task.coffee @@ -20,5 +20,5 @@ module.exports = (grunt) -> fs.writeFileSync(control, filled) cmd = path.join('script', 'mkdeb') - args = [version, control] + args = [version, control, grunt.config.get('atom.buildDir')] spawn({cmd, args}, done) diff --git a/script/mkdeb b/script/mkdeb index 7ceff41c5..d327474e1 100755 --- a/script/mkdeb +++ b/script/mkdeb @@ -1,5 +1,5 @@ #!/bin/bash -# mkdeb version control-file-path +# mkdeb version control-file-path deb-file-path SCRIPT=`readlink -f "$0"` ROOT=`readlink -f $(dirname $SCRIPT)/..` @@ -7,6 +7,8 @@ cd $ROOT VERSION="$1" CONTROL_FILE="$2" +DEB_PATH="$3" + TARGET_ROOT="`mktemp -d`" TARGET="$TARGET_ROOT/atom-$VERSION" @@ -17,5 +19,5 @@ mkdir -p "$TARGET/DEBIAN" mv "$CONTROL_FILE" "$TARGET/DEBIAN/control" dpkg-deb -b "$TARGET" -mv "$TARGET_ROOT/atom-$VERSION.deb" /tmp/atom-build/ +mv "$TARGET_ROOT/atom-$VERSION.deb" "$DEB_PATH" rm -rf $TARGET_ROOT From 9c070cd71debf41f7f6d988e36de1afdde26b1c5 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 24 Mar 2014 19:12:41 +0800 Subject: [PATCH 09/11] :penguin: Add desktop file. --- build/tasks/mkdeb-task.coffee | 17 +++++++++++------ resources/linux/Atom.desktop.in | 7 +++++++ script/mkdeb | 6 +++++- 3 files changed, 23 insertions(+), 7 deletions(-) create mode 100644 resources/linux/Atom.desktop.in diff --git a/build/tasks/mkdeb-task.coffee b/build/tasks/mkdeb-task.coffee index e7f3218c8..c9918f9ed 100644 --- a/build/tasks/mkdeb-task.coffee +++ b/build/tasks/mkdeb-task.coffee @@ -2,23 +2,28 @@ fs = require 'fs' path = require 'path' _ = require 'underscore-plus' +fillTemplate = (filePath, data) -> + template = _.template(String(fs.readFileSync(filePath + '.in'))) + filled = template(data) + fs.writeFileSync(filePath, filled) + module.exports = (grunt) -> {spawn} = require('./task-helpers')(grunt) grunt.registerTask 'mkdeb', 'Create debian package', -> done = @async() - control = path.join('resources', 'linux', 'debian', 'control') - controlTemplate = control + '.in' {name, version, description} = grunt.file.readJSON('package.json') section = 'devel' arch = 'amd64' maintainer = 'GitHub ' + data = {name, version, description, section, arch, maintainer} - template = _.template(String(fs.readFileSync(controlTemplate))) - filled = template({name, version, description, section, arch, maintainer}) - fs.writeFileSync(control, filled) + control = path.join('resources', 'linux', 'debian', 'control') + fillTemplate(control, data) + desktop = path.join('resources', 'linux', 'Atom.desktop') + fillTemplate(desktop, data) cmd = path.join('script', 'mkdeb') - args = [version, control, grunt.config.get('atom.buildDir')] + args = [version, control, desktop, grunt.config.get('atom.buildDir')] spawn({cmd, args}, done) diff --git a/resources/linux/Atom.desktop.in b/resources/linux/Atom.desktop.in new file mode 100644 index 000000000..ad03c3402 --- /dev/null +++ b/resources/linux/Atom.desktop.in @@ -0,0 +1,7 @@ +[Desktop Entry] +Name=Atom +Comment=<%= description %> +Exec=/usr/share/atom/atom %U +Icon=atom +Type=Application +Categories=GNOME;GTK;Utility;TextEditor; diff --git a/script/mkdeb b/script/mkdeb index d327474e1..d28c90cdf 100755 --- a/script/mkdeb +++ b/script/mkdeb @@ -7,7 +7,8 @@ cd $ROOT VERSION="$1" CONTROL_FILE="$2" -DEB_PATH="$3" +DESKTOP_FILE="$3" +DEB_PATH="$4" TARGET_ROOT="`mktemp -d`" TARGET="$TARGET_ROOT/atom-$VERSION" @@ -18,6 +19,9 @@ env INSTALL_PREFIX="$TARGET/usr" script/grunt install mkdir -p "$TARGET/DEBIAN" mv "$CONTROL_FILE" "$TARGET/DEBIAN/control" +mkdir -p "$TARGET/usr/share/applications" +mv "$DESKTOP_FILE" "$TARGET/usr/share/applications" + dpkg-deb -b "$TARGET" mv "$TARGET_ROOT/atom-$VERSION.deb" "$DEB_PATH" rm -rf $TARGET_ROOT From 2da9ee0cee37e04a97d220ab370d7de622243026 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 24 Mar 2014 19:24:12 +0800 Subject: [PATCH 10/11] :penguin: Add icon file in deb package. --- build/tasks/mkdeb-task.coffee | 4 +++- script/mkdeb | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/build/tasks/mkdeb-task.coffee b/build/tasks/mkdeb-task.coffee index c9918f9ed..2d503ac7f 100644 --- a/build/tasks/mkdeb-task.coffee +++ b/build/tasks/mkdeb-task.coffee @@ -23,7 +23,9 @@ module.exports = (grunt) -> fillTemplate(control, data) desktop = path.join('resources', 'linux', 'Atom.desktop') fillTemplate(desktop, data) + icon = path.join('resources', 'atom.png') + buildDir = grunt.config.get('atom.buildDir') cmd = path.join('script', 'mkdeb') - args = [version, control, desktop, grunt.config.get('atom.buildDir')] + args = [version, control, desktop, icon, buildDir] spawn({cmd, args}, done) diff --git a/script/mkdeb b/script/mkdeb index d28c90cdf..66ce9686b 100755 --- a/script/mkdeb +++ b/script/mkdeb @@ -8,7 +8,8 @@ cd $ROOT VERSION="$1" CONTROL_FILE="$2" DESKTOP_FILE="$3" -DEB_PATH="$4" +ICON_FILE="$4" +DEB_PATH="$5" TARGET_ROOT="`mktemp -d`" TARGET="$TARGET_ROOT/atom-$VERSION" @@ -22,6 +23,9 @@ mv "$CONTROL_FILE" "$TARGET/DEBIAN/control" mkdir -p "$TARGET/usr/share/applications" mv "$DESKTOP_FILE" "$TARGET/usr/share/applications" +mkdir -p "$TARGET/usr/share/pixmaps" +cp "$ICON_FILE" "$TARGET/usr/share/pixmaps" + dpkg-deb -b "$TARGET" mv "$TARGET_ROOT/atom-$VERSION.deb" "$DEB_PATH" rm -rf $TARGET_ROOT From 72ceaf772d89df7bd09d1aa4b88acbdec354f231 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 24 Mar 2014 19:34:01 +0800 Subject: [PATCH 11/11] :penguin: Use startup notification. --- resources/linux/Atom.desktop.in | 1 + 1 file changed, 1 insertion(+) diff --git a/resources/linux/Atom.desktop.in b/resources/linux/Atom.desktop.in index ad03c3402..e88ed122f 100644 --- a/resources/linux/Atom.desktop.in +++ b/resources/linux/Atom.desktop.in @@ -4,4 +4,5 @@ Comment=<%= description %> Exec=/usr/share/atom/atom %U Icon=atom Type=Application +StartupNotify=true Categories=GNOME;GTK;Utility;TextEditor;