BLFS porg style package management:

- update envarc.conf so that the system is made aware of the wrapInstall
and packInstall functions
- update scripts.xsl for wrapping install commands
- update gen_config.xsl to add the variable WRAP_INSTALL
- use the variable WRAP_INSTALL in gen_pkg_book
TODO: install the correct pack - wrap functions when installing BLFS tools
This commit is contained in:
Pierre Labastie 2016-08-24 15:15:14 +00:00
parent df42c7cff7
commit e234d23768
4 changed files with 73 additions and 7 deletions

View file

@ -150,3 +150,16 @@ export MAKEFLAGS="-j5"
# up to date # up to date
if [ -r /etc/profile ]; then source /etc/profile; fi if [ -r /etc/profile ]; then source /etc/profile; fi
#======== Package management ========
# We need the functions in "packInstall.sh" when installing a package,
# if package management is requested. Note that we have no way to know
# whether package management is requested for a given build.
# Furthermore, "sudo -E" exports varaubales, but not functions from
# the environment, and sudo needs to be called before porg, due
# to porg limitations. So we just export the location of the file
# where the functions are dfined, and we'll source it just before
# installing.
export PACK_INSTALL=${HOME}/blfs_root/packInstall.sh # change as needed

View file

@ -26,6 +26,7 @@ declare BLFS_XML="${TOPDIR}/blfs-xml"
declare -a TARGET declare -a TARGET
declare DEP_LEVEL declare DEP_LEVEL
declare SUDO declare SUDO
declare WRAP_INSTALL
#--------------------------# #--------------------------#
parse_configuration() { # parse_configuration() { #
@ -44,6 +45,7 @@ parse_configuration() { #
# Create global variables for these parameters. # Create global variables for these parameters.
optDependency=* | \ optDependency=* | \
MAIL_SERVER=* | \ MAIL_SERVER=* | \
WRAP_INSTALL=* | \
SUDO=* ) eval ${REPLY} # Define/set a global variable.. SUDO=* ) eval ${REPLY} # Define/set a global variable..
continue ;; continue ;;
esac esac
@ -62,13 +64,14 @@ parse_configuration() { #
TARGET=(${optTARGET[*]}) TARGET=(${optTARGET[*]})
DEP_LEVEL=$optDependency DEP_LEVEL=$optDependency
SUDO=${SUDO:-n} SUDO=${SUDO:-n}
WRAP_INSTALL=${WRAP_INSTALL:-n}
} }
#--------------------------# #--------------------------#
validate_configuration() { # validate_configuration() { #
#--------------------------# #--------------------------#
local -r dotSTR=".................." local -r dotSTR=".................."
local -r PARAM_LIST="DEP_LEVEL SUDO MAIL_SERVER" local -r PARAM_LIST="DEP_LEVEL SUDO MAIL_SERVER WRAP_INSTALL"
local -r PARAM_VALS='${config_param}${dotSTR:${#config_param}} ${L_arrow}${BOLD}${!config_param}${OFF}${R_arrow}' local -r PARAM_VALS='${config_param}${dotSTR:${#config_param}} ${L_arrow}${BOLD}${!config_param}${OFF}${R_arrow}'
local config_param local config_param
local -i index local -i index
@ -179,6 +182,7 @@ echo -en "\n\tGenerating the build scripts ...\n"
rm -rf scripts rm -rf scripts
xsltproc --xinclude --nonet \ xsltproc --xinclude --nonet \
--stringparam sudo $SUDO \ --stringparam sudo $SUDO \
--stringparam wrap-install $WRAP_INSTALL \
-o ./scripts/ ${MakeScripts} \ -o ./scripts/ ${MakeScripts} \
${BookXml} ${BookXml}
# Make the scripts executable. # Make the scripts executable.

View file

@ -58,6 +58,16 @@ config SUDO
help help
Select if sudo will be used (you build as a normal user) Select if sudo will be used (you build as a normal user)
otherwise sudo is not needed (you build as root) otherwise sudo is not needed (you build as root)
config WRAP_INSTALL
bool "Use `porg style' package management"
default n
help
Select if you want the installation commands to be wrapped
between "wrapInstall '" and "' ; packInstall" functions,
where wrapInstall is used to set up a LD_PRELOAD library (for
example using porg), and packInstall makes the package tarball
</xsl:text> </xsl:text>
</xsl:template> </xsl:template>

View file

@ -9,6 +9,10 @@
<!-- XSLT stylesheet to create shell scripts from "linear build" BLFS books. --> <!-- XSLT stylesheet to create shell scripts from "linear build" BLFS books. -->
<!-- Wrap "root" commands inside a wrapper function, allowing
"porg style" package management -->
<xsl:param name="wrap-install" select="'n'"/>
<!-- Build as user (y) or as root (n)? --> <!-- Build as user (y) or as root (n)? -->
<xsl:param name="sudo" select="'y'"/> <xsl:param name="sudo" select="'y'"/>
@ -57,8 +61,10 @@
<xsl:choose> <xsl:choose>
<!-- Package page --> <!-- Package page -->
<xsl:when test="sect2[@role='package']"> <xsl:when test="sect2[@role='package']">
<!-- We build in a subdirectory --> <!-- We build in a subdirectory, whose name may be needed
<xsl:text>PKG_DIR=</xsl:text> if using package management (see envars.conf), so
"export" it -->
<xsl:text>export PKG_DIR=</xsl:text>
<xsl:value-of select="$filename"/> <xsl:value-of select="$filename"/>
<xsl:text>&#xA;</xsl:text> <xsl:text>&#xA;</xsl:text>
<!-- Download code and build commands --> <!-- Download code and build commands -->
@ -124,6 +130,7 @@ case $PACKAGE in
cp $PACKAGE $UNPACKDIR cp $PACKAGE $UNPACKDIR
;; ;;
esac esac
export UNPACKDIR
cd $UNPACKDIR&#xA; cd $UNPACKDIR&#xA;
</xsl:text> </xsl:text>
<xsl:apply-templates select=".//screen | .//para/command"/> <xsl:apply-templates select=".//screen | .//para/command"/>
@ -380,13 +387,31 @@ fi
<xsl:if test="child::* = userinput and not(@role = 'nodump')"> <xsl:if test="child::* = userinput and not(@role = 'nodump')">
<xsl:choose> <xsl:choose>
<xsl:when test="@role = 'root'"> <xsl:when test="@role = 'root'">
<xsl:if test="not(preceding-sibling::screen[@role='root'])">
<xsl:if test="$sudo = 'y'"> <xsl:if test="$sudo = 'y'">
<xsl:text>sudo -E sh &lt;&lt; ROOT_EOF&#xA;</xsl:text> <xsl:text>sudo -E sh &lt;&lt; ROOT_EOF&#xA;</xsl:text>
</xsl:if> </xsl:if>
<xsl:if test="$wrap-install = 'y' and
ancestor::sect2[@role='installation']">
<xsl:text>if [ -r "$PACK_INSTALL" ]; then
source $PACK_INSTALL
export -f wrapInstall
export -f packInstall
fi
wrapInstall '
</xsl:text>
</xsl:if>
</xsl:if>
<xsl:apply-templates mode="root"/> <xsl:apply-templates mode="root"/>
<xsl:if test="not(following-sibling::screen[@role='root'])">
<xsl:if test="$wrap-install = 'y' and
ancestor::sect2[@role='installation']">
<xsl:text>'&#xA;packInstall</xsl:text>
</xsl:if>
<xsl:if test="$sudo = 'y'"> <xsl:if test="$sudo = 'y'">
<xsl:text>&#xA;ROOT_EOF</xsl:text> <xsl:text>&#xA;ROOT_EOF</xsl:text>
</xsl:if> </xsl:if>
</xsl:if>
</xsl:when> </xsl:when>
<xsl:otherwise> <xsl:otherwise>
<xsl:apply-templates select="userinput"/> <xsl:apply-templates select="userinput"/>
@ -462,6 +487,8 @@ popd</xsl:text>
</xsl:call-template> </xsl:call-template>
</xsl:template> </xsl:template>
<xsl:variable name="APOS">'</xsl:variable>
<xsl:template name="output-root"> <xsl:template name="output-root">
<xsl:param name="out-string" select="''"/> <xsl:param name="out-string" select="''"/>
<xsl:choose> <xsl:choose>
@ -509,6 +536,18 @@ popd</xsl:text>
select="substring-after($out-string,'\')"/> select="substring-after($out-string,'\')"/>
</xsl:call-template> </xsl:call-template>
</xsl:when> </xsl:when>
<xsl:when test="contains($out-string,string($APOS))
and $wrap-install = 'y'">
<xsl:call-template name="output-root">
<xsl:with-param name="out-string"
select="substring-before($out-string,string($APOS))"/>
</xsl:call-template>
<xsl:text>'\''</xsl:text>
<xsl:call-template name="output-root">
<xsl:with-param name="out-string"
select="substring-after($out-string,string($APOS))"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise> <xsl:otherwise>
<xsl:value-of select="$out-string"/> <xsl:value-of select="$out-string"/>
</xsl:otherwise> </xsl:otherwise>