Stop clobbering the signed packages.

Fixes #5635

PiperOrigin-RevId: 446002436
This commit is contained in:
Adin Scannell 2022-05-02 12:34:27 -07:00 committed by gVisor bot
parent 32c474d82f
commit 87180c225b
1 changed files with 15 additions and 10 deletions

View File

@ -92,7 +92,7 @@ keyid=$(
awk '{print $2;}') awk '{print $2;}')
readonly keyid readonly keyid
# Copy the packages into the root. # Copy the packages into the pool.
for pkg in "$@"; do for pkg in "$@"; do
if ! [[ -f "${pkg}" ]]; then if ! [[ -f "${pkg}" ]]; then
continue continue
@ -110,17 +110,22 @@ for pkg in "$@"; do
version=${version// /} # Ditto. version=${version// /} # Ditto.
destdir="${root}/pool/${version}/binary-${arch}" destdir="${root}/pool/${version}/binary-${arch}"
# Copy & sign the package. # Copy & sign the package, only if not in the pool already.
mkdir -p "${destdir}" mkdir -p "${destdir}"
cp -a -L "$(dirname "${pkg}")/${name}.deb" "${destdir}" if ! [[ -f "${destdir}/${name}.deb" ]]; then
if [[ -f "$(dirname "${pkg}")/${name}.changes" ]]; then # Copy the file.
cp -a -L "$(dirname "${pkg}")/${name}.changes" "${destdir}" cp -a -L "$(dirname "${pkg}")/${name}.deb" "${destdir}"
chmod 0644 "${destdir}"/"${name}".deb
# Sign a package only if it isn't signed yet.
# We use [*] here to expand the gpg_opts array into a single shell-word.
dpkg-sig -g "${gpg_opts[*]}" --verify "${destdir}/${name}.deb" ||
dpkg-sig -g "${gpg_opts[*]}" --sign builder -k "${keyid}" "${destdir}/${name}.deb"
fi
if [[ -f "$(dirname "${pkg}")/${name}.changes" ]] && ! [[ -f "${destdir}/${name}.changes" ]]; then
# Copy the changes file.
cp -a -L "$(dirname "${pkg}")/${name}.changes" "${destdir}"
chmod 0644 "${destdir}"/"${name}".changes
fi fi
chmod 0644 "${destdir}"/"${name}".*
# Sign a package only if it isn't signed yet.
# We use [*] here to expand the gpg_opts array into a single shell-word.
dpkg-sig -g "${gpg_opts[*]}" --verify "${destdir}/${name}.deb" ||
dpkg-sig -g "${gpg_opts[*]}" --sign builder -k "${keyid}" "${destdir}/${name}.deb"
done done
# Build the package list. # Build the package list.