source: BLFS/gen_pkg_book.sh@ 3b4399c9

ablfs-more legacy trunk
Last change on this file since 3b4399c9 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
Line 
1#!/bin/bash
2#
3# $Id$
4#
5# Read and parse the configuration parameters..
6#
7set -e
8
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
17LFS_FULL=$3
18if test -z "$LFS_FULL"; then
19 LFS_FULL=${TOPDIR}/lfs-xml/tmp/lfs-full.xml
20fi
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
31declare DEP_LEVEL
32declare SUDO
33declare WRAP_INSTALL
34
35#--------------------------#
36parse_configuration() { #
37#--------------------------#
38 local -i cntr=0
39 local -a optTARGET
40
41 while read; do
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=* | \
52 WRAP_INSTALL=* | \
53 DEL_LA_FILES=* | \
54 STATS=* | \
55 SUDO=* ) eval ${REPLY} # Define/set a global variable..
56 continue ;;
57 esac
58
59 if [[ "${REPLY}" =~ ^CONFIG_ ]]; then
60 echo "$REPLY"
61 optTARGET[$((cntr++))]=$( echo $REPLY | sed -e 's@CONFIG_@@' -e 's@=y@@' )
62 fi
63 done < $ConfigFile
64
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"
68 exit 0
69 fi
70 TARGET=(${optTARGET[*]})
71 DEP_LEVEL=$optDependency
72 SUDO=${SUDO:-n}
73 WRAP_INSTALL=${WRAP_INSTALL:-n}
74 DEL_LA_FILES=${DEL_LA_FILES:-n}
75 STATS=${STATS:-n}
76}
77
78#--------------------------#
79validate_configuration() { #
80#--------------------------#
81 local -r dotSTR=".................."
82 local -r PARAM_LIST="DEP_LEVEL SUDO MAIL_SERVER WRAP_INSTALL DEL_LA_FILES STATS"
83 local -r PARAM_VALS='${config_param}${dotSTR:${#config_param}} ${L_arrow}${BOLD}${!config_param}${OFF}${R_arrow}'
84 local config_param
85 local -i index
86
87 for config_param in ${PARAM_LIST}; do
88 echo -e "`eval echo $PARAM_VALS`"
89 done
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
93}
94
95#
96# Generates the root of the dependency tree
97#
98#--------------------------#
99generate_deps() { #
100#--------------------------#
101
102 local -i index
103 local DepDir=$1
104 rm -f $DepDir/*.{tree,dep}
105 for (( index=0 ; index < ${#TARGET[*]} ; index ++ )); do
106 echo 1 b ${TARGET[${index}]} >> $DepDir/root.dep
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
119tail -n 15 ${ConfigFile} > ${ConfigFile}.tmp
120mv ${ConfigFile}.tmp ${ConfigFile}
121
122}
123
124#---------------------
125# Constants
126source ${LibDir}/constants.inc
127[[ $? > 0 ]] && echo -e "\n\tERROR: constants.inc did not load..\n" && exit
128
129#---------------------
130# Dependencies module
131source ${LibDir}/func_dependencies
132[[ $? > 0 ]] && echo -e "\n\tERROR: func_dependencies did not load..\n" && exit
133
134#------- MAIN --------
135if [[ ! -f ${PackFile} ]] ; then
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_}"
152
153rm -rf $DepDir
154mkdir $DepDir
155generate_deps $DepDir
156pushd $DepDir > /dev/null
157set +e
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)"
175set -e
176popd > /dev/null
177rm -f ${BookXml}
178echo Making XML book
179xsltproc --stringparam list "$LIST" \
180 --stringparam MTA "$MAIL_SERVER" \
181 --stringparam lfsbook "$LFS_FULL" \
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
199 do sed -i 's@\.\./stylesheets@stylesheets@' $ht
200 sed -i 's@\.\./images@images@' $ht
201done
202echo -en "\n\tGenerating the build scripts ...\n"
203rm -rf scripts
204if test $STATS = y; then
205 LIST_STAT="${TARGET[*]}"
206else
207 LIST_STAT=""
208fi
209xsltproc --xinclude --nonet \
210 --stringparam sudo "$SUDO" \
211 --stringparam wrap-install "$WRAP_INSTALL" \
212 --stringparam del-la-files "$DEL_LA_FILES" \
213 --stringparam list-stat "$LIST_STAT" \
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.