fix: add postinst template conditions (#225097)

This commit is contained in:
Raymond Zhao 2024-08-07 17:00:39 -07:00 committed by GitHub
parent 4a7a65c55b
commit 28ba9f5e58
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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
@ -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