aboutsummaryrefslogtreecommitdiff
path: root/Makefile
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 /Makefile
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 'Makefile')
-rw-r--r--Makefile52
1 files changed, 38 insertions, 14 deletions
diff --git a/Makefile b/Makefile
index 17f6f10..3d4fde2 100644
--- a/Makefile
+++ b/Makefile
@@ -1,18 +1,50 @@
# Top-level package build for Cryptech Alpha board.
-PACKAGE_NAME := cryptech-alpha
-PACKAGE_VERSION := 2.0.$(shell git show -s --format=%ct HEAD)
+# What we call the package before we start mucking with branches and revision numbers
+
+PACKAGE_BASE_NAME := cryptech-alpha
+PACKAGE_BASE_VERSION := 2.0
+
+# Git voodoo: plumbing commands to pull the current branch and list of
+# all (local) branches, and to pull something we can use as a version
+# number suffix.
+#
+# Using a timestamp here is not particularly friendly, but we're
+# looking for something simple that all the packaging systems involved
+# are willing to accept as a version number, so, at least for now, we
+# avoid more interesting options such as git-describe.
+
+GIT_VERSION := $(shell git show -s --format=%ct HEAD)
+GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
+GIT_BRANCHES := $(notdir $(shell git for-each-ref --format '%(refname)' refs/heads/))
+
+# Make voodoo: construct the package name, version number, and list of
+# other package names (constructed on other branches) with which this
+# one conflicts.
+
+PACKAGE_BRANCH = ${PACKAGE_BASE_NAME}$(and $(filter-out master,$(1)),-$(1))
+PACKAGE_NAME := $(call PACKAGE_BRANCH,${GIT_BRANCH})
+PACKAGE_CONFLICT := $(foreach I,$(filter-out ${GIT_BRANCH},${GIT_BRANCHES}),$(call PACKAGE_BRANCH,${I}))
+PACKAGE_VERSION := ${PACKAGE_BASE_VERSION}.${GIT_VERSION}
+
+# gpg setup, for signing packages and repositories
export GNUPGHOME := /home/aptbot/gnupg
GPG_USER := APT Builder Robot <aptbot@cryptech.is>
GPG_KEYID := 37A8E93F5D7E7B9A
+# Package repository setup
+
REPO_BASE := /home/aptbot
REPO_UMASK := 002
+# Debian clean-room package builder setup
+
PBUILDER_BASE := ${HOME}/pbuilder
PBUILDER_TARGETS := debian/jessie/i386 debian/jessie/amd64 ubuntu/xenial/i386 ubuntu/xenial/amd64
+# Where we upload the final results (if we do)
+
REPO_UPLOAD_USER := aptbot
REPO_UPLOAD_HOST := bikeshed.cryptech.is
REPO_UPLOAD_DIRS := apt brew
@@ -28,14 +60,6 @@ BITSTREAM := build/core/platform/alpha/build/alpha_fmc.bit
ELVES := build/sw/stm32/projects/bootloader/bootloader.elf build/sw/stm32/projects/hsm/hsm.elf
TAMPER := build/sw/tamper/tamper.hex
-# Command to generate a new changelog containing one entry.
-# Does nothing if the changelog already exists.
-
-DCH = test -f debian/changelog || \
- EDITOR=true VISUAL=true TZ=UTC DEBEMAIL='${GPG_USER}' \
- dch --create --package ${PACKAGE_NAME} --newversion '${PACKAGE_VERSION}' \
- 'Software and firmware for Cryptech Alpha development board.'
-
all: init firmware dsc pbuilder homebrew expire
enchilada: all upload
@@ -54,10 +78,10 @@ sandblast: clean
firmware: shadow ${FIRMWARE_TARBALL}
shadow:
- ./build-shadow-tree.py
+ ./scripts/build-shadow-tree.py
${FIRMWARE_TARBALL}: ${BITSTREAM} $(sort ${ELVES} ${ELVES:.elf=.bin}) ${TAMPER}
- fakeroot ./build-firmware-package.py $@ $^
+ fakeroot ./scripts/build-firmware-package.py $@ $^
bitstream: ${BITSTREAM}
@@ -76,7 +100,7 @@ tamper:
dsc:
rm -f source/debian/changelog ${PACKAGE_NAME}_*.dsc ${PACKAGE_NAME}_*.tar.xz ${PACKAGE_NAME}_*_source.build ${PACKAGE_NAME}_*_source.changes
- cd source; ${DCH}
+ cd source; ../scripts/build-debian-control-files.py --debemail='${GPG_USER}' --package ${PACKAGE_NAME} --newversion '${PACKAGE_VERSION}' --conflicts='${PACKAGE_CONFLICT}'
cd source; debuild -S -uc -us
pbuilder:
@@ -95,7 +119,7 @@ homebrew:
umask ${REPO_UMASK}; \
git clone ${REPO_BASE}/brew/tap tap; \
cd tap; \
- ../build-homebrew-formula.py ${REPO_BASE}/brew/tarballs/${PACKAGE_NAME}_${PACKAGE_VERSION}.tar.xz ${PACKAGE_VERSION} ${PACKAGE_NAME}.rb; \
+ ../scripts/build-homebrew-formula.py ${REPO_BASE}/brew/tarballs/${PACKAGE_NAME}_${PACKAGE_VERSION}.tar.xz ${PACKAGE_VERSION} ${PACKAGE_NAME}.rb ${PACKAGE_CONFLICT}; \
git add ${PACKAGE_NAME}.rb; \
git commit -S${GPG_KEYID} --author='${GPG_USER}' -m '${PACKAGE_NAME} ${PACKAGE_VERSION}'; \
git push