Initial version

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2018-11-10 14:25:53 +01:00
commit 7619e28917
Signed by: luzifer
GPG key ID: DC2729FDD34BE99E
3 changed files with 90 additions and 0 deletions

22
Dockerfile Normal file
View file

@ -0,0 +1,22 @@
FROM archlinux/base:latest
RUN set -ex \
&& pacman -Sy \
&& pacman -S --noconfirm --needed \
base-devel \
curl \
git \
&& useradd -m -u 1000 builder \
&& echo "builder ALL=(ALL) NOPASSWD: ALL" >/etc/sudoers.d/builder \
&& curl -sSfLo /usr/local/bin/dumb-init "https://github.com/Yelp/dumb-init/releases/download/v1.2.1/dumb-init_1.2.1_amd64" \
&& curl -sSfLo /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/1.11/gosu-amd64" \
&& chmod 0755 \
/usr/local/bin/dumb-init \
/usr/local/bin/gosu
VOLUME ["/src", "/repo"]
WORKDIR /src
COPY run.sh /usr/local/bin/
ENTRYPOINT ["/usr/local/bin/run.sh"]

32
README.md Normal file
View file

@ -0,0 +1,32 @@
# luzifer-docker / arch-repo-builder
This repo contains a docker image to build and automatically add Archlinux packages to a local repository (which then can be served through an HTTP server).
## Usage
### Local `PKGBUILD`
First possibility to use this image is to build a local `PKGBUILD` file:
```bash
docker run --rm -ti \
-v "$(pwd):/src" \
-v "/path/to/repo:/repo" \
luzifer/arch-repo-builder
```
This will build an image from this Gist, take the local `PKGBUILD` in `/src`, build the package, move the result into `/repo` and add it to the `*.db.tar.*` file found in the repo. (Which means you need to initialize the repo first: `repo-add /path/to/repo/reponame.db.tar.xz`)
### Remote git repository
The second possibility is to build any git repo containing a `PKGBUILD` file:
```bash
docker run --rm -ti \
-v "/path/to/repo:/repo" \
luzifer/arch-repo-builder \
https://aur.archlinux.org/nerd-fonts-dejavu-complete.git
```
This will clone the given repository and then execute the same process as above.
### Build without repo
If no db-file was found in `/repo` the package will not be added to the repo but only reside in the mounted `/src`.

36
run.sh Executable file
View file

@ -0,0 +1,36 @@
#!/usr/local/bin/dumb-init /bin/bash
set -euxo pipefail
SRC=${1:-}
# Override WORKDIR
cd /src
if [ ! -e PKGBUILD ]; then
if [ -z "${SRC}" ]; then
echo "No /src/PKGBUILD was found and no repo to clone was given as parameter"
exit 1
fi
# Ensure permissions on src
chown -R builder /src
gosu builder git clone "${SRC}" /src/git
cd /src/git
fi
# Execute the build itself
gosu builder makepkg -cCs --noconfirm --needed
PACKAGE=$(ls *.pkg.*) # This should be only one file
REPODB=$(find /repo -name '*.db.*' ! -name '*.old')
if [ -z "${REPODB}" ]; then
echo "No database found in /repo, not adding package."
echo "The built package is available in ${PACKAGE}"
fi
gosu builder mv "${PACKAGE}" /repo
cd /repo
gosu builder repo-add ${REPODB} "${PACKAGE}"