-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathdotnet-prepare
executable file
·190 lines (173 loc) · 5.92 KB
/
dotnet-prepare
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
#!/bin/bash
set -e -u -x -o pipefail
BASEDIR=$(pwd)
PACKAGESDIR=${BASEDIR}/local-packages
filter=()
if git -C "$(dirname "$0")" fetch --filter=tree:0 >/dev/null 2>&1; then
filter=(--filter=tree:0)
fi
function update_nuget_config {
gawk -f - -i inplace NuGet.config <<EOF
/<\/packageSources>/ { if (Src) print " <add key=\"nuget\" value=\"https://api.nuget.org/v3/index.json\" />"; Src = 0 }
{ print }
/<packageSources>/ { Src = 1 }
/<clear \/>/ { if (Src) print " <add key=\"local\" value=\"${PACKAGESDIR}\" />" }
EOF
}
function install_host_sdk {
# Already installed?
root=$1/.dotnet
if [ -d "$root" ]; then return; fi
# Installer available?
version=$(jq -r .tools.dotnet "$1/global.json")
cache_dir=$HOME/.dotnet
tgz_name=dotnet-sdk-$version-linux-$(uname -m).tar.gz
tgz=$cache_dir/$tgz_name
if [ ! -e "$tgz" ]; then
if ! gh release download --dir "$cache_dir" --pattern "$tgz_name" "v$version"; then
return
fi
fi
# Install.
mkdir -p "$root"
tar -C "$root" -xf "$tgz"
}
function backport {
# Commit that introduced the bug, or an empty string.
fixes=$1
# Commit or patch that fixes the bug, optionally followed by backported or
# conflicting commits.
commitids=$2
if [ -n "$fixes" ] && ! git merge-base --is-ancestor "$fixes" HEAD; then
return
fi
for commitid in $commitids; do
if [ -e "$commitid" ]; then
continue
fi
if git merge-base --is-ancestor "$commitid" HEAD; then
return
fi
done
for commitid in $commitids; do
if [ -e "$commitid" ]; then
git am "$commitid"
else
git cherry-pick "$commitid"
fi
break
done
}
function prepare_runtime {
pushd runtime
git fetch "${filter[@]}"
# [custom_attrs] Use the image's ALC instead of the default one
# https://github.com/dotnet/runtime/pull/70346
backport "" 32670bdf9973
# Fix -cmakeargs option handling in build.sh
# https://github.com/dotnet/runtime/pull/70901
backport 643e9cf30c02 2a38e2093ab2
# [mono] Build mono logging profiler on s390x
# https://github.com/dotnet/runtime/pull/72049
backport 0e800a6139f1 eaf0bb292dfa
backport d2dff5d7e2d4 "../runtime-patches/Build-mono-logging-profiler-on-s390x.patch eaf0bb292dfa 0e800a6139f1"
# Add cmake check for ioclt prototype
# https://github.com/dotnet/runtime/pull/82173
backport f478cfe83eb5 4e0ff826321d
# Add stub for mini_is_gsharedvt_inst
# https://github.com/dotnet/runtime/pull/82678
backport "" 961418a93f7e
# [mono] Invoke AssemblyLoad hooks from RuntimeAssemblyBuilder:.ctor () instead from native code.
# https://github.com/dotnet/runtime/pull/85307
backport 93b487ad8075 5cea3d67b9b1
# fix runtime build failures on ppc64le
# https://github.com/dotnet/runtime/pull/88145
backport 910362b50c34 52bc96de5104
# [mono] Handle enum return type when inlining CreateInstance
# https://github.com/dotnet/runtime/pull/91008
backport cab57d89a5d7 "f51b3979f5f4 fe64d25f43e9"
# [mono] Fix GetCustomAttributes System.Reflection API with a custom attribute provider
# https://github.com/dotnet/runtime/pull/94602
backport "" 0cfad5669224
# [mono] [imt] Don't increment vt_slot for non-virtual generic methods
# https://github.com/dotnet/runtime/pull/94437
backport "" "0fb7b7dd0813 141b386ee2a 6f3f5dc97ad4"
# Persist FPU variables across try_compile passes
# https://github.com/dotnet/runtime/pull/83206
backport 2f1694ea116c "../runtime-patches/Fix-cmakeargs-in-corehost-and-build-native-projs.patch c22b79ae2d1b 3c126e6e42b0"
# Make the cross-component build just another invocation of the build-runtime script
# https://github.com/dotnet/runtime/pull/67108
backport 51bf70e94b0c "../runtime-patches/Fix-cmakeargs-in-coreclr-proj.patch 7d562f9d2a42 2811e7c7551c"
# https://github.com/dotnet/runtime/pull/93875
backport 1c80769c0d6e "dc944d57c4f4 3cd64558e864"
# https://github.com/dotnet/runtime/pull/107559
backport ab28e0a0c263 4930e1b44027
# https://github.com/dotnet/runtime/pull/110985
backport a5eced487f63 1613dd360914
if [ -s ../runtime-patches/series ]; then
rm -rf .pc
ln -fsT ../runtime-patches patches
quilt push -a
fi
popd
}
function prepare_msbuild {
pushd msbuild
need_msbuild=0
git fetch
# Enable building the net472 variant.
if ! git merge-base --is-ancestor ceed7cab7523 HEAD; then
git cherry-pick ceed7cab7523
# Do not set need_msbuild: if this is the only patch we need, then the
# downloaded binaries are good enough.
fi
# https://github.com/dotnet/msbuild/pull/7731
if git merge-base --is-ancestor 67deba37040a HEAD &&
! git merge-base --is-ancestor 486a4599f4a5 HEAD; then
git cherry-pick 486a4599f4a5
need_msbuild=1
fi
if [ "$need_msbuild" -eq 0 ]; then
touch .skip-build
touch .skip-package
fi
popd
}
function prepare_roslyn {
pushd roslyn
need_roslyn=0
# https://github.com/dotnet/roslyn/pull/57003
if ! git merge-base --is-ancestor d6eeb64a0191 HEAD; then
git cherry-pick d6eeb64a0191
need_roslyn=1
fi
if [ "$need_roslyn" -eq 0 ]; then
touch .skip-build
touch .skip-package
fi
popd
}
function prepare_sdk {
pushd sdk
update_nuget_config
# https://github.com/dotnet/sdk/pull/33682
backport b6ca751324b8 ebc32022e152
popd
}
function prepare_aspnetcore {
pushd aspnetcore
update_nuget_config
popd
}
if [ "$#" -gt 0 ]; then
projects=("$@")
else
projects=(runtime msbuild roslyn sdk aspnetcore)
fi
git submodule update "${filter[@]}" --init --recursive -- "${projects[@]}"
for project in "${projects[@]}"; do
eval "prepare_${project}"
done
for project in "${projects[@]}"; do
install_host_sdk "$project"
done