2023-07-06 14:16:01 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Usage:
|
|
|
|
# ./update-release sdk-version runtime-version [--bug bug-id] [--tarball tarball-name] [--larger-rpm-release]
|
|
|
|
|
|
|
|
set -euo pipefail
|
|
|
|
IFS=$'\n\t'
|
|
|
|
|
|
|
|
print_usage() {
|
|
|
|
echo " Usage:"
|
2023-12-22 17:12:45 +00:00
|
|
|
echo " ./update-release sdk-version runtime-version [--bug bug-id] [--tarball tarball-name] [--release-json release-json] [--larger-rpm-release]"
|
2023-07-06 14:16:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
user_provided_tarball_name=""
|
|
|
|
|
|
|
|
rpm_release=1
|
|
|
|
positional_args=()
|
|
|
|
bug_ids=()
|
|
|
|
while [[ "$#" -gt 0 ]]; do
|
|
|
|
arg="$1"
|
|
|
|
case "${arg}" in
|
|
|
|
--bug)
|
|
|
|
bug_ids+=("$2")
|
|
|
|
shift;
|
|
|
|
shift;
|
|
|
|
;;
|
|
|
|
-h|--help)
|
|
|
|
print_usage
|
|
|
|
exit 0
|
|
|
|
;;
|
2023-12-22 17:12:45 +00:00
|
|
|
--release-json)
|
|
|
|
release_json="$2"
|
|
|
|
shift;
|
|
|
|
shift;
|
|
|
|
;;
|
2023-07-06 14:16:01 +00:00
|
|
|
--tarball)
|
|
|
|
user_provided_tarball_name="$2"
|
|
|
|
shift;
|
|
|
|
shift;
|
|
|
|
;;
|
|
|
|
--larger-rpm-release)
|
|
|
|
rpm_release="2"
|
|
|
|
shift;
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
positional_args+=("$1")
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
spec_files=( ./*.spec )
|
|
|
|
spec_file="${spec_files[0]}"
|
|
|
|
|
|
|
|
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"
|
|
|
|
|
2023-12-22 17:12:45 +00:00
|
|
|
if [[ "$runtime_version" == "6.0"* ]] || [[ "$runtime_version" == "7.0"* ]] ; then
|
2023-07-06 14:16:01 +00:00
|
|
|
tag=v${sdk_version}
|
|
|
|
else
|
2023-12-22 17:12:45 +00:00
|
|
|
tag=v${runtime_version}
|
2023-07-06 14:16:01 +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"
|
|
|
|
|
2023-12-22 17:12:45 +00:00
|
|
|
|
|
|
|
if [[ "$runtime_version" == "6.0"* ]] || [[ "$runtime_version" == "7.0"* ]] ; then
|
|
|
|
if [[ -f "dotnet-${tag}.tar.gz" ]]; then
|
|
|
|
echo "dotnet-${tag}.tar.gz already exists, not rebuilding tarball"
|
|
|
|
else
|
|
|
|
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
|
|
|
|
cp -a "$user_provided_tarball_name" "dotnet-${tag}-original.tar.gz"
|
|
|
|
elif [[ -f "dotnet-${sdk_version}-SDK.tar.gz" ]]; then
|
|
|
|
cp -a "dotnet-${sdk_version}-SDK.tar.gz" "dotnet-${tag}-original.tar.gz"
|
|
|
|
elif [[ -f "dotnet-${sdk_version}.tar.gz" ]]; then
|
|
|
|
cp -a "dotnet-${sdk_version}.tar.gz" "dotnet-${tag}-original.tar.gz"
|
|
|
|
elif [[ -f "dotnet-${runtime_version}.tar.gz" ]]; then
|
|
|
|
cp -a "dotnet-${runtime_version}.tar.gz" "dotnet-${tag}-original.tar.gz"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
./build-dotnet-tarball "${tag}"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
if [[ -f "dotnet-${tag}.tar.gz" ]]; then
|
|
|
|
echo "dotnet-${tag}.tar.gz already exists, not rebuilding tarball"
|
|
|
|
elif [[ -n ${user_provided_tarball_name} ]]; then
|
|
|
|
cp -a "${user_provided_tarball_name}" "dotnet-${tag}.tar.gz"
|
|
|
|
cp -a "${release_json}" release.json
|
|
|
|
else
|
|
|
|
rm -f release.json
|
|
|
|
spectool -g "$spec_file"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2023-07-06 14:16:01 +00:00
|
|
|
comment="Update to .NET SDK ${sdk_version} and Runtime ${runtime_version}"
|
|
|
|
commit_message="$comment
|
|
|
|
"
|
|
|
|
for bug_id in "${bug_ids[@]}"; do
|
2023-10-18 13:22:51 +00:00
|
|
|
if [[ "$bug_id" =~ ^[[:digit:]]+$ ]]; then
|
2023-09-12 21:32:17 +00:00
|
|
|
comment="$comment
|
2023-07-06 14:16:01 +00:00
|
|
|
- Resolves: RHBZ#$bug_id"
|
2023-09-12 21:32:17 +00:00
|
|
|
commit_message="$commit_message
|
2023-07-06 14:16:01 +00:00
|
|
|
Resolves: RHBZ#$bug_id"
|
2023-09-12 21:32:17 +00:00
|
|
|
else
|
|
|
|
comment="$comment
|
|
|
|
- Resolves: $bug_id"
|
|
|
|
commit_message="$commit_message
|
|
|
|
Resolves: $bug_id"
|
|
|
|
fi
|
2023-07-06 14:16:01 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
echo "$commit_message" > git-commit-message
|
|
|
|
|
|
|
|
rpmdev-bumpspec --comment="$comment" "$spec_file"
|
|
|
|
|
|
|
|
# Reset release in 'Release' tag
|
|
|
|
sed -i -E 's|^Release: [[:digit:]]+%|Release: '"$rpm_release"'%|' "$spec_file"
|
|
|
|
# Reset Release in changelog comment
|
|
|
|
# See https://stackoverflow.com/questions/18620153/find-matching-text-and-replace-next-line
|
|
|
|
sed -i -E '/^%changelog$/!b;n;s/-[[:digit:]]+$/-'"$rpm_release"'/' "$spec_file"
|