root/build-tools/stx
Davlet Panech e66aead87b downloader: succeed on GPG errors in DSCs files
Downloader sometimes fails on external .dsc files signed with unusable
GPG keys:
- expired keys
- .dsc file signed with a key that is not in apt's GPG database.
These files are typically signed by individual package maintainers, not
the official Debian/binary repository key that APT uses for binary
package indexes.

Downloader uses 2 different methods to fetch source packages, which
behave differently w.r.t. GPG checks:
- with "archive" key present in meta_data.yaml, we download using the
  "dget" utility, which in turn validates against a set of known keys
  in /usr/share/keyrings/
- without "archive", we download using "apt-get source", which doesn't
  validate GPG at all

This patch makes the downloader script ignore GPG signature errors, but
print a warning in the log. We also allow package maintainers to add an
additional option, "dsc_sha256", to check the .dsc file's checksum,
instead of its GPG signature (this will suppress the warning).
Rationale:
- it's difficult to make GPG verification accept expired keys
- we always verify sha256 checksums of the files making up the source
  package (ie the files referenced by .dsc)
- as for the .dsc file itself, we only verify its checksum if it is
  present in meta_data.yaml, "dsc_sha256". No packages do that as of
  this writing.

CHANGES
=====================
- utils.py: add a slightly different version of run_shell_cmd that
  captures and returns both STDOUT and STDERR
- debrepack.py:
  * use "dscverify" (from "devscripts" package) to verify .dsc files
  * if normal verification fails, try again with GPG check disabled
  * new key in meta_data.yaml: dsc_sha256. If present, make sure .dsc
    file's checksum matches.
  * workaround for "dget" and "dscverify" falsely succeeding when
    files referenced by .dsc are missing
  * removed functions "download_check_dsc" and "check_dsc" as they are
    no longer used after this change

HOW TO REPRODUCE
=====================
One example of a package signed with a key that is not in the current
(bullseye) version of debian-keyring, is golang-github-golang-jwt-jwt
[1]. The download fails on that package.

TESTS
=====================
- Remove golang-github-golang-jwt-jwt from /import/mirrors and reproduce
  the download error (unknown GPG key)
- Apply this patch, remove all downloaded sources, re-run downloader and
  make sure it succeeds with GPG-related warnings
- Simulate various problems with a .dsc file and make sure they are
  detected (ie the script fails):
  * .dsc URL in meta_data.yml returns http 404
  * one of the files referenced by .dsc returns http 404
  * one of the checksums in .dsc doesn't match
  * .dsc checksum it self doesn't match "dsc_sha256" in meta_data.yaml

[1] 2b7ac3c340/golang-github-dev/golang-github-golang-jwt-jwt-dev/debian/meta_data.yaml

Closes-Bug: 2072650
Signed-off-by: Davlet Panech <davlet.panech@windriver.com>
Change-Id: I2c91a997eafdcfd546d79e575c81bf6f9530ca0a
2024-07-11 20:40:49 -04:00
..
patch Automatically add prechecks scripts to patch 2024-04-29 16:30:26 -03:00
.gitignore stx: discover buildable packages 2022-04-19 17:42:35 +08:00
aptly_deb_usage.py aptly: update expired GPG key 2024-02-23 22:46:41 -05:00
build-image build-image: rename ISO to reflect build timestamp 2024-06-17 15:28:32 -04:00
build-pkgs build-pkgs: Fixed "exit on failure" feature broken 2024-02-28 00:53:49 +08:00
circular_dep.conf Circular dependency removal while building openssl package with sctp. 2024-06-05 14:08:42 -04:00
debdownloader build-tools: apt repo priority based on "Origin" 2022-07-05 20:39:40 -04:00
debian-image.inc Remove redfishtool from opensource Debian include list 2024-05-07 16:59:35 -04:00
debrepack.py downloader: succeed on GPG errors in DSCs files 2024-07-11 20:40:49 -04:00
debsentry.py build-pkgs: Fixed the deb packages missing issue after reuse 2023-05-25 18:33:57 +08:00
discovery.py Debian: build-image support debian_iso_image.inc 2022-08-27 21:43:39 +08:00
downloader Add package cache update to downloader 2024-07-01 12:39:11 -03:00
dsc_depend.py Log members of a circular dependency 2023-11-07 10:19:04 -05:00
dsccache.py Reuse fix to not rebuild if no source changes 2022-12-16 13:12:03 -08:00
git_utils.py stx: discover buildable packages 2022-04-19 17:42:35 +08:00
image-layers.conf Create layer-specific aptly binary repositories 2023-10-05 00:39:09 +00:00
repo_manage.py Allow our repositories to have multiple versions of a package 2023-10-05 00:41:20 +00:00
repo_utils.py stx: discover buildable packages 2022-04-19 17:42:35 +08:00
utils.py downloader: succeed on GPG errors in DSCs files 2024-07-11 20:40:49 -04:00