diff options
author | Rob Austein <sra@hactrn.net> | 2016-12-14 00:56:24 -0500 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2016-12-14 00:56:24 -0500 |
commit | b94f9f9d3816d3cd26a4cc8f3da9f4616bd05a35 (patch) | |
tree | fbeb9b09ce998632986b2ad623adc832f795e6bf /scripts/build-firmware-package.py | |
parent | eb5aaecab2b988f3ff4d36817fb56aca5a30aebb (diff) |
Support multiple packages corresponding to multiple releng branches.
We want to be able to provide packaged builds of development branches.
The most straightforward way to do this is a 1:1 correspondence
between branches in the releng tree and variant package names.
We adopt a simple convention: the base package name corresponds to the
master branch, all other branches are named with the base package name
followed by the branch name. So the master branch is the
cryptech-alpha package, the ksng branch is the cryptech-alpha-ksng
branch, and so forth. This isn't a perfect solution, but it's
probably good enough.
In order to do this, we need to generate the debian/control file at
build-time, so that we can generate the list of conflicting packages.
This commit also pulls in a few changes that had collected on the
master branches of various repositories, chiefly because a few of them
were necessary to get it the build to run at all.
Diffstat (limited to 'scripts/build-firmware-package.py')
-rwxr-xr-x | scripts/build-firmware-package.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/scripts/build-firmware-package.py b/scripts/build-firmware-package.py new file mode 100755 index 0000000..c44b8bd --- /dev/null +++ b/scripts/build-firmware-package.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python + +import subprocess +import tempfile +import argparse +import hashlib +import tarfile +import json +import os + +parser = argparse.ArgumentParser() +parser.add_argument("tarfile", type = argparse.FileType("wb"), help = "tarball to create") +parser.add_argument("firmware", nargs = "+", help = "firmware files to stuff into tarball") +args = parser.parse_args() + +tar = tarfile.TarFile.open(fileobj = args.tarfile, mode = "w|gz") +head = subprocess.check_output(("git", "rev-parse", "HEAD")).strip() +time = subprocess.check_output(("git", "show", "-s", "--format=%ct", "HEAD")).strip() +commits = [line.split() for line in subprocess.check_output(("git", "submodule", "status")).splitlines()] +sha256 = {} + +for fn in args.firmware: + with open(fn, "rb") as f: + sha256[os.path.basename(fn)] = hashlib.sha256(f.read()).hexdigest() + tar.add(fn, os.path.basename(fn)) + +with tempfile.NamedTemporaryFile() as f: + os.fchmod(f.fileno(), 0644) + gpg = subprocess.Popen(("gpg", "--clearsign", "--personal-digest-preferences", "SHA256", "--no-permission-warning"), + stdin = subprocess.PIPE, stdout = f) + json.dump(dict(head = head, time = time, commits = commits, sha256 = sha256), gpg.stdin, indent = 2) + gpg.stdin.close() + if gpg.wait(): + raise subprocess.CalledProcessError(gpg.returncode, "gpg") + tar.add(f.name, "MANIFEST") + +tar.close() +args.tarfile.close() |