source: BLFS/gen_pkg_book.sh@ 5a8939e

ablfs-more legacy trunk
Last change on this file since 5a8939e was 607ef21, checked in by Pierre Labastie <pierre@…>, 7 years ago

Add missing bits to generate scripts for LFS in BLFS tools

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