BLFS tools: Take variables from config instead of envars.conf

Get them in gen_pkg_book, and pass them to sripts.xsl
use them in scripts.xsl. We set them at the beginning of
of the scriptlet, so that it is easy to modify them.
This commit is contained in:
Pierre Labastie 2021-11-06 15:43:58 +01:00
parent 60e539b9fc
commit 9daa202654
2 changed files with 174 additions and 31 deletions

View file

@ -30,8 +30,18 @@ declare DEP_LEVEL
declare SUDO
declare LANGUAGE
declare WRAP_INSTALL
declare PACK_INSTALL
declare DEL_LA_FILES
declare STATS
declare SRC_ARCHIVE
declare SRC_SUBDIRS
declare BUILD_ROOT
declare BUILD_SUBDIRS
declare KEEP_FILES
declare -i JOBS
declare CFG_CFLAGS
declare CFG_CXXFLAGS
declare CFG_LDFLAGS
#--------------------------#
parse_configuration() { #
@ -51,10 +61,20 @@ parse_configuration() { #
optDependency=* | \
MAIL_SERVER=* | \
WRAP_INSTALL=* | \
PACK_INSTALL=* | \
DEL_LA_FILES=* | \
STATS=* | \
LANGUAGE=* | \
SUDO=* ) eval ${REPLY} # Define/set a global variable..
SUDO=* | \
SRC_ARCHIVE=* | \
SRC_SUBDIRS=* | \
BUILD_ROOT=* | \
BUILD_SUBDIRS=* | \
KEEP_FILES=* | \
JOBS=* | \
CFG_CFLAGS=* | \
CFG_CXXFLAGS=* | \
CFG_LDFLAGS=* ) eval ${REPLY} # Define/set a global variable..
continue ;;
esac
@ -75,13 +95,15 @@ parse_configuration() { #
WRAP_INSTALL=${WRAP_INSTALL:-n}
DEL_LA_FILES=${DEL_LA_FILES:-n}
STATS=${STATS:-n}
# Other boolean variables are supposed to be either set or unset. Their values
# are not relevant
}
#--------------------------#
validate_configuration() { #
#--------------------------#
local -r dotSTR=".................."
local -r PARAM_LIST="DEP_LEVEL SUDO LANGUAGE MAIL_SERVER WRAP_INSTALL DEL_LA_FILES STATS"
local -r PARAM_LIST="DEP_LEVEL SUDO LANGUAGE MAIL_SERVER WRAP_INSTALL PACK_INSTALL DEL_LA_FILES STATS SRC_ARCHIVE SRC_SUBDIRS BUILD_ROOT BUILD_SUBDIRS KEEP_FILES JOBS CFG_CFLAGS CFG_CXXFLAGS CFG_LDFLAGS"
local -r PARAM_VALS='${config_param}${dotSTR:${#config_param}} ${L_arrow}${BOLD}${!config_param}${OFF}${R_arrow}'
local config_param
local -i index
@ -209,13 +231,24 @@ else
LIST_STAT=""
fi
xsltproc --xinclude --nonet \
--stringparam language "$LANGUAGE" \
--stringparam sudo "$SUDO" \
--stringparam wrap-install "$WRAP_INSTALL" \
--stringparam pack-install "$PACK_INSTALL" \
--stringparam del-la-files "$DEL_LA_FILES" \
--stringparam list-stat "$LIST_STAT" \
--stringparam language "$LANGUAGE" \
--stringparam src-archive "$SRC_ARCHIVE" \
--stringparam src-subdirs "$SRC_SUBDIRS" \
--stringparam build-root "$BUILD_ROOT" \
--stringparam build-subdirs "$BUILD_SUBDIRS" \
--stringparam keep-files "$KEEP_FILES" \
--param jobs "$JOBS" \
--stringparam cfg-cflags "$CFG_CFLAGS" \
--stringparam cfg-cxxflags "$CFG_CXXFLAGS" \
--stringparam cfg-ldflags "$CFG_LDFLAGS" \
--stringparam fqdn "$(hostname -f)" \
-o ./scripts/ ${MakeScripts} \
--output ./scripts/ \
${MakeScripts} \
${BookXml}
# Make the scripts executable.
chmod -R +x scripts

View file

@ -23,6 +23,7 @@
<!-- Wrap "root" commands inside a wrapper function, allowing
"porg style" package management -->
<xsl:param name="wrap-install" select="'n'"/>
<xsl:param name="pack-install" select="'$HOME/blfs_root/packInstall.sh'"/>
<!-- list of packages needing stats -->
<xsl:param name="list-stat" select="''"/>
@ -33,6 +34,26 @@
<!-- Build as user (y) or as root (n)? -->
<xsl:param name="sudo" select="'y'"/>
<!-- Root of sources directory -->
<xsl:param name="src-archive" select="'/sources'"/>
<!-- Download and archive tarballs to subdirs. Can be 'y' or '',
not 'n' -->
<xsl:param name="src-subdirs" select="''"/>
<!-- Root of build directory -->
<xsl:param name="build-root" select="'/sources'"/>
<!-- extract sources and build into subdirs. Can be 'y' or '',
not 'n' -->
<xsl:param name="build-subdirs" select="''"/>
<!-- Keep files in the build directory after building. Can be 'y' or '',
not 'n' -->
<xsl:param name="keep-files" select="''"/>
<!-- Number of parallel jobs; type integer, not string -->
<xsl:param name="jobs" select="0"/>
<!-- simple instructions for removing .la files. -->
<!-- We'll use the rule that any text output begins with a linefeed if needed
so that we do not need to output one at the end-->
@ -109,15 +130,100 @@ done</xsl:variable>
<exsl:document href="{$order}-z-{$filename}" method="text">
<xsl:text>#!/bin/bash
set -e
unset MAKELEVEL
# Variables coming from configuration
export JH_PACK_INSTALL="</xsl:text>
<xsl:copy-of select="$pack-install"/>
<xsl:text>"
export JH_SRC_ARCHIVE="</xsl:text>
<xsl:copy-of select="$src-archive"/>
<xsl:text>"
export JH_SRC_SUBDIRS="</xsl:text>
<xsl:copy-of select="$src-subdirs"/>
<xsl:text>"
export JH_BUILD_ROOT="</xsl:text>
<xsl:copy-of select="$build-root"/>
<xsl:text>"
export JH_BUILD_SUBDIRS="</xsl:text>
<xsl:copy-of select="$build-subdirs"/>
<xsl:text>"
export JH_KEEP_FILES="</xsl:text>
<xsl:copy-of select="$keep-files"/>
<xsl:text>"
</xsl:text>
<xsl:choose>
<xsl:when test="$cfg-cflags = 'EMPTY'">
<xsl:text>unset CFLAGS
</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>export CFLAGS="</xsl:text>
<xsl:copy-of select="$cfg-cflags"/>
<xsl:text>"
</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="$cfg-cxxflags = 'EMPTY'">
<xsl:text>unset CXXFLAGS
</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>export CXXFLAGS="</xsl:text>
<xsl:copy-of select="$cfg-cxxflags"/>
<xsl:text>"
</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="$cfg-ldflags = 'EMPTY'">
<xsl:text>unset LDFLAGS
</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>export LDFLAGS="</xsl:text>
<xsl:copy-of select="$cfg-ldflags"/>
<xsl:text>"
</xsl:text>
</xsl:otherwise>
</xsl:choose>
<!-- We use MAKEFLAGS and NINJAJOBS for setting the number of
parallel jobs. This supposes that ninja has been build with
support for NINJAJOBS in lfs. We'll have to change that code
if lfs changes its policy for ninja. -->
<xsl:text>export MAKEFLAGS="-j</xsl:text>
<xsl:choose>
<xsl:when test="$jobs = 0">
<xsl:text>$(nproc)"
</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$jobs"/>
<xsl:text>"
</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="$jobs = 0">
<xsl:text>unset NINJAJOBS
</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>export NINJAJOBS="</xsl:text>
<xsl:value-of select="$jobs"/>
<xsl:text>"
</xsl:text>
</xsl:otherwise>
</xsl:choose>
<!-- Unsetting MAKELEVEL is needed for some packages which assume that
their top level Makefile is at level zero -->
<xsl:text>unset MAKELEVEL
# End of environment</xsl:text>
<xsl:choose>
<!-- Package page -->
<xsl:when test="sect2[@role='package']">
<!-- We build in a subdirectory, whose name may be needed
if using package management (see envars.conf), so
if using package management, so
"export" it -->
<xsl:text>
export JH_PKG_DIR=</xsl:text>
@ -129,19 +235,23 @@ mkdir -p $SRC_DIR
mkdir -p $BUILD_DIR
</xsl:text>
<!-- If stats are requested, include some definitions and intitializations -->
<!-- If stats are requested, include some definitions and initializations -->
<xsl:if test="$want-stats">
<xsl:text>
INFOLOG=$(pwd)/info-${JH_PKG_DIR}
TESTLOG=$(pwd)/test-${JH_PKG_DIR}
unset MAKEFLAGS
#MAKEFLAGS=-j4
echo MAKEFLAGS: $MAKEFLAGS > $INFOLOG
echo NINJAJOBS: $NINJAJOBS >> $INFOLOG
: > $TESTLOG
PKG_DEST=${BUILD_DIR}/dest
rm -rf $PKG_DEST
</xsl:text>
<!-- in some cases, DESTDIR may have been populated by root -->
<xsl:if test="$sudo = 'y'">
<xsl:text>sudo </xsl:text>
</xsl:if>
<xsl:text>rm -rf $PKG_DEST
</xsl:text>
</xsl:if><!-- want-stats -->
<!-- Download code and build commands -->
<xsl:apply-templates select="sect2">
<xsl:with-param name="want-stats" select="$want-stats"/>
@ -333,33 +443,33 @@ echo Start Time: ${SECONDS} >> $INFOLOG
<xsl:text>&#xA;if [[ ! -f $</xsl:text>
<xsl:value-of select="$varname"/>
<xsl:text> ]] ; then
if [[ -f $JH_SRC_ARCHIVE/$</xsl:text>
if [ -f "$JH_SRC_ARCHIVE/$</xsl:text>
<xsl:value-of select="$varname"/>
<xsl:text> ]] ; then&#xA;</xsl:text>
<xsl:text> cp $JH_SRC_ARCHIVE/$</xsl:text>
<xsl:text>" ] ; then&#xA;</xsl:text>
<xsl:text> cp "$JH_SRC_ARCHIVE/$</xsl:text>
<xsl:value-of select="$varname"/>
<xsl:text> $</xsl:text>
<xsl:text>" "$</xsl:text>
<xsl:value-of select="$varname"/>
<xsl:text>
<xsl:text>"
else&#xA;</xsl:text>
<!-- Download from upstream http -->
<xsl:if test="string-length($httpurl) &gt; 10">
<xsl:text> wget -T 30 -t 5 </xsl:text>
<xsl:text> wget -T 30 -t 5 "</xsl:text>
<xsl:value-of select="$httpurl"/>
<xsl:text> ||&#xA;</xsl:text>
<xsl:text>" ||&#xA;</xsl:text>
</xsl:if>
<!-- Download from upstream ftp -->
<xsl:if test="string-length($ftpurl) &gt; 10">
<xsl:text> wget -T 30 -t 5 </xsl:text>
<xsl:text> wget -T 30 -t 5 "</xsl:text>
<xsl:value-of select="$ftpurl"/>
<xsl:text> ||&#xA;</xsl:text>
<xsl:text>" ||&#xA;</xsl:text>
</xsl:if>
<!-- The FTP_SERVER mirror as a last resort -->
<xsl:text> wget -T 30 -t 5 ${JH_FTP_SERVER}svn/</xsl:text>
<xsl:text> wget -T 30 -t 5 "${JH_FTP_SERVER}svn/</xsl:text>
<xsl:value-of select="$first_letter"/>
<xsl:text>/$</xsl:text>
<xsl:value-of select="$varname"/>
<xsl:text>
<xsl:text>"
fi
fi</xsl:text>
<xsl:if test="string-length($md5) &gt; 10">
@ -374,9 +484,9 @@ echo "</xsl:text>
be there-->
<xsl:if test="string($varname) != 'PACKAGE'">
<xsl:text>
[[ "$SRC_DIR" != "$BUILD_DIR" ]] &amp;&amp; ln -sf $SRC_DIR/$</xsl:text>
[ "$SRC_DIR" != "$BUILD_DIR" ] &amp;&amp; ln -sf "$SRC_DIR/$</xsl:text>
<xsl:value-of select="$varname"/>
<xsl:text> $BUILD_DIR</xsl:text>
<xsl:text>" "$BUILD_DIR"</xsl:text>
</xsl:if>
<xsl:text>&#xA;</xsl:text>
</xsl:template>