[f4ed135] | 1 | #!/bin/bash
|
---|
| 2 | #
|
---|
| 3 | # $Id$
|
---|
| 4 | #
|
---|
| 5 | # Read and parse the configuration parameters..
|
---|
| 6 | #
|
---|
| 7 | set -e
|
---|
| 8 |
|
---|
[e576789] | 9 | TOPDIR=$1
|
---|
| 10 | if test -z "$TOPDIR"; then
|
---|
| 11 | TOPDIR=$(pwd)
|
---|
| 12 | fi
|
---|
| 13 | BLFS_FULL=$2
|
---|
| 14 | if test -z "$BLFS_FULL"; then
|
---|
| 15 | BLFS_FULL=${TOPDIR}/blfs-xml/tmp/blfs-full.xml
|
---|
| 16 | fi
|
---|
| 17 | declare -r ConfigFile="${TOPDIR}/configuration"
|
---|
| 18 | declare DepDir="${TOPDIR}/dependencies"
|
---|
| 19 | declare LibDir="${TOPDIR}/libs"
|
---|
| 20 | declare PackFile="${TOPDIR}/packages.xml"
|
---|
| 21 | declare BookXml="${TOPDIR}/book.xml"
|
---|
| 22 | declare MakeBook="${TOPDIR}/xsl/make_book.xsl"
|
---|
| 23 | declare MakeScripts="${TOPDIR}/xsl/scripts.xsl"
|
---|
| 24 | declare BookHtml="${TOPDIR}/book-html"
|
---|
| 25 | declare BLFS_XML="${TOPDIR}/blfs-xml"
|
---|
| 26 | declare -a TARGET
|
---|
[f4ed135] | 27 | declare DEP_LEVEL
|
---|
| 28 | declare SUDO
|
---|
[e234d23] | 29 | declare WRAP_INSTALL
|
---|
[f4ed135] | 30 |
|
---|
| 31 | #--------------------------#
|
---|
| 32 | parse_configuration() { #
|
---|
| 33 | #--------------------------#
|
---|
[e576789] | 34 | local -i cntr=0
|
---|
| 35 | local -a optTARGET
|
---|
[f4ed135] | 36 |
|
---|
[e576789] | 37 | while read; do
|
---|
[f4ed135] | 38 |
|
---|
| 39 | # Garbage collection
|
---|
| 40 | case ${REPLY} in
|
---|
| 41 | \#* | '') continue ;;
|
---|
| 42 | esac
|
---|
| 43 |
|
---|
| 44 | case "${REPLY}" in
|
---|
| 45 | # Create global variables for these parameters.
|
---|
| 46 | optDependency=* | \
|
---|
| 47 | MAIL_SERVER=* | \
|
---|
[e234d23] | 48 | WRAP_INSTALL=* | \
|
---|
[f4ed135] | 49 | SUDO=* ) eval ${REPLY} # Define/set a global variable..
|
---|
| 50 | continue ;;
|
---|
| 51 | esac
|
---|
| 52 |
|
---|
[a96109a] | 53 | if [[ "${REPLY}" =~ ^CONFIG_ ]]; then
|
---|
[e576789] | 54 | echo "$REPLY"
|
---|
| 55 | optTARGET[$((cntr++))]=$( echo $REPLY | sed -e 's@CONFIG_@@' -e 's@=y@@' )
|
---|
[f4ed135] | 56 | fi
|
---|
[e576789] | 57 | done < $ConfigFile
|
---|
[f4ed135] | 58 |
|
---|
[e576789] | 59 | if (( $cntr == 0 )); then
|
---|
| 60 | echo -e "\n>>> NO TARGET SELECTED.. application terminated"
|
---|
| 61 | echo -e " Run <make> again and select (a) package(s) to build\n"
|
---|
[f4ed135] | 62 | exit 0
|
---|
| 63 | fi
|
---|
[e576789] | 64 | TARGET=(${optTARGET[*]})
|
---|
[f4ed135] | 65 | DEP_LEVEL=$optDependency
|
---|
| 66 | SUDO=${SUDO:-n}
|
---|
[e234d23] | 67 | WRAP_INSTALL=${WRAP_INSTALL:-n}
|
---|
[f4ed135] | 68 | }
|
---|
| 69 |
|
---|
| 70 | #--------------------------#
|
---|
| 71 | validate_configuration() { #
|
---|
| 72 | #--------------------------#
|
---|
| 73 | local -r dotSTR=".................."
|
---|
[e234d23] | 74 | local -r PARAM_LIST="DEP_LEVEL SUDO MAIL_SERVER WRAP_INSTALL"
|
---|
[f4ed135] | 75 | local -r PARAM_VALS='${config_param}${dotSTR:${#config_param}} ${L_arrow}${BOLD}${!config_param}${OFF}${R_arrow}'
|
---|
| 76 | local config_param
|
---|
[e576789] | 77 | local -i index
|
---|
[f4ed135] | 78 |
|
---|
| 79 | for config_param in ${PARAM_LIST}; do
|
---|
| 80 | echo -e "`eval echo $PARAM_VALS`"
|
---|
| 81 | done
|
---|
[e576789] | 82 | for (( index=0 ; index < ${#TARGET[*]} ; index ++ )); do
|
---|
| 83 | echo -e "TARGET${index}${dotSTR:6} ${L_arrow}${BOLD}${TARGET[${index}]}${OFF}${R_arrow}"
|
---|
| 84 | done
|
---|
[f4ed135] | 85 | }
|
---|
| 86 |
|
---|
| 87 | #
|
---|
[e576789] | 88 | # Generates the root of the dependency tree
|
---|
[f4ed135] | 89 | #
|
---|
| 90 | #--------------------------#
|
---|
[e576789] | 91 | generate_deps() { #
|
---|
[f4ed135] | 92 | #--------------------------#
|
---|
| 93 |
|
---|
[e576789] | 94 | local -i index
|
---|
| 95 | local DepDir=$1
|
---|
[7dc8595] | 96 | rm -f $DepDir/*.{o,}dep
|
---|
[e576789] | 97 | for (( index=0 ; index < ${#TARGET[*]} ; index ++ )); do
|
---|
[7dc8595] | 98 | echo 1 ${TARGET[${index}]} >> $DepDir/root.odep
|
---|
[f4ed135] | 99 | done
|
---|
[7dc8595] | 100 | echo 1 > $DepDir/root.dep
|
---|
| 101 | echo 1 >> $DepDir/root.dep
|
---|
| 102 | cat $DepDir/root.odep >> $DepDir/root.dep
|
---|
[f4ed135] | 103 | }
|
---|
| 104 |
|
---|
| 105 | #
|
---|
| 106 | # Clean configuration file keeping only global default settings.
|
---|
| 107 | # That prevent "trying to assign nonexistent symbol" messages
|
---|
| 108 | # and assures that there is no TARGET selected from a previous run
|
---|
| 109 | #
|
---|
| 110 | #--------------------------#
|
---|
| 111 | clean_configuration() { #
|
---|
| 112 | #--------------------------#
|
---|
| 113 |
|
---|
[e576789] | 114 | tail -n 15 ${ConfigFile} > ${ConfigFile}.tmp
|
---|
| 115 | mv ${ConfigFile}.tmp ${ConfigFile}
|
---|
[f4ed135] | 116 |
|
---|
| 117 | }
|
---|
| 118 |
|
---|
| 119 | #---------------------
|
---|
| 120 | # Constants
|
---|
[e576789] | 121 | source ${LibDir}/constants.inc
|
---|
[f4ed135] | 122 | [[ $? > 0 ]] && echo -e "\n\tERROR: constants.inc did not load..\n" && exit
|
---|
| 123 |
|
---|
| 124 | #---------------------
|
---|
| 125 | # Dependencies module
|
---|
[e576789] | 126 | source ${LibDir}/func_dependencies
|
---|
[f4ed135] | 127 | [[ $? > 0 ]] && echo -e "\n\tERROR: func_dependencies did not load..\n" && exit
|
---|
| 128 |
|
---|
| 129 | #------- MAIN --------
|
---|
[e576789] | 130 | if [[ ! -f ${PackFile} ]] ; then
|
---|
[f4ed135] | 131 | echo -e "\tNo packages file has been found.\n"
|
---|
| 132 | echo -e "\tExecution aborted.\n"
|
---|
| 133 | exit 1
|
---|
| 134 | fi
|
---|
| 135 |
|
---|
| 136 |
|
---|
| 137 | parse_configuration
|
---|
| 138 | validate_configuration
|
---|
| 139 | echo "${SD_BORDER}${nl_}"
|
---|
| 140 | echo -n "Are you happy with these settings? yes/no (no): "
|
---|
| 141 | read ANSWER
|
---|
| 142 | if [ x$ANSWER != "xyes" ] ; then
|
---|
| 143 | echo "${nl_}Rerun make and fix your settings.${nl_}"
|
---|
| 144 | exit 1
|
---|
| 145 | fi
|
---|
| 146 | echo "${nl_}${SD_BORDER}${nl_}"
|
---|
[e576789] | 147 |
|
---|
| 148 | rm -rf $DepDir
|
---|
| 149 | mkdir $DepDir
|
---|
| 150 | generate_deps $DepDir
|
---|
| 151 | pushd $DepDir > /dev/null
|
---|
| 152 | set +e
|
---|
[7dc8595] | 153 | generate_dependency_tree root.dep 1
|
---|
[e576789] | 154 | echo
|
---|
| 155 | LIST="$(tree_browse root.dep)"
|
---|
| 156 | set -e
|
---|
| 157 | popd > /dev/null
|
---|
| 158 | rm -f ${BookXml}
|
---|
| 159 | echo Making XML book
|
---|
| 160 | xsltproc --stringparam list "$LIST" \
|
---|
| 161 | -o ${BookXml} \
|
---|
| 162 | ${MakeBook} \
|
---|
| 163 | $BLFS_FULL
|
---|
| 164 | echo "making HTML book (may take some time...)"
|
---|
| 165 | xsltproc -o ${BookHtml}/ \
|
---|
| 166 | -stringparam chunk.quietly 1 \
|
---|
| 167 | ${BLFS_XML}/stylesheets/blfs-chunked.xsl \
|
---|
| 168 | ${BookXml}
|
---|
| 169 | if [ ! -d ${BookHtml}/stylesheets ]
|
---|
| 170 | then mkdir -p ${BookHtml}/stylesheets
|
---|
| 171 | cp ${BLFS_XML}/stylesheets/lfs-xsl/*.css ${BookHtml}/stylesheets
|
---|
| 172 | fi
|
---|
| 173 | if [ ! -d ${BookHtml}/images ]
|
---|
| 174 | then mkdir -p ${BookHtml}/images
|
---|
| 175 | cp ${BLFS_XML}/images/*.png ${BookHtml}/images
|
---|
| 176 | fi
|
---|
| 177 | for ht in ${BookHtml}/*.html
|
---|
[c5650f9] | 178 | do sed -i 's@\.\./stylesheets@stylesheets@' $ht
|
---|
| 179 | sed -i 's@\.\./images@images@' $ht
|
---|
[e576789] | 180 | done
|
---|
| 181 | echo -en "\n\tGenerating the build scripts ...\n"
|
---|
| 182 | rm -rf scripts
|
---|
| 183 | xsltproc --xinclude --nonet \
|
---|
| 184 | --stringparam sudo $SUDO \
|
---|
[e234d23] | 185 | --stringparam wrap-install $WRAP_INSTALL \
|
---|
[e576789] | 186 | -o ./scripts/ ${MakeScripts} \
|
---|
| 187 | ${BookXml}
|
---|
| 188 | # Make the scripts executable.
|
---|
| 189 | chmod -R +x scripts
|
---|
| 190 | echo -e "done\n"
|
---|
| 191 |
|
---|
| 192 | #clean_configuration
|
---|