# Maintainer: Antoine Martin (ayakael) # Based on Archlinux PKGBUILD by: # Maxime Gauduin # Kristian Mosegaard # Max Liebkies # Krzysztof Bogacki # Build vars _bootstrap=true _bootstrap_sdk='3.1.115' _bootstrap_runtime='3.1.1' _llvmver=12 # Certain check and balances are mitigated when doing a portable build, thus making targetRID linux-musl-x64. TBD if we really want this. Maybe newer version are less capricious. _targetrid=linux-musl-x64 # Part of the core-setup mitigation detailed below _coreclrbld=21470.3 _coreclrver=3.1.20-servicing pkgname=dotnet-3.1 pkgdesc='The .NET Core SDK' pkgver=3.1.20 pkgrel=0 arch='x86_64' url=https://www.microsoft.com/net/core license='MIT' makedepends=" bash clang cmake git icu-dev inetutils-syslogd krb5-dev libgit2-dev libunwind-dev libxml2-dev libxml2-utils lldb-dev llvm$_llvmver-dev lttng-ust-dev linux-headers nodejs openssl-dev zlib-dev " if [ ${_bootstrap} != 'true' ]; then makedepends=" ${makedepends} dotnet-bootstrap-sdk-3.1 dotnet-bootstrap-runtime-3.1 " fi subpackages="dotnet-sdk-3.1:sdk dotnet-host:host dotnet-runtime-3.1:runtime aspnet-runtime-3.1:aspnet_runtime:noarch dotnet-targeting-pack-3.1:targeting_pack aspnet-targeting-pack-3.1:aspnet_targeting_pack:noarch" _gittag=v${pkgver}-runtime _giturl=https://github.com/dotnet/source-build options="!check !archcheck" source=" $pkgname-$pkgver.git.zip dotnet.sh " # # Patches description # # coreclr_fix-build-on-Alpine-edge-45352.patch # Fixes a build error for Alpine Linux. It has since been fixed in dotnet-5.0, see issue dotnet/runtime 45352. # # corefx_fix-build-clang10.patch # Fixes a build error for clang 10 # # xliff-tasks_use_netcoreapp21.patch # For some god awful reason, xliff looks for netcoreapp2.0 when building, when netcoreapp2.1 is provided. This patch gives it the correct path. # # coresetup_rid-plat-generation-on-alpine-fix.patch # build.sh for corehost on coresetup seems to generate the wrong rid on alpine. Rather than building corehost for the expected alpine.3.xx-x64 platform, # it compiles to linux-musl-x64. This patch adjusts the computed RID to match what's expected, implementing the rest of coreclr_non-portable-distrorid-fix-alpine.patch # # coreclr_non-portable-distrorid-fix-alpine.patch # coreclr's DistroRid generation seems broken on alpine by leaving a trailing version ID. Thus, the distroRid for alpine 3.15 comes out as alpine-3.15.0-x64 instead of # the expected alpine-3.15-x64. This patch fixes this by bring alpine's Rid generation under RHEL's algorithm. # # installer_hack-for-building-on-alpine-with-core-setup-rid-patc.patch # Hack that adjusts where dotnet-runtime-3.1.20-alpine.3.15-x64.tar.gz is expected. # Expectation: artifacts/obj/x64/Release/blobs/Runtime/3.1.20 # Actual: artifacts/obj/x64/Release/blobs/Runtime/3.1.20-alpine.3.15 # This is likely caused by core-setup_rid-plat-generation-on-alpine-fix.patch as part of the build system # expected musl-linux-x64 while another part expects alpine-3.15-x64. # What's weird is that, at worst, the blobs should be sent to 3.1.20-alpine.3.15-x64. # Why ommit arch? Probably is worth another patch in core-setup # # applications-insights_fix-net40-location.patch # Because Linux is sane, paths are case sensitive. Applications insights looks for Utils.cs in net40 while the repo has it in Net40. Patch makes it all okay. # # build_applicationinsights-alternative-source.patch # Another act of the spaguetti monster: there is a difference between the official ApplicationInsights-dotnet repo and unofficial "original" versions for commit 53b8094 which breaks certain paths (again) # This patch changes the repo URL to an "original" version that I host on github.com, which I forked from SergeyRazmyslov, who forked it originally from ApplicationInsights-dotnet before (presumably) # Microsoft did a forced push. Not entirely sure what's up here. # # build_coreclr-tools-path.patch # Coreclr looks for its ilasm and ildasm tools in the wrong path. # Patch makes it all okay by adjusting the paths accordingly # Ideal solution is to provide ilasm and ildasm in a seperate package. # # build_darc-fix-alpine.patch # Darc has a segmentation fault on Alpine due to not chosing the correct binary architecture. # This patch deletes all the wrong ones so that it is forced to chose the correct one. # See dotnet/source-build issue #1868, and dotnet/source-build issue #297 (which would also fix all the other RID issues. # source=" ${source} coreclr_fix-build-on-Alpine-edge-45352.patch coreclr_non-portable-distrorid-fix-alpine.patch core-setup_rid-plat-generation-on-alpine-fix.patch installer_hack-for-building-on-alpine-with-core-setup-rid-patc.patch corefx_fix-build-clang10.patch corefx_added-alpine-315-rid.patch build_darc-fix-alpine.patch " builddir="$srcdir/$pkgname" # # A custom version of snapshot is used because Darc expects the build directory to be a git repo, thus the auto-generated tar.gz on github is not sufficient. # There's a way to trick Darc into thinking its in a git repo but it's hardly elegant. Thus make sure to 'abuild snapshot' before 'abuild -r' # snapshot() { mkdir -p "$srcdir" cd "${srcdir}" if ! [ -d $pkgname.git ]; then git clone $_giturl $pkgname.git || return 1 cd $pkgname.git else cd $pkgname.git git fetch || return 1 fi echo "Repo archive" mkfifo $pkgname-$pkgver.git git bundle create - $_gittag > $pkgname-$pkgver.git & zip --fifo "${SRCDEST}"/$pkgname-$pkgver.git.zip $pkgname-$pkgver.git rm $pkgname-$pkgver.git ln -s "$SRCDEST"/$pkgname-$pkgver.git.zip "$startdir"/$pkgname-$pkgver.git.zip } unpack() { default_unpack cd "${srcdir}" git clone $pkgname-$pkgver.git $pkgname --branch $_gittag 1>/dev/null 2>&1 } prepare() { local i failed= [ -n "$builddir" -a -d "$builddir" ] && cd "$builddir" msg "Settings up bootstrap SDK" if [ "${_bootstrap}" == 'true' ]; then eng/common/dotnet-install.sh -runtime dotnet -version $_bootstrap_runtime bash .dotnet/dotnet-install.sh --version $_bootstrap_sdk --install-dir ./ bash .dotnet/dotnet-install.sh --version $_bootstrap_runtime --install-dir ./ --runtime dotnet else cp -r /usr/share/dotnet/* ./ fi # disable warnings sed -i 's|skiptests|skiptests ignorewarnings|' repos/coreclr.common.props export SOURCE_BUILD_SKIP_SUBMODULE_CHECK=1 if ! have_patches; then return 0 fi [ -d "$builddir" ] || { error "Is \$builddir set correctly?"; return 1; } msg "Deploying patches" for i in $source; do case ${i%::*} in build_*.patch) patch ${patch_args:--p1} -i "$srcdir/$(filename_from_uri $i)" || failed="$failed $i" ;; *.patch) local _package=$(echo ${i} | sed 's|_.*||') local _patch=$(echo ${i} | sed "s|${_package}_||") echo "cp $_patch -> $_package" [ -d patches/$_package ] || mkdir patches/$_package cp "$srcdir"/"$i" patches/${_package}/${_patch} ;; esac done if [ -z "$failed" ]; then return 0 fi error "The following patches failed to apply:" for i in $failed; do printf " %s\n" "$i" done return 1 } pkgver() { cd "$builddir" local _runtimever=$(xmllint --xpath "//Dependency[@Name='Microsoft.NETCore.App.Runtime.win-x64']/@Version" eng/Version.Details.xml | cut -d '=' -f 2 | sed 's/^"//; s/"$//') local _sdkver=$(xmllint --xpath "//Dependency[@Name='Microsoft.NET.Sdk']/@Version" eng/Version.Details.xml | cut -d '=' -f 2 | sed 's/^"//; s/"$//; s/-rtm.*//; s/-servicing.*//') echo "${_runtimever}.sdk${_sdkver##*.}" } build() { cd "$builddir" export SOURCE_BUILD_SKIP_SUBMODULE_CHECK=1 # # Notes # # Very important that --with-sdk stays at ../$pkgname. For some reason *anything else* makes "Building 'sdk' to produce tarball" step stalls after creating Microsoft.NET.Sdk nupkg. # To be investigated further why this is so finicky. If all else fails, remove that line and make sure _bootstrap=true. # # Rid generation for alpine on dotnet-3.1 tend to be finicky. For simplicity's sake (and my sanity), TargetRid is set to linux-musl-x64. # ./build.sh \ --with-sdk ../$pkgname \ /p:ArchiveDownloadedPackages=true \ /p:ContinueOnPrebuiltBaselineError=true \ /p:SkipPortableRuntimeBuild=true \ /p:SkipPrebuiltEnforcement=true \ /p:UseSystemLibraries=true \ /p:UseSystemLibunwind=true } package() { depends=' dotnet-sdk-3.1 dotnet-host dotnet-runtime-3.1 dotnet-targetting-pack-3.1 aspnet-runtime-3.1 aspnet-targeting-pack-3.1 netstandard-targeting-pack ' mkdir -p "${pkgdir}" } sdk() { depends=' dotnet-runtime-3.1 dotnet-targeting-pack-3.1 musl libgcc netstandard-targeting-pack aspnet-targeting-pack-3.1 ' # XXX: This is a hack to allow this abuild to depend on itself. Adding "dotnet" # to makedepends would not work, because abuild implicitly removes $pkgname # and $subpackages from the abuild's dependencies. # provides="dotnet-bootstrap-sdk-3.1=$pkgver-r$pkgrel" cd "$builddir"/artifacts/x64/Release install -dm 755 "$subpkgdir"/usr/share/dotnet "$subpkgdir"/usr/share/licenses bsdtar -xf dotnet-sdk-${pkgver%.*}.*-$_targetrid.tar.gz -C "${subpkgdir}"/usr/share/dotnet/ --no-same-owner sdk templates ln -s dotnet-host "${subpkgdir}"/usr/share/licenses/dotnet-sdk-3.1 } host() { pkgdesc='A generic driver for the .NET Core Command Line Interface' depends=' gcc musl ' cd $builddir/artifacts/x64/Release install -dm 755 "$subpkgdir"/etc/profile.d "$subpkgdir"/usr/bin "$subpkgdir"/usr/lib "$subpkgdir"/usr/share/dotnet "$subpkgdir"/usr/share/licenses/dotnet-host bsdtar -xf dotnet-sdk-${pkgver%.*}.*-$_targetrid.tar.gz -C "${subpkgdir}"/usr/share/dotnet/ --no-same-owner dotnet host bsdtar -xf dotnet-sdk-${pkgver%.*}.*-$_targetrid.tar.gz -C "${subpkgdir}"/usr/share/licenses/dotnet-host/ --no-same-owner LICENSE.txt ThirdPartyNotices.txt ln -s /usr/share/dotnet/dotnet "${subpkgdir}"/usr/bin/dotnet ln -s /usr/share/dotnet/host/fxr/${pkgver}/libhostfxr.so "${subpkgdir}"/usr/lib/libhostfxr.so install -Dm 644 "${srcdir}"/dotnet.sh -t "${subpkgdir}"/etc/profile.d/ } runtime() { pkgdesc='The .NET Core runtime' makedepends=' icu-dev krb5-dev libunwind-dev zlib-dev openssl-dev ' depends=' dotnet-host libgcc musl icu krb5-libs libunwind zlib openssl ' # XXX: This is a hack to allow this abuild to depend on itself. Adding "dotnet" # to makedepends would not work, because abuild implicitly removes $pkgname # and $subpackages from the abuild's dependencies. # provides="dotnet-bootstrap-runtime-3.1=$pkgver-r$pkgrel" cd "$builddir"/artifacts/x64/Release install -dm 755 "$subpkgdir"/usr/share/dotnet "$subpkgdir"/usr/share/licenses bsdtar -xf dotnet-sdk-${pkgver%.*}.*-$_targetrid.tar.gz -C "${subpkgdir}"/usr/share/dotnet/ --no-same-owner shared/Microsoft.NETCore.App ln -s dotnet-host "${subpkgdir}"/usr/share/licenses/dotnet-runtime-3.1 } aspnet_runtime() { pkgdesc='The ASP.NET Core runtime' depends='dotnet-runtime-3.1' cd "$builddir"/artifacts/x64/Release install -dm 755 "$subpkgdir"/usr/share/dotnet "$subpkgdir"/usr/share/licenses bsdtar -xf dotnet-sdk-${pkgver%.*}.*-$_targetrid.tar.gz -C "${subpkgdir}"/usr/share/dotnet/ --no-same-owner shared/Microsoft.AspNetCore.App ln -s dotnet-host "${subpkgdir}"/usr/share/licenses/aspnet-runtime-3.1 } targeting_pack() { pkgdesc='The .NET Core targeting pack' depends='netstandard-targeting-pack' cd "$builddir"/artifacts/x64/Release install -dm 755 "$subpkgdir"/usr/share/dotnet "$subpkgdir"/usr/share/licenses bsdtar -xf dotnet-sdk-${pkgver%.*}.*-$_targetrid.tar.gz -C "${subpkgdir}"/usr/share/dotnet/ --no-same-owner packs/Microsoft.NETCore.App.Host.$_targetrid packs/Microsoft.NETCore.App.Ref ln -s dotnet-host "${subpkgdir}"/usr/share/licenses/dotnet-targeting-pack-3.1 } aspnet_targeting_pack() { pkgdesc='The ASP.NET Core targeting pack' depends='dotnet-targeting-pack-3.1' cd "$builddir"/artifacts/x64/Release install -dm 755 "$subpkgdir"/usr/share/dotnet "$subpkgdir"/usr/share/licenses bsdtar -xf dotnet-sdk-${pkgver%.*}.*-$_targetrid.tar.gz -C "${subpkgdir}"/usr/share/dotnet/ --no-same-owner packs/Microsoft.AspNetCore.App.Ref ln -s dotnet-host "${subpkgdir}"/usr/share/licenses/aspnet-targeting-pack-3.1 } # vim: ts=2 sw=2 et: sha512sums=" 9e5e2bccb4338a18996e53e80c45525b3ba332d11cd896d1ba72bd8406735281aae7b98f614212a99475621000ca3fa5daf2d639953b163196aa2884c8773f2e dotnet-3.1-3.1.20.git.zip e61b9e3e5a2305646a616d598378230c9755c5dd5363692cc363f8f4add3807563c324dd86f3a7ae9d358c82d730608e7b293935a2b6c81c0c0f62d752a0a1cf dotnet.sh b3475c0b727c5258c7bc6f4c53305f9ced991e57f9f46a2ad323bed40627662eb8bf57286bf6a22d9a22bfdea9282da4630dd094166f0805c783aece5df5dff3 coreclr_fix-build-on-Alpine-edge-45352.patch 6ac9bdbc47b24cafbb3386e21756c540313680fed6994791ff5a3c75b422742ecf102d7736ac79de6d7f1a0892464f83cbab181ed505e4d827dc7f113e3a4017 coreclr_non-portable-distrorid-fix-alpine.patch 983a81bbcef45fbcd9a44187c3e7565631c8e72fca8427958b23097e7b291148e6f8656fe5619b7f5270311f47379498aaaa82919845bac96d02c764f95ac1f5 core-setup_rid-plat-generation-on-alpine-fix.patch ccdfd8e4e726bf626e7d922ecb79de70d2852875b6f1c66c5d72d9605aac5701e3ab45e546b8d266cc6b83ce3a88bf5d79e1675a06a7b41dc7cdce7e4cb79c71 installer_hack-for-building-on-alpine-with-core-setup-rid-patc.patch eb107ae9765d9eebe2f2ab4cebda4d3f76d683e21d88f806bb008e29051ad196ea637d410075b7ed61f4997a22085e4c36021860b82c4c0822c23ba9ded9656a corefx_fix-build-clang10.patch 72092a7323bb91e8d011ad09cefcc3fd0e4ebfc7c258895d454cc1d015eda36c7de97b09af76a492fa689f39b9216435faace77edd0ca75d8e39a34ed6641840 corefx_added-alpine-315-rid.patch 74767c34f15e0eaee3682516e093296621efaeeb6d84e62d826587db9b559fb7c00c42aafbf4fdfd34460d1cf16edad3fd5f720f2b37f8bf52b26d7f73f79d5e build_darc-fix-alpine.patch "