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