[Cryptech-Commits] [user/sra/alpha-releng/firmware] branch master updated: Cleanup.

git at cryptech.is git at cryptech.is
Wed Jun 22 04:40:45 UTC 2016


This is an automated email from the git hooks/post-receive script.

sra at hactrn.net pushed a commit to branch master
in repository user/sra/alpha-releng/firmware.

The following commit(s) were added to refs/heads/master by this push:
       new  d0d8f2b   Cleanup.
d0d8f2b is described below

commit d0d8f2b2a61b16496f3dfa7debb995f8e9e55064
Author: Rob Austein <sra at hactrn.net>
AuthorDate: Wed Jun 22 00:40:39 2016 -0400

    Cleanup.
---
 Makefile         | 18 +++++++++++-------
 build-package.py | 30 +++++++++++++++++++-----------
 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")

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Commits mailing list