[0208570] | 1 | #!/bin/bash
|
---|
[baea398] | 2 | #
|
---|
| 3 | # $Id$
|
---|
[0208570] | 4 | #
|
---|
| 5 | # Read and parse the configuration parameters..
|
---|
| 6 | #
|
---|
[fb6913a] | 7 | set -e
|
---|
| 8 |
|
---|
| 9 | declare -r ConfigFile="configuration"
|
---|
| 10 | declare TARGET
|
---|
| 11 | declare DEP_LEVEL
|
---|
| 12 | declare SUDO
|
---|
| 13 | declare PKGXML
|
---|
| 14 | declare BLFS_XML
|
---|
| 15 | declare VERBOSITY=1
|
---|
| 16 |
|
---|
| 17 | #--------------------------#
|
---|
| 18 | parse_configuration() { #
|
---|
| 19 | #--------------------------#
|
---|
| 20 | local cntr
|
---|
| 21 | local optTARGET
|
---|
[ba72197] | 22 |
|
---|
[fb6913a] | 23 | while [ 0 ]; do
|
---|
| 24 | read || break 1
|
---|
| 25 |
|
---|
| 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..
|
---|
[0208570] | 56 | continue ;;
|
---|
[fb6913a] | 57 | esac
|
---|
| 58 |
|
---|
| 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
|
---|
[fc62e52] | 67 | fi
|
---|
[fb6913a] | 68 | done <$ConfigFile
|
---|
[ba72197] | 69 |
|
---|
[fb6913a] | 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
|
---|
[0208570] | 74 | fi
|
---|
[fb6913a] | 75 |
|
---|
| 76 | TARGET=$optTARGET
|
---|
| 77 | DEP_LEVEL=$optDependency
|
---|
[ba72197] | 78 | SUDO=${SUDO:-n}
|
---|
[fb6913a] | 79 | }
|
---|
| 80 |
|
---|
[740b8c0] | 81 | #--------------------------#
|
---|
| 82 | validate_configuration() { #
|
---|
| 83 | #--------------------------#
|
---|
| 84 | local -r dotSTR=".................."
|
---|
| 85 | local -r PARAM_LIST="TARGET DEP_LEVEL SUDO PRINT_SERVER MAIL_SERVER GHOSTSCRIPT KBR5 X11"
|
---|
| 86 | local -r PARAM_VALS='${config_param}${dotSTR:${#config_param}} ${L_arrow}${BOLD}${!config_param}${OFF}${R_arrow}'
|
---|
| 87 | local config_param
|
---|
| 88 |
|
---|
| 89 | for config_param in ${PARAM_LIST}; do
|
---|
| 90 | echo -e "`eval echo $PARAM_VALS`"
|
---|
| 91 | done
|
---|
| 92 | }
|
---|
[0208570] | 93 |
|
---|
| 94 | #
|
---|
| 95 | # Regenerate the META-package dependencies from the configuration file
|
---|
| 96 | #
|
---|
[fb6913a] | 97 | #--------------------------#
|
---|
| 98 | regenerate_deps() { #
|
---|
| 99 | #--------------------------#
|
---|
| 100 |
|
---|
| 101 | rm -f libs/*.dep-MOD
|
---|
| 102 | while [ 0 ]; do
|
---|
| 103 | read || break 1
|
---|
| 104 | case ${REPLY} in
|
---|
| 105 | \#* | '') continue ;;
|
---|
| 106 | esac
|
---|
[fc62e52] | 107 |
|
---|
[0208570] | 108 | # Drop the "=y"
|
---|
[fb6913a] | 109 | REPLY=${REPLY%=*}
|
---|
| 110 | if [[ "${REPLY}" =~ "^DEP_" ]]; then
|
---|
| 111 | META_PACKAGE=$(echo $REPLY | cut -d "_" -f2 | tr [A-Z] [a-z])
|
---|
| 112 | DEP_FNAME=$(echo $REPLY | cut -d "_" -f3)
|
---|
| 113 | echo "${DEP_FNAME}" >>libs/${META_PACKAGE}.dep-MOD
|
---|
| 114 | fi
|
---|
[0208570] | 115 |
|
---|
[fb6913a] | 116 | done <$ConfigFile
|
---|
| 117 | #
|
---|
| 118 | # Replace to 'old' dependency file with a new one.
|
---|
| 119 | #
|
---|
| 120 | for dst in `ls ./libs/*.dep-MOD 2>/dev/null`; do
|
---|
[910206c] | 121 | cp -vf $dst ${dst%-MOD}
|
---|
[fb6913a] | 122 | done
|
---|
| 123 | }
|
---|
[0208570] | 124 |
|
---|
[7c9aa21] | 125 | #
|
---|
| 126 | # Clean configuration file keeping only global default settings.
|
---|
[aea74cb] | 127 | # That prevent "trying to assign nonexistent symbol" messages
|
---|
| 128 | # and assures that there is no TARGET selected from a previous run
|
---|
[7c9aa21] | 129 | #
|
---|
| 130 | #--------------------------#
|
---|
| 131 | clean_configuration() { #
|
---|
| 132 | #--------------------------#
|
---|
| 133 |
|
---|
| 134 | tail -n 30 configuration > configuration.tmp
|
---|
| 135 | mv configuration.tmp configuration
|
---|
| 136 |
|
---|
| 137 | }
|
---|
[0208570] | 138 |
|
---|
| 139 | #---------------------
|
---|
| 140 | # Constants
|
---|
| 141 | source libs/constants.inc
|
---|
| 142 | [[ $? > 0 ]] && echo -e "\n\tERROR: constants.inc did not load..\n" && exit
|
---|
| 143 |
|
---|
| 144 | #---------------------
|
---|
| 145 | # Dependencies module
|
---|
| 146 | source libs/func_dependencies
|
---|
| 147 | [[ $? > 0 ]] && echo -e "\n\tERROR: func_dependencies did not load..\n" && exit
|
---|
| 148 |
|
---|
| 149 | #---------------------
|
---|
| 150 | # parser module
|
---|
| 151 | source libs/func_parser
|
---|
| 152 | [[ $? > 0 ]] && echo -e "\n\tERROR: func_parser did not load..\n" && exit
|
---|
| 153 |
|
---|
| 154 |
|
---|
| 155 | #------- MAIN --------
|
---|
| 156 | if [[ ! -f packages ]] ; then
|
---|
| 157 | echo -e "\tNo packages file has been found.\n"
|
---|
| 158 | echo -e "\tExecution aborted.\n"
|
---|
| 159 | exit 1
|
---|
| 160 | fi
|
---|
| 161 |
|
---|
[fb6913a] | 162 |
|
---|
| 163 | parse_configuration
|
---|
[740b8c0] | 164 | validate_configuration
|
---|
| 165 | echo "${SD_BORDER}${nl_}"
|
---|
| 166 | echo -n "Are you happy with these settings? yes/no (no): "
|
---|
| 167 | read ANSWER
|
---|
| 168 | if [ x$ANSWER != "xyes" ] ; then
|
---|
| 169 | echo "${nl_}Rerun make and fix your settings.${nl_}"
|
---|
| 170 | exit 1
|
---|
| 171 | fi
|
---|
| 172 | echo "${nl_}${SD_BORDER}${nl_}"
|
---|
[fb6913a] | 173 | regenerate_deps
|
---|
[0208570] | 174 | generate_dependency_tree
|
---|
| 175 | generate_TARGET_xml
|
---|
| 176 | generate_target_book
|
---|
| 177 | create_build_scripts "${SUDO}"
|
---|
[7c9aa21] | 178 | clean_configuration
|
---|