mirror of
https://abf.rosa.ru/djam/angie.git
synced 2025-02-24 19:32:47 +00:00
48 lines
1.4 KiB
Bash
Executable file
48 lines
1.4 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# Script to partly automate updating this package
|
|
# Based on upd.sh from abf.io/import/zabbix5.0
|
|
# sudo dnf install /usr/bin/rpmbuild /usr/bin/spectool /usr/bin/rpmspec /usr/bin/git /usr/bin/curl /usr/bin/abf /usr/bin/rpm-sort /usr/bin/tar /usr/bin/xz
|
|
|
|
set -x
|
|
set -e
|
|
set -f
|
|
set -u
|
|
|
|
spec="$PWD"/nginx.spec
|
|
dir0="$PWD"
|
|
|
|
old_version="$(rpmspec -q --srpm --qf '%{version}' "$spec")"
|
|
latest_version="$(curl http://nginx.org/download/ | grep -E -- '^<a href.*nginx-1\.22\..*\.tar\.gz' | awk -F '>' '{print $2}' | awk -F '<' '{print $1}' | grep '\.tar.\gz$' | tail -n 1 | sed -e 's,^nginx-,,' -e 's,.tar.gz$,,')"
|
|
[ -n "$latest_version" ]
|
|
if [ "$old_version" = "$latest_version" ]; then
|
|
echo "No updates"
|
|
exit 0
|
|
fi
|
|
|
|
sed -E -i'' "$spec" \
|
|
-e "s,^Version:.+,Version:\t${latest_version}," \
|
|
-e "s,^Release:.+,Release:\t1," \
|
|
--
|
|
|
|
source0="$(rpmspec --parse "$spec" | grep -i ^Source0: | awk -F '/' '{print $NF}')"
|
|
spectool --get-files --source 0 "$spec"
|
|
[ -f "$source0" ]
|
|
|
|
# TODO: add RTMP module
|
|
|
|
patches_ok=0
|
|
|
|
tmp="$(mktemp --tmpdir=/tmp -d)"
|
|
trap 'if [ "$patches_ok" = 1 ]; then rm -fr "$tmp"; fi' EXIT
|
|
# check appliability of patches
|
|
abf fetch
|
|
rpmbuild --define "_sourcedir $PWD" --define "_builddir $tmp" -bp "$spec" && patches_ok=1
|
|
abf put
|
|
|
|
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
|