2021-11-28 22:31:42 +03:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
# Script to partly automate updating this package
|
2021-11-28 23:23:15 +03:00
|
|
|
# sudo dnf install /usr/bin/rpmbuild /usr/bin/spectool /usr/bin/rpmspec /usr/bin/git /usr/bin/curl /usr/bin/abf
|
2021-11-28 22:31:42 +03:00
|
|
|
|
|
|
|
set -x
|
|
|
|
set -e
|
|
|
|
set -f
|
|
|
|
set -u
|
|
|
|
|
2021-11-28 23:23:15 +03:00
|
|
|
# try to avoid asking for password in `sudo mount -t tmpfs <...>`
|
|
|
|
#sudo echo
|
|
|
|
|
2021-11-28 22:31:42 +03:00
|
|
|
spec=chromium-browser-stable.spec
|
|
|
|
|
|
|
|
old_version="$(rpmspec -q --srpm --qf '%{version}' "$spec")"
|
|
|
|
latest_version="$(curl -s 'https://omahaproxy.appspot.com/all?os=linux&channel=stable' | sed 1d | cut -d , -f 3)"
|
|
|
|
[ -n "$latest_version" ]
|
|
|
|
if [ "$old_version" = "$latest_version" ]; then
|
|
|
|
echo "No updates"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
# https://stackoverflow.com/a/66636133
|
|
|
|
latest_commit_chromium_gost="$(curl -s -H "Accept: application/vnd.github.VERSION.sha" "https://api.github.com/repos/deemru/chromium-gost/commits/master")"
|
|
|
|
[ -n "$latest_commit_chromium_gost" ]
|
|
|
|
|
|
|
|
latest_commit_msspi="$(curl -s -H "Accept: application/vnd.github.VERSION.sha" "https://api.github.com/repos/deemru/msspi/commits/master")"
|
|
|
|
[ -n "$latest_commit_msspi" ]
|
|
|
|
|
|
|
|
sed -E -i'' "$spec" \
|
|
|
|
-e "s,^Version:.+,Version:\t${latest_version}," \
|
|
|
|
-e "s,^Release:.+,Release:\t1," \
|
|
|
|
-e "s,^%define chromium_gost_commit .+,%define chromium_gost_commit ${latest_commit_chromium_gost}," \
|
|
|
|
-e "s,^%define msspi_commit .+,%define msspi_commit ${latest_commit_msspi}," \
|
|
|
|
--
|
|
|
|
|
|
|
|
spectool --get-files --source 0,1101,1102 "$spec"
|
2021-11-28 23:23:15 +03:00
|
|
|
|
|
|
|
# check appliability of patches
|
|
|
|
patches_ok=0
|
|
|
|
# unpack >8 GiB of source code, I do not have so much RAM to store it in tmpfs
|
|
|
|
tmp="$(mktemp --tmpdir=/var/tmp -d)"
|
|
|
|
#sudo mount -t tmpfs -o size=30G tmpfs "$tmp"
|
|
|
|
trap 'if [ "$patches_ok" = 1 ]; then rm -fr "$tmp"; fi' EXIT
|
2021-11-28 22:31:42 +03:00
|
|
|
sed -i'' .abf.yml -e '/^ chromium-/d' -e '/^ msspi-/d'
|
|
|
|
abf put -n
|
|
|
|
# abf put erronously uploads *.json
|
|
|
|
git checkout master_preferences.json
|
2022-05-29 23:50:43 +03:00
|
|
|
# store SVG in git
|
|
|
|
git checkout rosa-logo-for-new-tab-page.svg
|
|
|
|
sed -i'' .abf.yml -e '/^ master_preferences.json/d' -e '/^ rosa-logo-for-new-tab-page.svg/d'
|
2021-11-28 22:31:42 +03:00
|
|
|
|
2022-01-05 04:49:40 +03:00
|
|
|
# download additional sources
|
|
|
|
abf fetch
|
|
|
|
rpmbuild --define "_sourcedir $PWD" --define "_builddir $tmp" -bp "$spec" && patches_ok=1
|
|
|
|
|
2021-11-28 22:31:42 +03:00
|
|
|
PAGER='' git diff
|
|
|
|
# can be copypasted for a commit message
|
|
|
|
echo "upd: $old_version -> $latest_version"
|
2021-11-28 23:23:15 +03:00
|
|
|
|
|
|
|
if [ "$patches_ok" = 0 ]; then
|
|
|
|
echo "PATCHES require attention!"
|
|
|
|
fi
|