diff --git a/bin/dunecontrol b/bin/dunecontrol index 1a6ee19d2710e3e150b922a1359bd4559dacc4d9..569ae198f8f5b8b8fd60e56e1523b08bd760821a 100755 --- a/bin/dunecontrol +++ b/bin/dunecontrol @@ -45,7 +45,7 @@ canonicalname(){ fdir="`canonicalname \"$fdir\"`" echo "$fdir/$fname" fi - # if this is a directory, then create an absolute + # if this is a directory, then create an absolute # directory name and we are done if test -d "$file"; then (cd "$file"; pwd) @@ -126,7 +126,7 @@ build_module() { # disable usage of opts file if test "x$DUNE_OPTS_FILE" != "x"; then echo "WARNING: commandline parameters will overwrite setting in opts file \"$DUNE_OPTS_FILE\"" - fi + fi fi # skip command delimiter @@ -146,7 +146,7 @@ build_module() { eval_control $runcommand $path/$CONTROL ); then eval echo "--- Failed to build \$NAME_${module} ---"; exit 1; fi trap onfailure EXIT - + eval echo "--- \$NAME_${module} done ---" done } @@ -246,7 +246,7 @@ for command in $COMMANDS; do done # -# default implementations for commands... +# default implementations for commands... # these can be overwritten in the $CONTROL files # @@ -325,7 +325,8 @@ run_default_vcsetup() { eval "$CMD_FLAGS" fi - if [ -d .git ]; then + # Check for both a file and a directory to cope with Git submodules + if [ -d .git -o -f .git ] ; then # Read Whitespace-Hook setting from dune.module file local SETUPGITHOOK="$($GREP -i "^[$BLANK]*Whitespace-Hook:" dune.module | cut -d ':' -f2 | eval $PARSER_TRIM | tr '[:upper:]' '[:lower:]')" @@ -333,33 +334,44 @@ run_default_vcsetup() { if [ "x$SETUPGITHOOK" = "xyes" ]; then # we have to install the Git whitespace hook + # The current Git repository might be a submodule, so we have to start by + # determining the location of the commit hook + + if [ -f .git ] ; then + # submodule -> .git contains a pointer to the repository + GITHOOKPATH="$(sed 's/gitdir: //' < .git)/hooks/pre-commit" + else + # standard case, .git is the repository + GITHOOKPATH=.git/hooks/pre-commit + fi + if [ -n "$DISABLEWHITESPACEHOOK" ] ; then # the user doesn't want the Git whitespace hook - deinstall it if necessary and warn the user echo "WARNING: The current module wants to install the DUNE whitespace hook, but you have disabled the hook in your options!" echo "WARNING: You will have to make sure that your commits don't introduce any trailing whitespace or indentation with tabs!" echo "WARNING: Otherwise, your commits might be rejected when trying to push them to an official repository!" - if [ -e .git/hooks/pre-commit ]; then + if [ -e "$GITHOOKPATH" ]; then # there is a pre-commit hook, check whether it is our whitespace hook - local HOOKTAG="$(head -n 2 .git/hooks/pre-commit | tail -n 1)" + local HOOKTAG="$(eval head -n 2 \"$GITHOOKPATH\" | tail -n 1)" if [ "x$HOOKTAG" = "x# dune-git-whitespace-hook" ]; then echo "--> Removing DUNE whitespace hook as requested by the user" - rm .git/hooks/pre-commit + rm "$GITHOOKPATH" fi fi else # standard handling of Git whitespace hook - if [ ! -e .git/hooks/pre-commit ]; then + if [ ! -e "$GITHOOKPATH" ]; then # there is no hook yet, we can safely install ours echo "--> Installing Git pre-commit hook to enforce whitespace policy" - cp -p $PREFIX_DIR/bin/git-whitespace-hook .git/hooks/pre-commit + cp -p "$PREFIX_DIR/bin/git-whitespace-hook" "$GITHOOKPATH" else # there is already a hook, check whether it is our whitespace hook - local HOOKTAG="$(head -n 2 .git/hooks/pre-commit | tail -n 1)" + local HOOKTAG="$(eval head -n 2 \"$GITHOOKPATH\" | tail -n 1)" if [ "x$HOOKTAG" = "x# dune-git-whitespace-hook" ]; then - if [ $PREFIX_DIR/bin/git-whitespace-hook -nt .git/hooks/pre-commit ]; then + if [ "$PREFIX_DIR/bin/git-whitespace-hook" -nt "$GITHOOKPATH" ]; then echo "--> Updating Git pre-commit hook with newer version" - cp -p $PREFIX_DIR/bin/git-whitespace-hook .git/hooks/pre-commit + cp -p "$PREFIX_DIR/bin/git-whitespace-hook" "$GITHOOKPATH" fi else echo "WARNING: Existing pre-commit hook found!" @@ -405,7 +417,7 @@ run_default_vcsetup() { fi # Run custom setup scripts - if [ -d .git -o -d .svn -o -d CVS -o -f stamp-vc ]; then + if [ -d .git -o -f .git -o -d .svn -o -d CVS -o -f stamp-vc ]; then if [ -d .vcsetup/run.d ]; then for SCRIPT in .vcsetup/run.d/* ; do if [ -x "$SCRIPT" ]; then @@ -474,7 +486,7 @@ run_default_autogen () { else echo Skipping dune-autogen fi - else + else echo Skipping dune-autogen because of CMake fi } @@ -483,7 +495,7 @@ run_default_configure () { PARAMS="$CMD_FLAGS" if test "x$USE_CMAKE" = "xyes" && test -e $(eval "echo \$PATH_$module")/CMakeLists.txt; then LOCAL_USE_CMAKE=yes - else + else LOCAL_USE_CMAKE=no fi echo "LOCAL_USE_CMAKE=$LOCAL_USE_CMAKE $(eval "echo \$PATH_$module")/CMakeLists.txt" @@ -747,11 +759,11 @@ while test $# -gt 0; do exit 1 fi ;; - -h|--help) + -h|--help) command=help break ;; - -p|--print) + -p|--print) command=print break ;; @@ -1011,7 +1023,7 @@ EOF fi EOF done - ### + ### for mod in $SORTEDMODULES_SUGS; do name=`eval echo \\$NAME_$mod` MOD=`echo $mod | tr [:lower:] [:upper:]`