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