From 347c8605c95fa9c4d34f2e7bcbe11208bf436daf Mon Sep 17 00:00:00 2001 From: Asger Gitz-Johansen Date: Mon, 19 Aug 2024 19:42:46 +0200 Subject: [PATCH] fix: automate arch packaging using docker just like debian. This makes the scripts easier to reproduce. --- .gitignore | 3 +++ PKGBUILD => PKGBUILD.in | 8 ++++---- TODO.md | 2 +- arch-builder.dockerfile | 15 +++++++++++++++ scripts/package-sci-arch.sh | 21 +++++++++++++++++++++ 5 files changed, 44 insertions(+), 5 deletions(-) rename PKGBUILD => PKGBUILD.in (69%) create mode 100644 arch-builder.dockerfile create mode 100755 scripts/package-sci-arch.sh diff --git a/.gitignore b/.gitignore index f115bc8..f311c24 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,10 @@ out/ examples/ +artifacts/ +pkg/ compile_commands.json .cache/ *.tar.gz *.log *.zst +PKGBUILD diff --git a/PKGBUILD b/PKGBUILD.in similarity index 69% rename from PKGBUILD rename to PKGBUILD.in index 92a5ad8..37a9923 100644 --- a/PKGBUILD +++ b/PKGBUILD.in @@ -4,9 +4,9 @@ pkgver=1.0.0 pkgrel=1 epoch= pkgdesc="A simple / minimal CI (Continuous Integration) system" -arch=('x86_64') # TODO: also arm64 when you're not tired -url="gitea.local:3000/agj/sci" -license=('GPL-3.0-or-later') # TODO: add LICENSE file and header +arch=('x86_64') +url="https://git.gtz.dk/agj/sci" +license=('GPL-3.0-or-later') groups=() depends=("glibc" "util-linux-libs") @@ -22,7 +22,7 @@ install= changelog= source=("$pkgname-$pkgver.tar.gz") noextract=() -sha256sums=("948092bdcc3591afcdc205263832a06c838aa9d524c762b061e91cffa04b7d63") +sha256sums=("SRC_SHA256") validpgpkeys=() build() { diff --git a/TODO.md b/TODO.md index e422613..98e7219 100644 --- a/TODO.md +++ b/TODO.md @@ -11,7 +11,7 @@ - [ ] Seventh things seventh, package the sucker (arch, debian, alpine, docker) - [x] archlinux - https://wiki.archlinux.org/title/Creating_packages - - [ ] debian + - [x] debian - see `/home/agj/documents/Projects/packaging/deb-packaging-tutorial.pdf` - just use docker. - [ ] alpine diff --git a/arch-builder.dockerfile b/arch-builder.dockerfile new file mode 100644 index 0000000..218c077 --- /dev/null +++ b/arch-builder.dockerfile @@ -0,0 +1,15 @@ +FROM archlinux +RUN pacman -Sy --noconfirm base-devel +ARG DOCKER_USER=arch + +# Set user and group +ARG user=appuser +ARG group=appuser +ARG uid=1000 +ARG gid=1000 +RUN groupadd -g ${gid} ${group} +RUN useradd -u ${uid} -g ${group} -s /bin/sh -m ${user} # <--- the '-m' create a user home directory +ENV USER=${user} + +# Switch to user +USER ${uid}:${gid} diff --git a/scripts/package-sci-arch.sh b/scripts/package-sci-arch.sh new file mode 100755 index 0000000..6ca5ba7 --- /dev/null +++ b/scripts/package-sci-arch.sh @@ -0,0 +1,21 @@ +#!/bin/bash +archbuilder_image=$(docker images | grep archbuilder) +set -e +if [ -z $archbuilder_image ]; then + echo "building archbuilder image..." + docker build -t archbuilder -f arch-builder.dockerfile . +fi + +echo "building source dist..." +make dist +SRC_SHA256=$(sha256sum sci-1.0.0.tar.gz | awk '{ print $1 }') +echo $SRC_SHA256 +sed "s/SRC_SHA256/$SRC_SHA256/g" < PKGBUILD.in > PKGBUILD + +echo "building arch package in archbuilder docker image..." +docker run --rm -it -v .:/src archbuilder sh -c '\ + cd && \ + cp /src/sci-1.0.0.tar.gz /src/PKGBUILD . && \ + makepkg && \ + cp *.zst /src +'