dotnet8.0/build-dotnet-tarball

206 lines
5.6 KiB
Plaintext
Raw Normal View History

2020-02-21 01:23:21 +00:00
#!/bin/bash
# Usage:
2021-11-11 13:10:43 +00:00
# build-dotnet-tarball [--bootstrap] <tag-from-installer>
2020-02-21 01:23:21 +00:00
#
2021-11-11 13:10:43 +00:00
# Creates a source archive from a tag (or commit) at github.com/dotnet/installer
2022-06-20 16:27:25 +00:00
#
# Clone dotnet/installer, check out the tag (if any), and build the
# source-tarball.
2020-02-21 01:23:21 +00:00
set -euo pipefail
IFS=$'\n\t'
2021-01-18 15:26:45 +00:00
function print_usage {
2020-02-21 01:23:21 +00:00
echo "Usage:"
2021-11-11 13:10:43 +00:00
echo "$0 [--bootstrap] <tag-from-installer>"
2020-02-21 01:23:21 +00:00
echo
2021-11-11 13:10:43 +00:00
echo "Creates a source archive from a tag at https://github.com/dotnet/installer"
2021-01-18 15:26:45 +00:00
echo ""
echo " --bootstrap build a source tarball usable for bootstrapping .NET"
2020-02-21 01:23:21 +00:00
}
2021-01-18 15:26:45 +00:00
function clean_dotnet_cache {
2020-02-21 01:23:21 +00:00
rm -rf ~/.aspnet ~/.dotnet/ ~/.nuget/ ~/.local/share/NuGet ~/.templateengine
rm -rf /tmp/NuGet /tmp/NuGetScratch /tmp/.NETCore* /tmp/.NETStandard* /tmp/.dotnet /tmp/dotnet.* /tmp/clr-debug-pipe* /tmp/Razor-Server /tmp/CoreFxPipe* /tmp/VBCSCompiler /tmp/.NETFramework*
}
2021-01-18 15:26:45 +00:00
function check_bootstrap_environment {
if rpm -qa | grep dotnet ; then
echo "error: dotnet is installed. Not a good idea for bootstrapping."
exit 1
fi
if [ -d /usr/lib/dotnet ] || [ -d /usr/lib64/dotnet ] || [ -d /usr/share/dotnet ] ; then
echo "error: one of /usr/lib/dotnet /usr/lib64/dotnet or /usr/share/dotnet/ exists. Not a good idea for bootstrapping."
exit 1
fi
if command -v dotnet ; then
echo "error: dotnet is in $PATH. Not a good idea for bootstrapping."
exit 1
fi
}
2020-02-21 01:23:21 +00:00
2021-01-18 15:26:45 +00:00
function runtime_id {
2020-02-21 01:23:21 +00:00
source /etc/os-release
case "${ID}" in
# Remove the RHEL minor version
rhel) rid_version=${VERSION_ID%.*} ;;
*) rid_version=${VERSION_ID} ;;
esac
echo "${ID}.${rid_version}-${arch}"
}
2021-01-18 15:26:45 +00:00
build_bootstrap=false
declare -A archmap
archmap=(
["aarch64"]="arm64"
["amd64"]="x64"
["armv8l"]="arm"
["i386"]="x86"
2022-06-20 16:27:25 +00:00
["i686"]="x86"
["ppc64le"]="ppc64le"
["s390x"]="s390x"
2021-01-18 15:26:45 +00:00
["x86_64"]="x64"
)
arch=${archmap["$(uname -m)"]}
2020-02-21 01:23:21 +00:00
positional_args=()
while [[ "$#" -gt 0 ]]; do
arg="${1}"
case "${arg}" in
2021-01-18 15:26:45 +00:00
--bootstrap)
check_bootstrap_environment
2021-01-18 15:26:45 +00:00
build_bootstrap=true
shift
;;
2020-02-21 01:23:21 +00:00
-h|--help)
print_usage
exit 0
;;
*)
positional_args+=("$1")
shift
;;
esac
done
tag=${positional_args[0]:-}
if [[ -z ${tag} ]]; then
echo "error: missing tag to build"
exit 1
fi
set -x
dir_name="dotnet-${tag}"
unmodified_tarball_name="${dir_name}-original"
tarball_name="${dir_name}"
2021-11-11 13:10:43 +00:00
tarball_suffix=.tar.gz
2020-02-21 01:23:21 +00:00
2021-01-18 15:26:45 +00:00
if [[ ${build_bootstrap} == true ]]; then
unmodified_tarball_name="${unmodified_tarball_name}-${arch}-bootstrap"
tarball_name="${tarball_name}-${arch}-bootstrap"
2021-11-11 13:10:43 +00:00
tarball_suffix=.tar.xz
2021-01-18 15:26:45 +00:00
fi
2021-11-11 13:10:43 +00:00
if [ -f "${tarball_name}${tarball_suffix}" ]; then
echo "error: ${tarball_name}${tarball_suffix} already exists"
2020-02-21 01:23:21 +00:00
exit 1
fi
if [ ! -f "${unmodified_tarball_name}.tar.gz" ]; then
temp_dir=$(mktemp -d -p "$(pwd)")
pushd "${temp_dir}"
2022-07-25 19:30:59 +00:00
mkdir installer
pushd installer
2022-07-25 19:30:59 +00:00
git init
git remote add origin https://github.com/dotnet/installer
git fetch --depth 1 origin "${tag}"
git checkout FETCH_HEAD
2020-02-21 01:23:21 +00:00
git submodule update --init --recursive
clean_dotnet_cache
mkdir -p "../${unmodified_tarball_name}"
2022-06-20 16:27:25 +00:00
./build.sh /p:ArcadeBuildTarball=true
popd
2021-01-18 15:26:45 +00:00
2020-02-21 01:23:21 +00:00
popd
2022-06-20 16:27:25 +00:00
cp -a \
"${temp_dir}"/installer/artifacts/packages/Debug/Shipping/dotnet-sdk-source-7*.tar.gz \
"${unmodified_tarball_name}.tar.gz"
2020-02-21 01:23:21 +00:00
rm -rf "${temp_dir}"
fi
rm -rf "${tarball_name}"
2022-06-20 16:27:25 +00:00
mkdir -p "${unmodified_tarball_name}"
pushd "${unmodified_tarball_name}"
tar xf ../"${unmodified_tarball_name}.tar.gz"
popd
2020-02-21 01:23:21 +00:00
mv "${unmodified_tarball_name}" "${tarball_name}"
pushd "${tarball_name}"
2021-01-18 15:26:45 +00:00
if [[ ${build_bootstrap} == true ]]; then
2021-11-11 13:10:43 +00:00
if [[ "$(wc -l < packages/archive/archiveArtifacts.txt)" != 1 ]]; then
echo "error: this is not going to work! update $0 to fix this issue."
exit 1
fi
./prep.sh --bootstrap
mkdir -p fixup-previously-source-built-artifacts
pushd fixup-previously-source-built-artifacts
tar xf ../packages/archive/Private.SourceBuilt.Artifacts.*.tar.gz
find . -iname '*fedora*nupkg' -delete
# We must keep the original file names in the archive, even prepending a ./ leads to issues
2021-11-11 13:10:43 +00:00
tar -I 'gzip -1' -cf ../packages/archive/Private.SourceBuilt.Artifacts.*.tar.gz *
popd
rm -rf fixup-previously-source-built-artifacts
else
2021-01-18 15:26:45 +00:00
find . -type f -iname '*.tar.gz' -delete
rm -rf .dotnet
fi
# Remove files with funny licenses and crypto implementations and
# other not-very-useful artifacts. We MUST NOT ship any files that
# have unapproved licenses and unexpected cryptographic
# implementations.
2022-07-26 19:53:08 +00:00
#
# We use rm -r (no -f) to make sure the operation fails if the files
# are not at the expected locations. If the files are not at the
# expected location, we need to find the new location of the files and
# delete them, or verify that upstream has already removed the files.
2021-11-11 13:10:43 +00:00
# Binaries for gradle
2022-06-20 16:27:25 +00:00
rm -r src/aspnetcore/src/SignalR/clients/java/signalr/gradle*
2021-11-11 13:10:43 +00:00
# https://github.com/dotnet/aspnetcore/issues/34785
2022-06-20 16:27:25 +00:00
find src/aspnetcore/src -type d -name samples -print0 | xargs -0 rm -r
# Unnecessary crypto implementation: IDEA
rm -r src/runtime/src/tests/JIT/Performance/CodeQuality/Bytemark/
2021-11-11 13:10:43 +00:00
# https://github.com/NuGet/Home/issues/11094
2022-06-20 16:27:25 +00:00
rm -r src/nuget-client/test/EndToEnd
2021-11-11 13:10:43 +00:00
# https://github.com/Humanizr/sample-aspnetmvc/issues/1
2022-06-20 16:27:25 +00:00
rm -r src/source-build-externals/src/humanizer/samples/
2020-02-21 01:23:21 +00:00
popd
2021-11-11 13:10:43 +00:00
if [[ ${build_bootstrap} == true ]]; then
2022-07-25 19:30:59 +00:00
tar -I 'xz -9 -T 0' -cf "${tarball_name}${tarball_suffix}" "${tarball_name}"
2021-11-11 13:10:43 +00:00
else
tar -czf "${tarball_name}${tarball_suffix}" "${tarball_name}"
fi