mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-31 00:10:04 +08:00
fix: post-install script doesn't check for existing sources (#311795)
* fix: post-install script doesn't check for existing sources Co-authored-by: Copilot <copilot@github.com> * Update resources/linux/debian/postinst.template Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * 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> * 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> --------- Co-authored-by: Copilot <copilot@github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -29,13 +29,35 @@ 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
|
||||
|
||||
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 "$APT_SOURCES_LIST"; 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
|
||||
@@ -54,6 +76,9 @@ if [ "@@NAME@@" != "code-oss" ]; then
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user