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
This commit is contained in:
Stefan Agner 2019-01-23 00:31:17 +01:00
commit 8dfabe4056
10 changed files with 107 additions and 0 deletions

18
.travis.yml Normal file
View file

@ -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'

25
Dockerfile Normal file
View file

@ -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"]

11
build Executable file
View file

@ -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 .

17
pacstrap-docker Executable file
View file

@ -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

11
push Executable file
View file

@ -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

1
rootfs/etc/locale.conf Normal file
View file

@ -0,0 +1 @@
LANG=en_US.UTF-8

1
rootfs/etc/locale.gen Normal file
View file

@ -0,0 +1 @@
en_US.UTF-8 UTF-8

View file

@ -0,0 +1 @@
Server = http://mirror.archlinuxarm.org/$arch/$repo

View file

@ -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/

View file

@ -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