Skip to content

Commit 28ba9f5

Browse files
authored
fix: add postinst template conditions (microsoft#225097)
1 parent 4a7a65c commit 28ba9f5

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

resources/linux/debian/postinst.template

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ if [ "@@NAME@@" != "code-oss" ]; then
3131
# Register apt repository
3232
eval $(apt-config shell APT_SOURCE_PARTS Dir::Etc::sourceparts/d)
3333
CODE_SOURCE_PART=${APT_SOURCE_PARTS}vscode.list
34+
CODE_SOURCE_PART_DEB822=${APT_SOURCE_PARTS}vscode.sources
3435

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

44-
# Install repository source list
45+
# Determine whether to install the repository source list
4546
WRITE_SOURCE=0
4647
if [ "$RET" = false ]; then
47-
# The user does not want to add the microsoft repository
48+
# The user does not want to add the Microsoft repository
4849
WRITE_SOURCE=0
49-
elif grep -q "http://packages.microsoft.com/repos/vscode" $CODE_SOURCE_PART; then
50+
elif [ -f "$CODE_SOURCE_PART_DEB822" ]; then
51+
# The user has migrated themselves to the DEB822 format
52+
WRITE_SOURCE=0
53+
elif [ -f "$CODE_SOURCE_PART" ] && (grep -q "http://packages.microsoft.com/repos/vscode" $CODE_SOURCE_PART); then
5054
# Migrate from old repository
5155
WRITE_SOURCE=2
52-
elif grep -q "http://packages.microsoft.com/repos/code" $CODE_SOURCE_PART; then
56+
elif [ -f "$CODE_SOURCE_PART" ] && (grep -q "http://packages.microsoft.com/repos/code" $CODE_SOURCE_PART); then
5357
# Migrate from old repository
5458
WRITE_SOURCE=2
5559
elif apt-cache policy | grep -q "https://packages.microsoft.com/repos/code"; then
56-
# Skip following checks if the repo is already known to apt
60+
# The user is already on the new repository
5761
WRITE_SOURCE=0
5862
elif [ ! -f $CODE_SOURCE_PART ] && [ ! -f /etc/rpi-issue ]; then
5963
# Write source list if it does not exist and we're not running on Raspberry Pi OS

0 commit comments

Comments
 (0)