Skip to content

Commit

Permalink
fix: add postinst template conditions (microsoft#225097)
Browse files Browse the repository at this point in the history
  • Loading branch information
rzhao271 authored Aug 8, 2024
1 parent 4a7a65c commit 28ba9f5
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions resources/linux/debian/postinst.template
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ if [ "@@NAME@@" != "code-oss" ]; then
# Register apt repository
eval $(apt-config shell APT_SOURCE_PARTS Dir::Etc::sourceparts/d)
CODE_SOURCE_PART=${APT_SOURCE_PARTS}vscode.list
CODE_SOURCE_PART_DEB822=${APT_SOURCE_PARTS}vscode.sources

eval $(apt-config shell APT_TRUSTED_PARTS Dir::Etc::trustedparts/d)
CODE_TRUSTED_PART=${APT_TRUSTED_PARTS}microsoft.gpg
Expand All @@ -41,19 +42,22 @@ if [ "@@NAME@@" != "code-oss" ]; then
db_get @@NAME@@/add-microsoft-repo || true
fi

# Install repository source list
# Determine whether to install the repository source list
WRITE_SOURCE=0
if [ "$RET" = false ]; then
# The user does not want to add the microsoft repository
# 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
elif [ -f "$CODE_SOURCE_PART_DEB822" ]; then
# The user has migrated themselves to the DEB822 format
WRITE_SOURCE=0
elif [ -f "$CODE_SOURCE_PART" ] && (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
elif [ -f "$CODE_SOURCE_PART" ] && (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
# The user is already on the new repository
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
Expand Down

0 comments on commit 28ba9f5

Please sign in to comment.