source: BLFS/gen_pkg_book.sh@ 8825e69

ablfs-more trunk
Last change on this file since 8825e69 was b734bfb, checked in by Pierre Labastie <pierre.labastie@…>, 3 years ago

install_blfs: update trackdir also in gen_pkg_book.sh

Now gen_pkf_book.sh depends on trackfile. This can be passed
as an argument, but to ease calling it standalone, we need to
set the default to the actual file used.

  • Property mode set to 100755
File size: 8.5 KB
RevLine 
[f4ed135]1#!/bin/bash
2#
3# Read and parse the configuration parameters..
4#
5set -e
6
[b8e5cad]7TRACKFILE=$1
8if test -z "$TRACKFILE"; then
[b734bfb]9 TRACKFILE=tracking-dir/instpkg.xml
[b8e5cad]10fi
11TOPDIR=$2
[e576789]12if test -z "$TOPDIR"; then
13 TOPDIR=$(pwd)
14fi
[b8e5cad]15BLFS_FULL=$3
[e576789]16if test -z "$BLFS_FULL"; then
17 BLFS_FULL=${TOPDIR}/blfs-xml/tmp/blfs-full.xml
18fi
[b8e5cad]19LFS_FULL=$4
[607ef21]20if test -z "$LFS_FULL"; then
21 LFS_FULL=${TOPDIR}/lfs-xml/tmp/lfs-full.xml
22fi
[e576789]23declare -r ConfigFile="${TOPDIR}/configuration"
24declare DepDir="${TOPDIR}/dependencies"
25declare LibDir="${TOPDIR}/libs"
26declare PackFile="${TOPDIR}/packages.xml"
27declare BookXml="${TOPDIR}/book.xml"
28declare MakeBook="${TOPDIR}/xsl/make_book.xsl"
[a690d42]29declare GetVersion="${TOPDIR}/xsl/get_version.xsl"
[e576789]30declare MakeScripts="${TOPDIR}/xsl/scripts.xsl"
31declare BookHtml="${TOPDIR}/book-html"
32declare BLFS_XML="${TOPDIR}/blfs-xml"
33declare -a TARGET
[f4ed135]34declare DEP_LEVEL
35declare SUDO
[625cb14]36declare LANGUAGE
[945ccaa]37declare WRAP_INSTALL
[9daa202]38declare PACK_INSTALL
[625cb14]39declare DEL_LA_FILES
40declare STATS
[9daa202]41declare SRC_ARCHIVE
42declare SRC_SUBDIRS
43declare BUILD_ROOT
44declare BUILD_SUBDIRS
45declare KEEP_FILES
46declare -i JOBS
47declare CFG_CFLAGS
48declare CFG_CXXFLAGS
49declare CFG_LDFLAGS
[f4ed135]50
51#--------------------------#
52parse_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#--------------------------#
108validate_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]128generate_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#--------------------------#
145clean_configuration() { #
146#--------------------------#
147
[e576789]148tail -n 15 ${ConfigFile} > ${ConfigFile}.tmp
149mv ${ConfigFile}.tmp ${ConfigFile}
[f4ed135]150
151}
152
153#---------------------
154# Constants
[e576789]155source ${LibDir}/constants.inc
[f4ed135]156[[ $? > 0 ]] && echo -e "\n\tERROR: constants.inc did not load..\n" && exit
157
158#---------------------
159# Dependencies module
[e576789]160source ${LibDir}/func_dependencies
[f4ed135]161[[ $? > 0 ]] && echo -e "\n\tERROR: func_dependencies did not load..\n" && exit
162
163#------- MAIN --------
[e576789]164if [[ ! -f ${PackFile} ]] ; then
[f4ed135]165 echo -e "\tNo packages file has been found.\n"
166 echo -e "\tExecution aborted.\n"
167 exit 1
168fi
169
170
171parse_configuration
172validate_configuration
173echo "${SD_BORDER}${nl_}"
174echo -n "Are you happy with these settings? yes/no (no): "
175read ANSWER
176if [ x$ANSWER != "xyes" ] ; then
177 echo "${nl_}Rerun make and fix your settings.${nl_}"
178 exit 1
179fi
180echo "${nl_}${SD_BORDER}${nl_}"
[e576789]181
182rm -rf $DepDir
183mkdir $DepDir
184generate_deps $DepDir
185pushd $DepDir > /dev/null
186set +e
[2140f22]187generate_subgraph root.dep 1 1 b
188echo -e "\n${SD_BORDER}"
189echo Graph contains $(ls |wc -l) nodes
190echo -e "${SD_BORDER}"
191echo Cleaning subgraph...
192clean_subgraph
193echo done
194echo Generating the tree
195echo 1 > root.tree
196echo 1 >> root.tree
197cat root.dep >> root.tree
198generate_dependency_tree root.tree 1
199echo -e "\n${SD_BORDER}"
[a690d42]200echo Generating the ordered full dependency list
201FULL_LIST="$(tree_browse root.tree)"
202set -e
203popd > /dev/null
204#echo "$FULL_LIST"
[2140f22]205#echo -e \\n provisional end...
206#exit
207echo Generating the ordered package list
[a690d42]208LIST=
209while read p; do
[7ae9774]210 if [ "$p" != "${p%-pass1}" ]; then
211# If the pass2 is installed, no need for pass1. We get its
212# installed version from TRACKFILE; We could use PackFile, but
213# the test would be slightly more complicated.
214echo Treating $p
215 pass2_v=$(xsltproc --stringparam package "${p%-pass1}" \
216 $GetVersion $TRACKFILE | head -n1)
217echo Found pass2_v=$pass2_v
218 if [ -n "$pass2_v" ]; then continue; fi
219# We need to get the installed version from TRACKFILE
220 inst_v=$(xsltproc --stringparam package "$p" $GetVersion $TRACKFILE | \
221 head -n1)
222 if [ -z "$inst_v" ]; then inst_v=0; fi
223echo Found inst_v=$inst_v
224# The available version is taken from PackFile
225 avail_v=$(xsltproc --stringparam package "${p%-pass1}" \
226 $GetVersion $PackFile | head -n1)
227echo Found avail_v=$avail_v
228 versions="$avail_v
229$inst_v"
230 echo which gives versions=$versions
231 else
232 versions=$(xsltproc --stringparam package "$p" $GetVersion $PackFile)
233 fi
[a690d42]234 if [ "$versions" != "$(sort -V <<<$versions)" ]; then
235 LIST="$LIST $p"
236 fi
237done <<<$FULL_LIST
238#echo \""$LIST"\"
239#echo -e \\n provisional end...
240#exit
[e576789]241rm -f ${BookXml}
242echo Making XML book
[607ef21]243xsltproc --stringparam list "$LIST" \
[2140f22]244 --stringparam MTA "$MAIL_SERVER" \
[607ef21]245 --stringparam lfsbook "$LFS_FULL" \
[e576789]246 -o ${BookXml} \
247 ${MakeBook} \
248 $BLFS_FULL
249echo "making HTML book (may take some time...)"
250xsltproc -o ${BookHtml}/ \
251 -stringparam chunk.quietly 1 \
252 ${BLFS_XML}/stylesheets/blfs-chunked.xsl \
253 ${BookXml}
254if [ ! -d ${BookHtml}/stylesheets ]
255 then mkdir -p ${BookHtml}/stylesheets
256 cp ${BLFS_XML}/stylesheets/lfs-xsl/*.css ${BookHtml}/stylesheets
257fi
258if [ ! -d ${BookHtml}/images ]
259 then mkdir -p ${BookHtml}/images
260 cp ${BLFS_XML}/images/*.png ${BookHtml}/images
261fi
262for ht in ${BookHtml}/*.html
[c5650f9]263 do sed -i 's@\.\./stylesheets@stylesheets@' $ht
264 sed -i 's@\.\./images@images@' $ht
[e576789]265done
266echo -en "\n\tGenerating the build scripts ...\n"
267rm -rf scripts
[67c3df4]268if test $STATS = y; then
269 LIST_STAT="${TARGET[*]}"
270else
271 LIST_STAT=""
272fi
[9daa202]273xsltproc --xinclude --nonet \
274 --stringparam language "$LANGUAGE" \
275 --stringparam sudo "$SUDO" \
276 --stringparam wrap-install "$WRAP_INSTALL" \
277 --stringparam pack-install "$PACK_INSTALL" \
278 --stringparam del-la-files "$DEL_LA_FILES" \
279 --stringparam list-stat "$LIST_STAT" \
280 --stringparam src-archive "$SRC_ARCHIVE" \
281 --stringparam src-subdirs "$SRC_SUBDIRS" \
282 --stringparam build-root "$BUILD_ROOT" \
283 --stringparam build-subdirs "$BUILD_SUBDIRS" \
284 --stringparam keep-files "$KEEP_FILES" \
285 --param jobs "$JOBS" \
286 --stringparam cfg-cflags "$CFG_CFLAGS" \
287 --stringparam cfg-cxxflags "$CFG_CXXFLAGS" \
288 --stringparam cfg-ldflags "$CFG_LDFLAGS" \
289 --stringparam fqdn "$(hostname -f)" \
290 --output ./scripts/ \
291 ${MakeScripts} \
[e576789]292 ${BookXml}
293# Make the scripts executable.
294chmod -R +x scripts
295echo -e "done\n"
296
297#clean_configuration
Note: See TracBrowser for help on using the repository browser.