Add script to automatically rebuild packages depending on a specific .so
What comes up a lot on IRC is people asking how to rebuild packages on soname version bumps. I think several developers have scripts in their ~/bin
for this purpose. Maybe it makes sense to add one of them to abuild itself to make it more obvious/easier for people to automate package rebuilds.
Thoughts?
I personally have the following script from @ncopa in my ~/bin
:
#!/bin/sh
prog=$0
usage() {
cat <<EOF
rebuilds and commits packages since given commit
list of packages is read from stdin
usage: $prog: <since commit> <commit message>
example:
apk search -r --origin --exact -q foo-libs | $prog affadeadbeef 'rebuild against foo-libs-1.0'
EOF
exit 1
}
skip_noarch=false
dryrun=false
ignore_error=false
while getopts "nac" opt; do
case $opt in
n) dryrun=true;;
a) skip_noarch=true;;
c) ignore_error=true;;
esac
done
shift $(($OPTIND - 1))
[ $# -lt 2 ] && usage
since=$1
shift
msg=$1
shift
echo "reading packages from stdin..."
pkgs=$(while read i; do echo ${i##*/}; done)
echo "considering: $pkgs"
dirs=
for dir in $(ap builddirs $pkgs); do
if $skip_noarch && grep -q '^arch=.*noarch' $dir/APKBUILD; then
echo "skipping due to noarch: $dir"
continue
fi
changes=$(git log --format=oneline ${since}.. -- $dir)
[ -n "$changes" ] && continue
dirs="$dirs $dir"
done
echo "Rebuilding: $dirs" | tr ' ' '\n'
if $dryrun; then
exit 0
fi
for dir in $dirs; do
name=${dir##*/}
repodir=${dir%/*}
repo=${repodir##*/}
cd $dir
apkgrel -g -a ./APKBUILD
git add APKBUILD \
&& git commit -m "$repo/$name: $msg" \
|| { if ! $ignore_error; then exit 1; fi; }
done