From 4a8a741ef087e13c8471ff3463bb0558ba239969 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 21 Jul 2014 16:30:27 -0700 Subject: [PATCH 01/10] Write Atom.desktop file directly from template Previously this was written to resources/linux/Atom.desktop which would create issues when running `sudo script/grunt install` followed by `script/grunt mkdeb` --- build/tasks/install-task.coffee | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/build/tasks/install-task.coffee b/build/tasks/install-task.coffee index d3a3aa010..4ef52a40b 100644 --- a/build/tasks/install-task.coffee +++ b/build/tasks/install-task.coffee @@ -4,11 +4,6 @@ _ = require 'underscore-plus' fs = require 'fs-plus' runas = null -fillTemplate = (filePath, data) -> - template = _.template(String(fs.readFileSync(filePath + '.in'))) - filled = template(data) - fs.writeFileSync(filePath, filled) - module.exports = (grunt) -> {cp, mkdir, rm} = require('./task-helpers')(grunt) @@ -32,7 +27,6 @@ module.exports = (grunt) -> shareDir = path.join(installDir, 'share', 'atom') iconName = path.join(shareDir,'resources','app','resources','atom.png') - desktopFile = path.join('resources', 'linux', 'Atom.desktop') mkdir binDir cp 'atom.sh', path.join(binDir, 'atom') @@ -42,13 +36,17 @@ module.exports = (grunt) -> # Create Atom.desktop if installation not in temporary folder tmpDir = if process.env.TMPDIR? then process.env.TMPDIR else '/tmp' - desktopInstallFile = path.join(installDir,'share','applications','Atom.desktop') + desktopInstallFile = path.join(installDir, 'share', 'applications', 'Atom.desktop') if installDir.indexOf(tmpDir) isnt 0 mkdir path.dirname(desktopInstallFile) {description} = grunt.file.readJSON('package.json') installDir = path.join(installDir,'.') # To prevent "Exec=/usr/local//share/atom/atom" - fillTemplate(desktopFile, {description, installDir, iconName}) - cp desktopFile, desktopInstallFile + + desktopFile = path.join('resources', 'linux', 'Atom.desktop.in') + template = _.template(String(fs.readFileSync(desktopFile))) + filled = template({description, installDir, iconName}) + + grunt.file.write(desktopInstallFile, filled) # Create relative symbol link for apm. process.chdir(binDir) From 4b07b803b3e6dce8b5b02d12729a8e15c9154f0d Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 21 Jul 2014 16:37:42 -0700 Subject: [PATCH 02/10] Move install file var under if block --- build/tasks/install-task.coffee | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build/tasks/install-task.coffee b/build/tasks/install-task.coffee index 4ef52a40b..726366716 100644 --- a/build/tasks/install-task.coffee +++ b/build/tasks/install-task.coffee @@ -36,13 +36,14 @@ module.exports = (grunt) -> # Create Atom.desktop if installation not in temporary folder tmpDir = if process.env.TMPDIR? then process.env.TMPDIR else '/tmp' - desktopInstallFile = path.join(installDir, 'share', 'applications', 'Atom.desktop') if installDir.indexOf(tmpDir) isnt 0 mkdir path.dirname(desktopInstallFile) {description} = grunt.file.readJSON('package.json') installDir = path.join(installDir,'.') # To prevent "Exec=/usr/local//share/atom/atom" + desktopInstallFile = path.join(installDir, 'share', 'applications', 'Atom.desktop') desktopFile = path.join('resources', 'linux', 'Atom.desktop.in') + template = _.template(String(fs.readFileSync(desktopFile))) filled = template({description, installDir, iconName}) From 74992b13975fa8952c144798e08b97317e4d7c63 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 21 Jul 2014 16:38:46 -0700 Subject: [PATCH 03/10] Group template variables together --- build/tasks/install-task.coffee | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/build/tasks/install-task.coffee b/build/tasks/install-task.coffee index 726366716..f34972ddc 100644 --- a/build/tasks/install-task.coffee +++ b/build/tasks/install-task.coffee @@ -37,13 +37,14 @@ module.exports = (grunt) -> # 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 - mkdir path.dirname(desktopInstallFile) - {description} = grunt.file.readJSON('package.json') - installDir = path.join(installDir,'.') # To prevent "Exec=/usr/local//share/atom/atom" - - desktopInstallFile = path.join(installDir, 'share', 'applications', 'Atom.desktop') desktopFile = path.join('resources', 'linux', 'Atom.desktop.in') + desktopInstallFile = path.join(installDir, 'share', 'applications', 'Atom.desktop') + mkdir path.dirname(desktopInstallFile) + + {description} = grunt.file.readJSON('package.json') + iconName = path.join(shareDir,'resources','app','resources','atom.png') + installDir = path.join(installDir, '.') # To prevent "Exec=/usr/local//share/atom/atom" template = _.template(String(fs.readFileSync(desktopFile))) filled = template({description, installDir, iconName}) From f5951425c3083ba3f8fb08b90c1d0d53d886fa9d Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 21 Jul 2014 16:39:23 -0700 Subject: [PATCH 04/10] grunt.file.write creates parent dirs --- build/tasks/install-task.coffee | 2 -- 1 file changed, 2 deletions(-) diff --git a/build/tasks/install-task.coffee b/build/tasks/install-task.coffee index f34972ddc..3dd67260f 100644 --- a/build/tasks/install-task.coffee +++ b/build/tasks/install-task.coffee @@ -40,8 +40,6 @@ module.exports = (grunt) -> desktopFile = path.join('resources', 'linux', 'Atom.desktop.in') desktopInstallFile = path.join(installDir, 'share', 'applications', 'Atom.desktop') - mkdir path.dirname(desktopInstallFile) - {description} = grunt.file.readJSON('package.json') iconName = path.join(shareDir,'resources','app','resources','atom.png') installDir = path.join(installDir, '.') # To prevent "Exec=/usr/local//share/atom/atom" From ab980d78d2277b32337c72539ba76b4e538be21b Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 21 Jul 2014 16:39:46 -0700 Subject: [PATCH 05/10] :lipstick: --- build/tasks/install-task.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/tasks/install-task.coffee b/build/tasks/install-task.coffee index 3dd67260f..cca951bf0 100644 --- a/build/tasks/install-task.coffee +++ b/build/tasks/install-task.coffee @@ -41,7 +41,7 @@ module.exports = (grunt) -> desktopInstallFile = path.join(installDir, 'share', 'applications', 'Atom.desktop') {description} = grunt.file.readJSON('package.json') - iconName = path.join(shareDir,'resources','app','resources','atom.png') + iconName = path.join(shareDir, 'resources', 'app', 'resources', 'atom.png') installDir = path.join(installDir, '.') # To prevent "Exec=/usr/local//share/atom/atom" template = _.template(String(fs.readFileSync(desktopFile))) filled = template({description, installDir, iconName}) From ccd631a93465b7328df8e6bef2f30d8184e7dfd4 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 21 Jul 2014 16:45:59 -0700 Subject: [PATCH 06/10] Write control/desktop files to temp folder --- .gitignore | 2 -- build/package.json | 9 +++++---- build/tasks/mkdeb-task.coffee | 18 +++++++++++------- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index 7103ce579..1257ab371 100644 --- a/.gitignore +++ b/.gitignore @@ -13,5 +13,3 @@ debug.log docs/output docs/includes spec/fixtures/evil-files/ -resources/linux/Atom.desktop -resources/linux/debian/control diff --git a/build/package.json b/build/package.json index 91a7e30f9..a7dc2b2b1 100644 --- a/build/package.json +++ b/build/package.json @@ -14,8 +14,8 @@ "grunt": "~0.4.1", "grunt-cli": "~0.1.9", "grunt-coffeelint": "git+https://github.com/atom/grunt-coffeelint.git", - "grunt-contrib-csslint": "~0.1.2", "grunt-contrib-coffee": "~0.9.0", + "grunt-contrib-csslint": "~0.1.2", "grunt-contrib-less": "~0.8.0", "grunt-cson": "0.8.0", "grunt-download-atom-shell": "~0.8.0", @@ -27,15 +27,16 @@ "json-front-matter": "~0.1.3", "legal-eagle": "~0.4.0", "minidump": "~0.7", - "read-package-json": "1.1.8", "normalize-package-data": "0.2.12", + "npm": "~1.4.5", "rcedit": "~0.1.2", + "read-package-json": "1.1.8", "request": "~2.27.0", "rimraf": "~2.2.2", "runas": "0.5.x", + "temp": "^0.8.0", "underscore-plus": "1.x", "unzip": "~0.1.9", - "vm-compatibility-layer": "~0.1.0", - "npm": "~1.4.5" + "vm-compatibility-layer": "~0.1.0" } } diff --git a/build/tasks/mkdeb-task.coffee b/build/tasks/mkdeb-task.coffee index 090168446..6fb4edab4 100644 --- a/build/tasks/mkdeb-task.coffee +++ b/build/tasks/mkdeb-task.coffee @@ -1,11 +1,17 @@ fs = require 'fs' path = require 'path' _ = require 'underscore-plus' +temp = require 'temp' + +tempResourcesFolder = temp.mkdirSync('atom-resources-') fillTemplate = (filePath, data) -> - template = _.template(String(fs.readFileSync(filePath + '.in'))) + template = _.template(String(fs.readFileSync("#{filePath}.in"))) filled = template(data) - fs.writeFileSync(filePath, filled) + + outputPath = path.join(tempResourcesFolder, path.basename(filePath)) + fs.writeFileSync(outputPath, filled) + outputPath module.exports = (grunt) -> {spawn} = require('./task-helpers')(grunt) @@ -27,13 +33,11 @@ module.exports = (grunt) -> iconName = 'atom' data = {name, version, description, section, arch, maintainer, installDir, iconName} - control = path.join('resources', 'linux', 'debian', 'control') - fillTemplate(control, data) - desktop = path.join('resources', 'linux', 'Atom.desktop') - fillTemplate(desktop, data) + controlFilePath = fillTemplate(path.join('resources', 'linux', 'debian', 'control'), data) + desktopFilePath = fillTemplate(path.join('resources', 'linux', 'Atom.desktop'), data) icon = path.join('resources', 'atom.png') buildDir = grunt.config.get('atom.buildDir') cmd = path.join('script', 'mkdeb') - args = [version, arch, control, desktop, icon, buildDir] + args = [version, arch, controlFilePath, desktopFilePath, icon, buildDir] spawn({cmd, args}, done) From a26cb6023e3edb047cd42a631645dbc92f2550fe Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 21 Jul 2014 16:47:08 -0700 Subject: [PATCH 07/10] Track temp folders --- build/tasks/mkdeb-task.coffee | 1 + 1 file changed, 1 insertion(+) diff --git a/build/tasks/mkdeb-task.coffee b/build/tasks/mkdeb-task.coffee index 6fb4edab4..98f1c797b 100644 --- a/build/tasks/mkdeb-task.coffee +++ b/build/tasks/mkdeb-task.coffee @@ -3,6 +3,7 @@ path = require 'path' _ = require 'underscore-plus' temp = require 'temp' +temp.track() tempResourcesFolder = temp.mkdirSync('atom-resources-') fillTemplate = (filePath, data) -> From 1757ff18f28fa43c58d9258f03f051592982737b Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 21 Jul 2014 16:52:20 -0700 Subject: [PATCH 08/10] Write control/desktop files to build dir --- build/package.json | 1 - build/tasks/mkdeb-task.coffee | 20 ++++++++------------ 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/build/package.json b/build/package.json index a7dc2b2b1..8b2d55027 100644 --- a/build/package.json +++ b/build/package.json @@ -34,7 +34,6 @@ "request": "~2.27.0", "rimraf": "~2.2.2", "runas": "0.5.x", - "temp": "^0.8.0", "underscore-plus": "1.x", "unzip": "~0.1.9", "vm-compatibility-layer": "~0.1.0" diff --git a/build/tasks/mkdeb-task.coffee b/build/tasks/mkdeb-task.coffee index 98f1c797b..502b797c1 100644 --- a/build/tasks/mkdeb-task.coffee +++ b/build/tasks/mkdeb-task.coffee @@ -1,22 +1,18 @@ fs = require 'fs' path = require 'path' _ = require 'underscore-plus' -temp = require 'temp' - -temp.track() -tempResourcesFolder = temp.mkdirSync('atom-resources-') - -fillTemplate = (filePath, data) -> - template = _.template(String(fs.readFileSync("#{filePath}.in"))) - filled = template(data) - - outputPath = path.join(tempResourcesFolder, path.basename(filePath)) - fs.writeFileSync(outputPath, filled) - outputPath 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)) + fs.writeFileSync(outputPath, filled) + outputPath + grunt.registerTask 'mkdeb', 'Create debian package', -> done = @async() From b9658e23f473ade07d4b90b41a9c56e7fcc74481 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 21 Jul 2014 16:53:27 -0700 Subject: [PATCH 09/10] Write file using grunt API --- build/tasks/mkdeb-task.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/tasks/mkdeb-task.coffee b/build/tasks/mkdeb-task.coffee index 502b797c1..ccf20b790 100644 --- a/build/tasks/mkdeb-task.coffee +++ b/build/tasks/mkdeb-task.coffee @@ -10,7 +10,7 @@ module.exports = (grunt) -> filled = template(data) outputPath = path.join(grunt.config.get('atom.buildDir'), path.basename(filePath)) - fs.writeFileSync(outputPath, filled) + grunt.file.write(outputPath, filled) outputPath grunt.registerTask 'mkdeb', 'Create debian package', -> From 89733300a55ccf70914b236566d34c7952459ae4 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 21 Jul 2014 17:00:53 -0700 Subject: [PATCH 10/10] :lipstick: --- build/tasks/install-task.coffee | 1 + 1 file changed, 1 insertion(+) diff --git a/build/tasks/install-task.coffee b/build/tasks/install-task.coffee index cca951bf0..13d349a50 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') + if process.platform is 'win32' runas ?= require 'runas' copyFolder = path.resolve 'script', 'copy-folder.cmd'