aboutsummaryrefslogtreecommitdiff
path: root/build-package.py
diff options
context:
space:
mode:
Diffstat (limited to 'build-package.py')
-rw-r--r--build-package.py39
1 files changed, 13 insertions, 26 deletions
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")