aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
blob: 26c20e3cfd8678ee1c2165d46ceb9903b6b919da (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
CC ?= gcc
CC += -m$(shell dpkg-architecture -qDEB_HOST_ARCH_BITS $(patsubst %,-a%, ${ARCH}))
DEB_ARCH = $(shell dpkg-architecture -qDEB_HOST_ARCH $(patsubst %,-a%, ${ARCH}))
# Multiarch: apt-get install gcc-multilib libc6-dev-x32

VERSION = 8.2.0
IMAGE_TYPE ?= iso

ISOIMG = debian-${VERSION}-${DEB_ARCH}-netinst.iso
PRESEEDED = $(patsubst %.iso,%-preseeded.${IMAGE_TYPE}, ${ISOIMG})
UDEBS = $(shell ./src/getname.sh)
CHECKSUMS = MD5 SHA1 SHA256 SHA512

# Preseed
preseed:
	make dist/${DEB_ARCH}/${PRESEEDED}
dist/${DEB_ARCH}/${PRESEEDED}: preseed.cfg $(wildcard ./include/*) dist/${DEB_ARCH}/${ISOIMG} ${UDEBS}
	DEB_ARCH=${DEB_ARCH} ./preseed.sh $@ dist/${DEB_ARCH}/${ISOIMG} ${UDEBS}

sig: dist/${DEB_ARCH}/${PRESEEDED}
	gpg2 --detach-sign $^

# Get, verify
iso-get: dist/${DEB_ARCH}/${ISOIMG}
iso-checksum: $(patsubst %,iso-checksum-%, ${CHECKSUMS})

# Verify a single digest
iso-checksum-%: dist/${DEB_ARCH}/${ISOIMG} dist/${DEB_ARCH}/%SUMS dist/${DEB_ARCH}/%SUMS.sign
	@echo Checking $* sum
	@cd dist/${DEB_ARCH}; grep "\s${ISOIMG}$$" $*SUMS | $$(echo $* | sed 's@.*@/usr/bin/\L&sum@') --strict -c
	gpg2 --verify dist/${DEB_ARCH}/$*SUMS.sign dist/${DEB_ARCH}/$*SUMS

# Download
.PRECIOUS: dist/${DEB_ARCH}/%
dist/${DEB_ARCH}/%:
	@[ -d dist/${DEB_ARCH} ] || mkdir -p dist/${DEB_ARCH}
	wget -nc -P dist/${DEB_ARCH} http://cdimage.debian.org/debian-cd/current/${DEB_ARCH}/iso-cd/$*

# All udebs
udebs: ${UDEBS}

# Single udeb; TODO: GPG sign
%.udeb: UDEB = $(shell ./src/getname.sh $*)
%.udeb: $(shell /usr/bin/git ls-files -- src/${UDEB})
	@cd src/${UDEB} && /usr/bin/debuild -e CC='${CC}' -i -us -uc -b -a${DEB_ARCH}

clean:
	@for d in src/*-udeb/; do rm -fv $${d%-udeb/}_*.build $${d%-udeb/}_*.changes $${d%-udeb/}_*.udeb; cd $$d && dh_clean && cd -; done
	@rm -fv $(patsubst %,dist/${DEB_ARCH}/%SUMS, ${CHECKSUMS}) $(patsubst %,dist/${DEB_ARCH}/%SUMS.sign, ${CHECKSUMS})

.PHONY: clean cleanall iso-get iso-checksum preseed udebs