source: BLFS/gen_pkg_book.sh@ a6fbc65

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

[BLFS] Ticket #1730: Do not forget "-pass1" packages

  • Property mode set to 100755
File size: 7.5 KB
Line 
1#!/bin/bash
2#
3# Read and parse the configuration parameters..
4#
5set -e
6
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
15LFS_FULL=$3
16if test -z "$LFS_FULL"; then
17 LFS_FULL=${TOPDIR}/lfs-xml/tmp/lfs-full.xml
18fi
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 GetVersion="${TOPDIR}/xsl/get_version.xsl"
26declare MakeScripts="${TOPDIR}/xsl/scripts.xsl"
27declare BookHtml="${TOPDIR}/book-html"
28declare BLFS_XML="${TOPDIR}/blfs-xml"
29declare -a TARGET
30declare DEP_LEVEL
31declare SUDO
32declare LANGUAGE
33declare WRAP_INSTALL
34declare PACK_INSTALL
35declare DEL_LA_FILES
36declare STATS
37declare SRC_ARCHIVE
38declare SRC_SUBDIRS
39declare BUILD_ROOT
40declare BUILD_SUBDIRS
41declare KEEP_FILES
42declare -i JOBS
43declare CFG_CFLAGS
44declare CFG_CXXFLAGS
45declare CFG_LDFLAGS
46
47#--------------------------#
48parse_configuration() { #
49#--------------------------#
50 local -i cntr=0
51 local -a optTARGET
52
53 while read; do
54
55 # Garbage collection
56 case ${REPLY} in
57 \#* | '') continue ;;
58 esac
59
60 case "${REPLY}" in
61 # Create global variables for these parameters.
62 optDependency=* | \
63 MAIL_SERVER=* | \
64 WRAP_INSTALL=* | \
65 PACK_INSTALL=* | \
66 DEL_LA_FILES=* | \
67 STATS=* | \
68 LANGUAGE=* | \
69 SUDO=* | \
70 SRC_ARCHIVE=* | \
71 SRC_SUBDIRS=* | \
72 BUILD_ROOT=* | \
73 BUILD_SUBDIRS=* | \
74 KEEP_FILES=* | \
75 JOBS=* | \
76 CFG_CFLAGS=* | \
77 CFG_CXXFLAGS=* | \
78 CFG_LDFLAGS=* ) eval ${REPLY} # Define/set a global variable..
79 continue ;;
80 esac
81
82 if [[ "${REPLY}" =~ ^CONFIG_ ]]; then
83 echo "$REPLY"
84 optTARGET[$((cntr++))]=$( echo $REPLY | sed -e 's@CONFIG_@@' -e 's@=y@@' )
85 fi
86 done < $ConfigFile
87
88 if (( $cntr == 0 )); then
89 echo -e "\n>>> NO TARGET SELECTED.. application terminated"
90 echo -e " Run <make> again and select (a) package(s) to build\n"
91 exit 0
92 fi
93 TARGET=(${optTARGET[*]})
94 DEP_LEVEL=$optDependency
95 SUDO=${SUDO:-n}
96 WRAP_INSTALL=${WRAP_INSTALL:-n}
97 DEL_LA_FILES=${DEL_LA_FILES:-n}
98 STATS=${STATS:-n}
99# Other boolean variables are supposed to be either set or unset. Their values
100# are not relevant
101}
102
103#--------------------------#
104validate_configuration() { #
105#--------------------------#
106 local -r dotSTR=".................."
107 local -r PARAM_LIST="DEP_LEVEL SUDO LANGUAGE MAIL_SERVER WRAP_INSTALL PACK_INSTALL DEL_LA_FILES STATS SRC_ARCHIVE SRC_SUBDIRS BUILD_ROOT BUILD_SUBDIRS KEEP_FILES JOBS CFG_CFLAGS CFG_CXXFLAGS CFG_LDFLAGS"
108 local -r PARAM_VALS='${config_param}${dotSTR:${#config_param}} ${L_arrow}${BOLD}${!config_param}${OFF}${R_arrow}'
109 local config_param
110 local -i index
111
112 for config_param in ${PARAM_LIST}; do
113 echo -e "`eval echo $PARAM_VALS`"
114 done
115 for (( index=0 ; index < ${#TARGET[*]} ; index ++ )); do
116 echo -e "TARGET${index}${dotSTR:6} ${L_arrow}${BOLD}${TARGET[${index}]}${OFF}${R_arrow}"
117 done
118}
119
120#
121# Generates the root of the dependency tree
122#
123#--------------------------#
124generate_deps() { #
125#--------------------------#
126
127 local -i index
128 local DepDir=$1
129 rm -f $DepDir/*.{tree,dep}
130 for (( index=0 ; index < ${#TARGET[*]} ; index ++ )); do
131 echo 1 b ${TARGET[${index}]} >> $DepDir/root.dep
132 done
133}
134
135#
136# Clean configuration file keeping only global default settings.
137# That prevent "trying to assign nonexistent symbol" messages
138# and assures that there is no TARGET selected from a previous run
139#
140#--------------------------#
141clean_configuration() { #
142#--------------------------#
143
144tail -n 15 ${ConfigFile} > ${ConfigFile}.tmp
145mv ${ConfigFile}.tmp ${ConfigFile}
146
147}
148
149#---------------------
150# Constants
151source ${LibDir}/constants.inc
152[[ $? > 0 ]] && echo -e "\n\tERROR: constants.inc did not load..\n" && exit
153
154#---------------------
155# Dependencies module
156source ${LibDir}/func_dependencies
157[[ $? > 0 ]] && echo -e "\n\tERROR: func_dependencies did not load..\n" && exit
158
159#------- MAIN --------
160if [[ ! -f ${PackFile} ]] ; then
161 echo -e "\tNo packages file has been found.\n"
162 echo -e "\tExecution aborted.\n"
163 exit 1
164fi
165
166
167parse_configuration
168validate_configuration
169echo "${SD_BORDER}${nl_}"
170echo -n "Are you happy with these settings? yes/no (no): "
171read ANSWER
172if [ x$ANSWER != "xyes" ] ; then
173 echo "${nl_}Rerun make and fix your settings.${nl_}"
174 exit 1
175fi
176echo "${nl_}${SD_BORDER}${nl_}"
177
178rm -rf $DepDir
179mkdir $DepDir
180generate_deps $DepDir
181pushd $DepDir > /dev/null
182set +e
183generate_subgraph root.dep 1 1 b
184echo -e "\n${SD_BORDER}"
185echo Graph contains $(ls |wc -l) nodes
186echo -e "${SD_BORDER}"
187echo Cleaning subgraph...
188clean_subgraph
189echo done
190echo Generating the tree
191echo 1 > root.tree
192echo 1 >> root.tree
193cat root.dep >> root.tree
194generate_dependency_tree root.tree 1
195echo -e "\n${SD_BORDER}"
196echo Generating the ordered full dependency list
197FULL_LIST="$(tree_browse root.tree)"
198set -e
199popd > /dev/null
200#echo "$FULL_LIST"
201#echo -e \\n provisional end...
202#exit
203echo Generating the ordered package list
204LIST=
205while read p; do
206 p=${p%-pass1}
207 versions=$(xsltproc --stringparam package "$p" $GetVersion $PackFile)
208 if [ "$versions" != "$(sort -V <<<$versions)" ]; then
209 LIST="$LIST $p"
210 fi
211done <<<$FULL_LIST
212#echo \""$LIST"\"
213#echo -e \\n provisional end...
214#exit
215rm -f ${BookXml}
216echo Making XML book
217xsltproc --stringparam list "$LIST" \
218 --stringparam MTA "$MAIL_SERVER" \
219 --stringparam lfsbook "$LFS_FULL" \
220 -o ${BookXml} \
221 ${MakeBook} \
222 $BLFS_FULL
223echo "making HTML book (may take some time...)"
224xsltproc -o ${BookHtml}/ \
225 -stringparam chunk.quietly 1 \
226 ${BLFS_XML}/stylesheets/blfs-chunked.xsl \
227 ${BookXml}
228if [ ! -d ${BookHtml}/stylesheets ]
229 then mkdir -p ${BookHtml}/stylesheets
230 cp ${BLFS_XML}/stylesheets/lfs-xsl/*.css ${BookHtml}/stylesheets
231fi
232if [ ! -d ${BookHtml}/images ]
233 then mkdir -p ${BookHtml}/images
234 cp ${BLFS_XML}/images/*.png ${BookHtml}/images
235fi
236for ht in ${BookHtml}/*.html
237 do sed -i 's@\.\./stylesheets@stylesheets@' $ht
238 sed -i 's@\.\./images@images@' $ht
239done
240echo -en "\n\tGenerating the build scripts ...\n"
241rm -rf scripts
242if test $STATS = y; then
243 LIST_STAT="${TARGET[*]}"
244else
245 LIST_STAT=""
246fi
247xsltproc --xinclude --nonet \
248 --stringparam language "$LANGUAGE" \
249 --stringparam sudo "$SUDO" \
250 --stringparam wrap-install "$WRAP_INSTALL" \
251 --stringparam pack-install "$PACK_INSTALL" \
252 --stringparam del-la-files "$DEL_LA_FILES" \
253 --stringparam list-stat "$LIST_STAT" \
254 --stringparam src-archive "$SRC_ARCHIVE" \
255 --stringparam src-subdirs "$SRC_SUBDIRS" \
256 --stringparam build-root "$BUILD_ROOT" \
257 --stringparam build-subdirs "$BUILD_SUBDIRS" \
258 --stringparam keep-files "$KEEP_FILES" \
259 --param jobs "$JOBS" \
260 --stringparam cfg-cflags "$CFG_CFLAGS" \
261 --stringparam cfg-cxxflags "$CFG_CXXFLAGS" \
262 --stringparam cfg-ldflags "$CFG_LDFLAGS" \
263 --stringparam fqdn "$(hostname -f)" \
264 --output ./scripts/ \
265 ${MakeScripts} \
266 ${BookXml}
267# Make the scripts executable.
268chmod -R +x scripts
269echo -e "done\n"
270
271#clean_configuration
Note: See TracBrowser for help on using the repository browser.