source: BLFS/gen_pkg_book.sh@ 1cb4c76

ablfs-more legacy trunk
Last change on this file since 1cb4c76 was 2140f22, checked in by Pierre Labastie <pierre@…>, 7 years ago

New management of dependencies:

  • Even if only required or recommended deps only are requested and built, account for optional deps to build the pacakge order
  • build "runtime" deps after the pacakge dependening on them, but before any other package
  • using the "first" role in the book, implement pass1 pacakges when there are circular dependencies
  • Documentation has still to be written
  • There must be bugs, thank you for testing...
  • Property mode set to 100755
File size: 5.4 KB
RevLine 
[f4ed135]1#!/bin/bash
2#
3# $Id$
4#
5# Read and parse the configuration parameters..
6#
7set -e
8
[e576789]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
[607ef21]17LFS_FULL=$3
18if test -z "$LFS_FULL"; then
19 LFS_FULL=${TOPDIR}/lfs-xml/tmp/lfs-full.xml
20fi
[e576789]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
[f4ed135]31declare DEP_LEVEL
32declare SUDO
[945ccaa]33declare WRAP_INSTALL
[f4ed135]34
35#--------------------------#
36parse_configuration() { #
37#--------------------------#
[e576789]38 local -i cntr=0
39 local -a optTARGET
[f4ed135]40
[e576789]41 while read; do
[f4ed135]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=* | \
[945ccaa]52 WRAP_INSTALL=* | \
[dc7fd7b]53 DEL_LA_FILES=* | \
[f4ed135]54 SUDO=* ) eval ${REPLY} # Define/set a global variable..
55 continue ;;
56 esac
57
[a96109a]58 if [[ "${REPLY}" =~ ^CONFIG_ ]]; then
[e576789]59 echo "$REPLY"
60 optTARGET[$((cntr++))]=$( echo $REPLY | sed -e 's@CONFIG_@@' -e 's@=y@@' )
[f4ed135]61 fi
[e576789]62 done < $ConfigFile
[f4ed135]63
[e576789]64 if (( $cntr == 0 )); then
65 echo -e "\n>>> NO TARGET SELECTED.. application terminated"
66 echo -e " Run <make> again and select (a) package(s) to build\n"
[f4ed135]67 exit 0
68 fi
[e576789]69 TARGET=(${optTARGET[*]})
[f4ed135]70 DEP_LEVEL=$optDependency
71 SUDO=${SUDO:-n}
[945ccaa]72 WRAP_INSTALL=${WRAP_INSTALL:-n}
[dc7fd7b]73 DEL_LA_FILES=${DEL_LA_FILES:-n}
[f4ed135]74}
75
76#--------------------------#
77validate_configuration() { #
78#--------------------------#
79 local -r dotSTR=".................."
[dc7fd7b]80 local -r PARAM_LIST="DEP_LEVEL SUDO MAIL_SERVER WRAP_INSTALL DEL_LA_FILES"
[f4ed135]81 local -r PARAM_VALS='${config_param}${dotSTR:${#config_param}} ${L_arrow}${BOLD}${!config_param}${OFF}${R_arrow}'
82 local config_param
[e576789]83 local -i index
[f4ed135]84
85 for config_param in ${PARAM_LIST}; do
86 echo -e "`eval echo $PARAM_VALS`"
87 done
[e576789]88 for (( index=0 ; index < ${#TARGET[*]} ; index ++ )); do
89 echo -e "TARGET${index}${dotSTR:6} ${L_arrow}${BOLD}${TARGET[${index}]}${OFF}${R_arrow}"
90 done
[f4ed135]91}
92
93#
[e576789]94# Generates the root of the dependency tree
[f4ed135]95#
96#--------------------------#
[e576789]97generate_deps() { #
[f4ed135]98#--------------------------#
99
[e576789]100 local -i index
101 local DepDir=$1
[2140f22]102 rm -f $DepDir/*.{tree,dep}
[e576789]103 for (( index=0 ; index < ${#TARGET[*]} ; index ++ )); do
[2140f22]104 echo 1 b ${TARGET[${index}]} >> $DepDir/root.dep
[f4ed135]105 done
106}
107
108#
109# Clean configuration file keeping only global default settings.
110# That prevent "trying to assign nonexistent symbol" messages
111# and assures that there is no TARGET selected from a previous run
112#
113#--------------------------#
114clean_configuration() { #
115#--------------------------#
116
[e576789]117tail -n 15 ${ConfigFile} > ${ConfigFile}.tmp
118mv ${ConfigFile}.tmp ${ConfigFile}
[f4ed135]119
120}
121
122#---------------------
123# Constants
[e576789]124source ${LibDir}/constants.inc
[f4ed135]125[[ $? > 0 ]] && echo -e "\n\tERROR: constants.inc did not load..\n" && exit
126
127#---------------------
128# Dependencies module
[e576789]129source ${LibDir}/func_dependencies
[f4ed135]130[[ $? > 0 ]] && echo -e "\n\tERROR: func_dependencies did not load..\n" && exit
131
132#------- MAIN --------
[e576789]133if [[ ! -f ${PackFile} ]] ; then
[f4ed135]134 echo -e "\tNo packages file has been found.\n"
135 echo -e "\tExecution aborted.\n"
136 exit 1
137fi
138
139
140parse_configuration
141validate_configuration
142echo "${SD_BORDER}${nl_}"
143echo -n "Are you happy with these settings? yes/no (no): "
144read ANSWER
145if [ x$ANSWER != "xyes" ] ; then
146 echo "${nl_}Rerun make and fix your settings.${nl_}"
147 exit 1
148fi
149echo "${nl_}${SD_BORDER}${nl_}"
[e576789]150
151rm -rf $DepDir
152mkdir $DepDir
153generate_deps $DepDir
154pushd $DepDir > /dev/null
155set +e
[2140f22]156generate_subgraph root.dep 1 1 b
157echo -e "\n${SD_BORDER}"
158echo Graph contains $(ls |wc -l) nodes
159echo -e "${SD_BORDER}"
160echo Cleaning subgraph...
161clean_subgraph
162echo done
163echo Generating the tree
164echo 1 > root.tree
165echo 1 >> root.tree
166cat root.dep >> root.tree
167generate_dependency_tree root.tree 1
168echo -e "\n${SD_BORDER}"
169#echo -e \\n provisional end...
170#exit
171echo Generating the ordered package list
172LIST="$(tree_browse root.tree)"
[e576789]173set -e
174popd > /dev/null
175rm -f ${BookXml}
176echo Making XML book
[607ef21]177xsltproc --stringparam list "$LIST" \
[2140f22]178 --stringparam MTA "$MAIL_SERVER" \
[607ef21]179 --stringparam lfsbook "$LFS_FULL" \
[e576789]180 -o ${BookXml} \
181 ${MakeBook} \
182 $BLFS_FULL
183echo "making HTML book (may take some time...)"
184xsltproc -o ${BookHtml}/ \
185 -stringparam chunk.quietly 1 \
186 ${BLFS_XML}/stylesheets/blfs-chunked.xsl \
187 ${BookXml}
188if [ ! -d ${BookHtml}/stylesheets ]
189 then mkdir -p ${BookHtml}/stylesheets
190 cp ${BLFS_XML}/stylesheets/lfs-xsl/*.css ${BookHtml}/stylesheets
191fi
192if [ ! -d ${BookHtml}/images ]
193 then mkdir -p ${BookHtml}/images
194 cp ${BLFS_XML}/images/*.png ${BookHtml}/images
195fi
196for ht in ${BookHtml}/*.html
[c5650f9]197 do sed -i 's@\.\./stylesheets@stylesheets@' $ht
198 sed -i 's@\.\./images@images@' $ht
[e576789]199done
200echo -en "\n\tGenerating the build scripts ...\n"
201rm -rf scripts
202xsltproc --xinclude --nonet \
[45f8a9c8]203 --stringparam sudo "$SUDO" \
204 --stringparam wrap-install "$WRAP_INSTALL" \
[dc7fd7b]205 --stringparam del-la-files "$DEL_LA_FILES" \
[e576789]206 -o ./scripts/ ${MakeScripts} \
207 ${BookXml}
208# Make the scripts executable.
209chmod -R +x scripts
210echo -e "done\n"
211
212#clean_configuration
Note: See TracBrowser for help on using the repository browser.