Makefile 1.45 KB
Newer Older
1
2
DOCKER_USER:=pierres
DOCKER_IMAGE:=archlinux
Pierre Schmitz's avatar
Pierre Schmitz committed
3

Pierre Schmitz's avatar
Pierre Schmitz committed
4
5
rootfs:
	$(eval TMPDIR := $(shell mktemp -d))
Pierre Schmitz's avatar
Pierre Schmitz committed
6
	pacstrap -C /usr/share/devtools/pacman-extra.conf -c -d -G -M $(TMPDIR) $(shell cat packages)
7
	cp --recursive --preserve=timestamps --backup --suffix=.pacnew rootfs/* $(TMPDIR)/
Pierre Schmitz's avatar
Pierre Schmitz committed
8
9
10
	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
11
	tar --numeric-owner --xattrs --acls --exclude-from=exclude -C $(TMPDIR) -c . -f archlinux.tar
Pierre Schmitz's avatar
Pierre Schmitz committed
12
13
14
	rm -rf $(TMPDIR)

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

17
18
19
20
docker-image-test: docker-image
	# FIXME: /etc/mtab is hidden by docker so the stricter -Qkk fails
	docker run --rm $(DOCKER_USER)/$(DOCKER_IMAGE) sh -c "/usr/bin/pacman -Sy && /usr/bin/pacman -Qqk"
	docker run --rm $(DOCKER_USER)/$(DOCKER_IMAGE) sh -c "/usr/bin/pacman -Syu --noconfirm docker && docker -v"
21
	# Ensure that the image does not include a private key
22
	! docker run --rm $(DOCKER_USER)/$(DOCKER_IMAGE) pacman-key --lsign-key pierre@archlinux.de
23

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

29
docker-push: docker-image-test
Pierre Schmitz's avatar
Pierre Schmitz committed
30
31
	docker login -u $(DOCKER_USER)
	docker push $(DOCKER_USER)/$(DOCKER_IMAGE)
Pierre Schmitz's avatar
Pierre Schmitz committed
32

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