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