Sign in

Search issue titles and bodies, change requests and comments. Private repositories you cannot read are not included.

vole
Site
Clone

Read only, no credentials:

https://rodent.software/vole.git

Write over SSH with a registered key:

git clone ssh://git@rodent.software/vole.git

Self-hosted forge that lives in your Git repo.

Publish signed pacman repositories with each release

fbdb3818bc53560d022234c741c539e59c82bc41 · Keenan Nemetz · 14d ago · parent fd86ba87

Publish signed pacman repositories with each release

Build Arch packages with the same nfpm contents, publish one pacman database per architecture, and sign the packages and databases with the release key. repo-add stamps tar entries from the clock, so the databases are repacked with the tag time before signing. The maintainer script becomes post_install/post_upgrade bodies, so it no longer exits the shell. Document pacman-key, SigLevel, installation, and upgrades, and build and verify the Arch tree in CI.

scripts/sign-release.py +43−2

@@ -18,12 +18,16 @@ What is signed, and why:
18 18
19 19 - the RPM packages, because dnf checks each package's signature when
20 20 `gpgcheck=1`;
21 - the Arch packages, as a detached `.sig` beside each package, because pacman
22 checks it with `SigLevel = Required`;
21 23 - the apt metadata (`InRelease` and `Release.gpg`), because apt verifies the
22 24 `Release` file and the hashes in it authenticate every `.deb` it lists. dpkg
23 25 does not check a signature on an individual `.deb`, so signing those files
24 26 would be a check nobody performs;
25 27 - the RPM repository metadata (`repomd.xml.asc`), because dnf verifies it when
26 28 `repo_gpgcheck=1`;
29 - the pacman databases (`vole.db` and `vole.files`), because pacman verifies
30 them with `DatabaseRequired`;
27 31 - `SHA256SUMS`, so a direct download can be authenticated without the
28 32 repository;
29 33 - the public key is exported to `apt/vole.gpg`, `yum/RPM-GPG-KEY-vole`, and
@@ -205,6 +209,18 @@ def sign_packages(dist: Path, home: Path, fingerprint: str, when: int) -> None:
205 209 if not signature or all(part == "(none)" for part in signature.split("|")):
206 210 sys.exit(f"{package} is still unsigned after rpm --addsign")
207 211
212 # An Arch package carries a detached .sig beside it rather than a signature
213 # inside the archive. repo-add records that signature in %PGPSIG%, and pacman
214 # checks it when the package is downloaded.
215 arch_packages = sorted(dist.glob("vole-*.pkg.tar.zst"))
216 if not arch_packages:
217 sys.exit(f"no Arch packages to sign in {dist}")
218 for package in arch_packages:
219 signature = package.with_name(package.name + ".sig")
220 gpg(home, "--yes", "--faked-system-time", str(when), "--local-user", fingerprint,
221 "--detach-sign", "--output", str(signature), str(package))
222 verify(home, signature, package)
223
208 224
209 225 def sign_repositories(dist: Path, home: Path, fingerprint: str, when: int) -> None:
210 226 release = dist / "apt" / "Release"
@@ -213,6 +229,14 @@ def sign_repositories(dist: Path, home: Path, fingerprint: str, when: int) -> No
213 229 if not required.is_file():
214 230 sys.exit(f"{required} is missing; build the repositories before signing them")
215 231
232 pacman_dirs = sorted(directory for directory in (dist / "pacman").glob("*") if directory.is_dir())
233 if not pacman_dirs:
234 sys.exit(f"no pacman repositories in {dist}")
235 for directory in pacman_dirs:
236 for name in ("vole.db", "vole.files"):
237 if not (directory / name).is_file():
238 sys.exit(f"{directory / name} is missing; build the pacman repository before signing it")
239
216 240 inrelease = release.with_name("InRelease")
217 241 release_gpg = release.with_name("Release.gpg")
218 242 repomd_sig = repomd.with_name("repomd.xml.asc")
@@ -228,6 +252,23 @@ def sign_repositories(dist: Path, home: Path, fingerprint: str, when: int) -> No
228 252 verify(home, release_gpg, release)
229 253 verify(home, repomd_sig, repomd)
230 254
255 # Pacman database signatures are detached binary files named after the
256 # database. SigLevel = Required DatabaseRequired checks both.
257 for directory in pacman_dirs:
258 # The database's %PGPSIG% comes from the package signature repo-add read.
259 # A release must not publish a database whose packages are unsigned.
260 for package in sorted(directory.glob("*.pkg.tar.zst")):
261 signature = package.with_name(package.name + ".sig")
262 if not signature.is_file():
263 sys.exit(f"{package} has no signature; sign the packages before signing the pacman database")
264 verify(home, signature, package)
265 for name in ("vole.db", "vole.files"):
266 path = directory / name
267 signature = path.with_name(name + ".sig")
268 gpg(home, "--yes", "--faked-system-time", str(when), "--local-user", fingerprint,
269 "--detach-sign", "--output", str(signature), str(path))
270 verify(home, signature, path)
271
231 272 # apt wants a keyring file, not armored text, in signed-by=. dnf and the
232 273 # release page are easier to read armored, so both forms are published.
233 274 binary = run_bytes([GPG, "--batch", "--no-tty", "--homedir", str(home), "--export", fingerprint])
@@ -252,8 +293,8 @@ def main() -> None:
252 293 parser = argparse.ArgumentParser(description=__doc__.splitlines()[0])
253 294 subparsers = parser.add_subparsers(dest="command", required=True)
254 295 for name, text in (
255 ("packages", "sign the RPM packages in the release tree"),
256 ("repositories", "sign apt and yum metadata and export the public key"),
296 ("packages", "sign the RPM and Arch packages in the release tree"),
297 ("repositories", "sign apt, yum, and pacman metadata and export the public key"),
257 298 ("sums", "sign SHA256SUMS"),
258 299 ):
259 300 sub = subparsers.add_parser(name, help=text)