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