commit 8dfabe4056d243433925c627ae2e7fb4f0846d86 Author: Stefan Agner Date: Wed Jan 23 00:31:17 2019 +0100 initial commit Create Arch Linux ARM images using multi-stage Dockerfile. This works well with binfmt emulation and allows to generate images from scratch. Inspiration taken from: - https://github.com/archlinux/archlinux-docker - https://github.com/lopsided98/archlinux diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..137e115 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,18 @@ +dist: xenial +language: generic +sudo: required +go: + - stable +services: + - docker +install: + - go get github.com/estesp/manifest-tool + - 'echo ''{ "experimental": true }'' | sudo tee /etc/docker/daemon.json' + - sudo systemctl restart docker + - sudo apt-get --yes --no-install-recommends install qemu-user-static + - sudo su -c 'echo -1 > /proc/sys/fs/binfmt_misc/qemu-arm' + - echo ':qemu-arm:M:0:\x7f\x45\x4c\x46\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-arm-static:CF' | sudo tee -a /proc/sys/fs/binfmt_misc/register +script: + - ./build +after_success: + - '[ "$TRAVIS_PULL_REQUEST" == "false" ] && docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD" && ./push' diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..78f4404 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,25 @@ +FROM agners/archlinuxarm-arm32v7 + +WORKDIR /archlinux + +RUN mkdir -p /archlinux/rootfs + +COPY pacstrap-docker /archlinux/ + +RUN ./pacstrap-docker /archlinux/rootfs \ + bash sed gzip pacman + +# Remove current pacman database, likely outdated very soon +RUN rm rootfs/var/lib/pacman/sync/* + +FROM scratch +COPY --from=0 /archlinux/rootfs/ / +COPY rootfs/ / + +ENV LANG=en_US.UTF-8 + +RUN locale-gen +RUN pacman-key --init +RUN pacman-key --populate archlinuxarm + +CMD ["/usr/bin/bash"] diff --git a/build b/build new file mode 100755 index 0000000..60fbd34 --- /dev/null +++ b/build @@ -0,0 +1,11 @@ +#!/bin/bash -ex + +DOCKER_ARCH=arm32v7 +DOCKER_ORG=agners +DOCKER_IMAGE=archlinuxarm-${DOCKER_ARCH} + +TAG_DATE=$(date +'%Y%m%d') + +docker build -t $DOCKER_ORG/$DOCKER_IMAGE \ + -t $DOCKER_ORG/$DOCKER_IMAGE:$TAG_DATE . + diff --git a/pacstrap-docker b/pacstrap-docker new file mode 100755 index 0000000..c361e71 --- /dev/null +++ b/pacstrap-docker @@ -0,0 +1,17 @@ +#!/bin/bash + +(( $# )) || die "No root directory specified" +newroot=$1; shift +pacman_args=("${@:-base}") + +[[ -d $newroot ]] || die "%s is not a directory" "$newroot" + +echo 'Creating install root at %s' "$newroot" +mkdir -m 0755 -p "$newroot"/var/{cache/pacman/pkg,lib/pacman,log} "$newroot"/{dev,run,etc} +mkdir -m 1777 -p "$newroot"/tmp +mkdir -m 0555 -p "$newroot"/{sys,proc} + +echo 'Installing packages to %s' "$newroot" +if ! pacman -r "$newroot" -Sy --noconfirm "${pacman_args[@]}"; then + die 'Failed to install packages to new root' +fi diff --git a/push b/push new file mode 100755 index 0000000..3c25578 --- /dev/null +++ b/push @@ -0,0 +1,11 @@ +#!/bin/bash -ex + +DOCKER_ARCH=arm32v7 +DOCKER_ORG=agners +DOCKER_IMAGE=archlinuxarm-${DOCKER_ARCH} + +TAG_DATE=$(date +'%Y%m%d') + +docker push $DOCKER_ORG/$DOCKER_IMAGE $DOCKER_ORG/$DOCKER_IMAGE:$TAG_DATE + + diff --git a/rootfs/etc/locale.conf b/rootfs/etc/locale.conf new file mode 100644 index 0000000..01ec548 --- /dev/null +++ b/rootfs/etc/locale.conf @@ -0,0 +1 @@ +LANG=en_US.UTF-8 diff --git a/rootfs/etc/locale.gen b/rootfs/etc/locale.gen new file mode 100644 index 0000000..a66d814 --- /dev/null +++ b/rootfs/etc/locale.gen @@ -0,0 +1 @@ +en_US.UTF-8 UTF-8 diff --git a/rootfs/etc/pacman.d/mirrorlist b/rootfs/etc/pacman.d/mirrorlist new file mode 100644 index 0000000..135d2fe --- /dev/null +++ b/rootfs/etc/pacman.d/mirrorlist @@ -0,0 +1 @@ +Server = http://mirror.archlinuxarm.org/$arch/$repo diff --git a/rootfs/usr/share/libalpm/hooks/man-page-remove.hook b/rootfs/usr/share/libalpm/hooks/man-page-remove.hook new file mode 100644 index 0000000..05a370b --- /dev/null +++ b/rootfs/usr/share/libalpm/hooks/man-page-remove.hook @@ -0,0 +1,11 @@ +[Trigger] +Operation = Install +Operation = Upgrade +Type = Package +Target = * + +[Action] +Description = Cleaning up package cache... +Depends = coreutils +When = PostTransaction +Exec = /usr/bin/rm -rf /usr/share/man/ diff --git a/rootfs/usr/share/libalpm/hooks/package-cleanup.hook b/rootfs/usr/share/libalpm/hooks/package-cleanup.hook new file mode 100644 index 0000000..448d871 --- /dev/null +++ b/rootfs/usr/share/libalpm/hooks/package-cleanup.hook @@ -0,0 +1,11 @@ +[Trigger] +Operation = Install +Operation = Upgrade +Type = Package +Target = * + +[Action] +Description = Cleaning up package cache... +Depends = coreutils +When = PostTransaction +Exec = /usr/bin/rm -rf /var/cache/pacman/pkg