ENH: makefile/Dockerfile: allow for non-root build

The old makefile required commands to be run as a superuser, which
may become problematic when deploying on the archlinux infrastructure.
Use fakeroot and regular pacman commands to allow for to bootstrap a
rootfs.
This commit is contained in:
Santiago Torres 2018-03-23 20:55:32 -04:00
parent eec02f2ea9
commit 0535b255ae
No known key found for this signature in database
GPG Key ID: 468F122CE8162295
2 changed files with 10 additions and 8 deletions

View File

@ -1,4 +1,6 @@
FROM scratch
ADD archlinux.tar /
RUN locale-gen
RUN pacman-key --init && pacman-key --populate archlinux
ENV LANG=en_US.UTF-8
CMD ["/usr/bin/bash"]

View File

@ -1,16 +1,16 @@
DOCKER_USER:=pierres
DOCKER_ORGANIZATION=archlinux
DOCKER_IMAGE:=base
BUILDDIR=build
rootfs:
$(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)
mkdir -vp $(BUILDDIR)/var/lib/pacman/
fakeroot -- pacman -Syu -r $(BUILDDIR) \
--noconfirm --dbpath $(PWD)/$(BUILDDIR)/var/lib/pacman \
--hookdir rootfs/usr/share/libalpm/hooks/ $(shell cat packages)
cp --recursive --preserve=timestamps --backup --suffix=.pacnew rootfs/* $(BUILDDIR)/
tar --numeric-owner --xattrs --acls --exclude-from=exclude -C $(BUILDDIR) -c . -f archlinux.tar
rm -rf $(BUILDDIR)
docker-image: rootfs
docker build -t $(DOCKER_ORGANIZATION)/$(DOCKER_IMAGE) .