diff --git a/build/gulpfile.vscode.js b/build/gulpfile.vscode.js index 3c55a147481..f054156a22d 100644 --- a/build/gulpfile.vscode.js +++ b/build/gulpfile.vscode.js @@ -289,7 +289,11 @@ function prepareDebPackage(arch) { .pipe(es.through(function (f) { that.emit('data', f); }, function () { that.emit('end'); })); })); - var all = es.merge(control, desktop, icon, shortcut, code); + var prerm = gulp.src('resources/linux/debian/prerm.template', { base: '.' }) + .pipe(replace('@@NAME@@', product.applicationName)) + .pipe(rename('DEBIAN/prerm')) + + var all = es.merge(control, prerm, desktop, icon, shortcut, code); // Register an apt repository if this is an official build if (product.updateUrl && product.quality) { @@ -300,6 +304,11 @@ function prepareDebPackage(arch) { .pipe(replace('@@ARCHITECTURE@@', debArch)) .pipe(rename('DEBIAN/postinst')) all = es.merge(all, postinst); + } else { + var postinst = gulp.src('resources/linux/debian/postinst.oss.template', { base: '.' }) + .pipe(replace('@@NAME@@', product.applicationName)) + .pipe(rename('DEBIAN/postinst')) + all = es.merge(all, postinst); } return all diff --git a/resources/linux/debian/postinst.oss.template b/resources/linux/debian/postinst.oss.template new file mode 100755 index 00000000000..f584ee6849d --- /dev/null +++ b/resources/linux/debian/postinst.oss.template @@ -0,0 +1,9 @@ +#!/usr/bin/env bash +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. + +# Register code in the alternatives system +# Priority of 0 should never make code the default editor in auto mode as most +# developers would prefer a terminal editor as the default. +update-alternatives --install /usr/bin/editor editor /usr/bin/@@NAME@@ 0 diff --git a/resources/linux/debian/postinst.template b/resources/linux/debian/postinst.template index 50cb3eef490..947bf140ec3 100755 --- a/resources/linux/debian/postinst.template +++ b/resources/linux/debian/postinst.template @@ -3,6 +3,12 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. +# Register code in the alternatives system +# Priority of 0 should never make code the default editor in auto mode as most +# developers would prefer a terminal editor as the default. +update-alternatives --install /usr/bin/editor editor /usr/bin/@@NAME@@ 0 + +# Register repository as an apt source get_apt_config_value() { echo $(apt-config dump | grep "$1 " | sed -e "s/$1 \"//" -e "s/\";$//") } diff --git a/resources/linux/debian/prerm.template b/resources/linux/debian/prerm.template new file mode 100755 index 00000000000..b637d88e30a --- /dev/null +++ b/resources/linux/debian/prerm.template @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. + +# Deregister code from the alternatives system +update-alternatives --remove editor /usr/bin/@@NAME@@ \ No newline at end of file