source: BLFS/gen_pkg_book.sh@ bc2f591

ablfs-more legacy trunk
Last change on this file since bc2f591 was 625cb14, checked in by Pierre Labastie <pierre@…>, 6 years ago

Add possibility to automate bash shell startup files, vimrc, and rng.
This adds a new variable to the configuration (LANGUAGE).
Also automate the generation of various <replaceable> instructions

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