3 # This code is licensed under the GPL version 2 or later. See
4 # the COPYING file in the top-level directory.
6 substat
=".git-submodule-status"
12 # if not running in a git checkout, do nothing
13 test "$command" = "ignore" && exit 0
15 test -z "$GIT" && GIT
=$
(command -v git
)
17 cd "$(dirname "$0")/.."
22 echo "Unable to automatically checkout GIT submodules '$modules'."
23 echo "If you require use of an alternative GIT binary (for example to"
24 echo "enable use of a transparent proxy), please disable automatic"
25 echo "GIT submodule checkout with:"
27 echo " $ ./configure --disable-download"
29 echo "and then manually update submodules prior to running make, with:"
31 echo " $ GIT='tsocks git' scripts/git-submodule.sh update $modules"
37 if test "$1" = "validate"; then
38 echo "GIT submodules checkout is out of date, and submodules"
39 echo "configured for validate only. Please run"
40 echo " scripts/git-submodule.sh update $maybe_modules"
41 echo "from the source directory or call configure with"
42 echo " --enable-download"
48 local CURSTATUS OLDSTATUS
49 CURSTATUS
=$
($GIT submodule status
$module)
50 OLDSTATUS
=$
(grep $module $substat)
51 test "$CURSTATUS" = "$OLDSTATUS"
54 if test -n "$maybe_modules" && ! test -e ".git"
56 echo "$0: unexpectedly called with submodules but no git checkout exists"
60 if test -n "$maybe_modules" && test -z "$GIT"
62 echo "$0: unexpectedly called with submodules but git binary not found"
67 for m
in $maybe_modules
69 $GIT submodule status
$m 1> /dev
/null
2>&1
74 echo "warn: ignoring non-existent submodule $m"
80 test -f "$substat" || validate_error
"$command"
81 test -z "$maybe_modules" && exit 0
82 for module
in $modules; do
83 check_updated
$module || validate_error
"$command"
88 test -e $substat ||
touch $substat
89 test -z "$maybe_modules" && exit 0
91 $GIT submodule update
--init $modules 1>/dev
/null
92 test $?
-ne 0 && update_error
"failed to update modules"
93 for module
in $modules; do
94 check_updated
$module ||
echo Updated
"$module"
98 for module
in $modules; do
100 *" $module "*) continue 2 ;;
103 printf '%s\n' "$REPLY"
105 $GIT submodule status
$modules
106 test $?
-ne 0 && update_error
"failed to save git submodule status" >&2) < $substat > $substat.new
107 mv -f $substat.new
$substat