source: BLFS/gen_pkg_book.sh@ 6990d80

ablfs-more legacy trunk
Last change on this file since 6990d80 was 945ccaa, checked in by Pierre Labastie <pierre@…>, 8 years ago

Merge the new_features branch (manully, thanks to svn)

  • Property mode set to 100755
File size: 4.9 KB
RevLine 
[f4ed135]1#!/bin/bash
2#
3# $Id$
4#
5# Read and parse the configuration parameters..
6#
7set -e
8
[e576789]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
[f4ed135]27declare DEP_LEVEL
28declare SUDO
[945ccaa]29declare WRAP_INSTALL
[f4ed135]30
31#--------------------------#
32parse_configuration() { #
33#--------------------------#
[e576789]34 local -i cntr=0
35 local -a optTARGET
[f4ed135]36
[e576789]37 while read; do
[f4ed135]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=* | \
[945ccaa]48 WRAP_INSTALL=* | \
[f4ed135]49 SUDO=* ) eval ${REPLY} # Define/set a global variable..
50 continue ;;
51 esac
52
[a96109a]53 if [[ "${REPLY}" =~ ^CONFIG_ ]]; then
[e576789]54 echo "$REPLY"
55 optTARGET[$((cntr++))]=$( echo $REPLY | sed -e 's@CONFIG_@@' -e 's@=y@@' )
[f4ed135]56 fi
[e576789]57 done < $ConfigFile
[f4ed135]58
[e576789]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"
[f4ed135]62 exit 0
63 fi
[e576789]64 TARGET=(${optTARGET[*]})
[f4ed135]65 DEP_LEVEL=$optDependency
66 SUDO=${SUDO:-n}
[945ccaa]67 WRAP_INSTALL=${WRAP_INSTALL:-n}
[f4ed135]68}
69
70#--------------------------#
71validate_configuration() { #
72#--------------------------#
73 local -r dotSTR=".................."
[945ccaa]74 local -r PARAM_LIST="DEP_LEVEL SUDO MAIL_SERVER WRAP_INSTALL"
[f4ed135]75 local -r PARAM_VALS='${config_param}${dotSTR:${#config_param}} ${L_arrow}${BOLD}${!config_param}${OFF}${R_arrow}'
76 local config_param
[e576789]77 local -i index
[f4ed135]78
79 for config_param in ${PARAM_LIST}; do
80 echo -e "`eval echo $PARAM_VALS`"
81 done
[e576789]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
[f4ed135]85}
86
87#
[e576789]88# Generates the root of the dependency tree
[f4ed135]89#
90#--------------------------#
[e576789]91generate_deps() { #
[f4ed135]92#--------------------------#
93
[e576789]94 local -i index
95 local DepDir=$1
[7dc8595]96 rm -f $DepDir/*.{o,}dep
[e576789]97 for (( index=0 ; index < ${#TARGET[*]} ; index ++ )); do
[7dc8595]98 echo 1 ${TARGET[${index}]} >> $DepDir/root.odep
[f4ed135]99 done
[7dc8595]100 echo 1 > $DepDir/root.dep
101 echo 1 >> $DepDir/root.dep
102 cat $DepDir/root.odep >> $DepDir/root.dep
[f4ed135]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
[e576789]114tail -n 15 ${ConfigFile} > ${ConfigFile}.tmp
115mv ${ConfigFile}.tmp ${ConfigFile}
[f4ed135]116
117}
118
119#---------------------
120# Constants
[e576789]121source ${LibDir}/constants.inc
[f4ed135]122[[ $? > 0 ]] && echo -e "\n\tERROR: constants.inc did not load..\n" && exit
123
124#---------------------
125# Dependencies module
[e576789]126source ${LibDir}/func_dependencies
[f4ed135]127[[ $? > 0 ]] && echo -e "\n\tERROR: func_dependencies did not load..\n" && exit
128
129#------- MAIN --------
[e576789]130if [[ ! -f ${PackFile} ]] ; then
[f4ed135]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_}"
[e576789]147
148rm -rf $DepDir
149mkdir $DepDir
150generate_deps $DepDir
151pushd $DepDir > /dev/null
152set +e
[7dc8595]153generate_dependency_tree root.dep 1
[e576789]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
[c5650f9]178 do sed -i 's@\.\./stylesheets@stylesheets@' $ht
179 sed -i 's@\.\./images@images@' $ht
[e576789]180done
181echo -en "\n\tGenerating the build scripts ...\n"
182rm -rf scripts
183xsltproc --xinclude --nonet \
184 --stringparam sudo $SUDO \
[945ccaa]185 --stringparam wrap-install $WRAP_INSTALL \
[e576789]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.