2020-10-14 21:49:41 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Usage:
|
2021-05-20 21:45:40 +00:00
|
|
|
# ./update-release sdk-version runtime-version [--bug bug-id] [--tarball tarball-name]
|
2020-10-14 21:49:41 +00:00
|
|
|
|
|
|
|
set -euo pipefail
|
|
|
|
IFS=$'\n\t'
|
|
|
|
|
|
|
|
print_usage() {
|
|
|
|
echo " Usage:"
|
2021-05-20 21:45:40 +00:00
|
|
|
echo " ./update-release sdk-version runtime-version [--bug bug-id] [--tarball tarball-name]"
|
2020-10-14 21:49:41 +00:00
|
|
|
}
|
|
|
|
|
2021-05-20 21:45:40 +00:00
|
|
|
user_provided_tarball_name=""
|
|
|
|
|
2020-10-14 21:49:41 +00:00
|
|
|
positional_args=()
|
2021-05-20 21:45:40 +00:00
|
|
|
bug_ids=()
|
2020-10-14 21:49:41 +00:00
|
|
|
while [[ "$#" -gt 0 ]]; do
|
2021-05-20 21:45:40 +00:00
|
|
|
arg="$1"
|
2020-10-14 21:49:41 +00:00
|
|
|
case "${arg}" in
|
2021-05-20 21:45:40 +00:00
|
|
|
--bug)
|
|
|
|
bug_ids+=("$2")
|
|
|
|
shift;
|
|
|
|
shift;
|
|
|
|
;;
|
2020-10-14 21:49:41 +00:00
|
|
|
-h|--help)
|
|
|
|
print_usage
|
|
|
|
exit 0
|
|
|
|
;;
|
2021-05-20 21:45:40 +00:00
|
|
|
--tarball)
|
|
|
|
user_provided_tarball_name="$2"
|
|
|
|
shift;
|
|
|
|
shift;
|
|
|
|
;;
|
2020-10-14 21:49:41 +00:00
|
|
|
*)
|
|
|
|
positional_args+=("$1")
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2021-05-20 21:45:40 +00:00
|
|
|
spec_files=( ./*.spec )
|
|
|
|
spec_file="${spec_files[0]}"
|
2020-10-14 21:49:41 +00:00
|
|
|
|
|
|
|
sdk_version=${positional_args[0]:-}
|
|
|
|
if [[ -z ${sdk_version} ]]; then
|
|
|
|
echo "error: missing sdk version"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
runtime_version=${positional_args[1]:-}
|
|
|
|
if [[ -z ${runtime_version} ]]; then
|
|
|
|
echo "error: missing runtime version"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
host_version="$runtime_version"
|
|
|
|
|
2021-05-20 21:45:40 +00:00
|
|
|
tag=v${sdk_version}-SDK
|
|
|
|
|
|
|
|
if [[ -f "dotnet-${tag}-original.tar.gz" ]]; then
|
|
|
|
echo "dotnet-${tag}-original.tar.gz alredy exists, not rebuilding tarball"
|
|
|
|
else
|
|
|
|
if [[ -n "${user_provided_tarball_name}" ]]; then
|
|
|
|
./rename-tarball "$user_provided_tarball_name" "dotnet-${tag}-original.tar.gz"
|
|
|
|
elif [[ -f "dotnet-${sdk_version}-SDK.tar.gz" ]]; then
|
|
|
|
./rename-tarball "dotnet-${sdk_version}-SDK.tar.gz" "dotnet-${tag}-original.tar.gz"
|
|
|
|
elif [[ -f "dotnet-${runtime_version}.tar.gz" ]]; then
|
|
|
|
./rename-tarball "dotnet-${runtime_version}.tar.gz" "dotnet-${tag}-original.tar.gz"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ ! -f "dotnet-${tag}.tar.gz" ]]; then
|
|
|
|
./build-dotnet-tarball "${tag}"
|
2020-10-14 21:49:41 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
set -x
|
|
|
|
|
|
|
|
sed -i -E "s|^%global host_version [[:digit:]]\.[[:digit:]]\.[[:digit:]]+|%global host_version ${host_version}|" "$spec_file"
|
|
|
|
sed -i -E "s|^%global runtime_version [[:digit:]]\.[[:digit:]]\.[[:digit:]]+|%global runtime_version ${runtime_version}|" "$spec_file"
|
|
|
|
sed -i -E "s|^%global sdk_version [[:digit:]]\.[[:digit:]]\.[[:digit:]][[:digit:]][[:digit:]]|%global sdk_version ${sdk_version}|" "$spec_file"
|
|
|
|
|
2021-05-20 21:45:40 +00:00
|
|
|
comment="Update to .NET SDK ${sdk_version} and Runtime ${runtime_version}"
|
|
|
|
for bug_id in "${bug_ids[@]}"; do
|
|
|
|
comment="$comment
|
|
|
|
- Resolves: RHBZ#$bug_id"
|
|
|
|
done
|
2020-10-14 21:49:41 +00:00
|
|
|
|
2021-05-20 21:45:40 +00:00
|
|
|
rpmdev-bumpspec --comment="$comment" "$spec_file"
|
2020-10-14 21:49:41 +00:00
|
|
|
|
|
|
|
# Reset release to 1 in 'Release' tag
|
2021-05-20 21:45:40 +00:00
|
|
|
sed -i -E 's|^Release: [[:digit:]]+%|Release: 1%|' "$spec_file"
|
2020-10-14 21:49:41 +00:00
|
|
|
# Reset Release in changelog comment
|
|
|
|
# See https://stackoverflow.com/questions/18620153/find-matching-text-and-replace-next-line
|
2021-05-20 21:45:40 +00:00
|
|
|
sed -i -E '/^%changelog$/!b;n;s/-[[:digit:]]+$/-1/' "$spec_file"
|