source: BLFS/gen_pkg_book.sh@ 63fc514

ablfs
Last change on this file since 63fc514 was 63fc514, checked in by Pierre Labastie <pierre@…>, 13 years ago

Initial modificaiton of BLFS tools

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