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

[dunecontrol]

* smaller cleanups
* remove unsused methods

[[Imported from SVN: r6823]]
parent f194b8b2
No related branches found
No related tags found
No related merge requests found
...@@ -45,10 +45,13 @@ BLANK="$space$tab" ...@@ -45,10 +45,13 @@ BLANK="$space$tab"
# #
parse_control() { parse_control() {
# check file existence # check file existence
if ! test -f "$1"; then if test ! -f "$1" -o "$(basename $1)" != "$CONTROL"; then
echo "ERROR: could not read file $1" >&2 echo "ERROR: '$1' is no $CONTROL file" >&2
exit 1 exit 1
fi fi
# reset information handling
local module=""
local module_inst="no"
# 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
...@@ -56,8 +59,7 @@ parse_control() { ...@@ -56,8 +59,7 @@ parse_control() {
exit 1 exit 1
fi fi
# create and check variable name from module name # create and check variable name from module name
export module_inst="no" module=$(fix_variable_name $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" >&2 echo "ERROR: $CONTROL files $1 contains an invalid Module entry" >&2
exit 1 exit 1
...@@ -83,7 +85,7 @@ parse_control() { ...@@ -83,7 +85,7 @@ parse_control() {
local pkgpath=$(canonicalname "$prefix/lib/dunecontrol/${name}") local pkgpath=$(canonicalname "$prefix/lib/dunecontrol/${name}")
if test x"$pkgpath" = x"$path"; then if test x"$pkgpath" = x"$path"; then
path="$prefix" path="$prefix"
export module_inst="yes" module_inst="yes"
fi fi
fi fi
# avoid multiple definition of the same module # avoid multiple definition of the same module
...@@ -113,7 +115,7 @@ parse_control() { ...@@ -113,7 +115,7 @@ parse_control() {
echo " $path/lib/dunecontrol/${name}/$CONTROL" >&2 echo " $path/lib/dunecontrol/${name}/$CONTROL" >&2
echo "using previously found locally built module" >&2 echo "using previously found locally built module" >&2
echo " $(eval echo \$PATH_$module)/$CONTROL" >&2 echo " $(eval echo \$PATH_$module)/$CONTROL" >&2
export module_inst="no" module_inst="no"
return return
;; ;;
# local modules supersede installed modules # local modules supersede installed modules
...@@ -143,6 +145,12 @@ parse_control() { ...@@ -143,6 +145,12 @@ parse_control() {
mod=$(fix_variable_name $name) mod=$(fix_variable_name $name)
export NAME_${mod}="$name" export NAME_${mod}="$name"
done done
# update list of modules
if test "$module_inst" = "yes"; then
export INSTMODULES="$MODULES$module "
else
export LOCALMODULES="$MODULES$module "
fi
} }
# #
...@@ -194,14 +202,14 @@ find_modules_in_path() { ...@@ -194,14 +202,14 @@ find_modules_in_path() {
while read dir; do while read dir; do
if test -d "$dir"; then if test -d "$dir"; then
while read m; do while read m; do
test -n "$m" && find_modules "$m" test -n "$m" && parse_control "$m"
TMPMODULES="$TMPMODULES$FM_MODULES$INSTMODULES" TMPMODULES="$TMPMODULES$LOCALMODULES$INSTMODULES"
done <<EOFM done <<EOFM
$(find -H "$dir" -name $CONTROL | $GREP -v 'dune-[-_a-zA-Z]/dune-[-a-zA-Z_]*-[0-9]\{1,\}.[0-9]\{1,\}/') $(find -H "$dir" -name $CONTROL | $GREP -v 'dune-[-_a-zA-Z]/dune-[-a-zA-Z_]*-[0-9]\{1,\}.[0-9]\{1,\}/')
EOFM EOFM
else else
find_modules $dir parse_control "$dir"
TMPMODULES="$TMPMODULES$FM_MODULES$INSTMODULES" TMPMODULES="$TMPMODULES$LOCALMODULES$INSTMODULES"
fi fi
done <<EOF done <<EOF
$(echo $DUNE_CONTROL_PATH | sed -e 's/:\+/:/g' | tr ':' '\n') $(echo $DUNE_CONTROL_PATH | sed -e 's/:\+/:/g' | tr ':' '\n')
...@@ -211,29 +219,6 @@ EOF ...@@ -211,29 +219,6 @@ EOF
fi fi
} }
#
# search a directory recursively for $CONTROL files
#
# paramters:
# $1 directory to search for modules
#
find_modules() {
if test -f "$1" &&
test "$(basename $1)" = "$CONTROL"; then
export module=""
export module_inst="no"
parse_control "$1"
if test "$module_inst" = "yes"; then
export INSTMODULES="$MODULES$module "
else
export FM_MODULES="$MODULES$module "
fi
else
echo "ERROR: '$1' is no $CONTROL file" >&2
false
fi
}
# #
# sort $MODULES according to the dependencies # sort $MODULES according to the dependencies
# #
...@@ -261,28 +246,6 @@ sort_modules() { ...@@ -261,28 +246,6 @@ sort_modules() {
done done
} }
#
# sort $MODULES's dependencies according to the dependencies
# don't include $MODULE itself
#
sort_dependencies() {
# get dependencies
sort_modules $1
# save result
export MODULES="$SORTEDMODULES_DEPS"
}
#
# sort $MODULES's dependencies according to the dependencies
# don't include $MODULE itself
#
sort_suggestions() {
# get suggestions
sort_modules $1
# save result
export MODULES="$SORTEDMODULES_SUGS"
}
# #
# recursive part of sort_modules # recursive part of sort_modules
# evaluate dependencies of one module # evaluate dependencies of one module
...@@ -419,11 +382,10 @@ eval_control() { ...@@ -419,11 +382,10 @@ eval_control() {
} }
# #
# fix a value such that it is suitable for a variable name and assign it # fix a value such that it is suitable for a variable name
# #
# parameters: # parameters:
# $1 name of variable # $1 value
# $2 value
# #
fix_variable_name() { fix_variable_name() {
# The replacement sequence has to be extended explicitly to the length of # The replacement sequence has to be extended explicitly to the length of
...@@ -431,6 +393,13 @@ fix_variable_name() { ...@@ -431,6 +393,13 @@ fix_variable_name() {
echo -n "$@" | tr '[:punct:]' '[_*]' echo -n "$@" | tr '[:punct:]' '[_*]'
} }
#
# fix a value such that it is suitable for a variable name and assign it
#
# parameters:
# $1 name of variable
# $2 value
#
fix_and_assign() { fix_and_assign() {
local name="$1" local name="$1"
if ! check_modname $name; then if ! check_modname $name; then
...@@ -442,6 +411,7 @@ fix_and_assign() { ...@@ -442,6 +411,7 @@ fix_and_assign() {
# #
# make sure the module name fits the naming convention # make sure the module name fits the naming convention
# (we try to assign the name and report upon failure)
# #
# parameters: # parameters:
# $1 module name # $1 module name
......
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