aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile18
-rw-r--r--build-package.py30
2 files changed, 30 insertions, 18 deletions
diff --git a/Makefile b/Makefile
index d8c159d..2b01f9d 100644
--- a/Makefile
+++ b/Makefile
@@ -10,18 +10,22 @@ bitstream:
elves:
cd sw/stm32; ${MAKE} bootloader hsm
-PACKAGE_FILES = sw/stm32/projects/bootloader/bootloader.bin \
+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 \
+ sw/stm32/projects/hsm/hsm.bin \
+ sw/stm32/projects/hsm/hsm.elf \
core/platform/alpha/build/alpha_fmc.bit
-package: bitstream elves
- python build-package.py package.tar ${PACKAGE_FILES}
- gzip -9f package.tar
+package: bitstream elves ${TARBALL}
+
+${TARBALL}: ${FIRMWARE}
+ ./build-package.py $(basename $@) $^
+ gzip -9f $(basename $@)
clean:
git clean -dfx
git submodule foreach git clean -dfx
-.PHONY: bitstream elves clean
+.PHONY: bitstream elves package clean
diff --git a/build-package.py b/build-package.py
index ae7b0b1..4f35cff 100644
--- a/build-package.py
+++ b/build-package.py
@@ -6,8 +6,11 @@ import argparse
import hashlib
import tarfile
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")
args = parser.parse_args()
@@ -17,23 +20,28 @@ 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))
+
for fn in args.firmware:
with open(fn, "rb") as f:
sha256[fn] = hashlib.sha256(f.read()).hexdigest()
- tar.add(fn)
-
-# export GNUPGHOME := /home/aptbot/gnupg
-# --no-default-keyring --keyring isc-pubring.gpg --secret-keyring isc-secring.gpg
+ tar_add(fn)
with tempfile.NamedTemporaryFile() as f:
- gpg = subprocess.Popen(("gpg", "--clearsign", "--no-default-keyring",
- "--keyring", "/home/aptbot/gnupg/pubring.gpg",
- "--secret-keyring", "/home/aptbot/gnupg/secring.gpg",
- "--trustdb-name", "/home/aptbot/gnupg/trustdb.gpg",
- "--no-random-seed-file", "--no-permission-warning",
- "--personal-digest-preferences", "SHA256"),
+ 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")),
stdin = subprocess.PIPE, stdout = f)
json.dump(dict(commits = status, sha256 = sha256), gpg.stdin, indent = 2)
gpg.stdin.close()
gpg.wait()
- tar.add(f.name, "+MANIFEST")
+ tar_add(f.name, "MANIFEST")