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