diff --git a/contrib/aur/README.md b/contrib/aur/README.md new file mode 100644 --- /dev/null +++ b/contrib/aur/README.md @@ -0,0 +1,13 @@ +# Update the AUR packages + +Edit the `PKGBUILD` for each package: + - To package a new version, update the `pkgver` value and reset `pkgrel` to 0. + - To re-package the same version, only increment the `pkgrel` value. + +You need to run in an archlinux environment and have write permission to the +AUR repositories. Then install the prerequisites and run the update script: + +```shell +pacman -S --needed base-devel git pacman-contrib +./update-aur.sh +``` diff --git a/contrib/aur/bitcoin-abc-qt/PKGBUILD b/contrib/aur/bitcoin-abc-qt/PKGBUILD --- a/contrib/aur/bitcoin-abc-qt/PKGBUILD +++ b/contrib/aur/bitcoin-abc-qt/PKGBUILD @@ -7,7 +7,7 @@ arch=('i686' 'x86_64') url="https://bitcoinabc.org" depends=('boost-libs' 'libevent' 'desktop-file-utils' 'qt5-base' 'protobuf' 'openssl' 'miniupnpc' 'zeromq' 'qrencode' 'jemalloc') -makedepends=('cmake' 'ninja' 'boost' 'qt5-tools') +makedepends=('cmake' 'ninja' 'boost' 'qt5-tools' 'python') license=('MIT') source=(https://github.com/Bitcoin-ABC/bitcoin-abc/archive/v$pkgver.tar.gz bitcoin.conf @@ -15,12 +15,6 @@ bitcoin.service bitcoin-reindex.service bitcoin.install) -sha256sums=('feaffb2129f49813692ec17ba5675a3ac44e6d0560af55bb4d1d2f160c5b4a0b' - 'c30e5c7e0e97b001fdeac5f4510d5ebc0e0499ec086325e845db609a24f2e22f' - '8f05207b586916d489b7d25a68eaacf6e678d7cbb5bfbac551903506b32f904f' - 'f2fd9d8331238727333cf2412ba3759cb194a65b2060eff36808b24c06382104' - '497dbeefb9cd9792757a9b6e1fbfd92710d19990ee2959add6c30533ae40b6f6' - '45429013dae87a58bc79ca7b7a037665bf8592cae0199bcf4aef088fb950e78a') backup=('etc/bitcoin/bitcoin.conf' 'etc/logrotate.d/bitcoin') provides=('bitcoin-cli' 'bitcoin-daemon' 'bitcoin-tx' 'bitcoin-qt' 'bitcoin-seeder') diff --git a/contrib/aur/bitcoin-abc/PKGBUILD b/contrib/aur/bitcoin-abc/PKGBUILD --- a/contrib/aur/bitcoin-abc/PKGBUILD +++ b/contrib/aur/bitcoin-abc/PKGBUILD @@ -7,7 +7,7 @@ arch=('i686' 'x86_64') url="https://bitcoinabc.org" depends=('boost-libs' 'libevent' 'openssl' 'zeromq' 'miniupnpc' 'jemalloc') -makedepends=('cmake' 'ninja' 'boost') +makedepends=('cmake' 'ninja' 'boost' 'python') license=('MIT') source=(https://github.com/Bitcoin-ABC/bitcoin-abc/archive/v$pkgver.tar.gz bitcoin.conf @@ -15,12 +15,6 @@ bitcoin.service bitcoin-reindex.service bitcoin.install) -sha256sums=('feaffb2129f49813692ec17ba5675a3ac44e6d0560af55bb4d1d2f160c5b4a0b' - 'c30e5c7e0e97b001fdeac5f4510d5ebc0e0499ec086325e845db609a24f2e22f' - '8f05207b586916d489b7d25a68eaacf6e678d7cbb5bfbac551903506b32f904f' - 'f2fd9d8331238727333cf2412ba3759cb194a65b2060eff36808b24c06382104' - '497dbeefb9cd9792757a9b6e1fbfd92710d19990ee2959add6c30533ae40b6f6' - '16ea5b19d554e0cb748ba14cbeee6015ed456b66f981fb8769f1403720b2d0a9') backup=('etc/bitcoin/bitcoin.conf' 'etc/logrotate.d/bitcoin') provides=('bitcoin-cli' 'bitcoin-daemon' 'bitcoin-tx' 'bitcoin-seeder') diff --git a/contrib/aur/update-aur.sh b/contrib/aur/update-aur.sh new file mode 100644 --- /dev/null +++ b/contrib/aur/update-aur.sh @@ -0,0 +1,75 @@ +#!/usr/bin/env bash + +export LC_ALL=C + +set -euxo pipefail + +# The nobody user is a default on Archlinux. It has no login and no home +# directory, its main use is for running unprivileged commands in scripts, which +# is exactly what we need for running makepkg which can't run as root. +run_as_nobody() { + su -l nobody -s /bin/bash -c "cd ${PWD} && $1" +} + +PACKAGES=( + bitcoin-abc + bitcoin-abc-qt +) + +for PACKAGE in "${PACKAGES[@]}" +do + # Give write permission to the nobody user + # This is required as makepkg cannot be run as root + chmod -R o+w "${PACKAGE}" + pushd "${PACKAGE}" + + # Get the data from the PKGBUILD + # shellcheck source=bitcoin-abc/PKGBUILD + source PKGBUILD + + # Install the dependencies + pacman -S --needed --noconfirm "${depends[@]}" "${makedepends[@]}" + + # Copy the common files + for f in "${source[@]}" + do + if [ -f "../common/$f" ] + then + cp "../common/$f" . + fi + done + + # Add the checksums to the PKGBUILD. Enforce SHA256. + echo "sha256sums=()" >> PKGBUILD + run_as_nobody "updpkgsums PKGBUILD" + + # Generate the .SRCINFO + run_as_nobody "makepkg --printsrcinfo > .SRCINFO" + + popd + + # Clone the upstream repository + git clone "https://aur.archlinux.org/${PACKAGE}.git" "${PACKAGE}-upstream" + + # Copy our modified files to the upstream repository + cp -R "${PACKAGE}"/* "${PACKAGE}-upstream" + + # Give write permission to the nobody user + # This is required as makepkg cannot be run as root + chmod -R o+w "${PACKAGE}-upstream" + pushd "${PACKAGE}-upstream" + + # The package is ready, let's check it works + run_as_nobody "makepkg --clean" + + # Cleanup the output files from the build + git clean -xffd + + # Commit the version change + git commit -a -m "Update to version ${pkgver} release ${pkgrel}" + + # Push the changes upstream + git push origin master + + popd +done