1
1
#! /bin/bash
2
2
3
- # ## This script is used for synchronizing the dotnet/dotnet VMR locally. This means pulling new
4
- # ## code from various repositories into the 'dotnet/dotnet' repository.
3
+ # ## This script is used for synchronizing the current repository into a local VMR.
4
+ # ## It pulls the current repository's code into the specified VMR directory for local testing or
5
+ # ## Source-Build validation.
5
6
# ##
6
- # ## The script is used during CI to ingest new code based on dotnet/sdk but it can also help
7
- # ## for reproducing potential failures during sdk's PRs, namely to fix the Source-Build.
8
- # ## Another usecase is to try manually synchronizing a given commit of some repo into the VMR and
9
- # ## trying to Source-Build the VMR. This can help when fixing the Source-Build but using a commit
10
- # ## from a not-yet merged branch (or fork) to test the fix will help.
11
- # ##
12
- # ## The tooling that synchronizes the VMR will need to clone the various repositories into a temporary
13
- # ## folder. These clones can be re-used in future synchronizations so it is advised you dedicate a
14
- # ## folder to this to speed up your re-runs.
7
+ # ## The tooling used for synchronization will clone the VMR repository into a temporary folder if
8
+ # ## it does not already exist. These clones can be reused in future synchronizations, so it is
9
+ # ## recommended to dedicate a folder for this to speed up re-runs.
15
10
# ##
16
11
# ## USAGE:
17
- # ## Synchronize current sdk and all dependencies into a local VMR:
18
- # ## ./vmr-sync.sh --vmr "$HOME/repos/dotnet" --tmp "$HOME/repos/tmp"
19
- # ##
20
- # ## Synchronize the VMR to a specific commit of dotnet/runtime using custom fork:
21
- # ## ./vmr-sync.sh \
22
- # ## --repository runtime:e7e71da303af8dc97df99b098f21f526398c3943 \
23
- # ## --remote runtime:https://github.com/yourfork/runtime \
24
- # ## --tmp "$HOME/repos/tmp"
12
+ # ## Synchronize current repository into a local VMR:
13
+ # ## ./vmr-sync.sh --tmp "$HOME/repos/tmp" "$HOME/repos/dotnet"
25
14
# ##
26
15
# ## Options:
27
16
# ## -t, --tmp, --tmp-dir PATH
33
22
# ## --debug
34
23
# ## Optional. Turns on the most verbose logging for the VMR tooling
35
24
# ##
36
- # ## --recursive
37
- # ## Optional. Recursively synchronize all the source build dependencies (declared in Version.Details.xml)
38
- # ## This is used when performing the full synchronization during sdk's CI and the final VMR sync.
39
- # ## Defaults to false unless no repository is supplied in which case a recursive sync of sdk is performed.
40
- # ##
41
25
# ## --remote name:URI
42
26
# ## Optional. Additional remote to use during the synchronization
43
27
# ## This can be used to synchronize to a commit from a fork of the repository
44
28
# ## Example: 'runtime:https://github.com/yourfork/runtime'
45
29
# ##
46
- # ## -r, --repository name:GIT_REF
47
- # ## Optional. Repository + git ref separated by colon to synchronize to.
48
- # ## This can be a specific commit, branch, tag.
49
- # ## If not supplied, the revision of the parent sdk repository of this script will be used (recursively).
50
- # ## Example: 'runtime:my-branch-name'
51
- # ##
52
- # ## --tpn-template
53
- # ## Optional. Template for the header of VMRs THIRD-PARTY-NOTICES file.
54
- # ## Defaults to src/VirtualMonoRepo/THIRD-PARTY-NOTICES.template.txt
55
- # ##
56
30
# ## --azdev-pat
57
31
# ## Optional. Azure DevOps PAT to use for cloning private repositories.
58
32
# ##
@@ -90,25 +64,16 @@ function highlight () {
90
64
}
91
65
92
66
# realpath is not available in macOS 12, try horrible-but-portable workaround
93
- sdk_dir =$( cd " $scriptroot /../" ; pwd -P)
67
+ repo_dir =$( cd " $scriptroot /../" ; pwd -P)
94
68
95
69
tmp_dir=' '
96
70
vmr_dir=' '
97
71
vmr_branch=' '
98
- repository=' '
99
72
additional_remotes=' '
100
- recursive=false
101
73
verbosity=verbose
102
- tpn_template=" $sdk_dir /src/VirtualMonoRepo/THIRD-PARTY-NOTICES.template.txt"
103
- enable_build_lookup=' '
104
74
azdev_pat=' '
105
75
ci=false
106
76
107
- # If sdk is a repo, we're in an sdk and not in the dotnet/dotnet repo
108
- if [[ -d " $sdk_dir /.git" ]]; then
109
- additional_remotes=" sdk:$sdk_dir "
110
- fi
111
-
112
77
while [[ $# -gt 0 ]]; do
113
78
opt=" $( echo " $1 " | tr " [:upper:]" " [:lower:]" ) "
114
79
case " $opt " in
@@ -124,24 +89,10 @@ while [[ $# -gt 0 ]]; do
124
89
vmr_branch=$2
125
90
shift
126
91
;;
127
- -r|--repository)
128
- repository=$2
129
- shift
130
- ;;
131
- --recursive)
132
- recursive=true
133
- ;;
134
92
--remote)
135
93
additional_remotes=" $additional_remotes $2 "
136
94
shift
137
95
;;
138
- --tpn-template)
139
- tpn_template=$2
140
- shift
141
- ;;
142
- --enable-build-lookup)
143
- enable_build_lookup=" --enable-build-lookup"
144
- ;;
145
96
--azdev-pat)
146
97
azdev_pat=$2
147
98
shift
168
119
169
120
# Validation
170
121
171
- if [[ ! -d " $sdk_dir " ]]; then
172
- fail " Directory '$sdk_dir ' does not exist. Please specify the path to the dotnet/sdk repo"
122
+ if [[ ! -d " $repo_dir " ]]; then
123
+ fail " Directory '$repo_dir ' does not exist. Please specify the path to the dotnet/sdk repo"
173
124
exit 1
174
125
fi
175
126
@@ -178,19 +129,8 @@ if [[ -z "$tmp_dir" ]]; then
178
129
exit 1
179
130
fi
180
131
181
- if [[ ! -f " $tpn_template " ]]; then
182
- fail " File '$tpn_template ' does not exist. Please specify a valid path to the THIRD-PARTY-NOTICES template"
183
- exit 1
184
- fi
185
-
186
132
# Sanitize the input
187
133
188
- # Default when no repository is provided
189
- if [[ -z " $repository " ]]; then
190
- repository=" sdk:$( git -C " $sdk_dir " rev-parse HEAD) "
191
- recursive=true
192
- fi
193
-
194
134
if [[ -z " $vmr_dir " ]]; then
195
135
vmr_dir=" $tmp_dir /dotnet"
196
136
fi
@@ -236,14 +176,9 @@ dotnetDir=$( cd $scriptroot/../.dotnet/; pwd -P )
236
176
dotnet=$dotnetDir /dotnet
237
177
" $dotnet " tool restore
238
178
239
- highlight " Starting the synchronization of ' $repository ' .."
179
+ highlight " Starting the synchronization of VMR .."
240
180
set +e
241
181
242
- recursive_arg=' '
243
- if [[ " $recursive " == " true" ]]; then
244
- recursive_arg=" --recursive"
245
- fi
246
-
247
182
if [[ -n " $additional_remotes " ]]; then
248
183
additional_remotes=" --additional-remotes $additional_remotes "
249
184
fi
259
194
260
195
# Synchronize the VMR
261
196
262
- " $dotnet " darc vmr update \
263
- --vmr " $vmr_dir " \
197
+ " $dotnet " darc vmr forwardflow " $vmr_dir " \
264
198
--tmp " $tmp_dir " \
265
199
$azdev_pat \
266
200
--$verbosity \
267
- $recursive_arg \
268
201
$ci_arg \
269
- $additional_remotes \
270
- --tpn-template " $tpn_template " \
271
- --discard-patches \
272
- --generate-credscansuppressions \
273
- $enable_build_lookup \
274
- " $repository "
202
+ $additional_remotes
275
203
276
204
if [[ $? == 0 ]]; then
277
205
highlight " Synchronization succeeded"
278
206
else
279
- fail " Synchronization of dotnet/dotnet to ' $repository ' failed!"
207
+ fail " Synchronization of repo to VMR failed!"
280
208
fail " '$vmr_dir ' is left in its last state (re-run of this script will reset it)."
281
209
fail " Please inspect the logs which contain path to the failing patch file (use --debug to get all the details)."
282
210
fail " Once you make changes to the conflicting VMR patch, commit it locally and re-run this script."
0 commit comments