From cd12a7e389bff8e7ef96a01735e287f536c7f07a Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Tue, 5 Apr 2016 14:50:59 -0700 Subject: [PATCH] Include the Linux bin command in the main dir This also changes the behavior of the bin command to find cli.js relatively, meaning the CLI now supports non-standard install locations. --- build/gulpfile.vscode.js | 16 ++++++---------- resources/linux/bin/code.sh | 18 ++++++++++++++---- resources/linux/rpm/code.spec.template | 1 - 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/build/gulpfile.vscode.js b/build/gulpfile.vscode.js index c8362cfe20e..118822a144a 100644 --- a/build/gulpfile.vscode.js +++ b/build/gulpfile.vscode.js @@ -238,6 +238,10 @@ function packageTask(platform, arch, opts) { result = es.merge(result, gulp.src('resources/win32/bin/code.sh', { base: 'resources/win32' }) .pipe(replace('@@NAME@@', product.nameShort)) .pipe(rename(function (f) { f.basename = product.applicationName; f.extname = ''; }))); + } else if (platform === 'linux') { + result = es.merge(result, gulp.src('resources/linux/bin/code.sh', { base: '.' }) + .pipe(replace('@@NAME@@', product.applicationName)) + .pipe(rename('bin/' + product.applicationName))); } return result.pipe(symdest(destination)); @@ -259,10 +263,6 @@ function prepareDebPackage(arch) { var packageRevision = getEpochTime(); return function () { - var shortcut = gulp.src('resources/linux/bin/code.sh', { base: '.' }) - .pipe(replace('@@NAME@@', product.applicationName)) - .pipe(rename('usr/share/' + product.applicationName + '/bin/' + product.applicationName)); - var desktop = gulp.src('resources/linux/code.desktop', { base: '.' }) .pipe(replace('@@NAME_LONG@@', product.nameLong)) .pipe(replace('@@NAME@@', product.applicationName)) @@ -299,7 +299,7 @@ function prepareDebPackage(arch) { .pipe(replace('@@UPDATEURL@@', product.updateUrl || '@@UPDATEURL@@')) .pipe(rename('DEBIAN/postinst')) - var all = es.merge(control, postinst, prerm, desktop, icon, shortcut, code); + var all = es.merge(control, postinst, prerm, desktop, icon, code); return all.pipe(symdest(destination)); }; @@ -335,10 +335,6 @@ function prepareRpmPackage(arch) { var packageRevision = getEpochTime(); return function () { - var shortcut = gulp.src('resources/linux/bin/code.sh', { base: '.' }) - .pipe(replace('@@NAME@@', product.applicationName)) - .pipe(rename('BUILD/usr/share/' + product.applicationName + '/bin/' + product.applicationName)); - var desktop = gulp.src('resources/linux/code.desktop', { base: '.' }) .pipe(replace('@@NAME_LONG@@', product.nameLong)) .pipe(replace('@@NAME@@', product.applicationName)) @@ -363,7 +359,7 @@ function prepareRpmPackage(arch) { var specIcon = gulp.src('resources/linux/rpm/code.xpm', { base: '.' }) .pipe(rename('SOURCES/' + product.applicationName + '.xpm')); - var all = es.merge(code, desktop, icon, shortcut, spec, specIcon); + var all = es.merge(code, desktop, icon, spec, specIcon); return all.pipe(symdest(destination)); } diff --git a/resources/linux/bin/code.sh b/resources/linux/bin/code.sh index 4806c026b61..0ebb4a496fc 100755 --- a/resources/linux/bin/code.sh +++ b/resources/linux/bin/code.sh @@ -3,9 +3,19 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. -NAME="@@NAME@@" -VSCODE_PATH="/usr/share/$NAME" -ELECTRON="$VSCODE_PATH/$NAME" +if [ ! -L $0 ]; then + # if path is not a symlink, find relatively + VSCODE_PATH="$(dirname $0)/.." +else + if which readlink >/dev/null; then + # if readlink exists, follow the symlink and find relatively + VSCODE_PATH="$(dirname $(readlink $0))/.." + else + # else use the standard install location + VSCODE_PATH="/usr/share/@@NAME@@" + fi +fi +ELECTRON="$VSCODE_PATH/@@NAME@@" CLI="$VSCODE_PATH/resources/app/out/cli.js" ATOM_SHELL_INTERNAL_RUN_AS_NODE=1 "$ELECTRON" "$CLI" "$@" -exit $? +exit $? \ No newline at end of file diff --git a/resources/linux/rpm/code.spec.template b/resources/linux/rpm/code.spec.template index bbc4b3c862f..33470043be6 100644 --- a/resources/linux/rpm/code.spec.template +++ b/resources/linux/rpm/code.spec.template @@ -46,6 +46,5 @@ ln -s /usr/share/@@NAME@@/bin/@@NAME@@ /usr/bin/@@NAME@@ %defattr(-,root,root) /usr/share/@@NAME@@/ -/usr/share/@@NAME@@/bin/@@NAME@@ /usr/share/applications/@@NAME@@.desktop /usr/share/pixmaps/@@NAME@@.png