Repackage internal code into functions. (readability). Made cntr a local var as it was interfering with a trace
This commit is contained in:
parent
b6f18566c8
commit
fb6913a214
1 changed files with 93 additions and 71 deletions
|
@ -4,94 +4,113 @@
|
|||
#
|
||||
# Read and parse the configuration parameters..
|
||||
#
|
||||
ConfigFile="configuration"
|
||||
while [ 0 ]; do
|
||||
read || break 1
|
||||
set -e
|
||||
|
||||
# Garbage collection
|
||||
case ${REPLY} in
|
||||
\#* | '') continue ;;
|
||||
esac
|
||||
declare -r ConfigFile="configuration"
|
||||
declare TARGET
|
||||
declare DEP_LEVEL
|
||||
declare SUDO
|
||||
declare PKGXML
|
||||
declare BLFS_XML
|
||||
declare VERBOSITY=1
|
||||
|
||||
case "${REPLY}" in
|
||||
CONFIG_ALSA=* | \
|
||||
CONFIG_GNOME-CORE=* | \
|
||||
CONFIG_GNOME-FULL=* | \
|
||||
CONFIG_KDE-CORE=* | \
|
||||
CONFIG_KDE-FULL=* | \
|
||||
CONFIG_KDE-KOFFICE=* | \
|
||||
CONFIG_XORG7=* ) REPLY=${REPLY%=*} # Strip the trailing '=y' test.. unecessary
|
||||
echo -n "${REPLY}"
|
||||
if [[ $((++cntr)) > 1 ]]; then
|
||||
echo " <<-- ERROR:: SELECT ONLY 1 PACKAGE AT A TIME, META-PACKAGE NOT SELECTED"
|
||||
else
|
||||
echo ""
|
||||
optTARGET=$(echo $REPLY | cut -d "_" -f2 | tr [A-Z] [a-z])
|
||||
fi
|
||||
continue ;;
|
||||
#--------------------------#
|
||||
parse_configuration() { #
|
||||
#--------------------------#
|
||||
local cntr
|
||||
local optTARGET
|
||||
|
||||
while [ 0 ]; do
|
||||
read || break 1
|
||||
|
||||
# Create global variables for these parameters.
|
||||
optDependency=* | \
|
||||
PRINT_SERVER=* | \
|
||||
MAIL_SERVER=* | \
|
||||
GHOSTSCRIPT=* | \
|
||||
KBR5=* | \
|
||||
X11=* | \
|
||||
SUDO=* ) eval ${REPLY} # Define/set a global variable..
|
||||
# Garbage collection
|
||||
case ${REPLY} in
|
||||
\#* | '') continue ;;
|
||||
esac
|
||||
|
||||
case "${REPLY}" in
|
||||
CONFIG_ALSA=* | \
|
||||
CONFIG_GNOME-CORE=* | \
|
||||
CONFIG_GNOME-FULL=* | \
|
||||
CONFIG_KDE-CORE=* | \
|
||||
CONFIG_KDE-FULL=* | \
|
||||
CONFIG_KDE-KOFFICE=* | \
|
||||
CONFIG_XORG7=* ) REPLY=${REPLY%=*} # Strip the trailing '=y' test.. unecessary
|
||||
echo -n "${REPLY}"
|
||||
if [[ $((++cntr)) > 1 ]]; then
|
||||
echo " <<-- ERROR:: SELECT ONLY 1 PACKAGE AT A TIME, META-PACKAGE NOT SELECTED"
|
||||
else
|
||||
echo ""
|
||||
optTARGET=$(echo $REPLY | cut -d "_" -f2 | tr [A-Z] [a-z])
|
||||
fi
|
||||
continue ;;
|
||||
|
||||
# Create global variables for these parameters.
|
||||
optDependency=* | \
|
||||
PRINT_SERVER=* | \
|
||||
MAIL_SERVER=* | \
|
||||
GHOSTSCRIPT=* | \
|
||||
KBR5=* | \
|
||||
X11=* | \
|
||||
SUDO=* ) eval ${REPLY} # Define/set a global variable..
|
||||
continue ;;
|
||||
esac
|
||||
esac
|
||||
|
||||
if [[ "${REPLY}" =~ "^CONFIG_" ]]; then
|
||||
echo -n "$REPLY"
|
||||
if [[ $((++cntr)) > 1 ]]; then
|
||||
echo " <<-- ERROR SELECT ONLY 1 PACKAGE AT A TIME, WILL NOT BUILD"
|
||||
else
|
||||
echo ""
|
||||
optTARGET=$( echo $REPLY | sed -e 's@CONFIG_@@' -e 's@=y@@' )
|
||||
if [[ "${REPLY}" =~ "^CONFIG_" ]]; then
|
||||
echo -n "$REPLY"
|
||||
if [[ $((++cntr)) > 1 ]]; then
|
||||
echo " <<-- ERROR SELECT ONLY 1 PACKAGE AT A TIME, WILL NOT BUILD"
|
||||
else
|
||||
echo ""
|
||||
optTARGET=$( echo $REPLY | sed -e 's@CONFIG_@@' -e 's@=y@@' )
|
||||
fi
|
||||
fi
|
||||
done <$ConfigFile
|
||||
|
||||
if [[ $optTARGET = "" ]]; then
|
||||
echo -e "\n>>> NO TARGET SELECTED.. applicaton terminated"
|
||||
echo -e " Run <make> again and select a package to build\n"
|
||||
exit 0
|
||||
fi
|
||||
done <$ConfigFile
|
||||
if [[ $optTARGET = "" ]]; then
|
||||
echo -e "\n>>> NO TARGET SELECTED.. applicaton terminated"
|
||||
echo -e " Run <make> again and select a package to build\n"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
TARGET=$optTARGET
|
||||
DEP_LEVEL=$optDependency
|
||||
SUDO=${SUDO:-y}
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# Regenerate the META-package dependencies from the configuration file
|
||||
#
|
||||
rm -f libs/*.dep-MOD
|
||||
while [ 0 ]; do
|
||||
read || break 1
|
||||
case ${REPLY} in
|
||||
\#* | '') continue ;;
|
||||
esac
|
||||
#--------------------------#
|
||||
regenerate_deps() { #
|
||||
#--------------------------#
|
||||
|
||||
rm -f libs/*.dep-MOD
|
||||
while [ 0 ]; do
|
||||
read || break 1
|
||||
case ${REPLY} in
|
||||
\#* | '') continue ;;
|
||||
esac
|
||||
|
||||
# Drop the "=y"
|
||||
REPLY=${REPLY%=*}
|
||||
if [[ "${REPLY}" =~ "^DEP_" ]]; then
|
||||
META_PACKAGE=$(echo $REPLY | cut -d "_" -f2 | tr [A-Z] [a-z])
|
||||
DEP_FNAME=$(echo $REPLY | cut -d "_" -f3)
|
||||
echo "${DEP_FNAME}" >>libs/${META_PACKAGE}.dep-MOD
|
||||
fi
|
||||
REPLY=${REPLY%=*}
|
||||
if [[ "${REPLY}" =~ "^DEP_" ]]; then
|
||||
META_PACKAGE=$(echo $REPLY | cut -d "_" -f2 | tr [A-Z] [a-z])
|
||||
DEP_FNAME=$(echo $REPLY | cut -d "_" -f3)
|
||||
echo "${DEP_FNAME}" >>libs/${META_PACKAGE}.dep-MOD
|
||||
fi
|
||||
|
||||
done <$ConfigFile
|
||||
#
|
||||
# Replace to 'old' dependency file with a new one.
|
||||
#
|
||||
for dst in `ls ./libs/*.dep-MOD 2>/dev/null`; do
|
||||
done <$ConfigFile
|
||||
#
|
||||
# Replace to 'old' dependency file with a new one.
|
||||
#
|
||||
for dst in `ls ./libs/*.dep-MOD 2>/dev/null`; do
|
||||
cp -vf $dst ${dst%-MOD}
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
set -e
|
||||
declare TARGET=$optTARGET
|
||||
declare DEP_LEVEL=$optDependency
|
||||
declare PKGXML
|
||||
declare BLFS_XML
|
||||
declare VERBOSITY=1
|
||||
[[ -z $SUDO ]] && SUDO=y
|
||||
|
||||
#---------------------
|
||||
# Constants
|
||||
source libs/constants.inc
|
||||
|
@ -115,6 +134,9 @@ if [[ ! -f packages ]] ; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
parse_configuration
|
||||
regenerate_deps
|
||||
generate_dependency_tree
|
||||
generate_TARGET_xml
|
||||
generate_target_book
|
||||
|
|
Reference in a new issue