source: BLFS/gen_pkg_book.sh@ c7b535b

ablfs-more legacy trunk
Last change on this file since c7b535b 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
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 WRAP_INSTALL
34
35#--------------------------#
36parse_configuration() { #
37#--------------------------#
38 local -i cntr=0
39 local -a optTARGET
40
41 while read; do
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=* | \
52 WRAP_INSTALL=* | \
53 DEL_LA_FILES=* | \
54 SUDO=* ) eval ${REPLY} # Define/set a global variable..
55 continue ;;
56 esac
57
58 if [[ "${REPLY}" =~ ^CONFIG_ ]]; then
59 echo "$REPLY"
60 optTARGET[$((cntr++))]=$( echo $REPLY | sed -e 's@CONFIG_@@' -e 's@=y@@' )
61 fi
62 done < $ConfigFile
63
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"
67 exit 0
68 fi
69 TARGET=(${optTARGET[*]})
70 DEP_LEVEL=$optDependency
71 SUDO=${SUDO:-n}
72 WRAP_INSTALL=${WRAP_INSTALL:-n}
73 DEL_LA_FILES=${DEL_LA_FILES:-n}
74}
75
76#--------------------------#
77validate_configuration() { #
78#--------------------------#
79 local -r dotSTR=".................."
80 local -r PARAM_LIST="DEP_LEVEL SUDO MAIL_SERVER WRAP_INSTALL DEL_LA_FILES"
81 local -r PARAM_VALS='${config_param}${dotSTR:${#config_param}} ${L_arrow}${BOLD}${!config_param}${OFF}${R_arrow}'
82 local config_param
83 local -i index
84
85 for config_param in ${PARAM_LIST}; do
86 echo -e "`eval echo $PARAM_VALS`"
87 done
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
91}
92
93#
94# Generates the root of the dependency tree
95#
96#--------------------------#
97generate_deps() { #
98#--------------------------#
99
100 local -i index
101 local DepDir=$1
102 rm -f $DepDir/*.{tree,dep}
103 for (( index=0 ; index < ${#TARGET[*]} ; index ++ )); do
104 echo 1 b ${TARGET[${index}]} >> $DepDir/root.dep
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
117tail -n 15 ${ConfigFile} > ${ConfigFile}.tmp
118mv ${ConfigFile}.tmp ${ConfigFile}
119
120}
121
122#---------------------
123# Constants
124source ${LibDir}/constants.inc
125[[ $? > 0 ]] && echo -e "\n\tERROR: constants.inc did not load..\n" && exit
126
127#---------------------
128# Dependencies module
129source ${LibDir}/func_dependencies
130[[ $? > 0 ]] && echo -e "\n\tERROR: func_dependencies did not load..\n" && exit
131
132#------- MAIN --------
133if [[ ! -f ${PackFile} ]] ; then
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_}"
150
151rm -rf $DepDir
152mkdir $DepDir
153generate_deps $DepDir
154pushd $DepDir > /dev/null
155set +e
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)"
173set -e
174popd > /dev/null
175rm -f ${BookXml}
176echo Making XML book
177xsltproc --stringparam list "$LIST" \
178 --stringparam MTA "$MAIL_SERVER" \
179 --stringparam lfsbook "$LFS_FULL" \
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
197 do sed -i 's@\.\./stylesheets@stylesheets@' $ht
198 sed -i 's@\.\./images@images@' $ht
199done
200echo -en "\n\tGenerating the build scripts ...\n"
201rm -rf scripts
202xsltproc --xinclude --nonet \
203 --stringparam sudo "$SUDO" \
204 --stringparam wrap-install "$WRAP_INSTALL" \
205 --stringparam del-la-files "$DEL_LA_FILES" \
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.