From f5c3bdb8453c51db694450d39fcce3de9c076c18 Mon Sep 17 00:00:00 2001 From: Pritam Baral Date: Fri, 16 May 2014 23:40:01 +0530 Subject: [PATCH 1/4] Use os.tmpdir() on Linux /tmp isn't always available, is on precious RAM-backed fs or simply not what the user has set his $TMPDIR to. According to the specification, we should use $TMPDIR, which node lets us find through os.tmpdir(). Also, contributing.md isn't in favour of using platform-dependent code. This commit focusses only on Linux, and leaves OS X as is with /tmp for discussion. --- build/Gruntfile.coffee | 4 ++-- script/clean | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/build/Gruntfile.coffee b/build/Gruntfile.coffee index 7ef1157fd..282a5ab6b 100644 --- a/build/Gruntfile.coffee +++ b/build/Gruntfile.coffee @@ -58,13 +58,13 @@ module.exports = (grunt) -> installDir = path.join('/Applications', appName) else appName = 'Atom' - tmpDir = '/tmp' + tmpDir = os.tmpdir() 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' + atomShellDownloadDir = path.join(tmpDir, 'atom-cached-atom-shells') installDir = process.env.INSTALL_PREFIX ? '/usr/local' coffeeConfig = diff --git a/script/clean b/script/clean index e55668215..833f64b62 100755 --- a/script/clean +++ b/script/clean @@ -8,7 +8,7 @@ var productName = require('../package.json').productName; process.chdir(path.dirname(__dirname)); var home = process.env[(process.platform === 'win32') ? 'USERPROFILE' : 'HOME']; -var tmpdir = process.platform === 'win32' ? os.tmpdir() : '/tmp'; +var tmpdir = process.platform !== 'darwin' ? os.tmpdir() : '/tmp'; // Windows: Use START as a way to ignore error if Atom.exe isnt running var killatom = process.platform === 'win32' ? 'START taskkill /F /IM ' + productName + '.exe' : 'pkill -9 ' + productName + ' || true'; From 2d96444e2199e935f5cb743b0da3a53f3342e0ad Mon Sep 17 00:00:00 2001 From: Pritam Baral Date: Sat, 17 May 2014 00:40:35 +0530 Subject: [PATCH 2/4] Use os.tmpdir() on OS X --- build/Gruntfile.coffee | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/Gruntfile.coffee b/build/Gruntfile.coffee index 282a5ab6b..4a58cea4b 100644 --- a/build/Gruntfile.coffee +++ b/build/Gruntfile.coffee @@ -48,13 +48,13 @@ module.exports = (grunt) -> installDir = path.join(process.env.ProgramFiles, appName) else if process.platform is 'darwin' appName = 'Atom.app' - tmpDir = '/tmp' + tmpDir = os.tmpdir() 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' + atomShellDownloadDir = path.join(os.tmpdir(), 'atom-cached-atom-shells') installDir = path.join('/Applications', appName) else appName = 'Atom' From 25d22064713b5c6044de17fc27d8690bc0ae9cc6 Mon Sep 17 00:00:00 2001 From: Pritam Baral Date: Sat, 17 May 2014 00:40:55 +0530 Subject: [PATCH 3/4] Consolidate redundant code --- build/Gruntfile.coffee | 20 +++++--------------- script/clean | 2 +- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/build/Gruntfile.coffee b/build/Gruntfile.coffee index 4a58cea4b..9778467c7 100644 --- a/build/Gruntfile.coffee +++ b/build/Gruntfile.coffee @@ -36,35 +36,25 @@ module.exports = (grunt) -> grunt.log.write = (args...) -> grunt.log [major, minor, patch] = packageJson.version.split('.') + tmpDir = os.tmpdir() + buildDir = grunt.option('build-dir') ? path.join(tmpDir, 'atom-build') + atomShellDownloadDir = path.join(os.tmpdir(), 'atom-cached-atom-shells') + symbolsDir = path.join(buildDir, 'Atom.breakpad.syms') + shellAppDir = path.join(buildDir, appName) if process.platform is 'win32' appName = 'Atom' - tmpDir = os.tmpdir() - 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 = os.tmpdir() - 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 = path.join(os.tmpdir(), 'atom-cached-atom-shells') installDir = path.join('/Applications', appName) else appName = 'Atom' - tmpDir = os.tmpdir() - 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(tmpDir, 'atom-cached-atom-shells') installDir = process.env.INSTALL_PREFIX ? '/usr/local' coffeeConfig = diff --git a/script/clean b/script/clean index 833f64b62..2ee2390e7 100755 --- a/script/clean +++ b/script/clean @@ -8,7 +8,7 @@ var productName = require('../package.json').productName; process.chdir(path.dirname(__dirname)); var home = process.env[(process.platform === 'win32') ? 'USERPROFILE' : 'HOME']; -var tmpdir = process.platform !== 'darwin' ? os.tmpdir() : '/tmp'; +var tmpdir = os.tmpdir(); // Windows: Use START as a way to ignore error if Atom.exe isnt running var killatom = process.platform === 'win32' ? 'START taskkill /F /IM ' + productName + '.exe' : 'pkill -9 ' + productName + ' || true'; From 7627e0b0f09e6cbdc040aef2346110912e1d6588 Mon Sep 17 00:00:00 2001 From: Pritam Baral Date: Mon, 19 May 2014 23:56:47 +0530 Subject: [PATCH 4/4] Minor fix + Remove last references to /tmp --- CONTRIBUTING.md | 3 +-- atom.sh | 8 +++++--- build/Gruntfile.coffee | 4 +--- build/tasks/clean-task.coffee | 2 +- docs/build-instructions/freebsd.md | 2 +- docs/build-instructions/linux.md | 4 ++-- 6 files changed, 11 insertions(+), 12 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 153f780fd..d9b837174 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -45,8 +45,7 @@ in the proper package's repository. * Beware of platform differences * Use `require('atom').fs.getHomeDirectory()` to get the home directory. * Use `path.join()` to concatenate filenames. - * Temporary directory is not `/tmp` on Windows, use `os.tmpdir()` when - possible + * Use `os.tmpdir()` instead of `/tmp ## Git Commit Messages * Use the present tense diff --git a/atom.sh b/atom.sh index 840c0364a..ddeba08d9 100755 --- a/atom.sh +++ b/atom.sh @@ -70,16 +70,18 @@ elif [ $OS == 'Linux' ]; then USR_DIRECTORY=$(readlink -f $(dirname $SCRIPT)/..) ATOM_PATH="$USR_DIRECTORY/share/atom/atom" - [ -x "$ATOM_PATH" ] || ATOM_PATH='/tmp/atom-build/Atom/atom' + : ${TMPDIR:=/tmp} + + [ -x "$ATOM_PATH" ] || ATOM_PATH="$TMPDIR/atom-build/Atom/atom" if [ $EXPECT_OUTPUT ]; then "$ATOM_PATH" --executed-from="$(pwd)" --pid=$$ "$@" exit $? else ( - nohup "$ATOM_PATH" --executed-from="$(pwd)" --pid=$$ "$@" > /tmp/atom-nohup.out 2>&1 + nohup "$ATOM_PATH" --executed-from="$(pwd)" --pid=$$ "$@" > "$TMPDIR/atom-nohup.out" 2>&1 if [ $? -ne 0 ]; then - cat /tmp/atom-nohup.out + cat "$TMPDIR/atom-nohup.out" exit $? fi ) & diff --git a/build/Gruntfile.coffee b/build/Gruntfile.coffee index 9778467c7..337c4833b 100644 --- a/build/Gruntfile.coffee +++ b/build/Gruntfile.coffee @@ -37,22 +37,20 @@ module.exports = (grunt) -> [major, minor, patch] = packageJson.version.split('.') tmpDir = os.tmpdir() + appName = if process.platform is 'darwin' then 'Atom.app' else 'Atom' buildDir = grunt.option('build-dir') ? path.join(tmpDir, 'atom-build') atomShellDownloadDir = path.join(os.tmpdir(), 'atom-cached-atom-shells') symbolsDir = path.join(buildDir, 'Atom.breakpad.syms') shellAppDir = path.join(buildDir, appName) if process.platform is 'win32' - appName = 'Atom' contentsDir = shellAppDir appDir = path.join(shellAppDir, 'resources', 'app') installDir = path.join(process.env.ProgramFiles, appName) else if process.platform is 'darwin' - appName = 'Atom.app' contentsDir = path.join(shellAppDir, 'Contents') appDir = path.join(contentsDir, 'Resources', 'app') installDir = path.join('/Applications', appName) else - appName = 'Atom' contentsDir = shellAppDir appDir = path.join(shellAppDir, 'resources', 'app') installDir = process.env.INSTALL_PREFIX ? '/usr/local' diff --git a/build/tasks/clean-task.coffee b/build/tasks/clean-task.coffee index 1d0befa3f..97f0a9105 100644 --- a/build/tasks/clean-task.coffee +++ b/build/tasks/clean-task.coffee @@ -5,7 +5,7 @@ module.exports = (grunt) -> {rm} = require('./task-helpers')(grunt) grunt.registerTask 'partial-clean', 'Delete some of the build files', -> - tmpdir = if process.platform is 'win32' then os.tmpdir() else '/tmp' + tmpdir = os.tmpdir() rm grunt.config.get('atom.buildDir') rm require('../src/coffee-cache').cacheDir diff --git a/docs/build-instructions/freebsd.md b/docs/build-instructions/freebsd.md index 2299d9cab..147c9da23 100644 --- a/docs/build-instructions/freebsd.md +++ b/docs/build-instructions/freebsd.md @@ -15,7 +15,7 @@ FreeBSD -RELEASE 64-bit is the recommended platform. ```sh git clone https://github.com/atom/atom cd atom - script/build # Creates application at /tmp/atom-build/Atom + script/build # Creates application at $TMPDIR/atom-build/Atom sudo script/grunt install # Installs command to /usr/local/bin/atom ``` diff --git a/docs/build-instructions/linux.md b/docs/build-instructions/linux.md index 359c780b9..259ef71d5 100644 --- a/docs/build-instructions/linux.md +++ b/docs/build-instructions/linux.md @@ -15,9 +15,9 @@ Ubuntu LTS 12.04 64-bit is the recommended platform. ```sh git clone https://github.com/atom/atom cd atom - script/build # Creates application at /tmp/atom-build/Atom + script/build # Creates application at $TMPDIR/atom-build/Atom sudo script/grunt install # Installs command to /usr/local/bin/atom - script/grunt mkdeb # Generates a .deb package at /tmp/atom-build + script/grunt mkdeb # Generates a .deb package at $TMPDIR/atom-build ``` ## Troubleshooting