summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorCedric Roijakkers2022-08-29 10:48:53 +0200
committerCedric Roijakkers2022-08-29 10:48:53 +0200
commitc38f74210311f28dc8da36c245e801af290e2e9f (patch)
treeb7bb30760992820e0ea650397678df4355e00a0b
parent590923ef5e9b906fea1abf6e021edd638667d6e1 (diff)
downloadaur-c38f74210311f28dc8da36c245e801af290e2e9f.tar.gz
Added a script to test builds in docker locally.
-rw-r--r--.gitignore1
-rwxr-xr-xbuild-in-docker.sh61
2 files changed, 62 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index 61d8f0084545..9fec5092c5f6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,5 +11,6 @@
*.log.*
*.sig
*.part
+tempscript.sh
*/
diff --git a/build-in-docker.sh b/build-in-docker.sh
new file mode 100755
index 000000000000..0ccc374742fa
--- /dev/null
+++ b/build-in-docker.sh
@@ -0,0 +1,61 @@
+#!/usr/bin/env bash
+
+#
+# This script is used to test AUR builds locally in a clean Arch Linux Docker container.
+# It is not used in the AUR builds in any way, and is only for debugging purposes.
+#
+
+set -e
+
+# Determine the current versions and if we should build or not
+aurversion=$(grep pkgver .SRCINFO | awk -F= '{print $2}' | sed -e 's/ //g')
+githubversion=$(curl https://api.github.com/repos/ferdium/ferdium-app/releases 2>/dev/null| jq -r 'map(select(.prerelease == false)) | first | .name')
+
+# Convert versions to AUR friendly names
+newpkgverorg="$(echo -n "${githubversion}" | sed 's/^v//')"
+newpkgver="$(echo -n "${newpkgverorg}" | sed 's/\([^-]*-\)g/r\1/;s/-/./g' | sed 's/^v//')"
+
+echo "Current AUR version: [${aurversion}]"
+echo "Current GitHub version: [${githubversion}]"
+echo "Future AUR version: [${newpkgver}]"
+
+if [ "${aurversion}" = "${newpkgver}" ]
+then
+ echo -n "Versions are identical, if you wish to build anyway, press Enter, otherwise press Ctrl-C now: "
+ read foo
+ echo "Okay, here we go! Creating the build script..."
+fi
+
+# Start the build
+cat << EOF > tempscript.sh
+set -e
+
+# System set-up
+pacman-key --init
+pacman -Sy archlinux-keyring --noconfirm
+pacman -Syu --noconfirm
+pacman -S pacman-contrib git openssh --noconfirm
+echo 'yay ALL=(ALL:ALL) NOPASSWD: ALL' >> /etc/sudoers
+useradd -d /home/yay -g users -m -s /bin/bash yay
+
+# Build the package
+cd /tmp
+sudo -u yay git clone https://aur@aur.archlinux.org/ferdium-bin.git
+cd /tmp/ferdium-bin
+EOF
+cat << 'EOF' >> tempscript.sh
+sed -i -e "s/^pkgverorg=.*/pkgverorg='${newpkgverorg}'/g" PKGBUILD
+sed -i -e "s/^pkgver=.*/pkgver='${newpkgver}'/g" PKGBUILD
+EOF
+cat << EOF >> tempscript.sh
+sudo -u yay updpkgsums
+sudo -u yay makepkg -s --noconfirm
+sudo -u yay makepkg --printsrcinfo > .SRCINFO
+EOF
+
+echo "Starting docker container with the build script..."
+
+docker run --rm -e newpkgverorg=${newpkgverorg} -e newpkgver=${newpkgver} -v $(pwd)/tempscript.sh:/root/tempscript.sh archlinux:base-devel /bin/bash /root/tempscript.sh
+
+echo "Cleaning up..."
+rm -rf tempscript.sh