Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kugland/c3e288b9ec960ebae144cf3a1ea177b8 to your computer and use it in GitHub Desktop.
Save kugland/c3e288b9ec960ebae144cf3a1ea177b8 to your computer and use it in GitHub Desktop.
makepkg
#!/usr/bin/env bash
THIS_SCRIPT="$(realpath "$0")"
set -eu -o pipefail
build_container() {
CONTEXT="$(mktemp -d)"
trap 'rm -rf "$CONTEXT"' EXIT
sed -nE '/^# INCIPIT DOCKERFILE/,$p' < "$THIS_SCRIPT" > "$CONTEXT/Dockerfile"
( cd "$CONTEXT"; docker build --build-arg MY_UID=$(id -u) --build-arg MY_GID=$(id -g) -t archlinux-makepkg . )
}
build_container
docker run --rm -v "$(pwd):/build" archlinux-makepkg "$@"
exit 0
# INCIPIT DOCKERFILE
FROM archlinux:latest
ARG MY_UID
ARG MY_GID
RUN { \
set -euxo pipefail; \
pacman -Sy --noconfirm; \
pacman -S --noconfirm base-devel; \
echo 'builder ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/builder; \
groupadd -g $MY_GID builder; \
useradd -u $MY_UID -g $MY_GID -d /build builder; \
}
USER builder
WORKDIR /build
ENTRYPOINT ["/usr/bin/makepkg"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment