source: BLFS/gen_pkg_book.sh@ 5e1d9dd

ablfs-more legacy trunk
Last change on this file since 5e1d9dd 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
RevLine 
[f4ed135]1#!/bin/bash
2#
3# Read and parse the configuration parameters..
4#
5set -e
6
[e576789]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
[607ef21]15LFS_FULL=$3
16if test -z "$LFS_FULL"; then
17 LFS_FULL=${TOPDIR}/lfs-xml/tmp/lfs-full.xml
18fi
[e576789]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"
[a690d42]25declare GetVersion="${TOPDIR}/xsl/get_version.xsl"
[e576789]26declare MakeScripts="${TOPDIR}/xsl/scripts.xsl"
27declare BookHtml="${TOPDIR}/book-html"
28declare BLFS_XML="${TOPDIR}/blfs-xml"
29declare -a TARGET
[f4ed135]30declare DEP_LEVEL
31declare SUDO
[625cb14]32declare LANGUAGE
[945ccaa]33declare WRAP_INSTALL
[9daa202]34declare PACK_INSTALL
[625cb14]35declare DEL_LA_FILES
36declare STATS
[9daa202]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
[f4ed135]46
47#--------------------------#
48parse_configuration() { #
49#--------------------------#
[e576789]50 local -i cntr=0
51 local -a optTARGET
[f4ed135]52
[e576789]53 while read; do
[f4ed135]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=* | \
[945ccaa]64 WRAP_INSTALL=* | \
[9daa202]65 PACK_INSTALL=* | \
[dc7fd7b]66 DEL_LA_FILES=* | \
[67c3df4]67 STATS=* | \
[625cb14]68 LANGUAGE=* | \
[9daa202]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..
[f4ed135]79 continue ;;
80 esac
81
[a96109a]82 if [[ "${REPLY}" =~ ^CONFIG_ ]]; then
[e576789]83 echo "$REPLY"
84 optTARGET[$((cntr++))]=$( echo $REPLY | sed -e 's@CONFIG_@@' -e 's@=y@@' )
[f4ed135]85 fi
[e576789]86 done < $ConfigFile
[f4ed135]87
[e576789]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"
[f4ed135]91 exit 0
92 fi
[e576789]93 TARGET=(${optTARGET[*]})
[f4ed135]94 DEP_LEVEL=$optDependency
95 SUDO=${SUDO:-n}
[945ccaa]96 WRAP_INSTALL=${WRAP_INSTALL:-n}
[dc7fd7b]97 DEL_LA_FILES=${DEL_LA_FILES:-n}
[67c3df4]98 STATS=${STATS:-n}
[9daa202]99# Other boolean variables are supposed to be either set or unset. Their values
100# are not relevant
[f4ed135]101}
102
103#--------------------------#
104validate_configuration() { #
105#--------------------------#
106 local -r dotSTR=".................."
[9daa202]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"
[f4ed135]108 local -r PARAM_VALS='${config_param}${dotSTR:${#config_param}} ${L_arrow}${BOLD}${!config_param}${OFF}${R_arrow}'
109 local config_param
[e576789]110 local -i index
[f4ed135]111
112 for config_param in ${PARAM_LIST}; do
113 echo -e "`eval echo $PARAM_VALS`"
114 done
[e576789]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
[f4ed135]118}
119
120#
[e576789]121# Generates the root of the dependency tree
[f4ed135]122#
123#--------------------------#
[67c3df4]124generate_deps() { #
[f4ed135]125#--------------------------#
126
[e576789]127 local -i index
128 local DepDir=$1
[2140f22]129 rm -f $DepDir/*.{tree,dep}
[e576789]130 for (( index=0 ; index < ${#TARGET[*]} ; index ++ )); do
[2140f22]131 echo 1 b ${TARGET[${index}]} >> $DepDir/root.dep
[f4ed135]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
[e576789]144tail -n 15 ${ConfigFile} > ${ConfigFile}.tmp
145mv ${ConfigFile}.tmp ${ConfigFile}
[f4ed135]146
147}
148
149#---------------------
150# Constants
[e576789]151source ${LibDir}/constants.inc
[f4ed135]152[[ $? > 0 ]] && echo -e "\n\tERROR: constants.inc did not load..\n" && exit
153
154#---------------------
155# Dependencies module
[e576789]156source ${LibDir}/func_dependencies
[f4ed135]157[[ $? > 0 ]] && echo -e "\n\tERROR: func_dependencies did not load..\n" && exit
158
159#------- MAIN --------
[e576789]160if [[ ! -f ${PackFile} ]] ; then
[f4ed135]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_}"
[e576789]177
178rm -rf $DepDir
179mkdir $DepDir
180generate_deps $DepDir
181pushd $DepDir > /dev/null
182set +e
[2140f22]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}"
[a690d42]196echo Generating the ordered full dependency list
197FULL_LIST="$(tree_browse root.tree)"
198set -e
199popd > /dev/null
200#echo "$FULL_LIST"
[2140f22]201#echo -e \\n provisional end...
202#exit
203echo Generating the ordered package list
[a690d42]204LIST=
205while read p; do
[5e1d9dd]206 p=${p%-pass1}
[a690d42]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
[e576789]215rm -f ${BookXml}
216echo Making XML book
[607ef21]217xsltproc --stringparam list "$LIST" \
[2140f22]218 --stringparam MTA "$MAIL_SERVER" \
[607ef21]219 --stringparam lfsbook "$LFS_FULL" \
[e576789]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
[c5650f9]237 do sed -i 's@\.\./stylesheets@stylesheets@' $ht
238 sed -i 's@\.\./images@images@' $ht
[e576789]239done
240echo -en "\n\tGenerating the build scripts ...\n"
241rm -rf scripts
[67c3df4]242if test $STATS = y; then
243 LIST_STAT="${TARGET[*]}"
244else
245 LIST_STAT=""
246fi
[9daa202]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} \
[e576789]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.