aboutsummaryrefslogtreecommitdiff
path: root/scripts/build-debian-control-files.py
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2016-12-14 00:56:24 -0500
committerRob Austein <sra@hactrn.net>2016-12-14 00:56:24 -0500
commitb94f9f9d3816d3cd26a4cc8f3da9f4616bd05a35 (patch)
treefbeb9b09ce998632986b2ad623adc832f795e6bf /scripts/build-debian-control-files.py
parenteb5aaecab2b988f3ff4d36817fb56aca5a30aebb (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-debian-control-files.py')
-rwxr-xr-xscripts/build-debian-control-files.py58
1 files changed, 58 insertions, 0 deletions
diff --git a/scripts/build-debian-control-files.py b/scripts/build-debian-control-files.py
new file mode 100755
index 0000000..1177049
--- /dev/null
+++ b/scripts/build-debian-control-files.py
@@ -0,0 +1,58 @@
+#!/usr/bin/env python
+
+import subprocess
+import argparse
+import sys
+import os
+
+parser = argparse.ArgumentParser()
+parser.add_argument("--debemail", required = True)
+parser.add_argument("--package", required = True)
+parser.add_argument("--newversion", required = True)
+parser.add_argument("--description", default = "Software and firmware for Cryptech Alpha development board.")
+parser.add_argument("--conflicts", nargs = "*")
+
+args = parser.parse_args()
+
+if os.path.exists("debian/control") and os.path.exists("debian/changelog"):
+ sys.exit(0)
+
+control_template= '''\
+Source: {args.package}
+Maintainer: {args.debemail}
+Section: misc
+Priority: optional
+Standards-Version: 3.9.6
+Build-Depends: debhelper (>= 9),
+ dh-python,
+ libsqlite3-dev,
+ python (>= 2.7),
+ python-yaml
+Homepage: http://trac.cryptech.is/wiki
+
+Package: cryptech-alpha
+Architecture: any
+Depends: python,
+ python-serial (>= 3.0),
+ ${{misc:Depends}},
+ ${{python:Depends}},
+ ${{shlibs:Depends}}
+{conflicts}\
+Description: Cryptech Project open-source cryptographic software and firmware.
+ {args.description}
+'''
+
+if args.conflicts:
+ conflicts = "Conflicts: {}\n".format(" ".join(args.conflicts))
+else:
+ conflicts = ""
+
+subprocess.check_call(("dch", "--create", "--package", args.package, "--newversion", args.newversion, args.description),
+ env = dict(os.environ,
+ EDITOR = "/bin/true",
+ VISUAL = "/bin/true",
+ TZ = "UTC",
+ DEBEMAIL = args.debemail))
+
+with open("debian/control", "w") as f:
+ f.write(control_template.format(args = args, conflicts = conflicts))