From a38d660aa37a1402e67ca6ee29d39be23fe1a7fc Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Tue, 26 Sep 2017 10:33:31 -0400 Subject: [PATCH 1/8] Use correct indentation for snapcraft.yaml --- .editorconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.editorconfig b/.editorconfig index 40381bd6a77de..1089ed4f54ef6 100644 --- a/.editorconfig +++ b/.editorconfig @@ -11,6 +11,6 @@ trim_trailing_whitespace = true # The indent size used in the `package.json` file cannot be changed # https://github.com/npm/npm/pull/3180#issuecomment-16336516 -[{.travis.yml,npm-shrinkwrap.json,package.json}] +[{.travis.yml,npm-shrinkwrap.json,package.json,snapcraft.yaml}] indent_style = space indent_size = 2 From d2b2b4d7ea285561c7ab9b66d01d9d91e4daa8b9 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Tue, 26 Sep 2017 14:18:00 -0400 Subject: [PATCH 2/8] Add support for building x64 snap package --- .editorconfig | 2 +- build/gulpfile.hygiene.js | 36 ++++++++++++-------- build/gulpfile.vscode.linux.js | 51 ++++++++++++++++++++++++++++ resources/linux/code.desktop | 2 +- resources/linux/snap/electron-launch | 30 ++++++++++++++++ resources/linux/snap/snapcraft.yaml | 51 ++++++++++++++++++++++++++++ 6 files changed, 155 insertions(+), 17 deletions(-) create mode 100644 resources/linux/snap/electron-launch create mode 100644 resources/linux/snap/snapcraft.yaml diff --git a/.editorconfig b/.editorconfig index 1089ed4f54ef6..f00ed01c2e335 100644 --- a/.editorconfig +++ b/.editorconfig @@ -11,6 +11,6 @@ trim_trailing_whitespace = true # The indent size used in the `package.json` file cannot be changed # https://github.com/npm/npm/pull/3180#issuecomment-16336516 -[{.travis.yml,npm-shrinkwrap.json,package.json,snapcraft.yaml}] +[{*.yml,*.yaml,npm-shrinkwrap.json,package.json}] indent_style = space indent_size = 2 diff --git a/build/gulpfile.hygiene.js b/build/gulpfile.hygiene.js index 97b1ab8367eae..1d94c725e1f8a 100644 --- a/build/gulpfile.hygiene.js +++ b/build/gulpfile.hygiene.js @@ -6,6 +6,7 @@ 'use strict'; const gulp = require('gulp'); +const path = require('path'); const filter = require('gulp-filter'); const es = require('event-stream'); const gulptslint = require('gulp-tslint'); @@ -172,21 +173,26 @@ const hygiene = exports.hygiene = (some, options) => { }); const indentation = es.through(function (file) { - file.contents - .toString('utf8') - .split(/\r\n|\r|\n/) - .forEach((line, i) => { - if (/^\s*$/.test(line)) { - // empty or whitespace lines are OK - } else if (/^[\t]*[^\s]/.test(line)) { - // good indent - } else if (/^[\t]* \*/.test(line)) { - // block comment using an extra space - } else { - console.error(file.relative + '(' + (i + 1) + ',1): Bad whitespace indentation'); - errorCount++; - } - }); + // Only do the indentation check for non-YAML files as they forbid tabs + // for indentation + const extname = path.extname(file.relative); + if (extname !== '.yaml' && extname !== '.yml') { + file.contents + .toString('utf8') + .split(/\r\n|\r|\n/) + .forEach((line, i) => { + if (/^\s*$/.test(line)) { + // empty or whitespace lines are OK + } else if (/^[\t]*[^\s]/.test(line)) { + // good indent + } else if (/^[\t]* \*/.test(line)) { + // block comment using an extra space + } else { + console.error(file.relative + '(' + (i + 1) + ',1): Bad whitespace indentation'); + errorCount++; + } + }); + } this.emit('data', file); }); diff --git a/build/gulpfile.vscode.linux.js b/build/gulpfile.vscode.linux.js index 54c73a538c207..bfc9108e2aa84 100644 --- a/build/gulpfile.vscode.linux.js +++ b/build/gulpfile.vscode.linux.js @@ -55,6 +55,7 @@ function prepareDebPackage(arch) { .pipe(replace('@@NAME_LONG@@', product.nameLong)) .pipe(replace('@@NAME_SHORT@@', product.nameShort)) .pipe(replace('@@NAME@@', product.applicationName)) + .pipe(replace('@@ICON@@', product.applicationName)) .pipe(rename('usr/share/applications/' + product.applicationName + '.desktop')); const appdata = gulp.src('resources/linux/code.appdata.xml', { base: '.' }) @@ -131,6 +132,7 @@ function prepareRpmPackage(arch) { .pipe(replace('@@NAME_LONG@@', product.nameLong)) .pipe(replace('@@NAME_SHORT@@', product.nameShort)) .pipe(replace('@@NAME@@', product.applicationName)) + .pipe(replace('@@ICON@@', product.applicationName)) .pipe(rename('BUILD/usr/share/applications/' + product.applicationName + '.desktop')); const appdata = gulp.src('resources/linux/code.appdata.xml', { base: '.' }) @@ -178,6 +180,51 @@ function buildRpmPackage(arch) { 'cp "' + rpmOut + '/$(ls ' + rpmOut + ')" ' + destination + '/' ]); } +function getSnapBuildPath(arch) { + return `.build/linux/snap/${arch}/${product.applicationName}-${arch}`; +} + +function prepareSnapPackage(arch) { + const binaryDir = '../VSCode-linux-' + arch; + const destination = getSnapBuildPath(arch); + + return function () { + const desktop = gulp.src('resources/linux/code.desktop', { base: '.' }) + .pipe(replace('@@NAME_LONG@@', product.nameLong)) + .pipe(replace('@@NAME_SHORT@@', product.nameShort)) + .pipe(replace('@@NAME@@', product.applicationName)) + .pipe(replace('@@ICON@@', `/usr/share/pixmaps/${product.applicationName}.png`)) + .pipe(rename(`usr/share/applications/${product.applicationName}.desktop`)); + + const icon = gulp.src('resources/linux/code.png', { base: '.' }) + .pipe(rename(`usr/share/pixmaps/${product.applicationName}.png`)); + + const code = gulp.src(binaryDir + '/**/*', { base: binaryDir }) + .pipe(rename(function (p) { p.dirname = 'usr/share/' + product.applicationName + '/' + p.dirname; })); + + const snapcraft = gulp.src('resources/linux/snap/snapcraft.yaml', { base: '.' }) + .pipe(replace('@@NAME@@', product.applicationName)) + .pipe(replace('@@VERSION@@', packageJson.version)) + .pipe(replace('@@EPOCH@@', linuxPackageRevision)) + .pipe(rename('snap/snapcraft.yaml')); + + const electronLaunch = gulp.src('resources/linux/snap/electron-launch', { base: '.' }) + .pipe(rename('electron-launch')); + + const all = es.merge(desktop, icon, code, snapcraft, electronLaunch); + + return all.pipe(vfs.dest(destination)); + }; +} + +function buildSnapPackage(arch) { + const snapBuildPath = getSnapBuildPath(arch); + + return shell.task([ + `chmod +x ${snapBuildPath}/electron-launch`, + `cd ${snapBuildPath} && snapcraft snap` + ]); +} function getFlatpakArch(arch) { return { x64: 'x86_64', ia32: 'i386', arm: 'arm' }[arch]; @@ -273,6 +320,10 @@ gulp.task('vscode-linux-ia32-build-rpm', ['vscode-linux-ia32-prepare-rpm'], buil gulp.task('vscode-linux-x64-build-rpm', ['vscode-linux-x64-prepare-rpm'], buildRpmPackage('x64')); gulp.task('vscode-linux-arm-build-rpm', ['vscode-linux-arm-prepare-rpm'], buildRpmPackage('arm')); +gulp.task('clean-vscode-linux-x64-snap', util.rimraf('.build/linux/snap/x64')); +gulp.task('vscode-linux-x64-prepare-snap', ['clean-vscode-linux-x64-snap'], prepareSnapPackage('x64')); +gulp.task('vscode-linux-x64-build-snap', ['vscode-linux-x64-prepare-snap'], buildSnapPackage('x64')); + gulp.task('clean-vscode-linux-ia32-flatpak', util.rimraf('.build/linux/flatpak/i386')); gulp.task('clean-vscode-linux-x64-flatpak', util.rimraf('.build/linux/flatpak/x86_64')); gulp.task('clean-vscode-linux-arm-flatpak', util.rimraf('.build/linux/flatpak/arm')); diff --git a/resources/linux/code.desktop b/resources/linux/code.desktop index 99a1189a0fe48..0048429416c15 100644 --- a/resources/linux/code.desktop +++ b/resources/linux/code.desktop @@ -3,7 +3,7 @@ Name=@@NAME_LONG@@ Comment=Code Editing. Redefined. GenericName=Text Editor Exec=/usr/share/@@NAME@@/@@NAME@@ --unity-launch %F -Icon=@@NAME@@ +Icon=@@ICON@@ Type=Application StartupNotify=true StartupWMClass=@@NAME_SHORT@@ diff --git a/resources/linux/snap/electron-launch b/resources/linux/snap/electron-launch new file mode 100644 index 0000000000000..aa403d5e07235 --- /dev/null +++ b/resources/linux/snap/electron-launch @@ -0,0 +1,30 @@ +#!/bin/sh + +if test "$1" = "classic"; then + shift + case $SNAP_ARCH in + amd64) + TRIPLET="x86_64-linux-gnu" + ;; + armhf) + TRIPLET="arm-linux-gnueabihf" + ;; + arm64) + TRIPLET="aarch64-linux-gnu" + ;; + *) + TRIPLET="$(uname -p)-linux-gnu" + ;; + esac + + # TODO: Swap LD lib paths whenever processes are launched + export LD_LIBRARY_PATH_OLD=$LD_LIBRARY_PATH + export LD_LIBRARY_PATH=$SNAP/usr/lib:$SNAP/usr/lib/$TRIPLET:$LD_LIBRARY_PATH + export LD_LIBRARY_PATH=$SNAP/lib:$SNAP/lib/$TRIPLET:$LD_LIBRARY_PATH +fi + +# Correct the TMPDIR path for Chromium Framework/Electron to ensure +# libappindicator has readable resources. +export TMPDIR=$XDG_RUNTIME_DIR + +exec ${SNAP}/bin/desktop-launch $@ diff --git a/resources/linux/snap/snapcraft.yaml b/resources/linux/snap/snapcraft.yaml new file mode 100644 index 0000000000000..adb177faf4837 --- /dev/null +++ b/resources/linux/snap/snapcraft.yaml @@ -0,0 +1,51 @@ +name: @@NAME@@ +version: @@VERSION@@ +epoch: @@EPOCH@@ +summary: Code editing. Redefined. +description: | + Visual Studio Code is a new choice of tool that combines the + simplicity of a code editor with what developers need for the core + edit-build-debug cycle. + +grade: stable +confinement: classic + +parts: + code: + plugin: dump + source: . + # source: https://az764295.vo.msecnd.net/stable/27492b6bf3acb0775d82d2f87b25a93490673c6d/code_1.16.1-1505406497_amd64.deb + # source-type: deb + # Correct path to icon. + # Remove translated Name[xx]= + # - Due to http://pad.lv/1662456 + # prepare: | + # sed -i 's|Icon=.code|Icon=/usr/share/pixmaps/code\.png|g' usr/share/applications/code.desktop + # sed -i '/^Name\[/d' usr/share/applications/code.desktop + after: + - desktop-gtk2 + stage-packages: + - gconf2 + - libasound2 + - libnotify4 + - libnspr4 + - libnss3 + - libpulse0 + - libxss1 + - libxtst6 + prime: + - -usr/share/dh-python + electron-launch: + plugin: dump + source: . + organize: + electron-launch: bin/electron-launch + prime: + - -monitor.sh + - -OLD_VERSION + - -*.bz2 + +apps: + @@NAME@@: + command: bin/electron-launch classic ${SNAP}/usr/share/@@NAME@@/bin/@@NAME@@ + desktop: usr/share/applications/@@NAME@@.desktop \ No newline at end of file From 7a155620528dee420efe840f349176dd61673179 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Tue, 26 Sep 2017 14:22:16 -0400 Subject: [PATCH 3/8] Add snap path echo to release.sh --- build/tfs/linux/release.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/build/tfs/linux/release.sh b/build/tfs/linux/release.sh index e4d2009a17215..01f379a0ef88d 100755 --- a/build/tfs/linux/release.sh +++ b/build/tfs/linux/release.sh @@ -49,6 +49,11 @@ RPM_PATH="$REPO/.build/linux/rpm/$RPM_ARCH/$RPM_FILENAME" step "Publish RPM package" \ node build/tfs/common/publish.js $VSCODE_QUALITY $PLATFORM_RPM package $RPM_FILENAME $VERSION true $RPM_PATH +SNAP_FILENAME="$(ls $REPO/.build/linux/snap/$ARCH/ | grep .snap)" +SNAP_PATH="$REPO/.build/linux/snap/$ARCH/$SNAP_FILENAME" +echo 'SNAP_PATH' +echo $SNAP_PATH + if [ -z "$VSCODE_QUALITY" ]; then echo "VSCODE_QUALITY is not set, skipping repo package publish" else From b557752d57b4cfcf4a2558a2ff562d6db1d5867e Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Tue, 26 Sep 2017 14:37:29 -0400 Subject: [PATCH 4/8] Fix typo --- build/tfs/common/publish.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/tfs/common/publish.ts b/build/tfs/common/publish.ts index d959159dc86f3..b18dc146d3e2d 100644 --- a/build/tfs/common/publish.ts +++ b/build/tfs/common/publish.ts @@ -156,7 +156,7 @@ async function publish(commit: string, quality: string, platform: string, type: console.log('Publishing...'); console.log('Quality:', quality); - console.log('Platforn:', platform); + console.log('Platform:', platform); console.log('Type:', type); console.log('Name:', name); console.log('Version:', version); From 562f7efe5d979b167bde326568059a43efe7a2b1 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Tue, 26 Sep 2017 14:50:41 -0400 Subject: [PATCH 5/8] Build snap package in release.sh --- build/tfs/linux/release.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/build/tfs/linux/release.sh b/build/tfs/linux/release.sh index 01f379a0ef88d..5025ed717ae5e 100755 --- a/build/tfs/linux/release.sh +++ b/build/tfs/linux/release.sh @@ -9,6 +9,9 @@ step "Build Debian package" \ step "Build RPM package" \ npm run gulp -- "vscode-linux-$ARCH-build-rpm" +step "Build snap package" \ + npm run gulp -- "vscode-linux-$ARCH-build-snap" + (cd $BUILD_SOURCESDIRECTORY/build/tfs/common && \ step "Install build dependencies" \ npm install --unsafe-perm) From ff6f0e462a301901c3c1968e53030a18f50fb3fe Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Thu, 28 Sep 2017 09:44:48 -0400 Subject: [PATCH 6/8] Add ia32 and arm snap builds --- build/gulpfile.vscode.linux.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/build/gulpfile.vscode.linux.js b/build/gulpfile.vscode.linux.js index bfc9108e2aa84..055397ca77d3d 100644 --- a/build/gulpfile.vscode.linux.js +++ b/build/gulpfile.vscode.linux.js @@ -305,6 +305,12 @@ gulp.task('clean-vscode-linux-arm-deb', util.rimraf('.build/linux/deb/armhf')); gulp.task('clean-vscode-linux-ia32-rpm', util.rimraf('.build/linux/rpm/i386')); gulp.task('clean-vscode-linux-x64-rpm', util.rimraf('.build/linux/rpm/x86_64')); gulp.task('clean-vscode-linux-arm-rpm', util.rimraf('.build/linux/rpm/armhf')); +gulp.task('clean-vscode-linux-ia32-snap', util.rimraf('.build/linux/snap/x64')); +gulp.task('clean-vscode-linux-x64-snap', util.rimraf('.build/linux/snap/x64')); +gulp.task('clean-vscode-linux-arm-snap', util.rimraf('.build/linux/snap/x64')); +gulp.task('clean-vscode-linux-ia32-flatpak', util.rimraf('.build/linux/flatpak/i386')); +gulp.task('clean-vscode-linux-x64-flatpak', util.rimraf('.build/linux/flatpak/x86_64')); +gulp.task('clean-vscode-linux-arm-flatpak', util.rimraf('.build/linux/flatpak/arm')); gulp.task('vscode-linux-ia32-prepare-deb', ['clean-vscode-linux-ia32-deb'], prepareDebPackage('ia32')); gulp.task('vscode-linux-x64-prepare-deb', ['clean-vscode-linux-x64-deb'], prepareDebPackage('x64')); @@ -320,18 +326,16 @@ gulp.task('vscode-linux-ia32-build-rpm', ['vscode-linux-ia32-prepare-rpm'], buil gulp.task('vscode-linux-x64-build-rpm', ['vscode-linux-x64-prepare-rpm'], buildRpmPackage('x64')); gulp.task('vscode-linux-arm-build-rpm', ['vscode-linux-arm-prepare-rpm'], buildRpmPackage('arm')); -gulp.task('clean-vscode-linux-x64-snap', util.rimraf('.build/linux/snap/x64')); +gulp.task('vscode-linux-ia32-prepare-snap', ['clean-vscode-linux-ia32-snap'], prepareSnapPackage('ia32')); gulp.task('vscode-linux-x64-prepare-snap', ['clean-vscode-linux-x64-snap'], prepareSnapPackage('x64')); +gulp.task('vscode-linux-arm-prepare-snap', ['clean-vscode-linux-arm-snap'], prepareSnapPackage('arm')); +gulp.task('vscode-linux-ia32-build-snap', ['vscode-linux-ia32-prepare-snap'], buildSnapPackage('ia32')); gulp.task('vscode-linux-x64-build-snap', ['vscode-linux-x64-prepare-snap'], buildSnapPackage('x64')); - -gulp.task('clean-vscode-linux-ia32-flatpak', util.rimraf('.build/linux/flatpak/i386')); -gulp.task('clean-vscode-linux-x64-flatpak', util.rimraf('.build/linux/flatpak/x86_64')); -gulp.task('clean-vscode-linux-arm-flatpak', util.rimraf('.build/linux/flatpak/arm')); +gulp.task('vscode-linux-arm-build-snap', ['vscode-linux-arm-prepare-snap'], buildSnapPackage('arm')); gulp.task('vscode-linux-ia32-prepare-flatpak', ['clean-vscode-linux-ia32-flatpak'], prepareFlatpak('ia32')); gulp.task('vscode-linux-x64-prepare-flatpak', ['clean-vscode-linux-x64-flatpak'], prepareFlatpak('x64')); gulp.task('vscode-linux-arm-prepare-flatpak', ['clean-vscode-linux-arm-flatpak'], prepareFlatpak('arm')); - gulp.task('vscode-linux-ia32-flatpak', ['vscode-linux-ia32-prepare-flatpak'], buildFlatpak('ia32')); gulp.task('vscode-linux-x64-flatpak', ['vscode-linux-x64-prepare-flatpak'], buildFlatpak('x64')); gulp.task('vscode-linux-arm-flatpak', ['vscode-linux-arm-prepare-flatpak'], buildFlatpak('arm')); From e05b15cd125543e9b0efcba1df661fde767793b8 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Mon, 2 Oct 2017 13:32:33 -0700 Subject: [PATCH 7/8] Clean up comment --- resources/linux/snap/snapcraft.yaml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/resources/linux/snap/snapcraft.yaml b/resources/linux/snap/snapcraft.yaml index adb177faf4837..b8818cd468b70 100644 --- a/resources/linux/snap/snapcraft.yaml +++ b/resources/linux/snap/snapcraft.yaml @@ -14,14 +14,6 @@ parts: code: plugin: dump source: . - # source: https://az764295.vo.msecnd.net/stable/27492b6bf3acb0775d82d2f87b25a93490673c6d/code_1.16.1-1505406497_amd64.deb - # source-type: deb - # Correct path to icon. - # Remove translated Name[xx]= - # - Due to http://pad.lv/1662456 - # prepare: | - # sed -i 's|Icon=.code|Icon=/usr/share/pixmaps/code\.png|g' usr/share/applications/code.desktop - # sed -i '/^Name\[/d' usr/share/applications/code.desktop after: - desktop-gtk2 stage-packages: From 081a57ca962a284e7e80341426cdd1621befd67b Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Mon, 2 Oct 2017 13:34:07 -0700 Subject: [PATCH 8/8] Remove epoch from snap package --- build/gulpfile.vscode.linux.js | 1 - resources/linux/snap/snapcraft.yaml | 1 - 2 files changed, 2 deletions(-) diff --git a/build/gulpfile.vscode.linux.js b/build/gulpfile.vscode.linux.js index 055397ca77d3d..ee92561849e45 100644 --- a/build/gulpfile.vscode.linux.js +++ b/build/gulpfile.vscode.linux.js @@ -205,7 +205,6 @@ function prepareSnapPackage(arch) { const snapcraft = gulp.src('resources/linux/snap/snapcraft.yaml', { base: '.' }) .pipe(replace('@@NAME@@', product.applicationName)) .pipe(replace('@@VERSION@@', packageJson.version)) - .pipe(replace('@@EPOCH@@', linuxPackageRevision)) .pipe(rename('snap/snapcraft.yaml')); const electronLaunch = gulp.src('resources/linux/snap/electron-launch', { base: '.' }) diff --git a/resources/linux/snap/snapcraft.yaml b/resources/linux/snap/snapcraft.yaml index b8818cd468b70..3b5daa2a8c544 100644 --- a/resources/linux/snap/snapcraft.yaml +++ b/resources/linux/snap/snapcraft.yaml @@ -1,6 +1,5 @@ name: @@NAME@@ version: @@VERSION@@ -epoch: @@EPOCH@@ summary: Code editing. Redefined. description: | Visual Studio Code is a new choice of tool that combines the