8f463db78c
And re-sync spec file modulo https://github.com/coreos/rpm-ostree/pull/4157.
58 lines
1.5 KiB
Bash
Executable File
58 lines
1.5 KiB
Bash
Executable File
#!/bin/bash
|
|
set -euo pipefail
|
|
|
|
KEEP_V_R=
|
|
while [ $# -gt 0 ]; do
|
|
case "$1" in
|
|
-h | --help)
|
|
echo "Usage: $0 [--keep-v-r]" >&2
|
|
exit 0
|
|
;;
|
|
--keep-v-r)
|
|
KEEP_V_R=1
|
|
;;
|
|
*)
|
|
echo "$0: unrecognized option: $1" >&2
|
|
exit 1
|
|
;;
|
|
esac
|
|
shift
|
|
done
|
|
|
|
main() {
|
|
local upstream
|
|
upstream=$(get_parsed_spec_field URL)
|
|
curl -Lo rpm-ostree.spec.new "$upstream/raw/main/packaging/rpm-ostree.spec.in"
|
|
# remove dummy changelog from upstream spec
|
|
sed -i -e '/%changelog/Q' rpm-ostree.spec.new
|
|
# append real changelog to upstream spec
|
|
sed -ne '/%changelog/,$ p' rpm-ostree.spec >> rpm-ostree.spec.new
|
|
|
|
if [ -n "${KEEP_V_R}" ]; then
|
|
local version release
|
|
version=$(get_raw_spec_field Version)
|
|
release=$(get_raw_spec_field Release)
|
|
|
|
sed -ie "s/^Version:.*/Version: $version/" rpm-ostree.spec.new
|
|
sed -ie "s/^Release:.*/Release: $release/" rpm-ostree.spec.new
|
|
fi
|
|
|
|
if git diff --quiet --exit-code rpm-ostree.spec; then
|
|
mv rpm-ostree.spec.new rpm-ostree.spec
|
|
echo "Updated rpm-ostree.spec" >&2
|
|
else
|
|
echo "Refusing to overwrite dirty rpm-ostree.spec" >&2
|
|
echo "Updated rpm-ostree.spec.new" >&2
|
|
fi
|
|
}
|
|
|
|
get_parsed_spec_field() {
|
|
rpmspec -P rpm-ostree.spec | grep "^${1}: " | head -n1 | cut -d ' ' -f 2
|
|
}
|
|
|
|
get_raw_spec_field() {
|
|
grep "^${1}: " rpm-ostree.spec | head -n1 | cut -d ' ' -f 2
|
|
}
|
|
|
|
main "$@"
|