source: BLFS/gen_pkg_book.sh@ fb63ddf

ablfs-more legacy trunk
Last change on this file since fb63ddf 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
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
[607ef21]17LFS_FULL=$3
18if test -z "$LFS_FULL"; then
19 LFS_FULL=${TOPDIR}/lfs-xml/tmp/lfs-full.xml
20fi
[e576789]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
[f4ed135]31declare DEP_LEVEL
32declare SUDO
[945ccaa]33declare WRAP_INSTALL
[f4ed135]34
35#--------------------------#
36parse_configuration() { #
37#--------------------------#
[e576789]38 local -i cntr=0
39 local -a optTARGET
[f4ed135]40
[e576789]41 while read; do
[f4ed135]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=* | \
[945ccaa]52 WRAP_INSTALL=* | \
[f4ed135]53 SUDO=* ) eval ${REPLY} # Define/set a global variable..
54 continue ;;
55 esac
56
[a96109a]57 if [[ "${REPLY}" =~ ^CONFIG_ ]]; then
[e576789]58 echo "$REPLY"
59 optTARGET[$((cntr++))]=$( echo $REPLY | sed -e 's@CONFIG_@@' -e 's@=y@@' )
[f4ed135]60 fi
[e576789]61 done < $ConfigFile
[f4ed135]62
[e576789]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"
[f4ed135]66 exit 0
67 fi
[e576789]68 TARGET=(${optTARGET[*]})
[f4ed135]69 DEP_LEVEL=$optDependency
70 SUDO=${SUDO:-n}
[945ccaa]71 WRAP_INSTALL=${WRAP_INSTALL:-n}
[f4ed135]72}
73
74#--------------------------#
75validate_configuration() { #
76#--------------------------#
77 local -r dotSTR=".................."
[945ccaa]78 local -r PARAM_LIST="DEP_LEVEL SUDO MAIL_SERVER WRAP_INSTALL"
[f4ed135]79 local -r PARAM_VALS='${config_param}${dotSTR:${#config_param}} ${L_arrow}${BOLD}${!config_param}${OFF}${R_arrow}'
80 local config_param
[e576789]81 local -i index
[f4ed135]82
83 for config_param in ${PARAM_LIST}; do
84 echo -e "`eval echo $PARAM_VALS`"
85 done
[e576789]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
[f4ed135]89}
90
91#
[e576789]92# Generates the root of the dependency tree
[f4ed135]93#
94#--------------------------#
[e576789]95generate_deps() { #
[f4ed135]96#--------------------------#
97
[e576789]98 local -i index
99 local DepDir=$1
[7dc8595]100 rm -f $DepDir/*.{o,}dep
[e576789]101 for (( index=0 ; index < ${#TARGET[*]} ; index ++ )); do
[7dc8595]102 echo 1 ${TARGET[${index}]} >> $DepDir/root.odep
[f4ed135]103 done
[7dc8595]104 echo 1 > $DepDir/root.dep
105 echo 1 >> $DepDir/root.dep
106 cat $DepDir/root.odep >> $DepDir/root.dep
[f4ed135]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
[e576789]118tail -n 15 ${ConfigFile} > ${ConfigFile}.tmp
119mv ${ConfigFile}.tmp ${ConfigFile}
[f4ed135]120
121}
122
123#---------------------
124# Constants
[e576789]125source ${LibDir}/constants.inc
[f4ed135]126[[ $? > 0 ]] && echo -e "\n\tERROR: constants.inc did not load..\n" && exit
127
128#---------------------
129# Dependencies module
[e576789]130source ${LibDir}/func_dependencies
[f4ed135]131[[ $? > 0 ]] && echo -e "\n\tERROR: func_dependencies did not load..\n" && exit
132
133#------- MAIN --------
[e576789]134if [[ ! -f ${PackFile} ]] ; then
[f4ed135]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_}"
[e576789]151
152rm -rf $DepDir
153mkdir $DepDir
154generate_deps $DepDir
155pushd $DepDir > /dev/null
156set +e
[7dc8595]157generate_dependency_tree root.dep 1
[e576789]158echo
159LIST="$(tree_browse root.dep)"
160set -e
161popd > /dev/null
162rm -f ${BookXml}
163echo Making XML book
[607ef21]164xsltproc --stringparam list "$LIST" \
165 --stringparam MTA "$SERVER_MAIL" \
166 --stringparam lfsbook "$LFS_FULL" \
[e576789]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
[c5650f9]184 do sed -i 's@\.\./stylesheets@stylesheets@' $ht
185 sed -i 's@\.\./images@images@' $ht
[e576789]186done
187echo -en "\n\tGenerating the build scripts ...\n"
188rm -rf scripts
189xsltproc --xinclude --nonet \
[45f8a9c8]190 --stringparam sudo "$SUDO" \
191 --stringparam wrap-install "$WRAP_INSTALL" \
[e576789]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.