From d5c31945879618f53fa981050ff3642475b02e15 Mon Sep 17 00:00:00 2001 From: Chewing_Bever Date: Thu, 16 Feb 2023 14:33:39 +0100 Subject: [PATCH] feat: add arch imag --- .woodpecker/arch-docker.yml | 23 ++++++++++++++++++++ README.md | 8 +++++++ arch/Dockerfile | 42 +++++++++++++++++++++++++++++++++++++ arch/files/mirrorlist-amd64 | 1 + arch/files/mirrorlist-arm64 | 1 + arch/files/pacstrap-docker | 31 +++++++++++++++++++++++++++ arch/files/repos-amd64 | 8 +++++++ arch/files/repos-arm64 | 14 +++++++++++++ 8 files changed, 128 insertions(+) create mode 100644 .woodpecker/arch-docker.yml create mode 100644 arch/Dockerfile create mode 100644 arch/files/mirrorlist-amd64 create mode 100644 arch/files/mirrorlist-arm64 create mode 100755 arch/files/pacstrap-docker create mode 100644 arch/files/repos-amd64 create mode 100644 arch/files/repos-arm64 diff --git a/.woodpecker/arch-docker.yml b/.woodpecker/arch-docker.yml new file mode 100644 index 0000000..baea66f --- /dev/null +++ b/.woodpecker/arch-docker.yml @@ -0,0 +1,23 @@ +platform: 'linux/amd64' + +when: + - path: + - 'arch/Dockerfile' + - '.woodpecker/arch-docker.yml' + event: [push] + - event: [cron] + +pipeline: + build: + image: 'woodpeckerci/plugin-docker-buildx' + secrets: + - 'docker_username' + - 'docker_password' + settings: + registry: 'git.rustybever.be' + repo: 'git.rustybever.be/vieter-v/vieter-builder' + tags: + - 'latest' + platforms: [ 'linux/arm64/v8', 'linux/amd64' ] + mtu: 1300 + context: 'arch' diff --git a/README.md b/README.md index b767658..55b87a5 100644 --- a/README.md +++ b/README.md @@ -35,3 +35,11 @@ docker buildx build \ This build requires a working buildx environment. The hash in the tag corresponds to the tag of the vlang repository. + +## Arch + +The Arch builder image is a soft fork of +[Menci/docker-archlinuxarm](https://github.com/Menci/docker-archlinuxarm), with +the following minimal changes: + +* Enable LTO by default diff --git a/arch/Dockerfile b/arch/Dockerfile new file mode 100644 index 0000000..a7f81a8 --- /dev/null +++ b/arch/Dockerfile @@ -0,0 +1,42 @@ +FROM alpine:3.15 AS bootstrapper +ARG TARGETARCH +COPY files /files +RUN \ + apk add arch-install-scripts pacman-makepkg curl && \ + cat /files/repos-$TARGETARCH >> /etc/pacman.conf && \ + mkdir -p /etc/pacman.d && \ + cp /files/mirrorlist-$TARGETARCH /etc/pacman.d/mirrorlist && \ + BOOTSTRAP_EXTRA_PACKAGES="" && \ + if [[ "$TARGETARCH" == "amd64" ]]; then \ + apk add zstd && \ + mkdir /tmp/archlinux-keyring && \ + curl -L https://archlinux.org/packages/core/any/archlinux-keyring/download | unzstd | tar -C /tmp/archlinux-keyring -xv && \ + mv /tmp/archlinux-keyring/usr/share/pacman/keyrings /usr/share/pacman/; \ + elif [[ "$TARGETARCH" == "arm64" ]]; then \ + curl -L https://github.com/archlinuxarm/archlinuxarm-keyring/archive/refs/heads/master.zip | unzip -d /tmp/archlinuxarm-keyring - && \ + mkdir /usr/share/pacman/keyrings && \ + mv /tmp/archlinuxarm-keyring/*/archlinuxarm* /usr/share/pacman/keyrings/ && \ + BOOTSTRAP_EXTRA_PACKAGES="archlinuxarm-keyring"; \ + fi && \ + pacman-key --init && \ + pacman-key --populate && \ + mkdir /rootfs && \ + /files/pacstrap-docker /rootfs base-devel $BOOTSTRAP_EXTRA_PACKAGES && \ + cp /etc/pacman.d/mirrorlist /rootfs/etc/pacman.d/mirrorlist && \ + echo "en_US.UTF-8 UTF-8" > /rootfs/etc/locale.gen && \ + echo "LANG=en_US.UTF-8" > /rootfs/etc/locale.conf && \ + chroot /rootfs locale-gen && \ + rm -rf /rootfs/var/lib/pacman/sync/* /rootfs/files + +FROM scratch +COPY --from=bootstrapper /rootfs/ / +ENV LANG=en_US.UTF-8 +RUN \ + ln -sf /usr/lib/os-release /etc/os-release && \ + pacman-key --init && \ + pacman-key --populate && \ + rm -rf /etc/pacman.d/gnupg/{openpgp-revocs.d/,private-keys-v1.d/,pubring.gpg~,gnupg.S.}* && \ + # Enable LTO by default \ + sed -i 's/!lto/lto/' /etc/makepkg.conf + +CMD ["/usr/bin/bash"] diff --git a/arch/files/mirrorlist-amd64 b/arch/files/mirrorlist-amd64 new file mode 100644 index 0000000..f2fbc08 --- /dev/null +++ b/arch/files/mirrorlist-amd64 @@ -0,0 +1 @@ +Server = http://mirrors.xtom.com/archlinux/$repo/os/$arch diff --git a/arch/files/mirrorlist-arm64 b/arch/files/mirrorlist-arm64 new file mode 100644 index 0000000..135d2fe --- /dev/null +++ b/arch/files/mirrorlist-arm64 @@ -0,0 +1 @@ +Server = http://mirror.archlinuxarm.org/$arch/$repo diff --git a/arch/files/pacstrap-docker b/arch/files/pacstrap-docker new file mode 100755 index 0000000..646aca8 --- /dev/null +++ b/arch/files/pacstrap-docker @@ -0,0 +1,31 @@ +#!/bin/bash + +out() { printf "$1 $2\n" "${@:3}"; } +error() { out "==> ERROR:" "$@"; } >&2 +die() { error "$@"; exit 1; } + +(( $# )) || die "No root directory specified" +newroot=$1; shift +pacman_args=("${@:-base}") + +if [[ $EUID -ne 0 ]]; then + die "This script must be run as root" +fi + +[[ -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 'Creating /dev/null in new root' +mknod "$newroot/dev/null" c 1 3 + +echo 'Installing packages to %s' "$newroot" +if ! pacman -r "$newroot" -Sy --noconfirm "${pacman_args[@]}"; then + die 'Failed to install packages to new root' +fi + +echo 'Deleting /dev/null from new root' +rm "$newroot/dev/null" diff --git a/arch/files/repos-amd64 b/arch/files/repos-amd64 new file mode 100644 index 0000000..99f7328 --- /dev/null +++ b/arch/files/repos-amd64 @@ -0,0 +1,8 @@ +[core] +Include = /etc/pacman.d/mirrorlist + +[extra] +Include = /etc/pacman.d/mirrorlist + +[community] +Include = /etc/pacman.d/mirrorlist diff --git a/arch/files/repos-arm64 b/arch/files/repos-arm64 new file mode 100644 index 0000000..c09cd9f --- /dev/null +++ b/arch/files/repos-arm64 @@ -0,0 +1,14 @@ +[core] +Include = /etc/pacman.d/mirrorlist + +[extra] +Include = /etc/pacman.d/mirrorlist + +[community] +Include = /etc/pacman.d/mirrorlist + +[alarm] +Include = /etc/pacman.d/mirrorlist + +[aur] +Include = /etc/pacman.d/mirrorlist