source: BLFS/gen_pkg_book.sh@ 203a64c

ablfs-more legacy trunk
Last change on this file since 203a64c was 45f8a9c8, checked in by Pierre Labastie <pierre@…>, 7 years ago

Forgotten quotes

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