diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | Makefile | 18 | ||||
-rw-r--r-- | build-package.py | 39 |
3 files changed, 24 insertions, 34 deletions
@@ -1 +1,2 @@ +package.tar.gz screenlog.0 @@ -2,6 +2,16 @@ # basic build sequence before we start messing with packaging scripts, # version numbers, and other forms of entertainment. Expect changes. +export GNUPGHOME := /home/aptbot/gnupg + +TARBALL := package.tar.gz + +FIRMWARE := sw/stm32/projects/bootloader/bootloader.bin \ + sw/stm32/projects/bootloader/bootloader.elf \ + sw/stm32/projects/hsm/hsm.bin \ + sw/stm32/projects/hsm/hsm.elf \ + core/platform/alpha/build/alpha_fmc.bit + all: bitstream elves package bitstream: @@ -10,14 +20,6 @@ bitstream: elves: cd sw/stm32; ${MAKE} bootloader hsm -TARBALL := package.tar.gz - -FIRMWARE := sw/stm32/projects/bootloader/bootloader.bin \ - sw/stm32/projects/bootloader/bootloader.elf \ - sw/stm32/projects/hsm/hsm.bin \ - sw/stm32/projects/hsm/hsm.elf \ - core/platform/alpha/build/alpha_fmc.bit - package: bitstream elves ${TARBALL} ${TARBALL}: ${FIRMWARE} diff --git a/build-package.py b/build-package.py index 4f35cff..494011e 100644 --- a/build-package.py +++ b/build-package.py @@ -9,39 +9,26 @@ import json import os parser = argparse.ArgumentParser() -parser.add_argument("--gpgdir", default = "/home/aptbot/gnupg", help = "gpg keyring directory") -parser.add_argument("--dir-name", help = "internal directory name for files") -parser.add_argument("tarfile", type = argparse.FileType("wb"), help = "tarball to create") -parser.add_argument("firmware", nargs = "+", help = "firmware files to stuff into tarball") +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(mode = "w", fileobj = args.tarfile) - -status = [line.split() for line in subprocess.check_output(("git", "submodule", "status")).splitlines()] -sha256 = {} - -def tar_add(fn, name = None): - if name is None: - name = os.path.basename(fn) - tar.add(fn, name if args.dir_name is None else os.path.join(args.dir_name, name)) +tar = tarfile.TarFile(mode = "w", fileobj = args.tarfile) +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[fn] = hashlib.sha256(f.read()).hexdigest() - tar_add(fn) + tar.add(fn, os.path.basename(fn)) with tempfile.NamedTemporaryFile() as f: - gpg = subprocess.Popen(("gpg", - "--clearsign", - "--no-random-seed-file", - "--no-default-keyring", - "--no-permission-warning", - "--personal-digest-preferences", "SHA256", - "--keyring", os.path.join(args.gpgdir, "pubring.gpg"), - "--secret-keyring", os.path.join(args.gpgdir, "secring.gpg"), - "--trustdb-name", os.path.join(args.gpgdir, "trustdb.gpg")), + gpg = subprocess.Popen(("gpg", "--clearsign", "--personal-digest-preferences", "SHA256"), stdin = subprocess.PIPE, stdout = f) - json.dump(dict(commits = status, sha256 = sha256), gpg.stdin, indent = 2) + json.dump(dict(head = head, time = time, commits = commits, sha256 = sha256), gpg.stdin, indent = 2) gpg.stdin.close() - gpg.wait() - tar_add(f.name, "MANIFEST") + if gpg.wait(): + raise subprocess.CalledProcessError(gpg.returncode, "gpg") + tar.add(f.name, "MANIFEST") |