Daniel P. Berrange | aef45d5 | 2017-09-29 11:11:56 +0100 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # |
| 3 | # This code is licensed under the GPL version 2 or later. See |
| 4 | # the COPYING file in the top-level directory. |
| 5 | |
Daniel P. Berrange | aef45d5 | 2017-09-29 11:11:56 +0100 | [diff] [blame] | 6 | substat=".git-submodule-status" |
| 7 | |
| 8 | command=$1 |
| 9 | shift |
| 10 | modules="$@" |
| 11 | |
Daniel P. Berrange | cc84d63 | 2017-10-20 15:02:43 +0100 | [diff] [blame] | 12 | test -z "$GIT" && GIT=git |
| 13 | |
| 14 | error() { |
| 15 | echo "$0: $*" |
| 16 | echo |
| 17 | echo "Unable to automatically checkout GIT submodules '$modules'." |
| 18 | echo "If you require use of an alternative GIT binary (for example to" |
| 19 | echo "enable use of a transparent proxy), then please specify it by" |
| 20 | echo "running configure by with the '--with-git' argument. e.g." |
| 21 | echo |
| 22 | echo " $ ./configure --with-git='tsocks git'" |
| 23 | echo |
| 24 | exit 1 |
| 25 | } |
| 26 | |
Daniel P. Berrange | aef45d5 | 2017-09-29 11:11:56 +0100 | [diff] [blame] | 27 | if test -z "$modules" |
| 28 | then |
| 29 | test -e $substat || touch $substat |
| 30 | exit 0 |
| 31 | fi |
| 32 | |
| 33 | if ! test -e ".git" |
| 34 | then |
| 35 | echo "$0: unexpectedly called with submodules but no git checkout exists" |
| 36 | exit 1 |
| 37 | fi |
| 38 | |
| 39 | case "$command" in |
| 40 | status) |
| 41 | test -f "$substat" || exit 1 |
Daniel P. Berrange | 96089f6 | 2017-10-26 13:45:38 +0100 | [diff] [blame^] | 42 | CURSTATUS=`$GIT submodule status $modules` |
| 43 | OLDSTATUS=`cat $substat` |
| 44 | test "$CURSTATUS" = "$OLDSTATUS" |
Daniel P. Berrange | aef45d5 | 2017-09-29 11:11:56 +0100 | [diff] [blame] | 45 | exit $? |
| 46 | ;; |
| 47 | update) |
Daniel P. Berrange | cc84d63 | 2017-10-20 15:02:43 +0100 | [diff] [blame] | 48 | $GIT submodule update --init $modules 1>/dev/null |
| 49 | test $? -ne 0 && error "failed to update modules" |
| 50 | |
| 51 | $GIT submodule status $modules > "${substat}" |
| 52 | test $? -ne 0 && error "failed to save git submodule status" >&2 |
Daniel P. Berrange | aef45d5 | 2017-09-29 11:11:56 +0100 | [diff] [blame] | 53 | ;; |
| 54 | esac |
Daniel P. Berrange | cc84d63 | 2017-10-20 15:02:43 +0100 | [diff] [blame] | 55 | |
| 56 | exit 0 |