From 28ba9f5e580996d430aaa5b575d59fab9963e635 Mon Sep 17 00:00:00 2001 From: Raymond Zhao <7199958+rzhao271@users.noreply.github.com> Date: Wed, 7 Aug 2024 17:00:39 -0700 Subject: [PATCH] fix: add postinst template conditions (#225097) --- resources/linux/debian/postinst.template | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/resources/linux/debian/postinst.template b/resources/linux/debian/postinst.template index 7dc5bef8c5c95..b292cff8b2921 100755 --- a/resources/linux/debian/postinst.template +++ b/resources/linux/debian/postinst.template @@ -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