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

Pierre Schmitz's avatar
Pierre Schmitz committed
5
6
rootfs:
	$(eval TMPDIR := $(shell mktemp -d))
7
	env -i pacstrap -C /usr/share/devtools/pacman-extra.conf -c -d -G -M $(TMPDIR) $(shell cat packages)
8
	cp --recursive --preserve=timestamps --backup --suffix=.pacnew rootfs/* $(TMPDIR)/
Pierre Schmitz's avatar
Pierre Schmitz committed
9
10
11
	arch-chroot $(TMPDIR) locale-gen
	arch-chroot $(TMPDIR) pacman-key --init
	arch-chroot $(TMPDIR) pacman-key --populate archlinux
Pierre Schmitz's avatar
Pierre Schmitz committed
12
	tar --numeric-owner --xattrs --acls --exclude-from=exclude -C $(TMPDIR) -c . -f archlinux.tar
Pierre Schmitz's avatar
Pierre Schmitz committed
13
14
15
	rm -rf $(TMPDIR)

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

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

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

32
docker-push: docker-image-test
Pierre Schmitz's avatar
Pierre Schmitz committed
33
	docker login -u $(DOCKER_USER)
34
	docker push $(DOCKER_ORGANIZATION)/$(DOCKER_IMAGE)
Pierre Schmitz's avatar
Pierre Schmitz committed
35

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