diff --git a/README.md b/README.md index 3d8189e7..2db4092e 100644 --- a/README.md +++ b/README.md @@ -51,9 +51,40 @@ Requests regarding binary packages can be tracked on the issue tracker of this GitHub project as well, e.g. within the [general discussion issue](https://github.com/Martchus/PKGBUILDs/issues/94). -## Docker image -Checkout the repository -[docker-mingw-qt5](https://github.com/mdimura/docker-mingw-qt5). +## Container image, building packages within a container +The directory `devel/container` contains a script to build a container image +suitable to run Arch Linux's `makepkg` script so you can build from PKGBUILDs on +any environment where Docker, Podman or any other suitable container runtime is +available. + +It also contains a script called `makecontainerpkg` which behaves like +`makechrootpkg` from Arch Linux's devtools but uses the previously mentioned +container image. Therefore it does *not* require devtools, a chroot setup and +systemd-nsapwn. Instead, any container runtime should be sufficient (tested with +Docker). + +The usage of `makecontainerpkg` is very similar to `makechrootpkg`. Simply run +the script in a directory containing a `PKGBUILD` file. If the directory +contains a file called `pacman.conf` and/or `makepkg.conf` those files are +configured to be used during the build. The call syntax is the following: +``` +makecontainerpkg [cre args] --- [makepkg args] +``` + +Example where the host pacman cache and ccache directories are mounted into the +container and a package rebuild is forced via `makepkg`'s flag `-f`: +``` +makecontainerpkg -v /var/cache/pacman/pkg/ -v /run/media/devel/ccache:/ccache -- -f CCACHE_DIR=/ccache +``` + +Set the environment variable `CRE` to the container runtime executable (by +default `docker`) and set `CRE_IMAGE` to use a different container image. + +--- + +There's also the 3rdparty repository +[docker-mingw-qt5](https://github.com/mdimura/docker-mingw-qt5) which contains +an image with many mingw-w64 package pre-installed. ## Structure Each package is in its own subdirectoy: diff --git a/devel/container/base-devel/Dockerfile b/devel/container/base-devel/Dockerfile index 03e8d47e..b8f0081c 100644 --- a/devel/container/base-devel/Dockerfile +++ b/devel/container/base-devel/Dockerfile @@ -4,7 +4,11 @@ MAINTAINER Martchus RUN mkdir -p /startdir /build && \ useradd -m -d /build -u 1000 -U -s /bin/bash builduser && \ chown -R builduser:builduser /build && \ - pacman -Syu --noconfirm --needed base-devel pacman-contrib && \ + pacman-key --init && \ + pacman-key --recv-keys B9E36A7275FC61B464B67907E06FE8F53CDC6A4C && \ + pacman-key --finger B9E36A7275FC61B464B67907E06FE8F53CDC6A4C && \ + pacman-key --lsign-key B9E36A7275FC61B464B67907E06FE8F53CDC6A4C && \ + pacman -Syu --noconfirm --needed base-devel pacman-contrib ccache && \ pacman -Scc --noconfirm && \ paccache -r -k0 && \ rm -rf /usr/share/man/* /tmp/* /var/tmp/* diff --git a/devel/container/containerbuild b/devel/container/containerbuild index 961d5315..3ed12c0a 100644 --- a/devel/container/containerbuild +++ b/devel/container/containerbuild @@ -1,7 +1,5 @@ #!/bin/bash set -e -source PKGBUILD -pacman -Syu --noconfirm --needed "${depends[@]}" "${makedepends[@]}" "${checkdepends[@]}" export LOGDEST=$PWD SRCPKGDEST=$PWD SRCDEST=$PWD PKGDEST=$PWD BUILDDIR=/build export BUILDTOOL=makecontainerbuild BUILDTOOLVER="0.0.1" chown builduser:builduser "$PWD" diff --git a/devel/container/containersync b/devel/container/containersync new file mode 100644 index 00000000..977076f1 --- /dev/null +++ b/devel/container/containersync @@ -0,0 +1,7 @@ +#!/bin/bash +set -e +for config_file in {makepkg,pacman}.conf; do + [[ -f $config_file ]] && cp --target-directory=/etc "$config_file" +done +source PKGBUILD +pacman -Syu --noconfirm --needed "${depends[@]}" "${makedepends[@]}" "${checkdepends[@]}" diff --git a/devel/container/imagebuild b/devel/container/imagebuild index 9ca8b501..76dc21f2 100755 --- a/devel/container/imagebuild +++ b/devel/container/imagebuild @@ -1,4 +1,4 @@ #!/bin/bash set -e bindir=$(dirname "$0") -"${CRE:-docker}" image build --tag "${CRE_IMAGE:-archlinux-base-devel}" "$bindir/base-devel" +${CRE:-docker} image build --tag "${CRE_IMAGE:-archlinux-base-devel}" "$bindir/base-devel" diff --git a/devel/container/makecontainerpkg b/devel/container/makecontainerpkg index e250a302..d482f7ae 100755 --- a/devel/container/makecontainerpkg +++ b/devel/container/makecontainerpkg @@ -1,15 +1,14 @@ #!/bin/bash set -e -# load "containerbuild" script -bindir=$(dirname "$0") -script=$(cat "$bindir/containerbuild") - # parse arguments cre_args=(--workdir "/startdir" -v "$PWD":/startdir --rm) -script_args= read_script_args= +script_args= read_script_args= no_sync= for arg in "$@"; do if [[ $read_script_args ]]; then + if [[ $arg == '--nodeps' ]] || [[ $arg == '-d' ]]; then + no_sync=1 + fi script_args+=" '$arg'" else if [[ $arg == '--' ]]; then @@ -20,9 +19,16 @@ for arg in "$@"; do fi done +# load "containerbuild" and "containersync" script +bindir=$(dirname "$0") +script=$(cat "$bindir/containerbuild") +if ! [[ $no_sync ]]; then + script_sync=$(cat "$bindir/containersync") +fi + # allow one to prevent the container from stopping via DEBUG variable if [[ $DEBUG ]]; then script_args+=' ; sleep infinity' fi -"${CRE:-docker}" run "${cre_args[@]}" "${CRE_IMAGE:-archlinux-base-devel}" bash -c "$script $script_args" +${CRE:-docker} run "${cre_args[@]}" "${CRE_IMAGE:-archlinux-base-devel}" bash -c "$script_sync $script $script_args"