source: BLFS/gen_pkg_book.sh@ a690d42

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

[BLFS] Ticket #1730: clean the dependency list

With the new xsl/dependencies.xsl, the full dependency list is generated.
We compare the version and installed version gotten from packages.xml
using xsl/get_version.xsl and only install if the installed version is
lower than the available version. Since the installed version returned
by get_version.xsl for a non installed package is 0, that version is
always lower than the available version and the package is installed.
Note that if a package does not exist, both versions are empty, and
they compare as equal with our method. So they are never installed...

  • 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 versions=$(xsltproc --stringparam package "$p" $GetVersion $PackFile)
207 if [ "$versions" != "$(sort -V <<<$versions)" ]; then
208 LIST="$LIST $p"
209 fi
210done <<<$FULL_LIST
211#echo \""$LIST"\"
212#echo -e \\n provisional end...
213#exit
214rm -f ${BookXml}
215echo Making XML book
216xsltproc --stringparam list "$LIST" \
217 --stringparam MTA "$MAIL_SERVER" \
218 --stringparam lfsbook "$LFS_FULL" \
219 -o ${BookXml} \
220 ${MakeBook} \
221 $BLFS_FULL
222echo "making HTML book (may take some time...)"
223xsltproc -o ${BookHtml}/ \
224 -stringparam chunk.quietly 1 \
225 ${BLFS_XML}/stylesheets/blfs-chunked.xsl \
226 ${BookXml}
227if [ ! -d ${BookHtml}/stylesheets ]
228 then mkdir -p ${BookHtml}/stylesheets
229 cp ${BLFS_XML}/stylesheets/lfs-xsl/*.css ${BookHtml}/stylesheets
230fi
231if [ ! -d ${BookHtml}/images ]
232 then mkdir -p ${BookHtml}/images
233 cp ${BLFS_XML}/images/*.png ${BookHtml}/images
234fi
235for ht in ${BookHtml}/*.html
236 do sed -i 's@\.\./stylesheets@stylesheets@' $ht
237 sed -i 's@\.\./images@images@' $ht
238done
239echo -en "\n\tGenerating the build scripts ...\n"
240rm -rf scripts
241if test $STATS = y; then
242 LIST_STAT="${TARGET[*]}"
243else
244 LIST_STAT=""
245fi
246xsltproc --xinclude --nonet \
247 --stringparam language "$LANGUAGE" \
248 --stringparam sudo "$SUDO" \
249 --stringparam wrap-install "$WRAP_INSTALL" \
250 --stringparam pack-install "$PACK_INSTALL" \
251 --stringparam del-la-files "$DEL_LA_FILES" \
252 --stringparam list-stat "$LIST_STAT" \
253 --stringparam src-archive "$SRC_ARCHIVE" \
254 --stringparam src-subdirs "$SRC_SUBDIRS" \
255 --stringparam build-root "$BUILD_ROOT" \
256 --stringparam build-subdirs "$BUILD_SUBDIRS" \
257 --stringparam keep-files "$KEEP_FILES" \
258 --param jobs "$JOBS" \
259 --stringparam cfg-cflags "$CFG_CFLAGS" \
260 --stringparam cfg-cxxflags "$CFG_CXXFLAGS" \
261 --stringparam cfg-ldflags "$CFG_LDFLAGS" \
262 --stringparam fqdn "$(hostname -f)" \
263 --output ./scripts/ \
264 ${MakeScripts} \
265 ${BookXml}
266# Make the scripts executable.
267chmod -R +x scripts
268echo -e "done\n"
269
270#clean_configuration
Note: See TracBrowser for help on using the repository browser.