diff --git a/d/dotnet11/LICENSE b/d/dotnet11/LICENSE new file mode 100644 index 0000000000..ad410e1130 --- /dev/null +++ b/d/dotnet11/LICENSE @@ -0,0 +1,201 @@ +Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/d/dotnet11/build_info.json b/d/dotnet11/build_info.json new file mode 100644 index 0000000000..e4cfdc41a9 --- /dev/null +++ b/d/dotnet11/build_info.json @@ -0,0 +1,12 @@ +{ + "maintainer": "shrinivas-sidral", + "package_name": "dotnet", + "github_url": "https://github.com/dotnet/dotnet", + "version": "11.0.100", + "package_dir": "d/dotnet11", + "default_branch": "v11.0.0", + "docker_build": false, + "build_script": "[\"dotnet-cross-build.sh\", \"dotnet-source-build.sh\"]", + "validate_build_script": false, + "use_non_root_user": false + } \ No newline at end of file diff --git a/d/dotnet11/dotnet-cross-build.sh b/d/dotnet11/dotnet-cross-build.sh new file mode 100644 index 0000000000..81f32c68d9 --- /dev/null +++ b/d/dotnet11/dotnet-cross-build.sh @@ -0,0 +1,339 @@ +#!/bin/bash +# ---------------------------------------------------------------------------- +# +# Package : dotnet +# Version : 11.0.100 +# Source repo : https://github.com/dotnet/dotnet +# Tested on : fedora-43 (x86_64) +# Language : dotnet +# Ci-Check : False +# Script License: Apache License, Version 2 or later +# Maintainer : Shrinivas Sidral +# +# Disclaimer: This script has been tested in root mode on given +# ========== platform using the mentioned version of the package. +# It may not work as expected with newer versions of the +# package and/or distribution. In such case, please +# contact "Maintainer" of this script. +# +# ---------------------------------------------------------------------------- +# .Net11 cross build for ppc64le using ubi image +# ./dotnet-cross-build.sh --ref --cross-release-version --cross-arch ppc64le --official-build-id + +set -euxo pipefail + +REPO=https://github.com/dotnet/dotnet +REF=main +CROSS_ARCH="" +PORTABLE_BUILD= +CROSS_RELEASE_VERSION="" +CROSS_RELEASE_OS="rhel" +CROSS_CONTAINER_BUILD="" +OFFICIAL_BUILD_ID="" +WITH_SYSTEM_LIBS="default" +build_arguments=() +common_arguments=() +container_build_arguments=() +HOST_ARCH=$(uname -m) + +while [ $# -ne 0 ] +do + name="$1" + case "$name" in + # repository and reference to build and test + # --repo: repo url + --repo) + shift + REPO="$1" + ;; + # --ref: ref to check out + --ref) + shift + REF="$1" + ;; + # --cross-arch: target architecture when cross-building + --cross-arch) + shift + CROSS_ARCH="$1" + ;; + # --cross-release-version: target another version of the OS + --cross-release-version) + shift + CROSS_RELEASE_VERSION="$1" + ;; + # --official-build-id: set the official build ID (from the release manifest) + --official-build-id) + shift + OFFICIAL_BUILD_ID="$1" + ;; + # Build using online sources. Can be set to 'true'/'false'. + --online) + shift + ONLINE="$1" + ;; + *) + echo "Unknown argument \`$name\`" + exit 1 + ;; + esac + shift +done + +get_linux_platform_name() +{ + . /etc/os-release + echo "$ID.$VERSION_ID" + return 0 +} + +linux_platform=$(get_linux_platform_name) + +fixup_rootfs() { + set +x + local ROOTFS="$1" + + # Ensure directories are writable. + find "$ROOTFS" -type d -exec chmod u+w {} + + + # Make absolute symlinks in the rootfs relative within the rootfs. + find "$ROOTFS" -type l | while read l; do + target="$(readlink "$l")" + if [[ "$target" == /* ]]; then + abs_target="$(realpath -sm "$ROOTFS/$target")" + rel_target="$(realpath -s --relative-to="$(dirname "$(realpath -s "$l")")" "$abs_target")" + echo "Changing '$l' from '$target' to '$rel_target'" + ln -fsn "$rel_target" "$l" + fi + done + set -x +} + +# When CROSS_RELEASE_VERSION is set without CROSS_ARCH, use HOST_ARCH +if [ -z "$CROSS_ARCH" ] && [ -n "$CROSS_RELEASE_VERSION" ]; then + CROSS_ARCH="$HOST_ARCH" +fi + +# Set TARGET_ARCH to CROSS_ARCH if set, otherwise use HOST_ARCH +TARGET_ARCH="${CROSS_ARCH:-$HOST_ARCH}" + +# Cross-builds are portable to minimize dependencies on the cross-build environment. +if [ -n "$CROSS_ARCH" ]; then + PORTABLE_BUILD="${PORTABLE_BUILD:-true}" +fi +PORTABLE_BUILD="${PORTABLE_BUILD:-false}" + +# When CROSS_ARCH is set without CROSS_RELEASE_VERSION, do a Ubuntu cross-compiler build +if [ -n "$CROSS_ARCH" ] && [ -z "$CROSS_RELEASE_VERSION" ]; then + CROSS_CONTAINER_BUILD="yes" +fi + +# Packages needed for the target platform +target_packages=( + brotli-devel + krb5-devel + libicu-devel + zlib-devel +) + +dotnet_version=${REF##*/} +fedora_version=${linux_platform##*.} +if [[ $fedora_version -ge 45 && ${dotnet_version%.0*} =~ ^(8|9|10)$ ]]; then + target_packages+=(openssl3-devel) +else + target_packages+=(openssl-devel) +fi + +# CROSS_RELEASE_VERSION for rhel uses ubi images to create the rootfs +# The images don't include lttng-ust-devel, so we do our builds without lttng-ust devel support. +# This matches the build configuration we use for RHEL and Fedora. +# Building without lttng-ust is supported for .NET 10+. +if [ -z "$CROSS_RELEASE_VERSION" ] || [ "$CROSS_RELEASE_OS" == "fedora" ]; then + target_packages+=(lttng-ust-devel) +fi + +# Building with system rapidjson is limited to Fedora. +if [[ $linux_platform == fedora.* && -z "$CROSS_RELEASE_VERSION" ]] || [[ "$CROSS_RELEASE_OS" == "fedora" ]]; then + target_packages+=(rapidjson-devel) +fi + +container_build_arguments=(--build-arg=TARGET_DEBIAN_ARCH=ppc64el) +container_build_arguments+=(--build-arg=TARGET_GNU_ARCH=powerpc64le) + +sudo dnf -y install podman + +export ROOTFS_DIR="$(pwd)/rootfs" +if [ -d "$ROOTFS_DIR" ]; then + sudo rm -rf "$ROOTFS_DIR" +fi +mkdir -p "$ROOTFS_DIR" + +# Populate sysroot from target OS version +if [ "$CROSS_RELEASE_OS" == "rhel" ]; then + podman run --rm \ + -v "$ROOTFS_DIR:/sysroot:Z" \ + registry.access.redhat.com/ubi$CROSS_RELEASE_VERSION/ubi:latest \ + dnf install \ + --installroot=/sysroot \ + --releasever=$CROSS_RELEASE_VERSION \ + --forcearch="$TARGET_ARCH" \ + --verbose \ + -y \ + filesystem basesystem \ + glibc-devel gcc libstdc++-devel gcc-c++ \ + "${target_packages[@]}" +else + echo "Error: Unsupported CROSS_RELEASE_OS: $CROSS_RELEASE_OS" + exit 1 +fi +fixup_rootfs "$ROOTFS_DIR" + +if [ "${BUILDING_IN_CONTAINER:-}" != "true" ]; then + # install dependencies + sudo dnf repolist --all + # Build host packages. + host_packages=( + clang + cmake + elfutils + file + findutils + git + glibc-langpack-en + hostname + jq + libicu + llvm + make + patch + python3 + rpm-build + tar + zip + ninja-build + lld + ) + + sudo dnf -y install "${host_packages[@]}" +fi + +# Clone the dotnet vmr repo +git clone "$REPO" +cd "$(basename "$REPO" .git)" +git checkout "$REF" +COMMIT=$(git rev-parse HEAD) +echo "$REPO is at $COMMIT" + +SDK_FULL_VERSION=$(jq -r .tools.dotnet global.json) +DOTNET_MAJOR=${SDK_FULL_VERSION%%.*} + +# If the repo includes a 'release.json' file in its root, use it as the release manifest. +if [ -f "release.json" ]; then + common_arguments+=(--release-manifest release.json) + # The build doesn't want there to be a git folder when using source link arguments. + rm -rf .git +# For .NET 10+, use a "daily build" version format. +elif (( DOTNET_MAJOR >= 10 )) && [ -z "$OFFICIAL_BUILD_ID" ]; then + DAILY_BUILD_INFO=$(curl -sSL "https://aka.ms/dotnet/$DOTNET_MAJOR.0.1xx/daily/productCommit-linux-x64.json") + DAILY_VERSION=$(echo "$DAILY_BUILD_INFO" | jq -r '.sdk.version') + + if [[ "$DAILY_VERSION" == *-* ]]; then + # expected format: 10.0.100-rc.2.25468.104 + # https://github.com/dotnet/arcade/blob/main/Documentation/CorePackages/Versioning.md#package-version + SHORT_DATE=${DAILY_VERSION%.*} + SHORT_DATE=${SHORT_DATE##*.} + SHORT_DATE_YY="${SHORT_DATE:0:2}" + SHORT_DATE_DD=$(( SHORT_DATE % 50 )) + SHORT_DATE_MM=$(( 10#${SHORT_DATE:2} / 50 )) # Force base 10. Otherwise this is treated as an octal number when it starts with zero in January. + REVISION=${DAILY_VERSION##*.} + REVISION=$((REVISION - 100)) + + SHORT_DATE_YY=$(printf "%02d" $SHORT_DATE_YY) + SHORT_DATE_MM=$(printf "%02d" $SHORT_DATE_MM) + SHORT_DATE_DD=$(printf "%02d" $SHORT_DATE_DD) + else + # expected format: 10.0.100, use the current date. + SHORT_DATE_YY=$(date +"%y") + SHORT_DATE_MM=$(date +"%m") + SHORT_DATE_DD=$(date +"%d") + REVISION=1 + fi + + OFFICIAL_BUILD_ID="20$SHORT_DATE_YY$SHORT_DATE_MM$SHORT_DATE_DD.$REVISION" + common_arguments+=(/p:OfficialBuildId="$OFFICIAL_BUILD_ID") +fi + +if [[ -n "$OFFICIAL_BUILD_ID" ]]; then + common_arguments+=(/p:OfficialBuildId="$OFFICIAL_BUILD_ID") +fi + +# Disable apphost for ppc64le as do not support .net11 +if [[ "$TARGET_ARCH" = ppc64le ]]; then + sed -i -E 's||false|' src/vstest/test/Intent/Intent.csproj +fi + +# Cross-release builds don't do lttng. +if [ -n "$CROSS_RELEASE_VERSION" ]; then + if [[ $WITH_SYSTEM_LIBS == "default" ]]; then + WITH_SYSTEM_LIBS="" + fi + WITH_SYSTEM_LIBS="${WITH_SYSTEM_LIBS}-lttng" +fi + +if [[ $WITH_SYSTEM_LIBS != "default" ]]; then + # Remove sources files that shouldn't be used because system libraries are used instead. + OFS=$IFS + IFS=+ + for lib in $WITH_SYSTEM_LIBS; do + if [[ $lib == *brotli* ]]; then + rm -rf src/runtime/src/native/external/brotli* + fi + if [[ $lib == *libunwind* ]]; then + rm -rf src/runtime/src/native/external/libunwind* + fi + if [[ $lib == *rapidjson* ]]; then + rm -rf src/runtime/src/native/external/rapidjson* + fi + if [[ $lib == *zlib* ]]; then + rm -rf src/runtime/src/native/external/zlib* + fi + done + IFS=$OFS + + common_arguments+=(--with-system-libs "${WITH_SYSTEM_LIBS}") +fi + +# Prep (install .NET, previously-source-built, and other pre-built .NET dependencies) +# prep scrip was moved/renamed for .NET 9. +if [ -f "./prep-source-build.sh" ]; then + ./prep-source-build.sh +else + ./prep.sh +fi + +# With recent versions of the VMR, we need the --source-only flag too. +# Otherwise the VMR may build in Unified Build mode. +# Build 'source-build' configuration. +common_arguments+=(--source-only) + + +# default to offline when building release branches. +if [[ "$REF" == release/* ]]; then + ONLINE="${ONLINE:-false}" +fi + +if [ "${ONLINE:-true}" == "true" ]; then + build_arguments+=(--online) +fi + +build_arguments+=(--use-mono-runtime /p:PortableBuild="$PORTABLE_BUILD" /p:TargetArchitecture="$CROSS_ARCH" /p:CrossBuild=true) + +# Don't pick up clang configuration that is meant for the host from /etc/clang. +export CLANG_NO_DEFAULT_CONFIG=1 + +# Apply the fix from https://github.com/dotnet/sdk/pull/44028 manually for +# non-source-build scenario used in cross-building +export NuGetAudit=false + +BUILD_EXIT_CODE=0 +./build.sh ${common_arguments[0]+"${common_arguments[@]}"} ${build_arguments[0]+"${build_arguments[@]}"} || BUILD_EXIT_CODE=$? +EXIT_CODE=$BUILD_EXIT_CODE \ No newline at end of file diff --git a/d/dotnet11/dotnet-source-build.sh b/d/dotnet11/dotnet-source-build.sh new file mode 100644 index 0000000000..eed9b3d108 --- /dev/null +++ b/d/dotnet11/dotnet-source-build.sh @@ -0,0 +1,271 @@ +#!/bin/bash +# ---------------------------------------------------------------------------- +# +# Package : dotnet +# Version : 11.0.100 +# Source repo : https://github.com/dotnet/dotnet +# Tested on : RHEL 10.2 +# Language : dotnet +# Ci-Check : False +# Script License: Apache License, Version 2 or later +# Maintainer : Shrinivas Sidral +# +# Disclaimer: This script has been tested in root mode on given +# ========== platform using the mentioned version of the package. +# It may not work as expected with newer versions of the +# package and/or distribution. In such case, please +# contact "Maintainer" of this script. +# +# ---------------------------------------------------------------------------- +# .NET11 source build for ppc64le on RHEL +# ./dotnet-source-build.sh --ref v11.0.100-rc.1.26425.128 --sdk-path /home/dotnet-sdk-11.0.100-rc.1.26425.128-linux-ppc64le.tar.gz --artifacts-path /home/Private.SourceBuilt.Artifacts.11.0.100-rc.1.26425.128.linux-ppc64le.tar.gz --official-build-id 20260825.28 + +set -euxo pipefail + +REPO=https://github.com/dotnet/dotnet +REF=main +CONFIGURATION="Release" +PORTABLE_BUILD=false +SDK_PATH="" +ARTIFACTS_PATH="" +ONLINE="false" +OFFICIAL_BUILD_ID="" +WITH_SYSTEM_LIBS="default" +PATCH_FILE_PATH="" + +build_arguments=() +common_arguments=() + +source /etc/os-release +ARCH=$(uname -m) +HOST_RID=${ID}.${VERSION_ID%.*}-${ARCH} + +while [ $# -ne 0 ] +do + name="$1" + case "$name" in + # repository and reference to build and test + # --repo: repo url + --repo) + shift + REPO="$1" + ;; + # --ref: ref to check out + --ref) + shift + REF="$1" + ;; + # --configuration: build configuration (Release/Debug) + --configuration) + shift + CONFIGURATION="$1" + ;; + # --sdk-path: path to the .NET SDK tarball file + --sdk-path) + shift + SDK_PATH="$1" + ;; + # tarballs with packages + # --artifacts-path: artifacts produced by previous build + --artifacts-path) + shift + ARTIFACTS_PATH="$1" + ;; + # --official-build-id: set the official build ID (from the release manifest) + --official-build-id) + shift + OFFICIAL_BUILD_ID="$1" + ;; + # Build using online sources. Can be set to 'true'/'false'. + --online) + shift + ONLINE="$1" + ;; + *) + echo "Unknown argument \`$name\`" + exit 1 + ;; + esac + shift +done + +# Install dependencies +sudo dnf repolist --all +packages=( + brotli-devel + clang + cmake + elfutils + file + findutils + git + glibc-langpack-en + hostname + jq + krb5-devel + libicu-devel + llvm + lttng-ust-devel + make + openssl-devel + python3 + tar + zip + zlib-devel + lld + ninja-build +) + +sudo dnf -y install "${packages[@]}" + +# Clone dotnet repo +git clone "$REPO" +cd "$(basename "$REPO" .git)" +git checkout "$REF" +COMMIT=$(git rev-parse HEAD) +echo "$REPO is at $COMMIT" + +# Env variables +BUILD_DIR="$(pwd)" +EXIT_CODE=256 +BUILD_EXIT_CODE=256 + +# Copy sdk and pre-built-artifacts tarball +mkdir dotnet-sdk-$ARCH +cp -r "$SDK_PATH" dotnet-sdk-$ARCH +cp -r "$ARTIFACTS_PATH" dotnet-sdk-$ARCH +nuget_dir=$(readlink -f "dotnet-sdk-$ARCH") + +# Make the pre-built ppc64le nuget packages available +find . -iname 'nuget.config' -exec sed -i -zE 's|(.*)|\1\n|' {} \; + +# Extract the previously build sdk tarball +if [ ! -d .dotnet ]; then + mkdir .dotnet + tar xf "$SDK_PATH" -C .dotnet + common_arguments+=(--with-sdk $(pwd)/.dotnet) +fi + +# Extract the previously build pre-built-artifacts tarball +mkdir packages +common_arguments+=(--with-packages $(pwd)/packages) +tar xf "$ARTIFACTS_PATH" -C packages + +sdk_versions=( .dotnet/sdk/* ) +sdk_version=$(basename "${sdk_versions[0]}") + +# Set dotnet path +DOTNET_ROOT=$(pwd)/.dotnet +export DOTNET_ROOT + +SDK_FULL_VERSION=$(jq -r .tools.dotnet global.json) +DOTNET_MAJOR=${SDK_FULL_VERSION%%.*} + +# Replace version but only when it appears on the line after the "sdk" key +# See https://stackoverflow.com/questions/18620153 +sed -i -E '/"sdk": \{/!b;n;s/"version": "[^"]+"/"version": "'"$sdk_version"'"/' global.json +# replace dotnet but only when it appears on the line after the "tools" key +sed -i -E '/"tools": \{/!b;n;s/"dotnet": "[^"]+"/"dotnet": "'"$sdk_version"'"/' global.json + +# Remove installation of runtimes, these will install invalid binaries, or, +# worse, overwrite our architecture-specific binaries with x86_64 binaries +sed -i -E '/"runtimes"/,+4d' global.json +sed -i -zE 's/,\n *\}/\n\}/' global.json + +# Disable apphost for ppc64le as do not support .net8/9/10. +sed -i -E 's||false|' src/vstest/test/Intent/Intent.csproj + +# --with-system-libs: allow users to use bundled/system libraries. Default is system libraries. +# Match rpm configuration. +if [[ $WITH_SYSTEM_LIBS == "default" ]] && (( DOTNET_MAJOR >= 9 )) && [[ $PORTABLE_BUILD == "false" ]]; then + WITH_SYSTEM_LIBS="${WITH_SYSTEM_LIBS}-lttng" + WITH_SYSTEM_LIBS="${WITH_SYSTEM_LIBS}+brotli+" + WITH_SYSTEM_LIBS="${WITH_SYSTEM_LIBS}+zlib+" +fi + +if [[ $WITH_SYSTEM_LIBS != "default" ]]; then + # Remove sources files that shouldn't be used because system libraries are used instead. + OFS=$IFS + IFS=+ + for lib in $WITH_SYSTEM_LIBS; do + if [[ $lib == *brotli* ]]; then + rm -rf src/runtime/src/native/external/brotli* + fi + if [[ $lib == *libunwind* ]]; then + rm -rf src/runtime/src/native/external/libunwind* + fi + if [[ $lib == *rapidjson* ]]; then + rm -rf src/runtime/src/native/external/rapidjson* + fi + if [[ $lib == *zlib* ]]; then + rm -rf src/runtime/src/native/external/zlib* + fi + done + IFS=$OFS + + common_arguments+=(--with-system-libs "${WITH_SYSTEM_LIBS}") +fi + +# If the repo includes a 'release.json' file in its root, use it as the release manifest. +if [ -f "release.json" ]; then + common_arguments+=(--release-manifest release.json) + # The build doesn't want there to be a git folder when using source link arguments. + rm -rf .git +# For .NET 10+, use a "daily build" version format. +elif (( DOTNET_MAJOR >= 10 )) && [ -z "$OFFICIAL_BUILD_ID" ]; then + DAILY_BUILD_INFO=$(curl -sSL "https://aka.ms/dotnet/$DOTNET_MAJOR.0.1xx/daily/productCommit-linux-x64.json") + DAILY_VERSION=$(echo "$DAILY_BUILD_INFO" | jq -r '.sdk.version') + + if [[ "$DAILY_VERSION" == *-* ]]; then + # expected format: 10.0.100-rc.2.25468.104 + # https://github.com/dotnet/arcade/blob/main/Documentation/CorePackages/Versioning.md#package-version + SHORT_DATE=${DAILY_VERSION%.*} + SHORT_DATE=${SHORT_DATE##*.} + SHORT_DATE_YY="${SHORT_DATE:0:2}" + SHORT_DATE_DD=$(( SHORT_DATE % 50 )) + SHORT_DATE_MM=$(( 10#${SHORT_DATE:2} / 50 )) # Force base 10. Otherwise this is treated as an octal number when it starts with zero in January. + REVISION=${DAILY_VERSION##*.} + REVISION=$((REVISION - 100)) + + SHORT_DATE_YY=$(printf "%02d" $SHORT_DATE_YY) + SHORT_DATE_MM=$(printf "%02d" $SHORT_DATE_MM) + SHORT_DATE_DD=$(printf "%02d" $SHORT_DATE_DD) + else + # expected format: 10.0.100, use the current date. + SHORT_DATE_YY=$(date +"%y") + SHORT_DATE_MM=$(date +"%m") + SHORT_DATE_DD=$(date +"%d") + REVISION=1 + fi + + OFFICIAL_BUILD_ID="20$SHORT_DATE_YY$SHORT_DATE_MM$SHORT_DATE_DD.$REVISION" + common_arguments+=(/p:OfficialBuildId="$OFFICIAL_BUILD_ID") +fi +if [[ -n "$OFFICIAL_BUILD_ID" ]]; then + common_arguments+=(/p:OfficialBuildId="$OFFICIAL_BUILD_ID") +fi + +# Verify arguments with spaces are handled properly (https://github.com/dotnet/fsharp/pull/19570). +common_arguments+=(/p:OfficialBuilder="Red Hat Inc.") + +# Allow fetching additional prebuilds while building non-release branches. +if [ "${ONLINE:-true}" == "true" ]; then + build_arguments+=(--online) +fi + +# Build 'source-build' configuration. +# .NET9+: set the target rid so RHEL builds use a rid that doesn't include a minor version (e.g. 'rhel.8' instead of 'rhel.8.9'). +common_arguments+=(--source-only /p:TargetRid="$HOST_RID") + +# Use mono runtime +build_arguments+=(--use-mono-runtime) + +# Set --PortableBuild for ppc64le +build_arguments+=(/p:PortableBuild="$PORTABLE_BUILD") + +# Build +BUILD_EXIT_CODE=0 +./build.sh ${common_arguments[0]+"${common_arguments[@]}"} ${build_arguments[0]+"${build_arguments[@]}"} || BUILD_EXIT_CODE=$? +EXIT_CODE=$BUILD_EXIT_CODE + +exit $EXIT_CODE \ No newline at end of file