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:
parent
df42c7cff7
commit
e234d23768
4 changed files with 73 additions and 7 deletions
|
@ -150,3 +150,16 @@ export MAKEFLAGS="-j5"
|
|||
# up to date
|
||||
|
||||
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
|
||||
|
|
|
@ -26,6 +26,7 @@ declare BLFS_XML="${TOPDIR}/blfs-xml"
|
|||
declare -a TARGET
|
||||
declare DEP_LEVEL
|
||||
declare SUDO
|
||||
declare WRAP_INSTALL
|
||||
|
||||
#--------------------------#
|
||||
parse_configuration() { #
|
||||
|
@ -44,6 +45,7 @@ parse_configuration() { #
|
|||
# Create global variables for these parameters.
|
||||
optDependency=* | \
|
||||
MAIL_SERVER=* | \
|
||||
WRAP_INSTALL=* | \
|
||||
SUDO=* ) eval ${REPLY} # Define/set a global variable..
|
||||
continue ;;
|
||||
esac
|
||||
|
@ -62,13 +64,14 @@ parse_configuration() { #
|
|||
TARGET=(${optTARGET[*]})
|
||||
DEP_LEVEL=$optDependency
|
||||
SUDO=${SUDO:-n}
|
||||
WRAP_INSTALL=${WRAP_INSTALL:-n}
|
||||
}
|
||||
|
||||
#--------------------------#
|
||||
validate_configuration() { #
|
||||
#--------------------------#
|
||||
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 config_param
|
||||
local -i index
|
||||
|
@ -179,6 +182,7 @@ echo -en "\n\tGenerating the build scripts ...\n"
|
|||
rm -rf scripts
|
||||
xsltproc --xinclude --nonet \
|
||||
--stringparam sudo $SUDO \
|
||||
--stringparam wrap-install $WRAP_INSTALL \
|
||||
-o ./scripts/ ${MakeScripts} \
|
||||
${BookXml}
|
||||
# Make the scripts executable.
|
||||
|
|
|
@ -58,6 +58,16 @@ config SUDO
|
|||
help
|
||||
Select if sudo will be used (you build as a normal user)
|
||||
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:template>
|
||||
|
||||
|
|
|
@ -9,6 +9,10 @@
|
|||
|
||||
<!-- 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)? -->
|
||||
<xsl:param name="sudo" select="'y'"/>
|
||||
|
||||
|
@ -57,8 +61,10 @@
|
|||
<xsl:choose>
|
||||
<!-- Package page -->
|
||||
<xsl:when test="sect2[@role='package']">
|
||||
<!-- We build in a subdirectory -->
|
||||
<xsl:text>PKG_DIR=</xsl:text>
|
||||
<!-- We build in a subdirectory, whose name may be needed
|
||||
if using package management (see envars.conf), so
|
||||
"export" it -->
|
||||
<xsl:text>export PKG_DIR=</xsl:text>
|
||||
<xsl:value-of select="$filename"/>
|
||||
<xsl:text>
</xsl:text>
|
||||
<!-- Download code and build commands -->
|
||||
|
@ -124,6 +130,7 @@ case $PACKAGE in
|
|||
cp $PACKAGE $UNPACKDIR
|
||||
;;
|
||||
esac
|
||||
export UNPACKDIR
|
||||
cd $UNPACKDIR

|
||||
</xsl:text>
|
||||
<xsl:apply-templates select=".//screen | .//para/command"/>
|
||||
|
@ -380,12 +387,30 @@ fi
|
|||
<xsl:if test="child::* = userinput and not(@role = 'nodump')">
|
||||
<xsl:choose>
|
||||
<xsl:when test="@role = 'root'">
|
||||
<xsl:if test="$sudo = 'y'">
|
||||
<xsl:text>sudo -E sh << ROOT_EOF
</xsl:text>
|
||||
<xsl:if test="not(preceding-sibling::screen[@role='root'])">
|
||||
<xsl:if test="$sudo = 'y'">
|
||||
<xsl:text>sudo -E sh << ROOT_EOF
</xsl:text>
|
||||
</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:if test="$sudo = 'y'">
|
||||
<xsl:text>
ROOT_EOF</xsl:text>
|
||||
<xsl:if test="not(following-sibling::screen[@role='root'])">
|
||||
<xsl:if test="$wrap-install = 'y' and
|
||||
ancestor::sect2[@role='installation']">
|
||||
<xsl:text>'
packInstall</xsl:text>
|
||||
</xsl:if>
|
||||
<xsl:if test="$sudo = 'y'">
|
||||
<xsl:text>
ROOT_EOF</xsl:text>
|
||||
</xsl:if>
|
||||
</xsl:if>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
|
@ -462,6 +487,8 @@ popd</xsl:text>
|
|||
</xsl:call-template>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:variable name="APOS">'</xsl:variable>
|
||||
|
||||
<xsl:template name="output-root">
|
||||
<xsl:param name="out-string" select="''"/>
|
||||
<xsl:choose>
|
||||
|
@ -509,6 +536,18 @@ popd</xsl:text>
|
|||
select="substring-after($out-string,'\')"/>
|
||||
</xsl:call-template>
|
||||
</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:value-of select="$out-string"/>
|
||||
</xsl:otherwise>
|
||||
|
|
Reference in a new issue