Skip to content

Instantly share code, notes, and snippets.

@TBK
Created February 21, 2020 18:44
Show Gist options
  • Save TBK/6ab42e73cfbddc95cceff200c1209af3 to your computer and use it in GitHub Desktop.
Save TBK/6ab42e73cfbddc95cceff200c1209af3 to your computer and use it in GitHub Desktop.
Simple script to bump pkgrel of a pkg's dependents. Could be improved and simplified if Alpine Linux tools were used, but this can be used on other OS'
#!/bin/bash
set -eu
if [ $# -eq 0 ]
then
echo 'No arguments supplied. Supply two!
- $1 search pattern - e.g. icu-dev
- $2 string containing name & version of the pkg to rebuild against - e.g. "icu 65.1"'
exit 1
fi
# Find all matching input
grep -rn "$1" --include="APKBUILD" . > bump_pkgrel.txt
# Cleanup input
## Remove all content from first colon until end of line
sed -i 's/:.*$//g' bump_pkgrel.txt
## Remove all lines with ./unmaintained/
sed -i '/^.\/unmaintained.*$/d' bump_pkgrel.txt
## Sort and remove duplicates
sort -u bump_pkgrel.txt -o bump_pkgrel.txt
## Move main pkgs to the top
sed -i '/^.\/main.*$/!H;//p;$!d;g;s/\n//' bump_pkgrel.txt
# Bump pkgrel & commit
while read i; do
echo "Currently working on: $i"
sed -i -r 's/(.*)(^pkgrel=)([0-9]+)(.*)/echo "\1\2$((\3+1))\4"/ge' "$i"
git add "$i"
git commit -m "${i:2:-9}: rebuild against $2"
done < bump_pkgrel.txt
echo -e "\n\nAll done!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment