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 test -z "$maybe_modules" && exit 0
13 test -z "$GIT" && GIT
=$
(command -v git
)
15 cd "$(dirname "$0")/.."
18 if ! test -e ".git"; then
19 no_git_error
='no git checkout exists'
20 elif test -z "$GIT"; then
21 no_git_error
='git binary not found'
25 test -z "$no_git_error"
31 echo "Unable to automatically checkout GIT submodules '$modules'."
32 echo "If you require use of an alternative GIT binary (for example to"
33 echo "enable use of a transparent proxy), please disable automatic"
34 echo "GIT submodule checkout with:"
36 echo " $ ./configure --disable-download"
38 echo "and then manually update submodules prior to running make, with:"
40 echo " $ GIT='tsocks git' scripts/git-submodule.sh update $modules"
46 if is_git
&& test "$1" = "validate"; then
47 echo "GIT submodules checkout is out of date, and submodules"
48 echo "configured for validate only. Please run"
49 echo " scripts/git-submodule.sh update $maybe_modules"
50 echo "from the source directory or call configure with"
51 echo " --enable-download"
57 local CURSTATUS OLDSTATUS
58 CURSTATUS
=$
($GIT submodule status
$module)
59 OLDSTATUS
=$
(grep $module $substat)
60 test "$CURSTATUS" = "$OLDSTATUS"
64 test -e $substat ||
touch $substat
66 for m
in $maybe_modules
68 $GIT submodule status
$m 1> /dev
/null
2>&1
72 grep $m $substat > /dev
/null
2>&1 ||
$GIT submodule status
$module >> $substat
74 echo "warn: ignoring non-existent submodule $m"
78 modules
=$maybe_modules
83 for module
in $modules; do
85 check_updated
$module || validate_error
"$command"
86 elif ! (set xyz
"$module"/* && test -e "$2"); then
87 # The directory does not exist or it contains no files
88 echo "$0: sources not available for $module and $no_git_error"
89 validate_error
"$command"
96 echo "$0: unexpectedly called with submodules but $no_git_error"
100 $GIT submodule update
--init $modules 1>/dev
/null
101 test $?
-ne 0 && update_error
"failed to update modules"
102 for module
in $modules; do
103 check_updated
$module ||
echo Updated
"$module"
106 (while read -r REPLY
; do
107 for module
in $modules; do
109 *" $module "*) continue 2 ;;
112 printf '%s\n' "$REPLY"
114 $GIT submodule status
$modules
115 test $?
-ne 0 && update_error
"failed to save git submodule status" >&2) < $substat > $substat.new
116 mv -f $substat.new
$substat