Makefile 1.77 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

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

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

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

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

Pierre Schmitz's avatar
Pierre Schmitz committed
35
docker-push:
Pierre Schmitz's avatar
Pierre Schmitz committed
36
	docker login -u $(DOCKER_USER)
37
	docker push $(DOCKER_ORGANIZATION)/$(DOCKER_IMAGE)
Pierre Schmitz's avatar
Pierre Schmitz committed
38

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