Merge pull request #5865 from kyulee1/fixgcstruct
[platform/upstream/coreclr.git] / sync.sh
1 #!/usr/bin/env bash
2
3 usage()
4 {
5     echo "Usage: sync [-p] [-s]"
6     echo "Repository syncing script."
7     echo "  -s         Fetch source history from all configured remotes"
8     echo "             (git fetch --all -p -v)"
9     echo "  -p         Restore all NuGet packages for the repository"
10     echo
11     echo "If no option is specified, then \"sync.sh -p -s\" is implied."
12     exit 1
13 }
14
15 working_tree_root="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
16 sync_log=$working_tree_root/sync.log
17
18 options="/nologo /v:minimal /clp:Summary /flp:v=detailed;Append;LogFile=$sync_log"
19 unprocessedBuildArgs=
20
21 echo "Running sync.sh $*" > $sync_log
22
23 # Parse arguments
24 if [ $# == 0 ]; then
25     sync_packages=true
26     sync_src=true
27 fi
28
29 while [[ $# > 0 ]]
30 do
31     opt="$1"
32     case $opt in
33         -h|--help)
34         usage
35         ;;
36         -p)
37         sync_packages=true
38         ;;
39         -s)
40         sync_src=true
41         ;;
42         *)
43         unprocessedBuildArgs="$unprocessedBuildArgs $1"
44     esac
45     shift
46 done
47
48 echo "Running init-tools.sh"
49 $working_tree_root/init-tools.sh
50
51 if [ "$sync_src" == true ]; then
52     echo "Fetching git database from remote repos..."
53     git fetch --all -p -v >> $sync_log 2>&1
54     if [ $? -ne 0 ]; then
55         echo -e "\ngit fetch failed. Aborting sync." >> $sync_log
56         echo "ERROR: An error occurred while fetching remote source code; see $sync_log for more details."
57         exit 1
58     fi
59 fi
60
61 if [ "$sync_packages" == true ]; then
62     options="$options /t:RestoreNETCorePlatforms /p:RestoreDuringBuild=true"
63     echo "Restoring all packages..."
64     echo -e "\n$working_tree_root/Tools/corerun $working_tree_root/Tools/MSBuild.exe $working_tree_root/build.proj $options $unprocessedBuildArgs" >> $sync_log
65     $working_tree_root/Tools/corerun $working_tree_root/Tools/MSBuild.exe $working_tree_root/build.proj $options $unprocessedBuildArgs
66     if [ $? -ne 0 ]
67     then
68         echo -e "\nPackage restored failed. Aborting sync." >> $sync_log
69         echo "ERROR: An error occurred while syncing packages; see $sync_log for more details. There may have been networking problems, so please try again in a few minutes."
70         exit 1
71     fi
72 fi
73
74 echo "Sync completed successfully."
75 echo -e "\nSync completed successfully." >> $sync_log
76 exit 0