From 53bcff9513d1e2274a710010a9bd6bc331f45977 Mon Sep 17 00:00:00 2001 From: unpackerr-auto-releaser Date: Wed, 31 Jul 2024 00:05:37 -0700 Subject: [PATCH] add aur push --- init/archlinux/PKGBUILD.template | 94 ++++++++++++++++---------------- init/archlinux/README.md | 3 +- init/archlinux/SRCINFO.template | 5 +- init/archlinux/aur-deploy.sh | 38 +++++-------- init/systemd/unpackerr.service | 7 ++- 5 files changed, 69 insertions(+), 78 deletions(-) diff --git a/init/archlinux/PKGBUILD.template b/init/archlinux/PKGBUILD.template index a61619b6..d1d708d2 100644 --- a/init/archlinux/PKGBUILD.template +++ b/init/archlinux/PKGBUILD.template @@ -5,60 +5,60 @@ pkgdesc='{{Desc}}' arch=('x86_64' 'arm' 'armv6h' 'armv7h' 'aarch64' 'i686' 'pentium4') url='https://golift.io/unpackerr' license=('MIT') -makedepends=('go' 'make') -source=("unpackerr-${pkgver}.tar.gz::{{SOURCE_PATH}}") -sha256sums=('{{SHA256}}') -configfile='unpackerr.conf' -backup=("etc/${pkgname}/${configfile}") -install="${pkgname}.aur.install" +makedepends=('go' 'gzip') -build() { - cd "$pkgname-$pkgver" - export EXTRA_LDFLAGS=-linkmode=external - export GOFLAGS="-buildmode=pie -trimpath -mod=readonly -modcacherw" - make man VERSION="${pkgver}" ITERATION="${pkgrel}" - make "${pkgname}.service" VERSION="${pkgver}" ITERATION="${pkgrel}" +source=("${pkgname}-${pkgver}.tar.gz::{{SOURCE_PATH}}") +sha512sums=('{{SHA}}') - if [ "$CARCH" == "x86_64" ]; then - make linux VERSION="${pkgver}" ITERATION="${pkgrel}" - mv "$pkgname.amd64.linux" "$pkgname" - elif [ "$CARCH" == "arm" ] || [ "$CARCH" == "armv6h" ] || [ "$CARCH" == "armv7h" ]; then - make armhf VERSION="${pkgver}" ITERATION="${pkgrel}" - mv "$pkgname.armhf.linux" "$pkgname" - elif [ "$CARCH" == "aarch64" ]; then - make arm64 VERSION="${pkgver}" ITERATION="${pkgrel}" - mv "$pkgname.arm64.linux" "$pkgname" - elif [ "$CARCH" == "i686" ] || [ "$CARCH" == "pentium4" ]; then - make linux386 VERSION="${pkgver}" ITERATION="${pkgrel}" - mv "$pkgname.i386.linux" "$pkgname" - fi +backup=("etc/${pkgname}/${pkgname}.conf") + +prepare(){ + cd "$pkgname-$pkgver" + mkdir -p build/ } -check() { +build() { cd "$pkgname-$pkgver" - go test ./... + + export CGO_CPPFLAGS="${CPPFLAGS}" + export CGO_CFLAGS="${CFLAGS}" + export CGO_CXXFLAGS="${CXXFLAGS}" + export CGO_LDFLAGS="${LDFLAGS}" + export GOFLAGS="-buildmode=pie -trimpath -modcacherw" + export VLDFLAGS="-w -s -X 'golift.io/version.Branch=main (${sha512sums[0]:0:11})' \ + -X golift.io/version.BuildDate=$(date -u +%Y-%m-%dT%H:%M:00Z) \ + -X golift.io/version.BuildUser=$(whoami) \ + -X golift.io/version.Revision=${pkgrel} \ + -X golift.io/version.Version=${pkgver}" + + go build -o unpackerr -ldflags "$VLDFLAGS" . + go run github.com/davidnewhall/md2roff@v0.0.1 --manual unpackerr --version ${pkgver} --date "${DATE}" README.md + go run github.com/davidnewhall/md2roff@v0.0.1 --manual unpackerr --version ${pkgver} --date "${DATE}" examples/MANUAL.md + gzip -9 examples/MANUAL + mv examples/MANUAL.gz ${pkgname}.1.gz } package() { - cd "$pkgname-$pkgver" - # Binary. - install -Dm755 "${pkgname}" "${pkgdir}/usr/bin/${pkgname}" + cd "${srcdir}/${pkgname}-${pkgver}" + # Directories. - install -dm0755 "${pkgdir}/share/doc/${pkgname}" \ - "${pkgdir}/usr/share/licenses/${pkgname}" "${pkgdir}/etc/${pkgname}" - # Man file. - install -Dm644 "${pkgname}.1.gz" "${pkgdir}/share/man/man1/${pkgname}.1.gz" - # Config file, and example config file. - install -m644 "examples/${configfile}.example" "${pkgdir}/etc/$pkgname/${configfile}.example" - install -m644 "examples/${configfile}.example" "${pkgdir}/etc/${pkgname}/${configfile}" - # Extra documentation. - install -m644 *.html examples/* "${pkgdir}/share/doc/${pkgname}/" - # License. - install -m644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE" - # User and group. - echo 'u unpackerr - "unpackerr file extracter" -' > sysusers.conf - install -Dm0644 "sysusers.conf" "${pkgdir}/usr/lib/sysusers.d/unpackerr.conf" - rm sysusers.conf - # Systemd Service Unit. - install -Dm644 "${pkgname}.service" "${pkgdir}/usr/lib/systemd/system/${pkgname}.service" + install -d -m 755 "${pkgdir}/usr/share/"{licenses,doc}"/${pkgname}" "${pkgdir}/etc/${pkgname}" + + # Install the binary + install -D -m 755 "${pkgname}" "${pkgdir}/usr/bin/${pkgname}" + + # Install configuration file(s). + install -D -m 644 "examples/${pkgname}.conf.example" "${pkgdir}/etc/${pkgname}/${pkgname}.conf" + install -D -m 644 "examples/${pkgname}.conf.example" "${pkgdir}/etc/${pkgname}/${pkgname}.conf.example" + + # License, documentation, manual. + install -D -m 644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE" + install -D -m 644 *.html examples/* "${pkgdir}/usr/share/doc/${pkgname}/" + install -D -m 644 "${pkgname}.1.gz" "${pkgdir}/usr/share/man/man1/${pkgname}.1.gz" + + # Install the systemd service unit and system user account. + install -D -m 644 "init/systemd/${pkgname}.service" "${pkgdir}/usr/lib/systemd/system/${pkgname}.service" + echo "u ${pkgname} - \"${pkgname} daemon\"" > "${pkgname}.sysusers" + install -D -m 644 "${pkgname}.sysusers" "${pkgdir}/usr/lib/sysusers.d/${pkgname}.conf" + rm "${pkgname}.sysusers" } diff --git a/init/archlinux/README.md b/init/archlinux/README.md index 15c2ae27..14b0580d 100644 --- a/init/archlinux/README.md +++ b/init/archlinux/README.md @@ -1 +1,2 @@ -This template file is built by GitHub Actions and uploaded to a [different github repo](https://github.com/golift/aur). +This template file is built by GitHub Actions and uploaded to the +[AUR repo](https://aur.archlinux.org/packages/unpackerr). diff --git a/init/archlinux/SRCINFO.template b/init/archlinux/SRCINFO.template index 8507a5d4..fc5be849 100644 --- a/init/archlinux/SRCINFO.template +++ b/init/archlinux/SRCINFO.template @@ -3,7 +3,6 @@ pkgbase = unpackerr pkgver = {{VERSION}} pkgrel = {{Iter}} url = https:/golift.io/unpackerr - install = unpackerr.aur.install arch = x86_64 arch = arm arch = armv6h @@ -13,9 +12,9 @@ pkgbase = unpackerr arch = pentium4 license = MIT makedepends = go - makedepends = make + makedepends = gzip backup = etc/unpackerr/unpackerr.conf source = unpackerr-{{VERSION}}.tar.gz::{{SOURCE_PATH}} - sha256sums = {{SHA256}} + sha512sums = {{SHA}} pkgname = unpackerr diff --git a/init/archlinux/aur-deploy.sh b/init/archlinux/aur-deploy.sh index 71c2808a..221cd2f1 100644 --- a/init/archlinux/aur-deploy.sh +++ b/init/archlinux/aur-deploy.sh @@ -1,13 +1,13 @@ #!/bin/bash -x -# Deploys a new aur PKGBUILD file to am arch linux aur github repo. +# Deploys a new aur PKGBUILD file to an arch linux aur github repo. # Run by GitHub Actions when a new release is created on GitHub. source settings.sh SOURCE_PATH=https://github.com/Unpackerr/unpackerr/archive/v${VERSION}.tar.gz echo "==> Using URL: $SOURCE_PATH" -SHA256=$(curl -sL $SOURCE_PATH | openssl dgst -r -sha256 | awk '{print $1}') +SHA=$(curl -sL $SOURCE_PATH | sha512sum | awk '{print $1}') push_it() { pushd release_repo @@ -21,13 +21,13 @@ push_it() { # Make an id_rsa file with our secret. mkdir -p $HOME/.ssh KEY_FILE="$(mktemp -u $HOME/.ssh/XXXXX)" -echo "${DEPLOY_KEY}" > "${KEY_FILE}" chmod 600 "${KEY_FILE}" -# Configure ssh to use this secret on a custom github hostname. -GITHUB_HOST="github.$(basename $KEY_FILE)" +echo "${DEPLOY_KEY}" > "${KEY_FILE}" +# Configure ssh to use this secret on a custom hostname. +AUR_HOST="arch.$(basename $KEY_FILE)" printf "%s\n" \ - "Host $GITHUB_HOST" \ - " HostName github.com" \ + "Host $AUR_HOST" \ + " HostName aur.archlinux.org" \ " IdentityFile ${KEY_FILE}" \ " StrictHostKeyChecking no" \ " LogLevel ERROR" | tee -a $HOME/.ssh/config @@ -36,32 +36,20 @@ git config --global user.email "unpackerr@auto.releaser" git config --global user.name "unpackerr-auto-releaser" rm -rf release_repo -git clone git@${GITHUB_HOST}:golift/aur.git release_repo -mkdir -p release_repo/unpackerr +git clone aur@${AUR_HOST}:unpackerr.git release_repo sed -e "s/{{VERSION}}/${VERSION}/g" \ -e "s/{{Iter}}/${ITERATION}/g" \ - -e "s/{{SHA256}}/${SHA256}/g" \ + -e "s/{{SHA}}/${SHA}/g" \ -e "s/{{Desc}}/${DESC}/g" \ -e "s%{{SOURCE_PATH}}%${SOURCE_PATH}%g" \ - init/archlinux/PKGBUILD.template | tee release_repo/unpackerr/PKGBUILD + init/archlinux/PKGBUILD.template | tee release_repo/PKGBUILD sed -e "s/{{VERSION}}/${VERSION}/g" \ -e "s/{{Iter}}/${ITERATION}/g" \ - -e "s/{{SHA256}}/${SHA256}/g" \ + -e "s/{{SHA}}/${SHA}/g" \ -e "s/{{Desc}}/${DESC}/g" \ -e "s%{{SOURCE_PATH}}%${SOURCE_PATH}%g" \ - init/archlinux/SRCINFO.template | tee release_repo/unpackerr/.SRCINFO - -tee release_repo/unpackerr/unpackerr.aur.install << EOF -post_upgrade() { - /bin/systemctl restart unpackerr -} - -pre_remove() { - /bin/systemctl stop unpackerr - /bin/systemctl disable unpackerr -} -EOF + init/archlinux/SRCINFO.template | tee release_repo/.SRCINFO -push_it +[ "$1" != "" ] || push_it diff --git a/init/systemd/unpackerr.service b/init/systemd/unpackerr.service index 5eb6869c..3a53f744 100644 --- a/init/systemd/unpackerr.service +++ b/init/systemd/unpackerr.service @@ -1,9 +1,12 @@ # Systemd service unit for unpackerr. +# Be sure to use `systemctl edit unpackerr` to modify this service with an override.conf because +# direct changes will be overwritten by package updates. +# Read more here: https://unpackerr.zip/docs/install/linux#change-the-uidgid [Unit] Description=unpackerr - archive extraction daemon -After=network.target -Requires=network.target +Wants=network-online.target +After=network-online.target [Service] ExecStart=/usr/bin/unpackerr $DAEMON_OPTS