From cc84d63a42e31c2afa884fc78610a65ab8ecc06a Mon Sep 17 00:00:00 2001 From: Daniel P. Berrange Date: Fri, 20 Oct 2017 15:02:43 +0100 Subject: build: allow setting a custom GIT binary for transparent proxying Some users can't run a bare 'git' command, due to need for a transparent proxying solution such as 'tsocks'. This adds an argument to configure to let users specify such a thing: ./configure --with-git="tsocks git" The submodule script is also updated to give the user a hint about using this flag, if we fail to checkout modules. Tested-by: Philippe Mathieu-Daudé Reviewed-by: Eric Blake Signed-off-by: Daniel P. Berrange --- scripts/git-submodule.sh | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) (limited to 'scripts/git-submodule.sh') diff --git a/scripts/git-submodule.sh b/scripts/git-submodule.sh index 08932a35f0..039f782d81 100755 --- a/scripts/git-submodule.sh +++ b/scripts/git-submodule.sh @@ -3,14 +3,27 @@ # This code is licensed under the GPL version 2 or later. See # the COPYING file in the top-level directory. -set -e - substat=".git-submodule-status" command=$1 shift modules="$@" +test -z "$GIT" && GIT=git + +error() { + echo "$0: $*" + echo + echo "Unable to automatically checkout GIT submodules '$modules'." + echo "If you require use of an alternative GIT binary (for example to" + echo "enable use of a transparent proxy), then please specify it by" + echo "running configure by with the '--with-git' argument. e.g." + echo + echo " $ ./configure --with-git='tsocks git'" + echo + exit 1 +} + if test -z "$modules" then test -e $substat || touch $substat @@ -27,12 +40,18 @@ case "$command" in status) test -f "$substat" || exit 1 trap "rm -f ${substat}.tmp" EXIT - git submodule status $modules > "${substat}.tmp" + $GIT submodule status $modules > "${substat}.tmp" + test $? -ne 0 && error "failed to query git submodule status" diff "${substat}" "${substat}.tmp" >/dev/null exit $? ;; update) - git submodule update --init $modules 1>/dev/null - git submodule status $modules > "${substat}" + $GIT submodule update --init $modules 1>/dev/null + test $? -ne 0 && error "failed to update modules" + + $GIT submodule status $modules > "${substat}" + test $? -ne 0 && error "failed to save git submodule status" >&2 ;; esac + +exit 0 -- cgit v1.2.3-55-g7522 From 96089f6d0e88446a16725f2152d252be34f1ad50 Mon Sep 17 00:00:00 2001 From: Daniel P. Berrange Date: Thu, 26 Oct 2017 13:45:38 +0100 Subject: build: don't create temporary files in source dir There are cases where users do VPATH builds with the source directory being on a read-only volume. In such a case they have to manually run the command 'git-submodule.sh ...modules...' ahead of time. When checking for status we should not then write into the source dir. Tested-by: Philippe Mathieu-Daudé Reviewed-by: Eric Blake Signed-off-by: Daniel P. Berrange --- scripts/git-submodule.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'scripts/git-submodule.sh') diff --git a/scripts/git-submodule.sh b/scripts/git-submodule.sh index 039f782d81..21909ea413 100755 --- a/scripts/git-submodule.sh +++ b/scripts/git-submodule.sh @@ -39,10 +39,9 @@ fi case "$command" in status) test -f "$substat" || exit 1 - trap "rm -f ${substat}.tmp" EXIT - $GIT submodule status $modules > "${substat}.tmp" - test $? -ne 0 && error "failed to query git submodule status" - diff "${substat}" "${substat}.tmp" >/dev/null + CURSTATUS=`$GIT submodule status $modules` + OLDSTATUS=`cat $substat` + test "$CURSTATUS" = "$OLDSTATUS" exit $? ;; update) -- cgit v1.2.3-55-g7522 From f62bbee55d503f639ee9498878ebf42ff4f4299a Mon Sep 17 00:00:00 2001 From: Daniel P. Berrange Date: Thu, 26 Oct 2017 13:52:26 +0100 Subject: build: allow automatic git submodule updates to be disabled Some people building QEMU use VPATH builds where the source directory is on a read-only volume. In such a case 'scripts/git-submodules.sh update' will always fail and users are required to run it manually themselves on their original writable source directory. While this is already supported, it is nice to give users a command line flag to configure to permanently disable automatic submodule updates, as it means they won't get hard to diagnose failures from git-submodules.sh at an arbitrary later date. This patch thus introduces a flag '--disable-git-update' which will prevent 'make' from ever running 'scripts/git-submodules.sh update'. It will still run the 'status' command to determine if a submodule update is needed, but when it does this it'll simply stop and print a message instructing the developer what todo. eg $ ./configure --target-list=x86_64-softmmu --disable-git-update ...snip... $ make GEN config-host.h GEN trace/generated-tcg-tracers.h GEN trace/generated-helpers-wrappers.h GEN trace/generated-helpers.h GEN trace/generated-helpers.c GEN module_block.h GIT submodule checkout is out of date. Please run scripts/git-submodule.sh update ui/keycodemapdb from the source directory checkout /home/berrange/src/virt/qemu make: *** [Makefile:31: git-submodule-update] Error 1 Tested-by: Philippe Mathieu-Daudé Reviewed-by: Eric Blake Signed-off-by: Daniel P. Berrange --- Makefile | 11 +++++++++++ configure | 7 +++++++ scripts/git-submodule.sh | 9 +++++++++ 3 files changed, 27 insertions(+) (limited to 'scripts/git-submodule.sh') diff --git a/Makefile b/Makefile index d218f8f3c8..a92d7b8e14 100644 --- a/Makefile +++ b/Makefile @@ -26,12 +26,23 @@ ifeq (0,$(MAKELEVEL)) ) ifeq (1,$(git_module_status)) +ifeq (no,$(GIT_UPDATE)) +git-submodule-update: + $(call quiet-command, \ + echo && \ + echo "GIT submodule checkout is out of date. Please run" && \ + echo " scripts/git-submodule.sh update $(GIT_SUBMODULES)" && \ + echo "from the source directory checkout $(SRC_PATH)" && \ + echo && \ + exit 1) +else git-submodule-update: $(call quiet-command, \ (cd $(SRC_PATH) && GIT="$(GIT)" ./scripts/git-submodule.sh update $(GIT_SUBMODULES)), \ "GIT","$(GIT_SUBMODULES)") endif endif +endif .git-submodule-status: git-submodule-update config-host.mak diff --git a/configure b/configure index 5af463fed6..a6055c0710 100755 --- a/configure +++ b/configure @@ -267,8 +267,10 @@ stack_protector="" if test -e "$source_path/.git" then + git_update=yes git_submodules="ui/keycodemapdb" else + git_update=no git_submodules="" fi git="git" @@ -1306,6 +1308,10 @@ for opt do ;; --with-git=*) git="$optarg" ;; + --enable-git-update) git_update=yes + ;; + --disable-git-update) git_update=no + ;; *) echo "ERROR: unknown option $opt" echo "Try '$0 --help' for more information" @@ -5610,6 +5616,7 @@ echo "qemu_localedir=$qemu_localedir" >> $config_host_mak echo "libs_softmmu=$libs_softmmu" >> $config_host_mak echo "GIT=$git" >> $config_host_mak echo "GIT_SUBMODULES=$git_submodules" >> $config_host_mak +echo "GIT_UPDATE=$git_update" >> $config_host_mak echo "ARCH=$ARCH" >> $config_host_mak diff --git a/scripts/git-submodule.sh b/scripts/git-submodule.sh index 21909ea413..63ace6fc55 100755 --- a/scripts/git-submodule.sh +++ b/scripts/git-submodule.sh @@ -21,6 +21,15 @@ error() { echo echo " $ ./configure --with-git='tsocks git'" echo + echo "Alternatively you may disable automatic GIT submodule checkout" + echo "with:" + echo + echo " $ ./configure --disable-git-update'" + echo + echo "and then manually update submodules prior to running make, with:" + echo + echo " $ scripts/git-sbumodule.sh update $modules" + echo exit 1 } -- cgit v1.2.3-55-g7522 From 37b5e74e28f4b3ee93c28eb0106a65e02521f48b Mon Sep 17 00:00:00 2001 From: Daniel P. Berrange Date: Fri, 27 Oct 2017 10:49:58 +0100 Subject: build: don't fail if given a git submodule which does not exist If going back in time in git history, across a commit that introduces a new submodule, the 'git-submodule.sh' script will fail, causing rebuild to fail. This is because config-host.mak contains a GIT_SUBMODULES variable that lists a submodule that only exists in the later commit. config-host.mak won't get repopulated until config.status is invoked, but make won't get this far due to the submodule error. This change makes 'git-submodule.sh' check whether each module is known to git and drops any which are not present. A warning message will be printed when any submodule is dropped in this manner. Tested-by: Philippe Mathieu-Daudé Reviewed-by: Eric Blake Signed-off-by: Daniel P. Berrange --- scripts/git-submodule.sh | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'scripts/git-submodule.sh') diff --git a/scripts/git-submodule.sh b/scripts/git-submodule.sh index 63ace6fc55..3683bc9a04 100755 --- a/scripts/git-submodule.sh +++ b/scripts/git-submodule.sh @@ -7,7 +7,7 @@ substat=".git-submodule-status" command=$1 shift -modules="$@" +maybe_modules="$@" test -z "$GIT" && GIT=git @@ -33,12 +33,24 @@ error() { exit 1 } -if test -z "$modules" +if test -z "$maybe_modules" then test -e $substat || touch $substat exit 0 fi +modules="" +for m in $maybe_modules +do + $GIT submodule status $m 1> /dev/null 2>&1 + if test $? = 0 + then + modules="$modules $m" + else + echo "warn: ignoring non-existent submodule $m" + fi +done + if ! test -e ".git" then echo "$0: unexpectedly called with submodules but no git checkout exists" -- cgit v1.2.3-55-g7522 From 49ad3cfa67145a71644d7832ed20c2a2b0620d15 Mon Sep 17 00:00:00 2001 From: Daniel P. Berrange Date: Mon, 30 Oct 2017 09:29:29 +0100 Subject: build: delay check for empty git submodule list We short circuit the git submodule update when passed an empty module list. This accidentally causes the 'status' command to write to the status file. The test needs to be delayed into the individual commands to avoid this premature writing of the status file. Tested-by: Philippe Mathieu-Daudé Reviewed-by: Eric Blake Signed-off-by: Daniel P. Berrange --- scripts/git-submodule.sh | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'scripts/git-submodule.sh') diff --git a/scripts/git-submodule.sh b/scripts/git-submodule.sh index 3683bc9a04..030617b4ac 100755 --- a/scripts/git-submodule.sh +++ b/scripts/git-submodule.sh @@ -33,12 +33,6 @@ error() { exit 1 } -if test -z "$maybe_modules" -then - test -e $substat || touch $substat - exit 0 -fi - modules="" for m in $maybe_modules do @@ -51,7 +45,7 @@ do fi done -if ! test -e ".git" +if test -n "$maybe_modules" && ! test -e ".git" then echo "$0: unexpectedly called with submodules but no git checkout exists" exit 1 @@ -59,6 +53,11 @@ fi case "$command" in status) + if test -z "$maybe_modules" + then + test -s ${substat} && exit 1 || exit 0 + fi + test -f "$substat" || exit 1 CURSTATUS=`$GIT submodule status $modules` OLDSTATUS=`cat $substat` @@ -66,6 +65,12 @@ status) exit $? ;; update) + if test -z "$maybe_modules" + then + test -e $substat || touch $substat + exit 0 + fi + $GIT submodule update --init $modules 1>/dev/null test $? -ne 0 && error "failed to update modules" -- cgit v1.2.3-55-g7522