source: BLFS/gen_pkg_book.sh@ 26e6739

2.4 ablfs-more legacy trunk
Last change on this file since 26e6739 was 7dc8595, checked in by Pierre Labastie <pierre@…>, 9 years ago

Automate the process of choosing action when there are circular dependencies.
This has to be tested, but hopefully, it should allow to find a coherent
build order when there are not too many circular dependencies

  • Property mode set to 100755
File size: 4.7 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
17declare -r ConfigFile="${TOPDIR}/configuration"
18declare DepDir="${TOPDIR}/dependencies"
19declare LibDir="${TOPDIR}/libs"
20declare PackFile="${TOPDIR}/packages.xml"
21declare BookXml="${TOPDIR}/book.xml"
22declare MakeBook="${TOPDIR}/xsl/make_book.xsl"
23declare MakeScripts="${TOPDIR}/xsl/scripts.xsl"
24declare BookHtml="${TOPDIR}/book-html"
25declare BLFS_XML="${TOPDIR}/blfs-xml"
26declare -a TARGET
27declare DEP_LEVEL
28declare SUDO
29
30#--------------------------#
31parse_configuration() { #
32#--------------------------#
33 local -i cntr=0
34 local -a optTARGET
35
36 while read; do
37
38 # Garbage collection
39 case ${REPLY} in
40 \#* | '') continue ;;
41 esac
42
43 case "${REPLY}" in
44 # Create global variables for these parameters.
45 optDependency=* | \
46 MAIL_SERVER=* | \
47 SUDO=* ) eval ${REPLY} # Define/set a global variable..
48 continue ;;
49 esac
50
51 if [[ "${REPLY}" =~ ^CONFIG_ ]]; then
52 echo "$REPLY"
53 optTARGET[$((cntr++))]=$( echo $REPLY | sed -e 's@CONFIG_@@' -e 's@=y@@' )
54 fi
55 done < $ConfigFile
56
57 if (( $cntr == 0 )); then
58 echo -e "\n>>> NO TARGET SELECTED.. application terminated"
59 echo -e " Run <make> again and select (a) package(s) to build\n"
60 exit 0
61 fi
62 TARGET=(${optTARGET[*]})
63 DEP_LEVEL=$optDependency
64 SUDO=${SUDO:-n}
65}
66
67#--------------------------#
68validate_configuration() { #
69#--------------------------#
70 local -r dotSTR=".................."
71 local -r PARAM_LIST="DEP_LEVEL SUDO MAIL_SERVER"
72 local -r PARAM_VALS='${config_param}${dotSTR:${#config_param}} ${L_arrow}${BOLD}${!config_param}${OFF}${R_arrow}'
73 local config_param
74 local -i index
75
76 for config_param in ${PARAM_LIST}; do
77 echo -e "`eval echo $PARAM_VALS`"
78 done
79 for (( index=0 ; index < ${#TARGET[*]} ; index ++ )); do
80 echo -e "TARGET${index}${dotSTR:6} ${L_arrow}${BOLD}${TARGET[${index}]}${OFF}${R_arrow}"
81 done
82}
83
84#
85# Generates the root of the dependency tree
86#
87#--------------------------#
88generate_deps() { #
89#--------------------------#
90
91 local -i index
92 local DepDir=$1
93 rm -f $DepDir/*.{o,}dep
94 for (( index=0 ; index < ${#TARGET[*]} ; index ++ )); do
95 echo 1 ${TARGET[${index}]} >> $DepDir/root.odep
96 done
97 echo 1 > $DepDir/root.dep
98 echo 1 >> $DepDir/root.dep
99 cat $DepDir/root.odep >> $DepDir/root.dep
100}
101
102#
103# Clean configuration file keeping only global default settings.
104# That prevent "trying to assign nonexistent symbol" messages
105# and assures that there is no TARGET selected from a previous run
106#
107#--------------------------#
108clean_configuration() { #
109#--------------------------#
110
111tail -n 15 ${ConfigFile} > ${ConfigFile}.tmp
112mv ${ConfigFile}.tmp ${ConfigFile}
113
114}
115
116#---------------------
117# Constants
118source ${LibDir}/constants.inc
119[[ $? > 0 ]] && echo -e "\n\tERROR: constants.inc did not load..\n" && exit
120
121#---------------------
122# Dependencies module
123source ${LibDir}/func_dependencies
124[[ $? > 0 ]] && echo -e "\n\tERROR: func_dependencies did not load..\n" && exit
125
126#------- MAIN --------
127if [[ ! -f ${PackFile} ]] ; then
128 echo -e "\tNo packages file has been found.\n"
129 echo -e "\tExecution aborted.\n"
130 exit 1
131fi
132
133
134parse_configuration
135validate_configuration
136echo "${SD_BORDER}${nl_}"
137echo -n "Are you happy with these settings? yes/no (no): "
138read ANSWER
139if [ x$ANSWER != "xyes" ] ; then
140 echo "${nl_}Rerun make and fix your settings.${nl_}"
141 exit 1
142fi
143echo "${nl_}${SD_BORDER}${nl_}"
144
145rm -rf $DepDir
146mkdir $DepDir
147generate_deps $DepDir
148pushd $DepDir > /dev/null
149set +e
150generate_dependency_tree root.dep 1
151echo
152LIST="$(tree_browse root.dep)"
153set -e
154popd > /dev/null
155rm -f ${BookXml}
156echo Making XML book
157xsltproc --stringparam list "$LIST" \
158 -o ${BookXml} \
159 ${MakeBook} \
160 $BLFS_FULL
161echo "making HTML book (may take some time...)"
162xsltproc -o ${BookHtml}/ \
163 -stringparam chunk.quietly 1 \
164 ${BLFS_XML}/stylesheets/blfs-chunked.xsl \
165 ${BookXml}
166if [ ! -d ${BookHtml}/stylesheets ]
167 then mkdir -p ${BookHtml}/stylesheets
168 cp ${BLFS_XML}/stylesheets/lfs-xsl/*.css ${BookHtml}/stylesheets
169fi
170if [ ! -d ${BookHtml}/images ]
171 then mkdir -p ${BookHtml}/images
172 cp ${BLFS_XML}/images/*.png ${BookHtml}/images
173fi
174for ht in ${BookHtml}/*.html
175 do sed -i 's@\.\./stylesheets@stylesheets@' $ht
176 sed -i 's@\.\./images@images@' $ht
177done
178echo -en "\n\tGenerating the build scripts ...\n"
179rm -rf scripts
180xsltproc --xinclude --nonet \
181 --stringparam sudo $SUDO \
182 -o ./scripts/ ${MakeScripts} \
183 ${BookXml}
184# Make the scripts executable.
185chmod -R +x scripts
186echo -e "done\n"
187
188#clean_configuration
Note: See TracBrowser for help on using the repository browser.