source: BLFS/gen_pkg_book.sh@ 6f74ca1

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

Process layout replaceable

  • Property mode set to 100755
File size: 5.9 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 LANGUAGE
34declare KBLAYOUT
35declare WRAP_INSTALL
36declare DEL_LA_FILES
37declare STATS
38
39#--------------------------#
40parse_configuration() { #
41#--------------------------#
42 local -i cntr=0
43 local -a optTARGET
44
45 while read; do
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=* | \
56 WRAP_INSTALL=* | \
57 DEL_LA_FILES=* | \
58 STATS=* | \
59 LANGUAGE=* | \
60 KBLAYOUT=* | \
61 SUDO=* ) eval ${REPLY} # Define/set a global variable..
62 continue ;;
63 esac
64
65 if [[ "${REPLY}" =~ ^CONFIG_ ]]; then
66 echo "$REPLY"
67 optTARGET[$((cntr++))]=$( echo $REPLY | sed -e 's@CONFIG_@@' -e 's@=y@@' )
68 fi
69 done < $ConfigFile
70
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"
74 exit 0
75 fi
76 TARGET=(${optTARGET[*]})
77 DEP_LEVEL=$optDependency
78 SUDO=${SUDO:-n}
79 WRAP_INSTALL=${WRAP_INSTALL:-n}
80 DEL_LA_FILES=${DEL_LA_FILES:-n}
81 STATS=${STATS:-n}
82}
83
84#--------------------------#
85validate_configuration() { #
86#--------------------------#
87 local -r dotSTR=".................."
88 local -r PARAM_LIST="DEP_LEVEL SUDO LANGUAGE KBLAYOUT MAIL_SERVER WRAP_INSTALL DEL_LA_FILES STATS"
89 local -r PARAM_VALS='${config_param}${dotSTR:${#config_param}} ${L_arrow}${BOLD}${!config_param}${OFF}${R_arrow}'
90 local config_param
91 local -i index
92
93 for config_param in ${PARAM_LIST}; do
94 echo -e "`eval echo $PARAM_VALS`"
95 done
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
99}
100
101#
102# Generates the root of the dependency tree
103#
104#--------------------------#
105generate_deps() { #
106#--------------------------#
107
108 local -i index
109 local DepDir=$1
110 rm -f $DepDir/*.{tree,dep}
111 for (( index=0 ; index < ${#TARGET[*]} ; index ++ )); do
112 echo 1 b ${TARGET[${index}]} >> $DepDir/root.dep
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
125tail -n 15 ${ConfigFile} > ${ConfigFile}.tmp
126mv ${ConfigFile}.tmp ${ConfigFile}
127
128}
129
130#---------------------
131# Constants
132source ${LibDir}/constants.inc
133[[ $? > 0 ]] && echo -e "\n\tERROR: constants.inc did not load..\n" && exit
134
135#---------------------
136# Dependencies module
137source ${LibDir}/func_dependencies
138[[ $? > 0 ]] && echo -e "\n\tERROR: func_dependencies did not load..\n" && exit
139
140#------- MAIN --------
141if [[ ! -f ${PackFile} ]] ; then
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_}"
158
159rm -rf $DepDir
160mkdir $DepDir
161generate_deps $DepDir
162pushd $DepDir > /dev/null
163set +e
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)"
181set -e
182popd > /dev/null
183rm -f ${BookXml}
184echo Making XML book
185xsltproc --stringparam list "$LIST" \
186 --stringparam MTA "$MAIL_SERVER" \
187 --stringparam lfsbook "$LFS_FULL" \
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
205 do sed -i 's@\.\./stylesheets@stylesheets@' $ht
206 sed -i 's@\.\./images@images@' $ht
207done
208echo -en "\n\tGenerating the build scripts ...\n"
209rm -rf scripts
210if test $STATS = y; then
211 LIST_STAT="${TARGET[*]}"
212else
213 LIST_STAT=""
214fi
215xsltproc --xinclude --nonet \
216 --stringparam sudo "$SUDO" \
217 --stringparam wrap-install "$WRAP_INSTALL" \
218 --stringparam del-la-files "$DEL_LA_FILES" \
219 --stringparam list-stat "$LIST_STAT" \
220 --stringparam language "$LANGUAGE" \
221 --stringparam xkblayout "$KBLAYOUT" \
222 --stringparam fqdn "$(hostname -f)" \
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.