projects/aports·blob master · refs

363 lines · 11.1 KiB

1# Contributor: Antoine Martin (ayakael) <[email protected]>
2# Maintainer: Antoine Martin (ayakael) <[email protected]>
3pkgname=dotnet10-sdk
4pkgver=10.0.401
5# ensures that built with current runtime
6_bldver=10.0.12
7pkgrel=0
8_gittag=v$pkgver
9_patches="
10 build_disable-build-server-shutdown.patch
11 build_disable-prebuilt-usage.patch
12 sdk_hard-dereference-tar-gz.patch
13 "
14# enable to send logs to where Gitlab runners can scoop them
15# uses lots of space, thus usually disabled
16_scoop_logs=false
17
18_pkgver_macro=${pkgver%.*}
19_pkgver_name=${_pkgver_macro/.*}
20pkgdesc="The .NET $_pkgver_macro SDK"
21# x86: blocked by https://github.com/dotnet/runtime/issues/77667
22# armhf: blocked by https://github.com/dotnet/runtime/issues/77663
23# riscv64: blocked by https://github.com/dotnet/runtime/issues/84834
24# s390x | ppc64le: mono-based builds are not yet stable on musl
25# loongarch64: blocked by dotnet9-runtime
26arch="all !x86 !armhf !riscv64 !s390x !ppc64le !loongarch64"
27url="https://dotnet.microsoft.com"
28license="MIT"
29makedepends="dotnet$_pkgver_name-runtime-bootstrap"
30makedepends="
31 alpine-release
32 bash
33 dotnet$_pkgver_name-runtime-bootstrap~$_bldver
34 dotnet$_pkgver_name-runtime-artifacts~$_bldver
35 grep
36 icu-data-full
37 icu-libs
38 jq
39 pigz
40 "
41subpackages="
42 dotnet$_pkgver_name-templates::noarch
43 dotnet$_pkgver_name-sdk-dbg::noarch
44 dotnet-zsh-completion:zshcomp:noarch
45 dotnet-bash-completion:bashcomp:noarch
46 dotnet-doc
47 "
48options="!check" # No test suite
49source="
50 dotnet-tarball-$_gittag.tar.gz::https://github.com/dotnet/dotnet/archive/refs/tags/$_gittag.tar.gz
51 dotnet-release-$_gittag.json::https://github.com/dotnet/dotnet/releases/download/$_gittag/release.json
52 $_patches
53 "
54builddir="$srcdir"/dotnet-${_gittag/v}
55
56# subpackage is not built for mono-based builds
57case $CARCH in
58 s390x|ppc64le) ;;
59 *) subpackages="$subpackages dotnet$_pkgver_name-sdk-aot";;
60esac
61
62case $CARCH in
63 x86_64) _dotnet_arch="x64";;
64 aarch64) _dotnet_arch="arm64";;
65 armv7) _dotnet_arch="arm";;
66 armhf) _dotnet_arch="armv6";;
67 *) _dotnet_arch="$CARCH";;
68esac
69
70_cli_root="$srcdir"/bootstrap
71_nuget="$_cli_root/dotnet nuget"
72_libdir="/usr/lib"
73
74# if true, then within pipeline environment, in which case send logs there
75# to be scooped
76if [ -d "$APORTSDIR/logs" ]; then
77 _logdir="$APORTSDIR"/logs/$pkgname
78else
79 _logdir="$srcdir"/logs
80fi
81
82case $CARCH in
83 x86_64) _dotnet_arch="x64";;
84 aarch64) _dotnet_arch="arm64";;
85 armv7) _dotnet_arch="arm";;
86 armhf) _dotnet_arch="armv6";;
87 *) _dotnet_arch="$CARCH";;
88esac
89
90# Build doesn't set all the right executable bits for the right file types
91_fix_executable() {
92 # add executable bit
93 find "$1" -type f \( \
94 -name 'apphost' -o \
95 -name 'singlefilehost' -o \
96 -name 'lib*so' -o \
97 -name 'ilc' -o \
98 -name '*.sh' \
99 \) \
100 -exec chmod +x '{}' \;
101
102 # remove executable bit
103 find "$1" -type f \( \
104 -name '*.a' -o \
105 -name '*.o' -o \
106 -name '*.dll' -o \
107 -name '*.h' -o \
108 -name '*.json' -o \
109 -name '*.pdb' -o \
110 -name '*.props' -o \
111 -name '*.pubxml' -o \
112 -name '*.targets' -o \
113 -name '*.txt' -o \
114 -name '*.xml' -o \
115 -name '*.c' -o \
116 -name '*.in' -o \
117 -name '*.m' -o \
118 -name '*.orig' -o \
119 -name '*.def' -o \
120 -name '*.cmake' -o \
121 -name '*.cpp' \
122 \) \
123 -exec chmod -x '{}' \;
124}
125
126prepare() {
127 default_prepare
128
129 # ensure that dotnet does not download artifacts provided by dotnet-artifacts
130 rm -rf "$builddir"/packages/archive
131
132
133 # links logfiles to pipeline logs for easy pickup in pipelines if _scoop_logs is true
134 # usually disabled since logs can take lots of space, in any case check logs are scooped
135 mkdir -p "$_logdir"
136 if $_scoop_logs; then
137 mkdir -p "$builddir"/artifacts
138 ln -s "$_logdir" "$builddir"/artifacts/logs
139 ln -s "$_logdir" "$builddir"/artifacts/log
140 for i in "$builddir"/src/*; do
141 if [ -f "$i" ]; then
142 continue
143 fi
144 mkdir -p "$_logdir"/${i##*\/} "$builddir"/src/${i##*\/}/artifacts
145 ln -s "$_logdir"/${i##*\/} "$builddir"/src/${i##*\/}/artifacts/log
146 done
147 fi
148
149 # dotnet requires its bootstrap to be in a writable dir
150 msg "Setting up bootstrap"
151 local _bootstrapdir=$(find $_libdir/dotnet/bootstrap/$_pkgver_macro* -maxdepth 0 | sort -r | head -n 1)
152 if [ ! -d "$_cli_root" ]; then
153 cp -r "$_bootstrapdir" "$_cli_root"
154 fi
155
156 # dotnet requires its shared-components dir to be in a writable dir
157 msg "Setting up shared components dir"
158 local _artifactsdir=$(find $_libdir/dotnet/artifacts/$_pkgver_macro* -maxdepth 0 | sort -r | head -n 1)
159 if [ ! -d "$_cli_root/shared-components" ]; then
160 cp -r "$_artifactsdir" "$_cli_root/shared-components"
161 fi
162
163 # build with sdk 10.0.1xx
164 jq --arg sdkver "10.0.100" '.sdk.version = $sdkver | .tools.dotnet = $sdkver' global.json > global.json.new
165 mv global.json.new global.json
166
167 # for some reason, SDK does not have local repo
168 $_nuget add source "$_cli_root"/shared_components --name local --configfile "$builddir"/src/sdk/NuGet.config
169
170 # for some reason, not executable
171 chmod +x "$builddir"/src/diagnostics/eng/common/build.sh
172}
173
174build() {
175 ulimit -n 4096
176
177 # Disable use of LTTng as tracing on lttng <=2.13.0 is broken
178 # See https://github.com/dotnet/runtime/issues/57784.
179 if [ -f "/usr/lib/liblttng-ust.so.1" ]; then
180 export DOTNET_LTTng=0
181 fi
182
183 # looks for most recent recent version of _artifactsdir
184 local _artifactsdir=$(find $_libdir/dotnet/artifacts/$_pkgver_macro* -maxdepth 0 | sort -r | head -n 1)
185
186 # ci args, else the output is forwarded to log files which isn't ideal in a
187 # pipeline environment, and build by defaults uses lots of space
188 local args="
189 /v:minimal
190 /p:LogVerbosity=minimal
191 /p:MinimalConsoleLogOutput=true
192 /p:CleanWhileBuilding=true
193 /p:OfficialBuilder=Alpine
194 /p:ContinueOnPrebuiltBaselineError=true
195 "
196
197 # Sets TargetRid manually as dotnet cannot be trusted to reliably
198 # compute the machine's runtime ID
199 local _version_id="$(awk -F'=' '{if($1=="VERSION_ID"){print $2}}' /etc/os-release)"
200 local _id="$(awk -F'=' '{if($1=="ID"){print $2}}' /etc/os-release)"
201 local _version_id_dot="${_version_id//[^.]}"
202 while [ ${#_version_id_dot} -gt 1 ]; do
203 local _version_id="${_version_id%.*}"
204 local _version_id_dot="${_version_id//[^.]}"
205 done
206 local _version_id_dash="${_version_id//[^_]}"
207 while [ ${#_version_id_dash} -ge 1 ]; do
208 local _version_id="${_version_id%_*}"
209 local _version_id_dash="${_version_id//[^_]}"
210 done
211 local _target_rid=$_id.$_version_id-$_dotnet_arch
212 local args="$args /p:TargetRid=$_target_rid"
213
214 msg "Building $pkgname-$pkgver with args:"
215 printf '%s\n' $args
216
217 # CI=true interferes with dotnet/aspire's build
218 # see https://github.com/dotnet/dotnet/blob/v9.0.0-rc.1.24431.7/src/aspire/Directory.Build.targets#L18
219 CI= ./build.sh \
220 --with-sdk "$_cli_root" \
221 --with-packages "$_artifactsdir" \
222 --with-shared-components "$_cli_root/shared-components" \
223 --release-manifest "$srcdir"/dotnet-release-$_gittag.json \
224 --source-only \
225 -- $args
226}
227
228package() {
229 # libucontext isn't automatically detected on all platforms
230 depends="
231 aspnetcore$_pkgver_name-runtime
232 aspnetcore$_pkgver_name-targeting-pack
233 dotnet$_pkgver_name-apphost-pack
234 dotnet$_pkgver_name-targeting-pack
235 dotnet$_pkgver_name-templates
236 libucontext
237 "
238 provides="
239 dotnet-sdk-$_pkgver_macro=$pkgver-r$pkgrel
240 dotnet$_pkgver_name-dev=$pkgver-r$pkgrel
241 "
242
243 install -dm 755 "$pkgdir"/$_libdir/dotnet
244
245 tar --use-compress-program="pigz" \
246 -xf "$builddir"/artifacts/assets/Release/dotnet-sdk-$_pkgver_macro*.tar.gz \
247 -C "$pkgdir"/$_libdir/dotnet/ \
248 --wildcards \
249 --no-same-owner \
250 ./sdk \
251 ./sdk-manifests \
252 ./packs/Microsoft.NETCore.App.Runtime.* \
253 ./packs/Microsoft.AspNetCore.App.Runtime.*
254
255 # some files either should or should not have executable bits
256 _fix_executable "$pkgdir"
257
258 # See https://github.com/dotnet/source-build/issues/2579
259 find "$pkgdir" -type f -name 'vstest.console' -delete
260 find "$pkgdir" -type f -name 'testhost.x86' -delete
261
262 # docs
263 install -dm 755 "$pkgdir"/usr/share/man/man1
264 find "$builddir" -iname 'dotnet*.1' -type f -exec cp '{}' "$pkgdir"/usr/share/man/man1/. \;
265}
266
267aot() {
268 pkgdesc="Ahead-of-Time (AOT) support for the .NET $_pkgver_macro Software Development Kit"
269 depends="dotnet$_pkgver_name-sdk clang openssl-dev zlib-dev brotli-dev"
270 provides="dotnet-sdk-aot-$_pkgver_macro=$pkgver-r$pkgrel"
271
272 install -dm 755 "$subpkgdir"/$_libdir/dotnet
273
274 tar --use-compress-program="pigz" \
275 -xf "$builddir"/artifacts/assets/Release/dotnet-sdk-$_pkgver_macro*.tar.gz \
276 -C "$subpkgdir"/$_libdir/dotnet/ \
277 --no-same-owner \
278 --wildcards \
279 ./packs/runtime.*.Microsoft.DotNet.ILCompiler \
280 ./packs/Microsoft.NETCore.App.Runtime.NativeAOT.*
281
282 # some files either should or should not have executable bits
283 _fix_executable "$subpkgdir"
284}
285
286dbg() {
287 pkgdesc="The .NET $_pkgver_macro SDK - debug pdb files"
288 depends="dotnet$_pkgver_name-sdk"
289 provides="dotnet-sdk-dbg-$_pkgver_macro=$pkgver-r$pkgrel"
290
291 install -dm 755 "$subpkgdir"/$_libdir/dotnet
292
293 # move pdb files
294 cd "$pkgdir" || return 0
295 find . -type f ! -name "$(printf "*\n*")" -name '*.pdb' > tmp
296 while IFS= read -r i; do
297 d="$subpkgdir/${i%/*}" # dirname $i
298 mkdir -p "$d"
299 mv "$pkgdir/$i" "$d"
300 rmdir "$pkgdir/${i%/*}" 2>/dev/null || :
301 done < tmp
302 rm tmp
303}
304
305templates() {
306 pkgdesc="The .NET $_pkgver_macro templates"
307 depends="dotnet-host"
308 provides="dotnet-templates-$_pkgver_macro=$pkgver-r$pkgrel"
309
310 install -dm 755 "$subpkgdir"/$_libdir/dotnet
311
312 tar --use-compress-program="pigz" \
313 -xf "$builddir"/artifacts/assets/Release/dotnet-sdk-$_pkgver_macro*.tar.gz \
314 -C "$subpkgdir"/$_libdir/dotnet/ \
315 --no-same-owner \
316 ./templates
317
318 # some files either should or should not have executable bits
319 _fix_executable "$subpkgdir"
320
321 # remove pdb files
322 find "$subpkgdir" -type f -name '*.pdb' -delete
323}
324
325zshcomp() {
326 depends=""
327 pkgdesc="zsh completion for .NET"
328 install_if="dotnet$_pkgver_name-sdk zsh"
329 depends="dotnet-host"
330
331 install -Dm 755 "$builddir"/src/sdk/scripts/register-completions.zsh "$subpkgdir"/usr/share/zsh/site-functions/_dotnet
332}
333
334bashcomp() {
335 depends=""
336 pkgdesc="bash completion for .NET"
337 install_if="dotnet$_pkgver_name-sdk bash-completion"
338 depends="dotnet-host"
339
340 install -Dm 755 "$builddir"/src/sdk/scripts/register-completions.bash "$subpkgdir"/usr/share/bash-completion/comppletions/_dotnet
341}
342
343doc() {
344 default_doc
345 pkgdesc="Docs for .NET"
346
347 # licenses
348 install -dm 755 "$subpkgdir"/usr/share/licenses/dotnet
349
350 tar --use-compress-program="pigz" \
351 -xf "$builddir"/artifacts/assets/Release/dotnet-sdk-$_pkgver_macro*.tar.gz \
352 -C "$subpkgdir"/usr/share/licenses/dotnet/ \
353 --no-same-owner \
354 ./LICENSE.txt \
355 ./ThirdPartyNotices.txt
356}
357sha512sums="
358b119a6ab0dad60ae34f4d6225e1f60aa9f4c54818aaa03721891857bb4d115ff7f6bcfbf2612673fb26acd3249c17af0768374cb9bb5409395f66a6f6e1c49c3 dotnet-tarball-v10.0.401.tar.gz
3598ba7d594521e1182674a67c2ab0085caffdf35c890fdce9f42fc69c411cebfe2c545c92cd71c73dcfb9bddcccc66e8f24b2b454682ef90b53f63bf28d496353f dotnet-release-v10.0.401.json
36074e009817265a29b1508a19b02e6c84461223ec365de962750504d6247b3a959da877a71651f94d8e47b93cbe8dc995582ba6f895a04ad97029b112e6035624c build_disable-build-server-shutdown.patch
3618005bb8d69dea77d7c10eb18b71a16d75d9795c6a3cbafddc8373d5f2b3c2c209033b294c2fb2f4ac439aaa5b6d976afaa65dff55ee43ef3103dce2d55c25792 build_disable-prebuilt-usage.patch
3620eed75752cee38c01abf40a77d013f17a137f3683cfd2388871710266f2d7e544f3c4aa58254657ffec45496558da4b4ea2a8a54142227c065e075b705017a30 sdk_hard-dereference-tar-gz.patch
363"