Add to new source format and the mandatory signed-by (#239390)

fixes #238697
This commit is contained in:
bhack
2025-05-07 03:33:19 +04:00
committed by GitHub
parent 6d49a47a77
commit 76c064bd87
2 changed files with 26 additions and 7 deletions

View File

@@ -33,8 +33,8 @@ if [ "@@NAME@@" != "code-oss" ]; then
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
CODE_TRUSTED_PART=/usr/share/keyrings/microsoft.gpg
CODE_TRUSTED_PART_OLD="/etc/apt/trusted.gpg.d/microsoft.gpg"
# RET seems to be true by default even after db_get is called on a first install.
RET='true'
@@ -48,7 +48,7 @@ if [ "@@NAME@@" != "code-oss" ]; then
if [ "$RET" = 'false' ]; then
# The user specified in debconf not to add the Microsoft repository
WRITE_SOURCE='no'
elif [ -f "$CODE_SOURCE_PART_DEB822" ]; then
elif [ -f "$CODE_SOURCE_PART_DEB822" ] && [ -f "$CODE_TRUSTED_PART" ]; then
# The user has migrated themselves to the DEB822 format
WRITE_SOURCE='no'
elif [ -f "$CODE_SOURCE_PART" ] && (grep -q "http://packages.microsoft.com/repos/vscode" $CODE_SOURCE_PART); then
@@ -81,6 +81,8 @@ if [ "@@NAME@@" != "code-oss" ]; then
db_get @@NAME@@/add-microsoft-repo
if [ "$RET" = false ]; then
WRITE_SOURCE='no'
else
WRITE_SOURCE='yes'
fi
else
# The terminal is interactive but there is no debconf.
@@ -90,9 +92,24 @@ if [ "@@NAME@@" != "code-oss" ]; then
fi
if [ "$WRITE_SOURCE" != 'no' ]; then
echo "### THIS FILE IS AUTOMATICALLY CONFIGURED ###
# Check if apt modernize-sources is available.
if apt modernize-sources --help >/dev/null 2>&1; then
# Write repository in deb822 format with Signed-By.
echo "### THIS FILE IS AUTOMATICALLY CONFIGURED ###
# You may comment out this entry, but any other modifications may be lost." > "$CODE_SOURCE_PART_DEB822"
cat <<EOF >> "$CODE_SOURCE_PART_DEB822"
Types: deb
URIs: https://packages.microsoft.com/repos/code
Suites: stable
Components: main
Architectures: amd64,arm64,armhf
Signed-By: $CODE_TRUSTED_PART
EOF
else
echo "### THIS FILE IS AUTOMATICALLY CONFIGURED ###
# You may comment out this entry, but any other modifications may be lost.
deb [arch=amd64,arm64,armhf] https://packages.microsoft.com/repos/code stable main" > $CODE_SOURCE_PART
fi
# Sourced from https://packages.microsoft.com/keys/microsoft.asc
if [ ! -f $CODE_TRUSTED_PART ]; then
@@ -116,6 +133,9 @@ NdCFTW7wY0Fb1fWJ+/KTsC4=
=J6gs
-----END PGP PUBLIC KEY BLOCK-----
" | gpg --dearmor > $CODE_TRUSTED_PART
if [ -f "$CODE_TRUSTED_PART_OLD" ]; then
rm -f "$CODE_TRUSTED_PART_OLD"
fi
fi
fi
fi