blob: 63ace6fc558ce7a451dc833293dfc814db36127d [file] [log] [blame]
Daniel P. Berrangeaef45d52017-09-29 11:11:56 +01001#!/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. Berrangeaef45d52017-09-29 11:11:56 +01006substat=".git-submodule-status"
7
8command=$1
9shift
10modules="$@"
11
Daniel P. Berrangecc84d632017-10-20 15:02:43 +010012test -z "$GIT" && GIT=git
13
14error() {
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
Daniel P. Berrangef62bbee2017-10-26 13:52:26 +010024 echo "Alternatively you may disable automatic GIT submodule checkout"
25 echo "with:"
26 echo
27 echo " $ ./configure --disable-git-update'"
28 echo
29 echo "and then manually update submodules prior to running make, with:"
30 echo
31 echo " $ scripts/git-sbumodule.sh update $modules"
32 echo
Daniel P. Berrangecc84d632017-10-20 15:02:43 +010033 exit 1
34}
35
Daniel P. Berrangeaef45d52017-09-29 11:11:56 +010036if test -z "$modules"
37then
38 test -e $substat || touch $substat
39 exit 0
40fi
41
42if ! test -e ".git"
43then
44 echo "$0: unexpectedly called with submodules but no git checkout exists"
45 exit 1
46fi
47
48case "$command" in
49status)
50 test -f "$substat" || exit 1
Daniel P. Berrange96089f62017-10-26 13:45:38 +010051 CURSTATUS=`$GIT submodule status $modules`
52 OLDSTATUS=`cat $substat`
53 test "$CURSTATUS" = "$OLDSTATUS"
Daniel P. Berrangeaef45d52017-09-29 11:11:56 +010054 exit $?
55 ;;
56update)
Daniel P. Berrangecc84d632017-10-20 15:02:43 +010057 $GIT submodule update --init $modules 1>/dev/null
58 test $? -ne 0 && error "failed to update modules"
59
60 $GIT submodule status $modules > "${substat}"
61 test $? -ne 0 && error "failed to save git submodule status" >&2
Daniel P. Berrangeaef45d52017-09-29 11:11:56 +010062 ;;
63esac
Daniel P. Berrangecc84d632017-10-20 15:02:43 +010064
65exit 0