Makefile 2.09 KB
Newer Older
1
DOCKER_USER:=pierres
2
3
DOCKER_ORGANIZATION=archlinux
DOCKER_IMAGE:=base
4
BUILDDIR=build
5
PWD=$(shell pwd)
Pierre Schmitz's avatar
Pierre Schmitz committed
6

Santiago Torres's avatar
Santiago Torres committed
7
8
9
10
11
hooks:
	mkdir -p alpm-hooks/usr/share/libalpm/hooks
	find /usr/share/libalpm/hooks -exec ln -s /dev/null $(PWD)/alpm-hooks{} \;

rootfs: hooks
12
	mkdir -vp $(BUILDDIR)/var/lib/pacman/
Santiago Torres's avatar
Santiago Torres committed
13
	fakechroot -- fakeroot -- pacman -Sy -r $(BUILDDIR) \
14
		--noconfirm --dbpath $(PWD)/$(BUILDDIR)/var/lib/pacman \
15
		--config pacman.conf \
16
		--noscriptlet \
Santiago Torres's avatar
Santiago Torres committed
17
		--hookdir $(PWD)/alpm-hooks/usr/share/libalpm/hooks/ $(shell cat packages)
18
	cp --recursive --preserve=timestamps --backup --suffix=.pacnew rootfs/* $(BUILDDIR)/
19
20
21
22
	
	# remove passwordless login for root (see CVE-2019-5021 for reference)
	sed -i -e 's/^root::/root:!:/' "$(BUILDDIR)/etc/shadow"

23
	tar --numeric-owner --xattrs --acls --exclude-from=exclude -C $(BUILDDIR) -c . -f archlinux.tar
Santiago Torres's avatar
Santiago Torres committed
24
	rm -rf $(BUILDDIR) alpm-hooks
Pierre Schmitz's avatar
Pierre Schmitz committed
25

26
27
28
29
compress-rootfs: rootfs
	xz archlinux.tar

docker-image: compress-rootfs
30
	docker build -t $(DOCKER_ORGANIZATION)/$(DOCKER_IMAGE) .
Pierre Schmitz's avatar
Pierre Schmitz committed
31

32
33
docker-image-test: docker-image
	# FIXME: /etc/mtab is hidden by docker so the stricter -Qkk fails
34
35
	docker run --rm $(DOCKER_ORGANIZATION)/$(DOCKER_IMAGE) sh -c "/usr/bin/pacman -Sy && /usr/bin/pacman -Qqk"
	docker run --rm $(DOCKER_ORGANIZATION)/$(DOCKER_IMAGE) sh -c "/usr/bin/pacman -Syu --noconfirm docker && docker -v"
36
	# Ensure that the image does not include a private key
37
	! docker run --rm $(DOCKER_ORGANIZATION)/$(DOCKER_IMAGE) pacman-key --lsign-key pierre@archlinux.de
38
	docker run --rm $(DOCKER_ORGANIZATION)/$(DOCKER_IMAGE) sh -c "/usr/bin/id -u http"
39
	docker run --rm $(DOCKER_ORGANIZATION)/$(DOCKER_IMAGE) sh -c "/usr/bin/pacman -Syu --noconfirm grep && locale | grep -q UTF-8"
40

41
ci-test:
42
	docker run --rm --privileged --tmpfs=/tmp:exec --tmpfs=/run/shm -v /run/docker.sock:/run/docker.sock \
43
		-v $(PWD):/app -w /app $(DOCKER_ORGANIZATION)/$(DOCKER_IMAGE) \
44
		sh -c 'pacman -Syu --noconfirm fakechroot fakeroot make devtools docker && make docker-image-test'
45

Pierre Schmitz's avatar
Pierre Schmitz committed
46
docker-push:
Pierre Schmitz's avatar
Pierre Schmitz committed
47
	docker login -u $(DOCKER_USER)
48
	docker push $(DOCKER_ORGANIZATION)/$(DOCKER_IMAGE)
Pierre Schmitz's avatar
Pierre Schmitz committed
49

50
.PHONY: rootfs docker-image docker-image-test ci-test docker-push