Design portable tail calls with helpers (#8596)
[platform/upstream/coreclr.git] / sync.sh
1 #!/usr/bin/env bash
2
3 usage()
4 {
5     echo "Usage: sync [-p]"
6     echo "Repository syncing script."
7     echo "  -p         Restore all NuGet packages for the repository"
8     echo "If no option is specified, then \"sync.sh -p\" is implied."
9     exit 1
10 }
11
12 working_tree_root="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
13 unprocessedBuildArgs=
14
15 # Parse arguments
16 if [ $# == 0 ]; then
17     buildArgs="-p"
18 fi
19
20 while [[ $# -gt 0 ]]
21 do
22     opt="$1"
23     case $opt in
24         -h|--help)
25         usage
26         ;;
27         -p)
28         buildArgs="-p"
29         ;;
30         *)
31         unprocessedBuildArgs="$unprocessedBuildArgs $1"
32     esac
33     shift
34 done
35
36 $working_tree_root/run.sh sync $buildArgs $unprocessedBuildArgs
37 if [ $? -ne 0 ]
38 then
39     echo "ERROR: An error occurred while syncing packages; See $working_tree_root/sync.log for more details. There may have been networking problems, so please try again in a few minutes."
40     exit 1
41 fi
42
43 echo "Sync completed successfully."
44 exit 0