source: BLFS/gen_pkg_book.sh@ 2507cf7

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

Correct hard linked directory in gen_pkg_book.sh

  • Property mode set to 100755
File size: 4.7 KB
RevLine 
[f4ed135]1#!/bin/bash
2#
3# $Id$
4#
5# Read and parse the configuration parameters..
6#
7set -e
8
[63fc514]9TOPDIR=$1
[d8add36]10if test -z "$TOPDIR"; then
[63fc514]11 TOPDIR=$(pwd)
12fi
13BLFS_FULL=$2
[d8add36]14if test -z "$BLFS_FULL"; then
[63fc514]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
29
30#--------------------------#
31parse_configuration() { #
32#--------------------------#
[63fc514]33 local -i cntr=0
34 local -a optTARGET
[f4ed135]35
[63fc514]36 while read; do
[f4ed135]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
[a96109a]54 if [[ "${REPLY}" =~ ^CONFIG_ ]]; then
[63fc514]55 echo "$REPLY"
56 optTARGET[$((cntr++))]=$( echo $REPLY | sed -e 's@CONFIG_@@' -e 's@=y@@' )
[f4ed135]57 fi
[63fc514]58 done < $ConfigFile
[f4ed135]59
[63fc514]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"
[f4ed135]63 exit 0
64 fi
[63fc514]65 TARGET=(${optTARGET[*]})
[f4ed135]66 DEP_LEVEL=$optDependency
67 SUDO=${SUDO:-n}
68}
69
70#--------------------------#
71validate_configuration() { #
72#--------------------------#
73 local -r dotSTR=".................."
[63fc514]74 local -r PARAM_LIST="DEP_LEVEL SUDO PRINT_SERVER MAIL_SERVER GHOSTSCRIPT KBR5"
[f4ed135]75 local -r PARAM_VALS='${config_param}${dotSTR:${#config_param}} ${L_arrow}${BOLD}${!config_param}${OFF}${R_arrow}'
76 local config_param
[63fc514]77 local -i index
[f4ed135]78
79 for config_param in ${PARAM_LIST}; do
80 echo -e "`eval echo $PARAM_VALS`"
81 done
[63fc514]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#
[63fc514]88# Generates the root of the dependency tree
[f4ed135]89#
90#--------------------------#
[63fc514]91generate_deps() { #
[f4ed135]92#--------------------------#
93
[63fc514]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
[f4ed135]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
[63fc514]112tail -n 15 ${ConfigFile} > ${ConfigFile}.tmp
113mv ${ConfigFile}.tmp ${ConfigFile}
[f4ed135]114
115}
116
117#---------------------
118# Constants
[63fc514]119source ${LibDir}/constants.inc
[f4ed135]120[[ $? > 0 ]] && echo -e "\n\tERROR: constants.inc did not load..\n" && exit
121
122#---------------------
123# Dependencies module
[63fc514]124source ${LibDir}/func_dependencies
[f4ed135]125[[ $? > 0 ]] && echo -e "\n\tERROR: func_dependencies did not load..\n" && exit
126
127#------- MAIN --------
[63fc514]128if [[ ! -f ${PackFile} ]] ; then
[f4ed135]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_}"
[63fc514]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
[b957bb6]169 cp ${BLFS_XML}/stylesheets/lfs-xsl/*.css ${BookHtml}/stylesheets
[63fc514]170fi
171if [ ! -d ${BookHtml}/images ]
172 then mkdir -p ${BookHtml}/images
[b957bb6]173 cp ${BLFS_XML}/images/*.png ${BookHtml}/images
[63fc514]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.