]> git.proxmox.com Git - mirror_qemu.git/blame - scripts/git-submodule.sh
build: allow setting a custom GIT binary for transparent proxying
[mirror_qemu.git] / scripts / git-submodule.sh
CommitLineData
aef45d51
DB
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
aef45d51
DB
6substat=".git-submodule-status"
7
8command=$1
9shift
10modules="$@"
11
cc84d63a
DB
12test -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
24 exit 1
25}
26
aef45d51
DB
27if test -z "$modules"
28then
29 test -e $substat || touch $substat
30 exit 0
31fi
32
33if ! test -e ".git"
34then
35 echo "$0: unexpectedly called with submodules but no git checkout exists"
36 exit 1
37fi
38
39case "$command" in
40status)
41 test -f "$substat" || exit 1
42 trap "rm -f ${substat}.tmp" EXIT
cc84d63a
DB
43 $GIT submodule status $modules > "${substat}.tmp"
44 test $? -ne 0 && error "failed to query git submodule status"
aef45d51
DB
45 diff "${substat}" "${substat}.tmp" >/dev/null
46 exit $?
47 ;;
48update)
cc84d63a
DB
49 $GIT submodule update --init $modules 1>/dev/null
50 test $? -ne 0 && error "failed to update modules"
51
52 $GIT submodule status $modules > "${substat}"
53 test $? -ne 0 && error "failed to save git submodule status" >&2
aef45d51
DB
54 ;;
55esac
cc84d63a
DB
56
57exit 0