Build GnuPG and verify detached signatures with the target gpgv
@@ -62,6 +62,8 @@ The x86_64 SQLite 3.48.0-1 build used 724 MiB at peak under the 1 GiB limit. Its
6262
6363The installed x86_64 XBPS 0.59.2-1 tools created a package, indexed it, installed it into an empty directory and read its version from the local database. The fixture compared the installed bytes with the input. Its 13-package signed root contained 57 target ELFs. See `foundation/signed-xbps-01`, receipt SHA-256 `c54c52e01e076177f73be1830574c3c256d6af8627679d1b24353f145cf1f078`.
6464
65+The GnuPG 2.4.9-1 recipe uses the SDK's `gpgrt-config` to locate libksba. Its build check verifies a detached signature with the target `gpgv` and requires a bad-signature result after changing the signed bytes. The x86_64 archive has SHA-256 `05a9da36d6f07114af1a1683690eec0452582b506262c445dde55d1a1b5e07c4`. Installing GnuPG, GPGME, the Vinix test keyring and BusyBox init pulled in 22 signed packages with 4,893 owned files and links and 76 target ELFs. See `foundation/signature-engine-x86-02/audit.log`, SHA-256 `9762624c6ba59640955091783d9bea47a6e9859ef3d5a1f45e11cecbc461ef34`.
66+
6567For later builds, `tools/build-queue.py` uses the source order and a verified bootstrap feed. Place the input archives and a `NAME.sha256` receipt for each in `$work/artifacts`. Configure the host compiler and signing tools as for a single native build, then select the ports to build. The worker uses this command form.
6668
6769```sh
@@ -0,0 +1,75 @@
1+; OpenPGP package signing, key management and offline verification.
2+defpkgbuild(gnupg,
3+ #:pkgname, "gnupg",
4+ #:pkgver, "2.4.9",
5+ #:pkgrel, 1,
6+ #:pkgdesc, "GnuPG tools and agent for signing and verifying packages",
7+ #:arch, [#:x86-64, #:aarch64],
8+ #:license, "GPL-3.0-or-later",
9+ #:url, "https://gnupg.org/",
10+ #:depends, ["musl", "bzip2", "libassuan", "libgcrypt", "libgpg-error", "libksba",
11+ "npth", "pinentry", "readline", "sqlite", "zlib"],
12+ #:source, ["https://gnupg.org/ftp/gcrypt/gnupg/gnupg-2.4.9.tar.bz2",
13+ "https://raw.githubusercontent.com/alpinelinux/aports/a7de3e63cc8015474a4feadd8bb7c0ecc097b1fa/main/gnupg/0010-avoid-beta-warning.patch",
14+ "https://raw.githubusercontent.com/alpinelinux/aports/a7de3e63cc8015474a4feadd8bb7c0ecc097b1fa/main/gnupg/0020-avoid-regenerating-defsincdate-use-shipped-file.patch",
15+ "https://raw.githubusercontent.com/alpinelinux/aports/a7de3e63cc8015474a4feadd8bb7c0ecc097b1fa/main/gnupg/0110-avoid-simple-memory-dumps-via-ptrace.patch",
16+ "https://raw.githubusercontent.com/alpinelinux/aports/a7de3e63cc8015474a4feadd8bb7c0ecc097b1fa/main/gnupg/0210-dirmngr-hkp-avoid-potential-race-condition-when-some-host-die.patch",
17+ "https://raw.githubusercontent.com/alpinelinux/aports/a7de3e63cc8015474a4feadd8bb7c0ecc097b1fa/main/gnupg/0230-dirmngr-avoid-automatically-checking-upstream-swdb.patch",
18+ "https://raw.githubusercontent.com/alpinelinux/aports/a7de3e63cc8015474a4feadd8bb7c0ecc097b1fa/main/gnupg/0330-gpg-default-to-sha512-for-all-signature-types-on-rsa-keys.patch",
19+ "https://raw.githubusercontent.com/alpinelinux/aports/a7de3e63cc8015474a4feadd8bb7c0ecc097b1fa/main/gnupg/0340-gpg-prefer-sha512-and-sha384-in-personal-digest.patch",
20+ "https://raw.githubusercontent.com/alpinelinux/aports/a7de3e63cc8015474a4feadd8bb7c0ecc097b1fa/main/gnupg/0420-gpg-drop-import-clean-from-default-keyserver-import-options.patch",
21+ "https://raw.githubusercontent.com/alpinelinux/aports/a7de3e63cc8015474a4feadd8bb7c0ecc097b1fa/main/gnupg/fix-i18n.patch",
22+ "https://raw.githubusercontent.com/alpinelinux/aports/a7de3e63cc8015474a4feadd8bb7c0ecc097b1fa/main/gnupg/HACK-revert-rfc4880bis-default.patch",
23+ "check.py"],
24+ #:sha256sums, ["dd17ab2e9a04fd79d39d853f599cbc852062ddb9ab52a4ddeb4176fd8b302964",
25+ "243c3a79295519b3931f9d846cf2af5caa064a78de812ee336dc786c1567b4d0",
26+ "9bd33f7d1b875bf710a9ad58db17d8217e747733a3118ff9403e1856a2c6754a",
27+ "9bb5282a5292f8fe4ff77253ba28bb5a2453d85ba4bdebcc646bf82bb9175c60",
28+ "9b30351f7eff35c27376f7b7c73ee23a1b737b5bb293fdf97e41924ae6851e88",
29+ "a059840eed2d1e0ed977fbc7420108d91031e3c256f95eede1d8fa61e6193ee4",
30+ "1b3b0f879f1cae1d734607a0f29e0ceecb186384e39a37232e60b0adcaa56bc3",
31+ "87b77fe213a66b78866f4865882d62649c8b861df7adf383cffb6a781675ed52",
32+ "6ade15b536c50a88efc2d9dc958433b0ccfaf2908025b7672753e6bfce51c3c6",
33+ "ce409e47ce4a0d8468ba7e791fd5a7311fd600a167e3a2a60f4330d5460b65be",
34+ "f75fdd02ba73ff93e6ce5d36a6ccff3ad06f1b2e08f8918d42c912e073893a3e",
35+ "d8a6178cd60146bdbcd509e570a85bd958b969ead3e896e90e3f085f5da1c6bd"],
36+ #:prepare, fn() {
37+ for-each(fn(file) {
38+ run("patch", "--batch", "-d", "gnupg-2.4.9", "-p1", "-i", string-append("../", file))
39+ }, list("0010-avoid-beta-warning.patch",
40+ "0020-avoid-regenerating-defsincdate-use-shipped-file.patch",
41+ "0110-avoid-simple-memory-dumps-via-ptrace.patch",
42+ "0210-dirmngr-hkp-avoid-potential-race-condition-when-some-host-die.patch",
43+ "0230-dirmngr-avoid-automatically-checking-upstream-swdb.patch",
44+ "0330-gpg-default-to-sha512-for-all-signature-types-on-rsa-keys.patch",
45+ "0340-gpg-prefer-sha512-and-sha384-in-personal-digest.patch",
46+ "0420-gpg-drop-import-clean-from-default-keyserver-import-options.patch",
47+ "fix-i18n.patch",
48+ "HACK-revert-rfc4880bis-default.patch"))
49+ run("rm", "-f", "gnupg-2.4.9/tests/gpgme/setup.scm")
50+ run("env", "-C", "gnupg-2.4.9", "AUTOCONF=autoconf", "AUTOHEADER=autoheader", "autoreconf", "-fi")
51+ },
52+ #:build, fn() {
53+ root := get-environment-variable("VPAC_MAKEPKG_ROOT")
54+ ; libksba supplies ksba.pc. The installed gpgrt-config shell script reads
55+ ; that record for configure, including when the target cannot run here.
56+ run("env", string-append("GPGRT_CONFIG=", root, "/usr/bin/gpgrt-config"),
57+ "vinix-configure", "gnupg-2.4.9/configure",
58+ string-append("--with-libgpg-error-prefix=", root, "/usr"),
59+ string-append("--with-libgcrypt-prefix=", root, "/usr"),
60+ string-append("--with-libassuan-prefix=", root, "/usr"),
61+ string-append("--with-libksba-prefix=", root, "/usr"), string-append("--with-npth-prefix=", root, "/usr"),
62+ "--localstatedir=/var", "--disable-nls", "--enable-tofu", "--disable-scdaemon", "--disable-ccid-driver",
63+ "--disable-dirmngr", "--disable-wks-tools", "--disable-ldap", "--disable-doc", "--disable-ntbtls")
64+ run("make")
65+ },
66+ #:check, fn() {
67+ run("vinix-run", "g10/gpg", "--version")
68+ run("vinix-run", "agent/gpg-agent", "--version")
69+ run("python3", "check.py")
70+ },
71+ #:package, fn() {
72+ run("make", "install", string-append("DESTDIR=", pkgdir()))
73+ run("rm", "-f", string-append(pkgdir(), "/usr/share/info/dir"))
74+ run("install", "-Dm644", "gnupg-2.4.9/COPYING", string-append(pkgdir(), "/usr/share/licenses/gnupg/COPYING"))
75+ })
@@ -0,0 +1,31 @@
1+"""Sign a fixture with a throwaway host key, then verify it with target gpgv."""
2+
3+from pathlib import Path
4+import subprocess
5+import tempfile
6+
7+
8+def run(*args, **kwargs):
9+ return subprocess.run(args, check=True, capture_output=True, timeout=30, **kwargs)
10+
11+
12+# Keep the agent socket below the kernel's Unix-domain path limit even in
13+# a deeply nested build tree. Only the exported fixture key enters the tree.
14+with tempfile.TemporaryDirectory(prefix="gpg-", dir="/tmp") as home:
15+ identity = "Vinix fixture <fixture@example.invalid>"
16+ host = ["gpg", "--homedir", home, "--batch"]
17+ try:
18+ run(*host, "--pinentry-mode", "loopback", "--passphrase", "", "--quick-generate-key",
19+ identity, "ed25519", "sign", "0")
20+ Path("fixture.gpg").write_bytes(run(*host, "--export", identity).stdout)
21+ package = Path("package-list")
22+ package.write_text("Vinix packages\n")
23+ run(*host, "--detach-sign", "--output", "package-list.sig", str(package))
24+ verify = ["vinix-run", "g10/gpgv", "--keyring", str(Path("fixture.gpg").resolve()),
25+ "--status-fd", "1", "package-list.sig", str(package)]
26+ assert b"[GNUPG:] VALIDSIG " in run(*verify).stdout
27+ package.write_text("changed\n")
28+ bad = subprocess.run(verify, capture_output=True, timeout=15)
29+ assert bad.returncode != 0 and b"[GNUPG:] BADSIG " in bad.stdout, bad.stderr
30+ finally:
31+ subprocess.run(["gpgconf", "--homedir", home, "--kill", "all"], timeout=10)