Skip to content
Snippets Groups Projects
Commit 1130cce0 authored by Christian Engwer's avatar Christian Engwer
Browse files

if the dune.module file is not found for a certain module, dunecontrol

tries to find an installed module via pkg-config. If pkg-config finds
an installed module, dunecontrol proceeds, although the module is
dropped from the internal tree, as installed modules don't need to be
built. If pkg-config does not find the module, an error is throughn.
If a dune.module file is found, installed versions of the module are
ignored.


[[Imported from SVN: r4741]]
parent e52435e6
No related branches found
No related tags found
No related merge requests found
...@@ -172,8 +172,8 @@ run_default_configure () { ...@@ -172,8 +172,8 @@ run_default_configure () {
eval ./configure "$PARAMS" || exit 1 eval ./configure "$PARAMS" || exit 1
else else
if test -f configure.in || test -f configure.ac; then if test -f configure.in || test -f configure.ac; then
echo "ERROR: configure.[in|ac] found, but configure missing" echo "ERROR: configure.[in|ac] found, but configure missing" > /dev/stderr
echo "did you forget to run autoconf?" echo "did you forget to run autoconf?" > /dev/stderr
exit 1 exit 1
fi fi
fi fi
...@@ -207,11 +207,12 @@ run_default_svn () { ...@@ -207,11 +207,12 @@ run_default_svn () {
### ###
onfailure() { onfailure() {
echo Execution terminated due to errors! echo Execution terminated due to errors! > /dev/stderr
exit 1 exit 1
} }
usage () { usage () {
(
echo "Usage: $(basename $0) [OPTIONS] COMMAND [COMMAND-OPTIONS]" echo "Usage: $(basename $0) [OPTIONS] COMMAND [COMMAND-OPTIONS]"
echo "" echo ""
echo "Execute COMMAND for all Dune modules found in and below the current directory." echo "Execute COMMAND for all Dune modules found in and below the current directory."
...@@ -229,6 +230,7 @@ usage () { ...@@ -229,6 +230,7 @@ usage () {
printf " \`$i'\t$(eval echo \$${i}_HELP)\n" printf " \`$i'\t$(eval echo \$${i}_HELP)\n"
done done
echo echo
) > /dev/stderr
} }
if test "x$1" = "x"; then if test "x$1" = "x"; then
...@@ -256,15 +258,15 @@ while test $# -gt 0; do ...@@ -256,15 +258,15 @@ while test $# -gt 0; do
--opts=*) --opts=*)
if test "x$arg" = "x"; then if test "x$arg" = "x"; then
usage usage
echo "ERROR: Parameter for --opts is missing" echo "ERROR: Parameter for --opts is missing" > /dev/stderr
echo echo > /dev/stderr
exit 1; exit 1;
fi fi
DUNE_OPTS_FILE=$(canonicalpath $arg)/$(basename $arg) DUNE_OPTS_FILE=$(canonicalpath $arg)/$(basename $arg)
if ! test -r "$DUNE_OPTS_FILE"; then if ! test -r "$DUNE_OPTS_FILE"; then
usage usage
echo "ERROR: could not read opts file \"$DUNE_OPTS_FILE\"" echo "ERROR: could not read opts file \"$DUNE_OPTS_FILE\"" > /dev/stderr
echo echo > /dev/stderr
exit 1; exit 1;
fi fi
;; ;;
...@@ -279,8 +281,8 @@ while test $# -gt 0; do ...@@ -279,8 +281,8 @@ while test $# -gt 0; do
--module=*) --module=*)
if test "x$arg" = "x"; then if test "x$arg" = "x"; then
usage usage
echo "ERROR: Parameter for --module is missing" echo "ERROR: Parameter for --module is missing" > /dev/stderr
echo echo > /dev/stderr
exit 1; exit 1;
fi fi
fix_and_assign MODULE "$arg" fix_and_assign MODULE "$arg"
...@@ -288,8 +290,8 @@ while test $# -gt 0; do ...@@ -288,8 +290,8 @@ while test $# -gt 0; do
--only=*) --only=*)
if test "x$arg" = "x"; then if test "x$arg" = "x"; then
usage usage
echo "ERROR: Parameter for --only is missing" echo "ERROR: Parameter for --only is missing" > /dev/stderr
echo echo > /dev/stderr
exit 1; exit 1;
fi fi
fix_and_assign ONLY "$arg" fix_and_assign ONLY "$arg"
...@@ -344,7 +346,7 @@ case "$command" in ...@@ -344,7 +346,7 @@ case "$command" in
usage usage
;; ;;
*) *)
echo "ERROR: unknown command \"$command\"" echo "ERROR: unknown command \"$command\"" > /dev/stderr
usage usage
exit 1 exit 1
;; ;;
......
...@@ -31,39 +31,39 @@ fi ...@@ -31,39 +31,39 @@ fi
parse_control() { parse_control() {
# check file existence # check file existence
if ! test -f "$1"; then if ! test -f "$1"; then
echo "ERROR: could not read file $1" echo "ERROR: could not read file $1" > /dev/stderr
exit 1 exit 1
fi fi
# read parameters from control file # read parameters from control file
local name="$(echo $($GREP Module: "$1" | cut -d ':' -f2))" local name="$(echo $($GREP Module: "$1" | cut -d ':' -f2))"
if test "x$name" = "x"; then if test "x$name" = "x"; then
echo "ERROR: $CONTROL files $1 does not contain a Module entry" echo "ERROR: $CONTROL files $1 does not contain a Module entry" > /dev/stderr
exit 1 exit 1
fi fi
local deps="$(echo $($GREP Depends: "$1" | cut -d ':' -f2))" local deps="$(echo $($GREP Depends: "$1" | cut -d ':' -f2))"
local sugs="$(echo $($GREP Suggests: "$1" | cut -d ':' -f2))" local sugs="$(echo $($GREP Suggests: "$1" | cut -d ':' -f2))"
local path="$(dirname "$1")" local path="$(dirname "$1")"
# create and check variable name from module name # create and check variable name from module name
fix_and_assign module $name export module=$(fix_variable_name $name)
if ! check_modname "$module"; then if ! check_modname "$module"; then
echo "ERROR: $CONTROL files $1 contains an invalid Module entry" echo "ERROR: $CONTROL files $1 contains an invalid Module entry" > /dev/stderr
exit 1 exit 1
fi fi
# avoid multiple definition of the same module # avoid multiple definition of the same module
if test "x$(eval echo \$HAVE_$module)" != "x"; then if test "x$(eval echo \$HAVE_$module)" != "x"; then
echo "ERROR: multiple definition of module $name" echo "ERROR: multiple definition of module $name" > /dev/stderr
echo "previous defined in:" echo "previous defined in:" > /dev/stderr
echo " $(eval echo \$PATH_$module)/$CONTROL" echo " $(eval echo \$PATH_$module)/$CONTROL" > /dev/stderr
echo "redefined in:" echo "redefined in:" > /dev/stderr
echo " $path/$CONTROL" echo " $path/$CONTROL" > /dev/stderr
exit 1 exit 1
fi fi
# set status variables # set status variables
export HAVE_${module}=yes export HAVE_${module}=yes
export PATH_${module}="$path" export PATH_${module}="$path"
export NAME_${module}="$name" export NAME_${module}="$name"
fix_and_assign DEPS_${module} "$deps" export DEPS_${module}="$deps"
fix_and_assign SUGS_${module} "$sugs" export SUGS_${module}="$sugs"
} }
# #
...@@ -103,7 +103,7 @@ EOF ...@@ -103,7 +103,7 @@ EOF
parse_control "$1" parse_control "$1"
export MODULES="$MODULES $module" export MODULES="$MODULES $module"
else else
echo "ERROR: '$1' is neither a directory nor a $CONTROL file" echo "ERROR: '$1' is neither a directory nor a $CONTROL file" > /dev/stderr
false false
fi fi
fi fi
...@@ -114,10 +114,11 @@ EOF ...@@ -114,10 +114,11 @@ EOF
# #
sort_modules() { sort_modules() {
for m in "$@"; do for m in "$@"; do
# did we find a module file for this mopdule?
if test "x$(eval echo \$HAVE_$m)" != "x"; then if test "x$(eval echo \$HAVE_$m)" != "x"; then
_sort_module $m _sort_module $m
else else
echo "ERROR: could not find module $dep" echo "ERROR: could not find module $dep" > /dev/stderr
exit 1 exit 1
fi fi
done done
...@@ -134,21 +135,37 @@ sort_modules() { ...@@ -134,21 +135,37 @@ sort_modules() {
_sort_module() { _sort_module() {
local module="$1" local module="$1"
shift 1 shift 1
if ! check_modname $module; then echo "ERROR: invalid module name $module"; exit 1; fi if ! check_modname $module; then
echo "ERROR: invalid module name $module" > /dev/stderr
exit 1
fi
if test "x$(eval echo \$SORT_DONE_${command}_${module})" != "xyes"; then if test "x$(eval echo \$SORT_DONE_${command}_${module})" != "xyes"; then
# resolve dependencies # resolve dependencies
for dep in $(eval "echo \$DEPS_$module"); do for name in $(eval "echo \$DEPS_$module"); do
if ! check_modname $dep; then echo "ERROR: invalid module name $dep"; exit 1; fi dep=$(fix_variable_name $name)
if ! check_modname $dep; then
echo "ERROR: invalid module name $dep" > /dev/stderr
exit 1
fi
if test "x$(eval echo \$HAVE_$dep)" != "x"; then if test "x$(eval echo \$HAVE_$dep)" != "x"; then
_sort_module $dep _sort_module $dep
else else
echo "ERROR: could not find module $dep" # perhaps this module is installed,
exit 1 # then it should be handled via pkg-config
if ! pkg-config $name; then
echo "ERROR: could not find module $dep" > /dev/stderr
echo " module is also unknown to pkg-config" > /dev/stderr
exit 1
fi
fi fi
done done
# resolve suggestions # resolve suggestions
for dep in $(eval "echo \$SUGS_$module"); do for name in $(eval "echo \$SUGS_$module"); do
if ! check_modname $dep; then echo "ERROR: invalid module name $dep"; exit 1; fi dep=$(fix_variable_name $name)
if ! check_modname $dep; then
echo "ERROR: invalid module name $dep" > /dev/stderr
exit 1
fi
if test "x$(eval echo \$HAVE_$dep)" != "x"; then if test "x$(eval echo \$HAVE_$dep)" != "x"; then
_sort_module $dep _sort_module $dep
fi fi
...@@ -183,7 +200,7 @@ eval_control() { ...@@ -183,7 +200,7 @@ eval_control() {
$command $command
) || false ) || false
else else
echo "ERROR: could not find $file" echo "ERROR: could not find $file" > /dev/stderr
exit 1 exit 1
fi fi
} }
...@@ -195,13 +212,17 @@ eval_control() { ...@@ -195,13 +212,17 @@ eval_control() {
# $1 name of variable # $1 name of variable
# $2 value # $2 value
# #
fix_variable_name() {
if ! check_modname $name; then
echo "ERROR: error in assignment. $name is not a valid variabel name." > /dev/stderr
fi
echo "$@" | tr '-' '_'
}
fix_and_assign() { fix_and_assign() {
local name="$1" local name="$1"
shift 1 shift 1
if ! check_modname $name; then export $name=$(fix_variable_name $@)
echo ERROR: error in assignment. $name is not a valid variabel name.
fi
export $name="$(echo "$@" | sed -e 's/-/_/g')"
} }
# #
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment