source: BLFS/gen_pkg_book.sh@ 82eacf5

ablfs-more legacy trunk
Last change on this file since 82eacf5 was 30732c6a, checked in by Pierre Labastie <pierre@…>, 5 years ago

Process layout replaceable

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