Ignore:
Timestamp:
08/22/2006 08:33:33 PM (18 years ago)
Author:
George Boudreau <georgeb@…>
Branches:
experimental
Children:
bcdbeef
Parents:
b6f18566
Message:

Repackage internal code into functions. (readability). Made cntr a local var as it was interfering with a trace

File:
1 edited

Legend:

Unmodified
Added
Removed
  • BLFS/gen_pkg_book.sh

    rb6f18566 rfb6913a  
    55#  Read and parse the configuration parameters..
    66#
    7 ConfigFile="configuration"
    8 while [ 0 ]; do
    9   read || break 1
     7set -e
    108
    11   # Garbage collection
    12   case ${REPLY} in
    13     \#* | '') continue ;;
    14   esac
     9declare -r ConfigFile="configuration"
     10declare TARGET
     11declare DEP_LEVEL
     12declare SUDO
     13declare PKGXML
     14declare BLFS_XML
     15declare VERBOSITY=1
    1516
    16   case "${REPLY}" in
    17     CONFIG_ALSA=* | \
    18     CONFIG_GNOME-CORE=* | \
    19     CONFIG_GNOME-FULL=* | \
    20     CONFIG_KDE-CORE=* | \
    21     CONFIG_KDE-FULL=* | \
    22     CONFIG_KDE-KOFFICE=* | \
    23     CONFIG_XORG7=* ) REPLY=${REPLY%=*}  # Strip the trailing '=y' test.. unecessary
    24                      echo -n "${REPLY}"
    25                      if [[ $((++cntr)) > 1 ]]; then
    26                        echo "  <<-- ERROR:: SELECT ONLY 1 PACKAGE AT A TIME, META-PACKAGE NOT SELECTED"
    27                      else
    28                        echo ""
    29                        optTARGET=$(echo $REPLY | cut -d "_" -f2 | tr [A-Z] [a-z])
    30                      fi
    31                      continue ;;
     17#--------------------------#
     18parse_configuration() {    #
     19#--------------------------#
     20  local cntr
     21  local optTARGET
     22 
     23  while [ 0 ]; do
     24    read || break 1
    3225
    33     # Create global variables for these parameters.
    34     optDependency=* | \
    35     PRINT_SERVER=*  | \
    36     MAIL_SERVER=*   | \
    37     GHOSTSCRIPT=*   | \
    38     KBR5=*  | \
    39     X11=*   | \
    40     SUDO=*  )  eval ${REPLY} # Define/set a global variable..
     26    # Garbage collection
     27    case ${REPLY} in
     28      \#* | '') continue ;;
     29    esac
     30
     31    case "${REPLY}" in
     32      CONFIG_ALSA=* | \
     33      CONFIG_GNOME-CORE=* | \
     34      CONFIG_GNOME-FULL=* | \
     35      CONFIG_KDE-CORE=* | \
     36      CONFIG_KDE-FULL=* | \
     37      CONFIG_KDE-KOFFICE=* | \
     38      CONFIG_XORG7=* ) REPLY=${REPLY%=*}  # Strip the trailing '=y' test.. unecessary
     39                       echo -n "${REPLY}"
     40                       if [[ $((++cntr)) > 1 ]]; then
     41                         echo "  <<-- ERROR:: SELECT ONLY 1 PACKAGE AT A TIME, META-PACKAGE NOT SELECTED"
     42                       else
     43                         echo ""
     44                         optTARGET=$(echo $REPLY | cut -d "_" -f2 | tr [A-Z] [a-z])
     45                       fi
     46                       continue ;;
     47
     48      # Create global variables for these parameters.
     49      optDependency=* | \
     50      PRINT_SERVER=*  | \
     51      MAIL_SERVER=*   | \
     52      GHOSTSCRIPT=*   | \
     53      KBR5=*  | \
     54      X11=*   | \
     55      SUDO=*  )  eval ${REPLY} # Define/set a global variable..
    4156                      continue ;;
    42   esac
     57    esac
    4358
    44   if [[ "${REPLY}" =~ "^CONFIG_" ]]; then
    45     echo -n "$REPLY"
    46     if [[ $((++cntr)) > 1 ]]; then
    47       echo "  <<-- ERROR SELECT ONLY 1 PACKAGE AT A TIME, WILL NOT BUILD"
    48     else
    49       echo ""
    50       optTARGET=$( echo $REPLY | sed -e 's@CONFIG_@@' -e 's@=y@@' )
     59    if [[ "${REPLY}" =~ "^CONFIG_" ]]; then
     60      echo -n "$REPLY"
     61      if [[ $((++cntr)) > 1 ]]; then
     62        echo "  <<-- ERROR SELECT ONLY 1 PACKAGE AT A TIME, WILL NOT BUILD"
     63      else
     64        echo ""
     65        optTARGET=$( echo $REPLY | sed -e 's@CONFIG_@@' -e 's@=y@@' )
     66      fi
    5167    fi
     68  done <$ConfigFile
     69 
     70  if [[ $optTARGET = "" ]]; then
     71    echo -e "\n>>> NO TARGET SELECTED.. applicaton terminated"
     72    echo -e "    Run <make> again and select a package to build\n"
     73    exit 0
    5274  fi
    53 done <$ConfigFile
    54 if [[ $optTARGET = "" ]]; then
    55   echo -e "\n>>> NO TARGET SELECTED.. applicaton terminated"
    56   echo -e "    Run <make> again and select a package to build\n"
    57   exit 0
    58 fi
     75
     76  TARGET=$optTARGET
     77  DEP_LEVEL=$optDependency
     78  SUDO=${SUDO:-y}
     79}
     80
    5981
    6082#
    6183# Regenerate the META-package dependencies from the configuration file
    6284#
    63 rm -f libs/*.dep-MOD
    64 while [ 0 ]; do
    65   read || break 1
    66   case ${REPLY} in
    67   \#* | '') continue ;;
    68   esac
     85#--------------------------#
     86regenerate_deps() {        #
     87#--------------------------#
     88
     89  rm -f libs/*.dep-MOD
     90  while [ 0 ]; do
     91    read || break 1
     92    case ${REPLY} in
     93      \#* | '') continue ;;
     94    esac
    6995
    7096    # Drop the "=y"
    71   REPLY=${REPLY%=*}
    72   if [[ "${REPLY}" =~ "^DEP_" ]]; then
    73     META_PACKAGE=$(echo $REPLY | cut -d "_" -f2 | tr [A-Z] [a-z])
    74     DEP_FNAME=$(echo $REPLY | cut -d "_" -f3)
    75      echo "${DEP_FNAME}" >>libs/${META_PACKAGE}.dep-MOD
    76   fi
     97    REPLY=${REPLY%=*}
     98    if [[ "${REPLY}" =~ "^DEP_" ]]; then
     99      META_PACKAGE=$(echo $REPLY | cut -d "_" -f2 | tr [A-Z] [a-z])
     100      DEP_FNAME=$(echo $REPLY | cut -d "_" -f3)
     101       echo "${DEP_FNAME}" >>libs/${META_PACKAGE}.dep-MOD
     102    fi
    77103
    78 done <$ConfigFile
    79 #
    80 # Replace to 'old' dependency file with a new one.
    81 #
    82 for dst in `ls ./libs/*.dep-MOD 2>/dev/null`; do
     104  done <$ConfigFile
     105  #
     106  # Replace to 'old' dependency file with a new one.
     107  #
     108  for dst in `ls ./libs/*.dep-MOD 2>/dev/null`; do
    83109    cp -vf $dst ${dst%-MOD}
    84 done
     110  done
     111}
    85112
    86 
    87 set -e
    88 declare TARGET=$optTARGET
    89 declare DEP_LEVEL=$optDependency
    90 declare PKGXML
    91 declare BLFS_XML
    92 declare VERBOSITY=1
    93 [[ -z $SUDO ]] && SUDO=y
    94113
    95114#---------------------
     
    116135fi
    117136
     137
     138parse_configuration
     139regenerate_deps
    118140generate_dependency_tree
    119141generate_TARGET_xml
Note: See TracChangeset for help on using the changeset viewer.