|
1 |
| -#!/usr/bin/env bash |
2 |
| - |
3 |
| -########################################################################## |
4 |
| -# This is the Cake bootstrapper script for Linux and OS X. |
5 |
| -# This file was downloaded from https://github.com/cake-build/resources |
6 |
| -# Feel free to change this file to fit your needs. |
7 |
| -########################################################################## |
8 |
| - |
9 |
| -# Define directories. |
10 |
| -SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) |
11 |
| -TOOLS_DIR=$SCRIPT_DIR/tools |
12 |
| -NUGET_EXE=$TOOLS_DIR/nuget.exe |
13 |
| -CAKE_EXE=$TOOLS_DIR/Cake/Cake.exe |
14 |
| -PACKAGES_CONFIG=$TOOLS_DIR/packages.config |
15 |
| -PACKAGES_CONFIG_MD5=$TOOLS_DIR/packages.config.md5sum |
16 |
| - |
17 |
| -# Define md5sum or md5 depending on Linux/OSX |
18 |
| -MD5_EXE= |
19 |
| -if [[ "$(uname -s)" == "Darwin" ]]; then |
20 |
| - MD5_EXE="md5 -r" |
21 |
| -else |
22 |
| - MD5_EXE="md5sum" |
23 |
| -fi |
24 |
| - |
25 |
| -# Define default arguments. |
26 |
| -SCRIPT="build.cake" |
27 |
| -TARGET="Default" |
28 |
| -CONFIGURATION="Release" |
29 |
| -VERBOSITY="verbose" |
30 |
| -DRYRUN= |
31 |
| -SHOW_VERSION=false |
32 |
| -SCRIPT_ARGUMENTS=() |
33 |
| - |
34 |
| -# Parse arguments. |
35 |
| -for i in "$@"; do |
36 |
| - case $1 in |
37 |
| - -s|--script) SCRIPT="$2"; shift ;; |
38 |
| - -t|--target) TARGET="$2"; shift ;; |
39 |
| - -c|--configuration) CONFIGURATION="$2"; shift ;; |
40 |
| - -v|--verbosity) VERBOSITY="$2"; shift ;; |
41 |
| - -d|--dryrun) DRYRUN="-dryrun" ;; |
42 |
| - --version) SHOW_VERSION=true ;; |
43 |
| - --) shift; SCRIPT_ARGUMENTS+=("$@"); break ;; |
44 |
| - *) SCRIPT_ARGUMENTS+=("$1") ;; |
45 |
| - esac |
46 |
| - shift |
47 |
| -done |
48 |
| - |
49 |
| -# Make sure the tools folder exist. |
50 |
| -if [ ! -d "$TOOLS_DIR" ]; then |
51 |
| - mkdir "$TOOLS_DIR" |
52 |
| -fi |
53 |
| - |
54 |
| -# Make sure that packages.config exist. |
55 |
| -if [ ! -f "$TOOLS_DIR/packages.config" ]; then |
56 |
| - echo "Downloading packages.config..." |
57 |
| - curl -Lsfo "$TOOLS_DIR/packages.config" https://cakebuild.net/download/bootstrapper/packages |
58 |
| - if [ $? -ne 0 ]; then |
59 |
| - echo "An error occured while downloading packages.config." |
60 |
| - exit 1 |
61 |
| - fi |
62 |
| -fi |
63 |
| - |
64 |
| -# Download NuGet if it does not exist. |
65 |
| -if [ ! -f "$NUGET_EXE" ]; then |
66 |
| - echo "Downloading NuGet..." |
67 |
| - curl -Lsfo "$NUGET_EXE" https://dist.nuget.org/win-x86-commandline/latest/nuget.exe |
68 |
| - if [ $? -ne 0 ]; then |
69 |
| - echo "An error occured while downloading nuget.exe." |
70 |
| - exit 1 |
71 |
| - fi |
72 |
| -fi |
73 |
| - |
74 |
| -# Restore tools from NuGet. |
75 |
| -pushd "$TOOLS_DIR" >/dev/null |
76 |
| -if [ ! -f $PACKAGES_CONFIG_MD5 ] || [ "$( cat $PACKAGES_CONFIG_MD5 | sed 's/\r$//' )" != "$( $MD5_EXE $PACKAGES_CONFIG | awk '{ print $1 }' )" ]; then |
77 |
| - find . -type d ! -name . | xargs rm -rf |
78 |
| -fi |
79 |
| - |
80 |
| -mono "$NUGET_EXE" install -ExcludeVersion |
81 |
| -if [ $? -ne 0 ]; then |
82 |
| - echo "Could not restore NuGet packages." |
83 |
| - exit 1 |
84 |
| -fi |
85 |
| - |
86 |
| -$MD5_EXE $PACKAGES_CONFIG | awk '{ print $1 }' >| $PACKAGES_CONFIG_MD5 |
87 |
| - |
88 |
| -popd >/dev/null |
89 |
| - |
90 |
| -# Make sure that Cake has been installed. |
91 |
| -if [ ! -f "$CAKE_EXE" ]; then |
92 |
| - echo "Could not find Cake.exe at '$CAKE_EXE'." |
93 |
| - exit 1 |
94 |
| -fi |
95 |
| - |
96 |
| -# Start Cake |
97 |
| -if $SHOW_VERSION; then |
98 |
| - exec mono "$CAKE_EXE" -version |
99 |
| -else |
100 |
| - exec mono "$CAKE_EXE" $SCRIPT -verbosity=$VERBOSITY -configuration=$CONFIGURATION -target=$TARGET $DRYRUN "${SCRIPT_ARGUMENTS[@]}" |
101 |
| -fi |
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +########################################################################## |
| 4 | +# This is the Cake bootstrapper script for Linux and OS X. |
| 5 | +# This file was downloaded from https://github.com/cake-build/resources |
| 6 | +# Feel free to change this file to fit your needs. |
| 7 | +########################################################################## |
| 8 | + |
| 9 | +# Define directories. |
| 10 | +SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) |
| 11 | +TOOLS_DIR=$SCRIPT_DIR/tools |
| 12 | +NUGET_EXE=$TOOLS_DIR/nuget.exe |
| 13 | +CAKE_EXE=$TOOLS_DIR/Cake/Cake.exe |
| 14 | +PACKAGES_CONFIG=$TOOLS_DIR/packages.config |
| 15 | +PACKAGES_CONFIG_MD5=$TOOLS_DIR/packages.config.md5sum |
| 16 | + |
| 17 | +# Define md5sum or md5 depending on Linux/OSX |
| 18 | +MD5_EXE= |
| 19 | +if [[ "$(uname -s)" == "Darwin" ]]; then |
| 20 | + MD5_EXE="md5 -r" |
| 21 | +else |
| 22 | + MD5_EXE="md5sum" |
| 23 | +fi |
| 24 | + |
| 25 | +# Define default arguments. |
| 26 | +SCRIPT="build.cake" |
| 27 | +TARGET="Default" |
| 28 | +CONFIGURATION="Release" |
| 29 | +VERBOSITY="verbose" |
| 30 | +DRYRUN= |
| 31 | +SHOW_VERSION=false |
| 32 | +SCRIPT_ARGUMENTS=() |
| 33 | + |
| 34 | +# Parse arguments. |
| 35 | +for i in "$@"; do |
| 36 | + case $1 in |
| 37 | + -s|--script) SCRIPT="$2"; shift ;; |
| 38 | + -t|--target) TARGET="$2"; shift ;; |
| 39 | + -c|--configuration) CONFIGURATION="$2"; shift ;; |
| 40 | + -v|--verbosity) VERBOSITY="$2"; shift ;; |
| 41 | + -d|--dryrun) DRYRUN="-dryrun" ;; |
| 42 | + --version) SHOW_VERSION=true ;; |
| 43 | + --) shift; SCRIPT_ARGUMENTS+=("$@"); break ;; |
| 44 | + *) SCRIPT_ARGUMENTS+=("$1") ;; |
| 45 | + esac |
| 46 | + shift |
| 47 | +done |
| 48 | + |
| 49 | +# Make sure the tools folder exist. |
| 50 | +if [ ! -d "$TOOLS_DIR" ]; then |
| 51 | + mkdir "$TOOLS_DIR" |
| 52 | +fi |
| 53 | + |
| 54 | +# Make sure that packages.config exist. |
| 55 | +if [ ! -f "$TOOLS_DIR/packages.config" ]; then |
| 56 | + echo "Downloading packages.config..." |
| 57 | + curl -Lsfo "$TOOLS_DIR/packages.config" https://cakebuild.net/download/bootstrapper/packages |
| 58 | + if [ $? -ne 0 ]; then |
| 59 | + echo "An error occured while downloading packages.config." |
| 60 | + exit 1 |
| 61 | + fi |
| 62 | +fi |
| 63 | + |
| 64 | +# Download NuGet if it does not exist. |
| 65 | +if [ ! -f "$NUGET_EXE" ]; then |
| 66 | + echo "Downloading NuGet..." |
| 67 | + curl -Lsfo "$NUGET_EXE" https://dist.nuget.org/win-x86-commandline/latest/nuget.exe |
| 68 | + if [ $? -ne 0 ]; then |
| 69 | + echo "An error occured while downloading nuget.exe." |
| 70 | + exit 1 |
| 71 | + fi |
| 72 | +fi |
| 73 | + |
| 74 | +# Restore tools from NuGet. |
| 75 | +pushd "$TOOLS_DIR" >/dev/null |
| 76 | +if [ ! -f $PACKAGES_CONFIG_MD5 ] || [ "$( cat $PACKAGES_CONFIG_MD5 | sed 's/\r$//' )" != "$( $MD5_EXE $PACKAGES_CONFIG | awk '{ print $1 }' )" ]; then |
| 77 | + find . -type d ! -name . | xargs rm -rf |
| 78 | +fi |
| 79 | + |
| 80 | +mono "$NUGET_EXE" install -ExcludeVersion |
| 81 | +if [ $? -ne 0 ]; then |
| 82 | + echo "Could not restore NuGet packages." |
| 83 | + exit 1 |
| 84 | +fi |
| 85 | + |
| 86 | +$MD5_EXE $PACKAGES_CONFIG | awk '{ print $1 }' >| $PACKAGES_CONFIG_MD5 |
| 87 | + |
| 88 | +popd >/dev/null |
| 89 | + |
| 90 | +# Make sure that Cake has been installed. |
| 91 | +if [ ! -f "$CAKE_EXE" ]; then |
| 92 | + echo "Could not find Cake.exe at '$CAKE_EXE'." |
| 93 | + exit 1 |
| 94 | +fi |
| 95 | + |
| 96 | +# Start Cake |
| 97 | +if $SHOW_VERSION; then |
| 98 | + exec mono "$CAKE_EXE" -version |
| 99 | +else |
| 100 | + exec mono "$CAKE_EXE" $SCRIPT -verbosity=$VERBOSITY -configuration=$CONFIGURATION -target=$TARGET $DRYRUN "${SCRIPT_ARGUMENTS[@]}" |
| 101 | +fi |
0 commit comments