add script for updating

This commit is contained in:
Mikhail Novosyolov 2024-04-06 11:04:30 +03:00
parent 0f7bc4b32a
commit 38a64ae5d6

47
upd.sh Executable file
View file

@ -0,0 +1,47 @@
#!/usr/bin/env bash
# Script to partly automate updating this package
# Based on upd.sh from abf.io/import/eepm
# sudo dnf install /usr/bin/rpmbuild /usr/bin/spectool /usr/bin/rpmspec /usr/bin/git /usr/bin/curl /usr/bin/abf /usr/bin/jq /usr/bin/sed /usr/bin/tar /usr/bin/xz /usr/bin/rpm-sort
set -x
set -e
set -f
set -u
spec="$PWD"/angie.spec
dir0="$PWD"
old_version="$(rpmspec -q --srpm --qf '%{version}' "$spec")"
latest_version="$(curl --silent https://api.github.com/repos/webserver-llc/angie/tags | jq -r '.[].name' | sed -e 's,^Angie-,,' | rpm-sort | tail -n1)"
[ -n "$latest_version" ]
if [ "$old_version" = "$latest_version" ]; then
echo "No updates"
exit 0
fi
# change only first Release tag, https://stackoverflow.com/a/148473
sed -E -i'' "$spec" \
-e "s,^Version:.+,Version:\t${latest_version}," \
-e '0,/^Release:.+/s//Release:\t1/' \
--
source0="$(rpmspec --parse "$spec" | grep -i ^Source0: | awk -F '/' '{print $NF}')"
spectool --get-files --source 0 "$spec"
[ -f "$source0" ]
patches_ok=0
tmp="$(mktemp --tmpdir=/tmp -d)"
trap 'if [ "$patches_ok" = 1 ]; then rm -fr "$tmp"; fi' EXIT
abf fetch
abf put -n
# check appliability of patches
rpmbuild --define "_sourcedir $PWD" --define "_builddir $tmp" -bp "$spec" && patches_ok=1
PAGER='' git diff
# can be copypasted for a commit message
echo "upd: $old_version -> $latest_version"
if [ "$patches_ok" = 0 ]; then
echo "PATCHES require attention!"
fi