From 8b9a3046dd4db10513985b92be489f84ae5c66e4 Mon Sep 17 00:00:00 2001 From: Raymond Zhao <7199958+rzhao271@users.noreply.github.com> Date: Tue, 21 Apr 2026 14:54:45 -0700 Subject: [PATCH 1/4] fix: post-install script doesn't check for existing sources Co-authored-by: Copilot --- resources/linux/debian/postinst.template | 25 ++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/resources/linux/debian/postinst.template b/resources/linux/debian/postinst.template index 5ee1ebb5af529..a49b6f6768819 100755 --- a/resources/linux/debian/postinst.template +++ b/resources/linux/debian/postinst.template @@ -36,6 +36,28 @@ if [ "@@NAME@@" != "code-oss" ]; then CODE_TRUSTED_PART=/usr/share/keyrings/microsoft.gpg CODE_TRUSTED_PART_OLD="/etc/apt/trusted.gpg.d/microsoft.gpg" + has_existing_repo_source() { + for source_file in "${APT_SOURCE_PARTS}"*.list "${APT_SOURCE_PARTS}"*.sources; do + if [ ! -f "$source_file" ]; then + continue + fi + + # Classic apt source list entry, for example: + # deb [arch=amd64] https://packages.microsoft.com/repos/code stable main + if grep -Eiq "^[[:space:]]*deb[[:space:]].*https://packages\\.microsoft\\.com/repos/code([[:space:]]|$)" "$source_file"; then + return 0 + fi + + # DEB822 source entry, for example: + # URIs: https://packages.microsoft.com/repos/code + if grep -Eiq "^[[:space:]]*URIs:[[:space:]]*https://packages\\.microsoft\\.com/repos/code([[:space:]]|$)" "$source_file"; then + return 0 + fi + done + + return 1 + } + # RET seems to be true by default even after db_get is called on a first install. RET='true' if [ -e '/usr/share/debconf/confmodule' ]; then @@ -48,6 +70,9 @@ if [ "@@NAME@@" != "code-oss" ]; then if [ "$RET" = 'false' ]; then # The user specified in debconf not to add the Microsoft repository WRITE_SOURCE='no' + elif has_existing_repo_source; then + # Another source list file already maps to this repository + WRITE_SOURCE='no' elif [ -f "$CODE_SOURCE_PART" ]; then # The user is not on the new DEB822 format WRITE_SOURCE='yes' From d7a3d3c7a337442c92c426bb10bd8c70563d699c Mon Sep 17 00:00:00 2001 From: Raymond Zhao <7199958+rzhao271@users.noreply.github.com> Date: Tue, 21 Apr 2026 15:30:45 -0700 Subject: [PATCH 2/4] Update resources/linux/debian/postinst.template Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- resources/linux/debian/postinst.template | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/linux/debian/postinst.template b/resources/linux/debian/postinst.template index a49b6f6768819..5c20afe46c3ff 100755 --- a/resources/linux/debian/postinst.template +++ b/resources/linux/debian/postinst.template @@ -44,13 +44,13 @@ if [ "@@NAME@@" != "code-oss" ]; then # Classic apt source list entry, for example: # deb [arch=amd64] https://packages.microsoft.com/repos/code stable main - if grep -Eiq "^[[:space:]]*deb[[:space:]].*https://packages\\.microsoft\\.com/repos/code([[:space:]]|$)" "$source_file"; then + if grep -Eiq "^[[:space:]]*deb[[:space:]].*https://packages\\.microsoft\\.com/repos/code/?([[:space:]]|$)" "$source_file"; then return 0 fi # DEB822 source entry, for example: # URIs: https://packages.microsoft.com/repos/code - if grep -Eiq "^[[:space:]]*URIs:[[:space:]]*https://packages\\.microsoft\\.com/repos/code([[:space:]]|$)" "$source_file"; then + if grep -Eiq "^[[:space:]]*URIs:[[:space:]]*https://packages\\.microsoft\\.com/repos/code/?([[:space:]]|$)" "$source_file"; then return 0 fi done From 286e6e167ae1df0ad898326c3280748d17196875 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 21 Apr 2026 22:35:12 +0000 Subject: [PATCH 3/4] fix: also scan Dir::Etc::sourcelist in has_existing_repo_source Agent-Logs-Url: https://github.com/microsoft/vscode/sessions/b5d0d54b-bcba-40d2-ae60-e5c15f38e959 Co-authored-by: rzhao271 <7199958+rzhao271@users.noreply.github.com> --- resources/linux/debian/postinst.template | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/linux/debian/postinst.template b/resources/linux/debian/postinst.template index 5c20afe46c3ff..7eb96c67d33cc 100755 --- a/resources/linux/debian/postinst.template +++ b/resources/linux/debian/postinst.template @@ -29,7 +29,7 @@ if [ "@@NAME@@" != "code-oss" ]; then fi # Register apt repository - eval $(apt-config shell APT_SOURCE_PARTS Dir::Etc::sourceparts/d) + eval $(apt-config shell APT_SOURCE_PARTS Dir::Etc::sourceparts/d APT_SOURCES_LIST Dir::Etc::sourcelist/f) CODE_SOURCE_PART=${APT_SOURCE_PARTS}vscode.list CODE_SOURCE_PART_DEB822=${APT_SOURCE_PARTS}vscode.sources @@ -37,7 +37,7 @@ if [ "@@NAME@@" != "code-oss" ]; then CODE_TRUSTED_PART_OLD="/etc/apt/trusted.gpg.d/microsoft.gpg" has_existing_repo_source() { - for source_file in "${APT_SOURCE_PARTS}"*.list "${APT_SOURCE_PARTS}"*.sources; do + for source_file in "${APT_SOURCE_PARTS}"*.list "${APT_SOURCE_PARTS}"*.sources "$APT_SOURCES_LIST"; do if [ ! -f "$source_file" ]; then continue fi From 350b462e083d866ea1e78be4fa42c0d5c0fbe6f3 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 24 Apr 2026 17:14:05 +0000 Subject: [PATCH 4/4] fix: check our own managed files before has_existing_repo_source Agent-Logs-Url: https://github.com/microsoft/vscode/sessions/a7ac5d3d-6a46-40a4-b04b-75aaa68fcea9 Co-authored-by: rzhao271 <7199958+rzhao271@users.noreply.github.com> --- resources/linux/debian/postinst.template | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/resources/linux/debian/postinst.template b/resources/linux/debian/postinst.template index 7eb96c67d33cc..fa21fc470f1a0 100755 --- a/resources/linux/debian/postinst.template +++ b/resources/linux/debian/postinst.template @@ -70,15 +70,15 @@ if [ "@@NAME@@" != "code-oss" ]; then if [ "$RET" = 'false' ]; then # The user specified in debconf not to add the Microsoft repository WRITE_SOURCE='no' - elif has_existing_repo_source; then - # Another source list file already maps to this repository - WRITE_SOURCE='no' elif [ -f "$CODE_SOURCE_PART" ]; then # The user is not on the new DEB822 format WRITE_SOURCE='yes' elif [ -f "$CODE_SOURCE_PART_DEB822" ]; then # The user is on the new DEB822 format, but refresh the file contents WRITE_SOURCE='yes' + elif has_existing_repo_source; then + # Another source list file already maps to this repository + WRITE_SOURCE='no' elif [ -f /etc/rpi-issue ]; then # Do not write on Raspberry Pi OS # https://github.com/microsoft/vscode/issues/118825