-
Notifications
You must be signed in to change notification settings - Fork 43
/
Makefile
102 lines (92 loc) · 3.49 KB
/
Makefile
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# dir that contans the filesystem that must be checked
TESTDIR ?= "prime/"
SNAP_NAME=core24
BUILDDIR=/build/$(SNAP_NAME)
.PHONY: all
all: check
# nothing
.PHONY: install
install:
# install base
set -ex; if [ -z "$(DESTDIR)" ]; then \
echo "no DESTDIR set"; \
exit 1; \
fi
rm -rf $(DESTDIR)
cp -aT $(CRAFT_STAGE)/base $(DESTDIR)
# ensure resolving works inside the chroot
cat /etc/resolv.conf > $(DESTDIR)/etc/resolv.conf
# copy-in launchpad's build archive
if grep -q ftpmaster.internal /etc/apt/sources.list; then \
cp /etc/apt/sources.list $(DESTDIR)/etc/apt/sources.list; \
cp /etc/apt/trusted.gpg $(DESTDIR)/etc/apt/ || true; \
cp -r /etc/apt/trusted.gpg.d $(DESTDIR)/etc/apt/ || true; \
fi
# since recently we're also missing some /dev files that might be
# useful during build - make sure they're there
[ -e $(DESTDIR)/dev/null ] || mknod -m 666 $(DESTDIR)/dev/null c 1 3
[ -e $(DESTDIR)/dev/zero ] || mknod -m 666 $(DESTDIR)/dev/zero c 1 5
[ -e $(DESTDIR)/dev/random ] || mknod -m 666 $(DESTDIR)/dev/random c 1 8
[ -e $(DESTDIR)/dev/urandom ] || \
mknod -m 666 $(DESTDIR)/dev/urandom c 1 9
# copy static files verbatim
/bin/cp -a static/* $(DESTDIR)
mkdir -p $(DESTDIR)/install-data
# customize
set -eux; for f in ./hooks/[0-9]*.chroot; do \
base="$$(basename "$${f}")"; \
cp -a "$${f}" $(DESTDIR)/install-data/; \
chroot $(DESTDIR) "/install-data/$${base}"; \
rm "$(DESTDIR)/install-data/$${base}"; \
done
rm -rf $(DESTDIR)/install-data
# see https://github.com/systemd/systemd/blob/v247/src/shared/clock-util.c#L145
touch $(DESTDIR)/usr/lib/clock-epoch
# generate the changelog, for this we need the previous core snap
# to be installed, this should be handled in snapcraft.yaml
if [ -e "/snap/$(SNAP_NAME)/current/usr/share/snappy/dpkg.yaml" ]; then \
./tools/generate-changelog.py \
"/snap/$(SNAP_NAME)/current/usr/share/snappy/dpkg.yaml" \
"$(DESTDIR)/usr/share/snappy/dpkg.yaml" \
"$(DESTDIR)/usr/share/doc" \
$(DESTDIR)/usr/share/doc/ChangeLog; \
else \
echo "WARNING: changelog will not be generated for this build"; \
fi
# only generate manifest and dpkg.yaml files for lp build
if [ -e $(BUILDDIR) ]; then \
/bin/cp $(DESTDIR)/usr/share/snappy/dpkg.list $(BUILDDIR)/$(SNAP_NAME)-$$(date +%Y%m%d%H%M)_$(DPKG_ARCH).manifest; \
/bin/cp $(DESTDIR)/usr/share/snappy/dpkg.yaml $(BUILDDIR)/$(SNAP_NAME)-$$(date +%Y%m%d%H%M)_$(DPKG_ARCH).dpkg.yaml; \
if [ -e $(DESTDIR)/usr/share/doc/ChangeLog ]; then \
/bin/cp $(DESTDIR)/usr/share/doc/ChangeLog $(BUILDDIR)/$(SNAP_NAME)-$$(date +%Y%m%d%H%M)_$(DPKG_ARCH).ChangeLog; \
fi \
fi;
# after generating changelogs we can cleanup those bits
# from the base
find "$(DESTDIR)/usr/share/doc/" -name 'changelog.Debian.gz' -print -delete
find "$(DESTDIR)/usr/share/doc/" -name 'changelog.gz' -print -delete
.PHONY: check
check:
# exclude "useless cat" from checks, while useless they also make
# some code more readable
shellcheck -e SC2002 hooks/*
.PHONY: test
test:
# run tests - each hook should have a matching ".test" file
set -ex; if [ ! -d $(TESTDIR) ]; then \
echo "no $(TESTDIR) found, please build the tree first "; \
exit 1; \
fi
set -ex; for f in $$(pwd)/hook-tests/[0-9]*.test; do \
if !(cd $(TESTDIR) && $$f); then \
exit 1; \
fi; \
done; \
set -ex; for f in $$(pwd)/tests/test_*.sh; do \
sh -e $$f; \
done
# Display a report of files that are (still) present in /etc
.PHONY: etc-report
etc-report:
cd stage && find etc/
echo "Amount of cruft in /etc left: `find stage/etc/ | wc -l`"