source: BLFS/gen_pkg_book.sh@ 60e539b

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

Remove KBLAYOUT setting

it is not needed anymore by any book.

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