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