Fix: only add apt sources for users that want them (#22145) (#221285)

Signed-off-by: Matthias Breithaupt <m.breithaupt@vogl-electronic.com>
pull/224992/head
Matthias B. 2024-08-06 23:54:05 +02:00 committed by GitHub
parent ab962cd422
commit cd340e6aa4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 61 additions and 6 deletions

View File

@ -108,7 +108,11 @@ function prepareDebPackage(arch) {
.pipe(replace('@@NAME@@', product.applicationName))
.pipe(rename('DEBIAN/postinst'));
const all = es.merge(control, postinst, postrm, prerm, desktops, appdata, workspaceMime, icon, bash_completion, zsh_completion, code);
const templates = gulp.src('resources/linux/debian/templates.template', { base: '.' })
.pipe(replace('@@NAME@@', product.applicationName))
.pipe(rename('DEBIAN/templates'));
const all = es.merge(control, templates, postinst, postrm, prerm, desktops, appdata, workspaceMime, icon, bash_completion, zsh_completion, code);
return all.pipe(vfs.dest(destination));
};

View File

@ -35,20 +35,46 @@ if [ "@@NAME@@" != "code-oss" ]; then
eval $(apt-config shell APT_TRUSTED_PARTS Dir::Etc::trustedparts/d)
CODE_TRUSTED_PART=${APT_TRUSTED_PARTS}microsoft.gpg
RET=true
if [ -e '/usr/share/debconf/confmodule' ]; then
. /usr/share/debconf/confmodule
db_get @@NAME@@/add-microsoft-repo || true
fi
# Install repository source list
WRITE_SOURCE=0
if [ ! -f $CODE_SOURCE_PART ] && [ ! -f /etc/rpi-issue ]; then
# Write source list if it does not exist and we're not running on Raspberry Pi OS
WRITE_SOURCE=1
elif grep -Eq "http:\/\/packages\.microsoft\.com\/repos\/vscode" $CODE_SOURCE_PART; then
if [ "$RET" = false ]; then
# The user does not want to add the microsoft repository
WRITE_SOURCE=0
elif grep -q "http://packages.microsoft.com/repos/vscode" $CODE_SOURCE_PART; then
# Migrate from old repository
WRITE_SOURCE=2
elif grep -q "http://packages.microsoft.com/repos/code" $CODE_SOURCE_PART; then
# Migrate from old repository
WRITE_SOURCE=2
elif apt-cache policy | grep -q "https://packages.microsoft.com/repos/code"; then
# Skip following checks if the repo is already known to apt
WRITE_SOURCE=0
elif [ ! -f $CODE_SOURCE_PART ] && [ ! -f /etc/rpi-issue ]; then
# Write source list if it does not exist and we're not running on Raspberry Pi OS
WRITE_SOURCE=1
elif grep -q "# disabled on upgrade to" $CODE_SOURCE_PART; then
# Write source list if it was disabled by OS upgrade
WRITE_SOURCE=1
fi
if [ "$WRITE_SOURCE" -eq "1" ]; then
if [ "$WRITE_SOURCE" -eq "1" ] && [ -e '/usr/share/debconf/confmodule' ]; then
# Ask the user whether to actually write the source list
db_input high @@NAME@@/add-microsoft-repo || true
db_go || true
db_get @@NAME@@/add-microsoft-repo
if [ "$RET" = false ]; then
WRITE_SOURCE=0
fi
fi
if [ "$WRITE_SOURCE" -ne "0" ]; then
echo "### THIS FILE IS AUTOMATICALLY CONFIGURED ###
# You may comment out this entry, but any other modifications may be lost.
deb [arch=amd64,arm64,armhf] https://packages.microsoft.com/repos/code stable main" > $CODE_SOURCE_PART

View File

@ -14,3 +14,22 @@ fi
if hash update-mime-database 2>/dev/null; then
update-mime-database /usr/share/mime
fi
RET=true
if [ -e '/usr/share/debconf/confmodule' ]; then
. /usr/share/debconf/confmodule
db_get @@NAME@@/add-microsoft-repo || true
fi
if [ "$RET" = "true" ]; then
eval $(apt-config shell APT_SOURCE_PARTS Dir::Etc::sourceparts/d)
CODE_SOURCE_PART=${APT_SOURCE_PARTS}vscode.list
rm -f $CODE_SOURCE_PART
eval $(apt-config shell APT_TRUSTED_PARTS Dir::Etc::trustedparts/d)
CODE_TRUSTED_PART=${APT_TRUSTED_PARTS}microsoft.gpg
rm -f $CODE_TRUSTED_PART
fi
if [ "$1" = "purge" ] && [ -e '/usr/share/debconf/confmodule' ]; then
db_purge
fi

View File

@ -0,0 +1,6 @@
Template: @@NAME@@/add-microsoft-repo
Type: boolean
Default: true
Description: Add Microsoft apt repository for Visual Studio Code?
The installer would like to add the Microsoft repository and signing
key to update VS Code through apt.