rpm-ostree/import-spec
Troy Dawson 76a7e09ea9 RHEL 9.0.0 Alpha bootstrap
The content of this branch was automatically imported from Fedora ELN
with the following as its source:
https://src.fedoraproject.org/rpms/rpm-ostree#9b9d36344ea8bcd8659bb8c1d281e72e2ccc7104
2020-10-14 21:52:01 -07:00

55 lines
1.3 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/master/packaging/rpm-ostree.spec.in"
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 "$@"