summaryrefslogtreecommitdiff
diff options
authorMatt Jolly <kangie@gentoo.org>2024-10-10 20:01:54 +1000
committerMatt Jolly <kangie@gentoo.org>2024-10-10 20:01:54 +1000
commit97423cbcc271276d24899f528c879ab011f28d1b (patch)
treeb1e5911a4ab313950983dd0de53f3b95b2db5b15
parentget-opera-version-mapping: major refactor (diff)
downloadchromium-tools-97423cbcc271276d24899f528c879ab011f28d1b.tar.gz
chromium-tools-97423cbcc271276d24899f528c879ab011f28d1b.tar.bz2
chromium-tools-97423cbcc271276d24899f528c879ab011f28d1b.zip
New script: iterate-over-ebuild.sh
Iterates over a chromium ebuild provided as an argument and updates `keeplibs` when the build fails. Signed-off-by: Matt Jolly <kangie@gentoo.org>
-rwxr-xr-xiterate-over-ebuild.sh59
1 files changed, 59 insertions, 0 deletions
diff --git a/iterate-over-ebuild.sh b/iterate-over-ebuild.sh
new file mode 100755
index 0000000..5013a45
--- /dev/null
+++ b/iterate-over-ebuild.sh
@@ -0,0 +1,59 @@
+#!/bin/bash
+# spdx-license-identifier: GPL-2.0-or-later
+# Script to iterate over `ebuild foo-1.2.3.ebuild clean merge` and automatically add values to keeplibs.
+# Usage: ./iterate-over-ebuild.sh foo-1.2.3.ebuild
+# This script will run until the ebuild is merged, or until you interrupt it with Ctrl+C.
+# It will add the libraries to keeplibs in the ebuild as it goes.
+
+package="${1%.ebuild}"
+tmpfile=$(mktemp)
+iter=0
+added=()
+
+# Trap for Ctrl+C
+trap 'cleanup' INT
+
+cleanup() {
+ echo "[$(date)]: Script interrupted."
+ echo "$tmpfile" for this iteration\'s logs.
+ exit 1
+}
+
+while true; do
+ libs=()
+ echo "[$(date)]: Processing $package; iteration $((++iter))"
+ echo "So far, we've added:"
+ if [ ${#added[@]} -eq 0 ]; then
+ echo " Nothing"
+ fi
+ for i in "${added[@]}"; do
+ echo " $i"
+ done
+ ebuild "${1}" clean merge 2>&1 | tee "$tmpfile"
+
+ # Should only ever be one but whatever
+ mapfile -t libs < <(grep 'ninja: error:' "$tmpfile" | awk '{print $3}' | cut -c 8- | awk -F/ '{OFS="/"; NF--; print}')
+
+ if [ ${#libs[@]} -eq 0 ]; then
+ echo "[$(date)]: No new libraries to whitelist."
+ else
+ for lib in "${libs[@]}"; do
+ echo "[$(date)]: Whitelisting $lib"
+ if grep -q "$lib" "${1}"; then
+ # Something went wrong if we're here but whatever.
+ echo "[$(date)]: $lib already exists in keeplibs"
+ else
+ echo "[$(date)]: Adding $lib to keeplibs"
+ sed -i "/^\s*local keeplibs=/a \t\t$lib" "${1}"
+ added+=("$lib")
+ fi
+ done
+ fi
+
+ if grep -q "www-client/$package merged" "$tmpfile"; then
+ rm "$tmpfile"
+ break
+ fi
+ # Start with a clean slate for the next iteration
+ rm "$tmpfile"
+done