source: BLFS/gen_pkg_book.sh@ 2e1c1c3

ablfs-more legacy trunk
Last change on this file since 2e1c1c3 was dc7fd7b, checked in by Pierre Labastie <pierre@…>, 6 years ago

Add .la file removal to LFS and BLFS scripts

  • Property mode set to 100755
File size: 5.2 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/*.{o,}dep
103 for (( index=0 ; index < ${#TARGET[*]} ; index ++ )); do
104 echo 1 ${TARGET[${index}]} >> $DepDir/root.odep
105 done
106 echo 1 > $DepDir/root.dep
107 echo 1 >> $DepDir/root.dep
108 cat $DepDir/root.odep >> $DepDir/root.dep
109}
110
111#
112# Clean configuration file keeping only global default settings.
113# That prevent "trying to assign nonexistent symbol" messages
114# and assures that there is no TARGET selected from a previous run
115#
116#--------------------------#
117clean_configuration() { #
118#--------------------------#
119
120tail -n 15 ${ConfigFile} > ${ConfigFile}.tmp
121mv ${ConfigFile}.tmp ${ConfigFile}
122
123}
124
125#---------------------
126# Constants
127source ${LibDir}/constants.inc
128[[ $? > 0 ]] && echo -e "\n\tERROR: constants.inc did not load..\n" && exit
129
130#---------------------
131# Dependencies module
132source ${LibDir}/func_dependencies
133[[ $? > 0 ]] && echo -e "\n\tERROR: func_dependencies did not load..\n" && exit
134
135#------- MAIN --------
136if [[ ! -f ${PackFile} ]] ; then
137 echo -e "\tNo packages file has been found.\n"
138 echo -e "\tExecution aborted.\n"
139 exit 1
140fi
141
142
143parse_configuration
144validate_configuration
145echo "${SD_BORDER}${nl_}"
146echo -n "Are you happy with these settings? yes/no (no): "
147read ANSWER
148if [ x$ANSWER != "xyes" ] ; then
149 echo "${nl_}Rerun make and fix your settings.${nl_}"
150 exit 1
151fi
152echo "${nl_}${SD_BORDER}${nl_}"
153
154rm -rf $DepDir
155mkdir $DepDir
156generate_deps $DepDir
157pushd $DepDir > /dev/null
158set +e
159generate_dependency_tree root.dep 1
160echo
161LIST="$(tree_browse root.dep)"
162set -e
163popd > /dev/null
164rm -f ${BookXml}
165echo Making XML book
166xsltproc --stringparam list "$LIST" \
167 --stringparam MTA "$SERVER_MAIL" \
168 --stringparam lfsbook "$LFS_FULL" \
169 -o ${BookXml} \
170 ${MakeBook} \
171 $BLFS_FULL
172echo "making HTML book (may take some time...)"
173xsltproc -o ${BookHtml}/ \
174 -stringparam chunk.quietly 1 \
175 ${BLFS_XML}/stylesheets/blfs-chunked.xsl \
176 ${BookXml}
177if [ ! -d ${BookHtml}/stylesheets ]
178 then mkdir -p ${BookHtml}/stylesheets
179 cp ${BLFS_XML}/stylesheets/lfs-xsl/*.css ${BookHtml}/stylesheets
180fi
181if [ ! -d ${BookHtml}/images ]
182 then mkdir -p ${BookHtml}/images
183 cp ${BLFS_XML}/images/*.png ${BookHtml}/images
184fi
185for ht in ${BookHtml}/*.html
186 do sed -i 's@\.\./stylesheets@stylesheets@' $ht
187 sed -i 's@\.\./images@images@' $ht
188done
189echo -en "\n\tGenerating the build scripts ...\n"
190rm -rf scripts
191xsltproc --xinclude --nonet \
192 --stringparam sudo "$SUDO" \
193 --stringparam wrap-install "$WRAP_INSTALL" \
194 --stringparam del-la-files "$DEL_LA_FILES" \
195 -o ./scripts/ ${MakeScripts} \
196 ${BookXml}
197# Make the scripts executable.
198chmod -R +x scripts
199echo -e "done\n"
200
201#clean_configuration
Note: See TracBrowser for help on using the repository browser.