Makefile 1.92 KB
Newer Older
1
DOCKER_USER:=pierres
2
3
DOCKER_ORGANIZATION=archlinux
DOCKER_IMAGE:=base
4
BUILDDIR=build
Pierre Schmitz's avatar
Pierre Schmitz committed
5

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

rootfs: hooks
11
	mkdir -vp $(BUILDDIR)/var/lib/pacman/
Santiago Torres's avatar
Santiago Torres committed
12
	fakechroot -- fakeroot -- pacman -Sy -r $(BUILDDIR) \
13
		--noconfirm --dbpath $(PWD)/$(BUILDDIR)/var/lib/pacman \
14
15
		--config rootfs/etc/pacman.conf \
		--noscriptlet \
Santiago Torres's avatar
Santiago Torres committed
16
		--hookdir $(PWD)/alpm-hooks/usr/share/libalpm/hooks/ $(shell cat packages)
17
	cp --recursive --preserve=timestamps --backup --suffix=.pacnew rootfs/* $(BUILDDIR)/
18
	rm -r build/var/cache/pacman/pkg
19
	tar --numeric-owner --xattrs --acls --exclude-from=exclude -C $(BUILDDIR) -c . -f archlinux.tar
Santiago Torres's avatar
Santiago Torres committed
20
	rm -rf $(BUILDDIR) alpm-hooks
Pierre Schmitz's avatar
Pierre Schmitz committed
21
22

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

25
26
docker-image-test: docker-image
	# FIXME: /etc/mtab is hidden by docker so the stricter -Qkk fails
27
28
	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"
29
	# Ensure that the image does not include a private key
30
	! docker run --rm $(DOCKER_ORGANIZATION)/$(DOCKER_IMAGE) pacman-key --lsign-key pierre@archlinux.de
31
	docker run --rm $(DOCKER_ORGANIZATION)/$(DOCKER_IMAGE) sh -c "/usr/bin/id -u http"
32
	docker run --rm $(DOCKER_ORGANIZATION)/$(DOCKER_IMAGE) sh -c "/usr/bin/pacman -Syu --noconfirm grep && locale | grep -q UTF-8"
33

34
ci-test:
35
	docker run --rm --privileged --tmpfs=/tmp:exec --tmpfs=/run/shm -v /run/docker.sock:/run/docker.sock \
36
		-v $(PWD):/app -w /app $(DOCKER_ORGANIZATION)/$(DOCKER_IMAGE) \
37
		sh -c 'pacman -Syu --noconfirm make devtools docker && make docker-image-test'
38

Pierre Schmitz's avatar
Pierre Schmitz committed
39
docker-push:
Pierre Schmitz's avatar
Pierre Schmitz committed
40
	docker login -u $(DOCKER_USER)
41
	docker push $(DOCKER_ORGANIZATION)/$(DOCKER_IMAGE)
Pierre Schmitz's avatar
Pierre Schmitz committed
42

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