├── .github └── workflows │ └── build.yaml ├── .pre-commit-config.yaml ├── Dockerfile ├── LICENCE ├── README.md └── run.sh /.github/workflows/build.yaml: -------------------------------------------------------------------------------- 1 | name: build image 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | pull_request: 8 | types: [opened, synchronize, reopened] 9 | schedule: 10 | - cron: '0 0 * * 0' 11 | 12 | jobs: 13 | build: 14 | name: Build image 15 | runs-on: ubuntu-latest 16 | 17 | steps: 18 | - uses: actions/checkout@v2 19 | 20 | - uses: redhat-actions/buildah-build@v2 21 | id: build-image 22 | with: 23 | image: whynothugo/makepkg 24 | tags: latest ${{ github.sha }} 25 | containerfiles: | 26 | ./Dockerfile 27 | 28 | - uses: redhat-actions/push-to-registry@v2 29 | if: ${{ github.ref == 'refs/heads/main' }} 30 | with: 31 | image: ${{ steps.build-image.outputs.image }} 32 | tags: ${{ steps.build-image.outputs.tags }} 33 | registry: docker.io 34 | username: whynothugo 35 | password: ${{ secrets.REGISTRY_PASSWORD }} 36 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | repos: 2 | - repo: https://github.com/pre-commit/pre-commit-hooks 3 | rev: v4.4.0 4 | hooks: 5 | - id: trailing-whitespace 6 | args: [--markdown-linebreak-ext=md] 7 | - id: end-of-file-fixer 8 | - id: check-added-large-files 9 | # - repo: https://github.com/hadolint/hadolint 10 | # rev: v2.7.0 (tag is broken) 11 | # hooks: 12 | # - id: hadolint-docker 13 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM archlinux:base-devel 2 | 3 | # makepkg cannot (and should not) be run as root: 4 | RUN useradd -m build && \ 5 | pacman -Syu --noconfirm && \ 6 | pacman -Sy --noconfirm git && \ 7 | # Allow build to run stuff as root (to install dependencies): 8 | echo "build ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/build 9 | 10 | # Continue execution (and CMD) as build: 11 | USER build 12 | WORKDIR /home/build 13 | 14 | # Auto-fetch GPG keys (for checking signatures): 15 | RUN mkdir .gnupg && \ 16 | touch .gnupg/gpg.conf && \ 17 | echo "keyserver-options auto-key-retrieve" > .gnupg/gpg.conf && \ 18 | git clone https://aur.archlinux.org/paru-bin.git && \ 19 | cd paru-bin && \ 20 | makepkg --noconfirm --syncdeps --rmdeps --install --clean 21 | 22 | COPY run.sh /run.sh 23 | 24 | # Build the package 25 | WORKDIR /pkg 26 | CMD ["/bin/bash", "/run.sh"] 27 | -------------------------------------------------------------------------------- /LICENCE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2017, Hugo Osvaldo Barrera 2 | 3 | Permission to use, copy, modify, and/or distribute this software for any 4 | purpose with or without fee is hereby granted, provided that the above 5 | copyright notice and this permission notice appear in all copies. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH 8 | REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 9 | FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, 10 | INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 12 | OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 13 | PERFORMANCE OF THIS SOFTWARE. 14 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | docker-makepkg 2 | ============== 3 | 4 | [![build status](https://github.com/WhyNotHugo/docker-makepkg/actions/workflows/build.yaml/badge.svg)](https://github.com/WhyNotHugo/docker-makepkg/actions/workflows/build.yaml) 5 | 6 | This docker image is intended to tests `PKGBUILDs`, by installing dependencies 7 | and running `makepkg -f` in a clean Arch installation. It is intended to be 8 | used by packagers, both via CI, and on non-ArchLinux environments. 9 | 10 | The package can be saved to the current director by adding `-e EXPORT_PKG=1`, 11 | and the updated `.SRCINFO` file for the built package with `-e EXPORT_SRC=1`. 12 | 13 | Usage locally 14 | ------------- 15 | 16 | ```sh 17 | docker run -v $PWD:/pkg -e SYNC_DATABASE=1 whynothugo/makepkg 18 | ``` 19 | 20 | Or export the built package file to the working directory 21 | 22 | ```sh 23 | docker run -e EXPORT_PKG=1 -v $PWD:/pkg whynothugo/makepkg 24 | ``` 25 | 26 | Or export the updated `.SRCINFO` for the package 27 | 28 | ```sh 29 | docker run -e EXPORT_SRC=1 -v $PWD:/pkg whynothugo/makepkg 30 | ``` 31 | 32 | If you are running Arch, you can share the mirror list from your host by adding 33 | `-v /etc/pacman.d/mirrorlist:/etc/pacman.d/mirrorlist:ro`. 34 | 35 | Usage with travis 36 | ----------------- 37 | 38 | Generally, this should be enough: 39 | 40 | ```yaml 41 | sudo: required 42 | 43 | services: 44 | - docker 45 | 46 | script: 47 | - docker run -v $TRAVIS_BUILD_DIR:/pkg whynothugo/makepkg 48 | ``` 49 | 50 | Usage with GitLab CI 51 | -------------------- 52 | 53 | Since GitLab CI uses Docker, it should be trivial to use these images there 54 | too. 55 | 56 | Extra details 57 | ------------- 58 | 59 | * `base-devel` is pre-installed. 60 | * All `depends` will be installed (including AUR packages using 61 | [paru](https://github.com/Morganamilo/paru)). 62 | * You may pass `SYNC_DATABASE=1` to force a `pacman -Sy` to refresh the 63 | database, since it updates quite frequently. 64 | * GPG keys used to verify signatures are auto-fetched. 65 | 66 | Licence 67 | ------- 68 | 69 | This repository is licensed under the ISC licence. See LICENCE for details. 70 | -------------------------------------------------------------------------------- /run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | # Make a copy so we never alter the original 6 | cp -r /pkg /tmp/pkg 7 | cd /tmp/pkg 8 | 9 | # Sync database 10 | if [ -n "$SYNC_DATABASE" ]; then 11 | paru -S --refresh 12 | fi 13 | 14 | # Do the actual building. Paru will fetch all dependencies for us (including 15 | # AUR dependencies) and then build the package. 16 | paru -U --noconfirm 17 | 18 | # Store the built package(s). Ensure permissions match the original PKGBUILD. 19 | if [ -n "$EXPORT_PKG" ]; then 20 | sudo chown "$(stat -c '%u:%g' /pkg/PKGBUILD)" ./*pkg.tar* 21 | sudo mv ./*pkg.tar* /pkg 22 | fi 23 | # Export .SRCINFO for built package 24 | if [ -n "$EXPORT_SRC" ]; then 25 | makepkg --printsrcinfo > .SRCINFO 26 | sudo chown "$(stat -c '%u:%g' /pkg/PKGBUILD)" ./.SRCINFO 27 | sudo mv ./.SRCINFO /pkg 28 | fi 29 | --------------------------------------------------------------------------------