source: BLFS/gen_pkg_book.sh@ 8fb1daa

ablfs-more legacy trunk
Last change on this file since 8fb1daa was df1f318, checked in by Pierre Labastie <pierre@…>, 7 years ago

Have the STATS variable displayed in jhalfs-blfs

  • Property mode set to 100755
File size: 5.6 KB
RevLine 
[f4ed135]1#!/bin/bash
2#
3# $Id$
4#
5# Read and parse the configuration parameters..
6#
7set -e
8
[e576789]9TOPDIR=$1
10if test -z "$TOPDIR"; then
11 TOPDIR=$(pwd)
12fi
13BLFS_FULL=$2
14if test -z "$BLFS_FULL"; then
15 BLFS_FULL=${TOPDIR}/blfs-xml/tmp/blfs-full.xml
16fi
[607ef21]17LFS_FULL=$3
18if test -z "$LFS_FULL"; then
19 LFS_FULL=${TOPDIR}/lfs-xml/tmp/lfs-full.xml
20fi
[e576789]21declare -r ConfigFile="${TOPDIR}/configuration"
22declare DepDir="${TOPDIR}/dependencies"
23declare LibDir="${TOPDIR}/libs"
24declare PackFile="${TOPDIR}/packages.xml"
25declare BookXml="${TOPDIR}/book.xml"
26declare MakeBook="${TOPDIR}/xsl/make_book.xsl"
27declare MakeScripts="${TOPDIR}/xsl/scripts.xsl"
28declare BookHtml="${TOPDIR}/book-html"
29declare BLFS_XML="${TOPDIR}/blfs-xml"
30declare -a TARGET
[f4ed135]31declare DEP_LEVEL
32declare SUDO
[945ccaa]33declare WRAP_INSTALL
[f4ed135]34
35#--------------------------#
36parse_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#--------------------------#
79validate_configuration() { #
80#--------------------------#
81 local -r dotSTR=".................."
[df1f318]82 local -r PARAM_LIST="DEP_LEVEL SUDO MAIL_SERVER WRAP_INSTALL DEL_LA_FILES STATS"
[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]99generate_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#--------------------------#
116clean_configuration() { #
117#--------------------------#
118
[e576789]119tail -n 15 ${ConfigFile} > ${ConfigFile}.tmp
120mv ${ConfigFile}.tmp ${ConfigFile}
[f4ed135]121
122}
123
124#---------------------
125# Constants
[e576789]126source ${LibDir}/constants.inc
[f4ed135]127[[ $? > 0 ]] && echo -e "\n\tERROR: constants.inc did not load..\n" && exit
128
129#---------------------
130# Dependencies module
[e576789]131source ${LibDir}/func_dependencies
[f4ed135]132[[ $? > 0 ]] && echo -e "\n\tERROR: func_dependencies did not load..\n" && exit
133
134#------- MAIN --------
[e576789]135if [[ ! -f ${PackFile} ]] ; then
[f4ed135]136 echo -e "\tNo packages file has been found.\n"
137 echo -e "\tExecution aborted.\n"
138 exit 1
139fi
140
141
142parse_configuration
143validate_configuration
144echo "${SD_BORDER}${nl_}"
145echo -n "Are you happy with these settings? yes/no (no): "
146read ANSWER
147if [ x$ANSWER != "xyes" ] ; then
148 echo "${nl_}Rerun make and fix your settings.${nl_}"
149 exit 1
150fi
151echo "${nl_}${SD_BORDER}${nl_}"
[e576789]152
153rm -rf $DepDir
154mkdir $DepDir
155generate_deps $DepDir
156pushd $DepDir > /dev/null
157set +e
[2140f22]158generate_subgraph root.dep 1 1 b
159echo -e "\n${SD_BORDER}"
160echo Graph contains $(ls |wc -l) nodes
161echo -e "${SD_BORDER}"
162echo Cleaning subgraph...
163clean_subgraph
164echo done
165echo Generating the tree
166echo 1 > root.tree
167echo 1 >> root.tree
168cat root.dep >> root.tree
169generate_dependency_tree root.tree 1
170echo -e "\n${SD_BORDER}"
171#echo -e \\n provisional end...
172#exit
173echo Generating the ordered package list
174LIST="$(tree_browse root.tree)"
[e576789]175set -e
176popd > /dev/null
177rm -f ${BookXml}
178echo Making XML book
[607ef21]179xsltproc --stringparam list "$LIST" \
[2140f22]180 --stringparam MTA "$MAIL_SERVER" \
[607ef21]181 --stringparam lfsbook "$LFS_FULL" \
[e576789]182 -o ${BookXml} \
183 ${MakeBook} \
184 $BLFS_FULL
185echo "making HTML book (may take some time...)"
186xsltproc -o ${BookHtml}/ \
187 -stringparam chunk.quietly 1 \
188 ${BLFS_XML}/stylesheets/blfs-chunked.xsl \
189 ${BookXml}
190if [ ! -d ${BookHtml}/stylesheets ]
191 then mkdir -p ${BookHtml}/stylesheets
192 cp ${BLFS_XML}/stylesheets/lfs-xsl/*.css ${BookHtml}/stylesheets
193fi
194if [ ! -d ${BookHtml}/images ]
195 then mkdir -p ${BookHtml}/images
196 cp ${BLFS_XML}/images/*.png ${BookHtml}/images
197fi
198for ht in ${BookHtml}/*.html
[c5650f9]199 do sed -i 's@\.\./stylesheets@stylesheets@' $ht
200 sed -i 's@\.\./images@images@' $ht
[e576789]201done
202echo -en "\n\tGenerating the build scripts ...\n"
203rm -rf scripts
[67c3df4]204if test $STATS = y; then
205 LIST_STAT="${TARGET[*]}"
206else
207 LIST_STAT=""
208fi
[e576789]209xsltproc --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.
217chmod -R +x scripts
218echo -e "done\n"
219
220#clean_configuration
Note: See TracBrowser for help on using the repository browser.