Build in different flavours

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2019-02-14 18:32:04 +01:00
parent c1f7a83627
commit d1e6c6c13e
Signed by: luzifer
GPG key ID: DC2729FDD34BE99E
3 changed files with 78 additions and 32 deletions

View file

@ -1,36 +1,43 @@
DOCKER_USER:=pierres DOCKER_ORGANIZATION=luzifer
DOCKER_ORGANIZATION=archlinux DOCKER_IMAGE:=archlinux
DOCKER_IMAGE:=base
rootfs: default: docker-image_minimal
$(eval TMPDIR := $(shell mktemp -d))
env -i pacstrap -C /usr/share/devtools/pacman-extra.conf -c -d -G -M $(TMPDIR) $(shell cat packages)
cp --recursive --preserve=timestamps --backup --suffix=.pacnew rootfs/* $(TMPDIR)/
arch-chroot $(TMPDIR) locale-gen
arch-chroot $(TMPDIR) pacman-key --init
arch-chroot $(TMPDIR) pacman-key --populate archlinux
tar --numeric-owner --xattrs --acls --exclude-from=exclude -C $(TMPDIR) -c . -f archlinux.tar
rm -rf $(TMPDIR)
docker-image: rootfs jenkins: docker-image_minimal
docker build -t $(DOCKER_ORGANIZATION)/$(DOCKER_IMAGE) . jenkins: docker-image-test_latest
jenkins: docker-push_latest
docker-image-test: docker-image jenkins: docker-image_base
jenkins: docker-image-test_base
jenkins: docker-push_base
jenkins: docker-image_base-devel
jenkins: docker-image-test_base-devel
jenkins: docker-push_base-devel
rootfs_minimal:
bash mkroots.sh
rootfs_%:
bash mkroots.sh $*
docker-image_minimal: rootfs_minimal
docker build -t $(DOCKER_ORGANIZATION)/$(DOCKER_IMAGE):latest .
docker-image_%:
$(MAKE) rootfs_$*
docker build -t $(DOCKER_ORGANIZATION)/$(DOCKER_IMAGE):$* .
docker-image-test_%:
# FIXME: /etc/mtab is hidden by docker so the stricter -Qkk fails # FIXME: /etc/mtab is hidden by docker so the stricter -Qkk fails
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 -Sy && /usr/bin/pacman -Qqk"
docker run --rm $(DOCKER_ORGANIZATION)/$(DOCKER_IMAGE) sh -c "/usr/bin/pacman -Syu --noconfirm docker && docker -v" docker run --rm $(DOCKER_ORGANIZATION)/$(DOCKER_IMAGE):$* sh -c "/usr/bin/pacman -Syu --noconfirm docker && docker -v"
# Ensure that the image does not include a private key # Ensure that the image does not include a private key
! docker run --rm $(DOCKER_ORGANIZATION)/$(DOCKER_IMAGE) pacman-key --lsign-key pierre@archlinux.de ! docker run --rm $(DOCKER_ORGANIZATION)/$(DOCKER_IMAGE):$* pacman-key --lsign-key pierre@archlinux.de
docker run --rm $(DOCKER_ORGANIZATION)/$(DOCKER_IMAGE) sh -c "/usr/bin/id -u http" docker run --rm $(DOCKER_ORGANIZATION)/$(DOCKER_IMAGE):$* sh -c "/usr/bin/id -u http"
docker run --rm $(DOCKER_ORGANIZATION)/$(DOCKER_IMAGE) sh -c "/usr/bin/pacman -Syu --noconfirm grep && locale | grep -q UTF-8" docker run --rm $(DOCKER_ORGANIZATION)/$(DOCKER_IMAGE):$* sh -c "/usr/bin/pacman -Syu --noconfirm grep && locale | grep -q UTF-8"
ci-test: docker-push_%:
docker run --rm --privileged --tmpfs=/tmp:exec --tmpfs=/run/shm -v /run/docker.sock:/run/docker.sock \ docker push $(DOCKER_ORGANIZATION)/$(DOCKER_IMAGE):$*
-v $(PWD):/app -w /app $(DOCKER_ORGANIZATION)/$(DOCKER_IMAGE) \
sh -c 'pacman -Syu --noconfirm make devtools docker && make docker-image-test'
docker-push:
docker login -u $(DOCKER_USER)
docker push $(DOCKER_ORGANIZATION)/$(DOCKER_IMAGE)
.PHONY: rootfs docker-image docker-image-test ci-test docker-push .PHONY: rootfs docker-image docker-image-test ci-test docker-push

43
mkroots.sh Normal file
View file

@ -0,0 +1,43 @@
#!/bin/bash
set -euxo pipefail
[ $(id -u) -eq 0 ] || exec sudo bash $0 "$@"
[ -e /usr/share/devtools/pacman-extra.conf ] || {
echo "Missing 'devtools' on this system. Please 'pacman -S devtools'."
exit 1
}
# Packages required for the minimal system
packages=(
gzip
pacman
sed
systemd
)
# In case more packages were passed add them to the package list
if [ $# -gt 0 ]; then
packages+=("$@")
fi
# Build in a tempdir
tmpdir=$(mktemp -d)
function rm_temp() {
rm -rf ${tmpdir}
}
trap rm_temp EXIT
# Pacstrap the requested packages
env -i pacstrap -C /usr/share/devtools/pacman-extra.conf -c -d -G -M ${tmpdir} "${packages[@]}"
# Add local configurations
cp --recursive --preserve=timestamps --backup --suffix=.pacnew rootfs/* ${tmpdir}/
# Initialize locales and pacman-keys
arch-chroot ${tmpdir} locale-gen
arch-chroot ${tmpdir} pacman-key --init
arch-chroot ${tmpdir} pacman-key --populate archlinux
# Pack rootfs
tar --numeric-owner --xattrs --acls --exclude-from=exclude -C ${tmpdir} -c . -f archlinux.tar

View file

@ -1,4 +0,0 @@
sed
gzip
pacman
systemd