dotnet8.0/rename-tarball
Omair Majid 7f6b8ec3f9 Update to .NET SDK 5.0.202 and Runtime 5.0.5
Also make update-release more flexible with optional bug ids and
optional already-built tarballs.
2021-04-14 23:02:35 -04:00

52 lines
1.0 KiB
Bash
Executable File

#!/bin/bash
# Usage:
# ./rename-tarball original-name.tar.gz new-name.tar.gz
set -euo pipefail
IFS=$'\n\t'
positional_args=()
while [[ "$#" -gt 0 ]]; do
arg="${1}"
case "${arg}" in
-h|--help)
print_usage
exit 0
;;
*)
positional_args+=("$1")
shift
;;
esac
done
if [[ -z "${positional_args[0]:-}" ]]; then
echo "error: missing original tarball name"
exit 1
fi
original_path=$(readlink -f "${positional_args[0]:-}")
original_name=$(basename "$original_path")
new_name=${positional_args[1]:-}
if [[ -z ${new_name} ]]; then
echo "error: missing new tarball name"
exit 1
fi
original_name=${original_name/%.tar.gz}
new_name=${new_name/.tar.gz}
echo "Original: ${original_name}.tar.gz"
echo "New name: ${new_name}.tar.gz"
mkdir "temp-${new_name}"
pushd "temp-${new_name}"
tar xf "${original_path}"
mv -- * "${new_name}"
tar czf ../"${new_name}.tar.gz" "${new_name}"
rm -rf "${new_name}"
popd
rmdir "temp-${new_name}"