forked from canonical/core20
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
83 lines (74 loc) · 2.41 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
DPKG_ARCH := $(shell dpkg --print-architecture)
LTS=$(shell ubuntu-distro-info --lts)
DEVEL=$(shell ubuntu-distro-info --devel)
ifeq ($(LTS),bionic)
BASE := $(DEVEL)-base-$(DPKG_ARCH).tar.gz
URL := http://cdimage.ubuntu.com/ubuntu-base/daily/current/$(BASE)
else
BASE := $(LTS)-base-$(DPKG_ARCH).tar.gz
URL := http://cdimage.ubuntu.com/ubuntu-base/$(LTS)/daily/current/$(BASE)
endif
# dir that contans the filesystem that must be checked
TESTDIR ?= "prime/"
.PHONY: all
all: check
# nothing
.PHONY: install
install:
# install base
set -ex; if [ -z "$(DESTDIR)" ]; then \
echo "no DESTDIR set"; \
exit 1; \
fi
if [ ! -f ../$(BASE) ]; then \
wget -P ../ $(URL); \
fi
rm -rf $(DESTDIR)
mkdir -p $(DESTDIR)
tar -x --xattrs-include=* -f ../$(BASE) -C $(DESTDIR)
# ensure resolving works inside the chroot
cat /etc/resolv.conf > $(DESTDIR)/etc/resolv.conf
# 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)
# customize
set -ex; for f in ./hooks/[0-9]*.chroot; do \
/bin/cp -a $$f $(DESTDIR)/tmp && \
if ! chroot $(DESTDIR) /tmp/$$(basename $$f); then \
exit 1; \
fi && \
rm -f $(DESTDIR)/tmp/$$(basename $$f); \
done;
# only generate manifest file for lp build
if [ -e /build/core20 ]; then \
echo $$f; \
/bin/cp $(DESTDIR)/usr/share/snappy/dpkg.list /build/core20/core20-$$(date +%Y%m%d%H%M)_$(DPKG_ARCH).manifest; \
fi;
.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; \
# 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`"