install-blfs-tools.sh:

- Add instructions to retrieve and parse LFS book into packages.xml
This commit is contained in:
Pierre Labastie 2017-08-09 13:55:55 +00:00
parent 200fbdee76
commit 506120eeec
4 changed files with 210 additions and 15 deletions

View file

@ -25,6 +25,7 @@ MENU = $(TOPDIR)/menu
# Those directories and files will be created and populated by make: # Those directories and files will be created and populated by make:
# directory of the book sources: # directory of the book sources:
LFS_XML = $(TOPDIR)/lfs-xml
BLFS_XML = $(TOPDIR)/blfs-xml BLFS_XML = $(TOPDIR)/blfs-xml
# contains the REV used in the preceding call: # contains the REV used in the preceding call:
REVFILE = $(TOPDIR)/revision REVFILE = $(TOPDIR)/revision
@ -37,7 +38,9 @@ CONFIG_OUT = $(TOPDIR)/configuration
# the linear book: # the linear book:
BOOK_XML = $(TOPDIR)/book.xml BOOK_XML = $(TOPDIR)/book.xml
LFSTMP = $(LFS_XML)/tmp
RENDERTMP = $(BLFS_XML)/tmp RENDERTMP = $(BLFS_XML)/tmp
LFS_FULL = $(LFSTMP)/lfs-full.xml
BLFS_FULL = $(RENDERTMP)/blfs-full.xml BLFS_FULL = $(RENDERTMP)/blfs-full.xml
# The right-hand side is updated by jhalfs: # The right-hand side is updated by jhalfs:
@ -57,16 +60,25 @@ define INITIAL_TRACK
</sublist> </sublist>
endef endef
LFS-SVN = svn://svn.linuxfromscratch.org/LFS/trunk/BOOK
SVN = svn://svn.linuxfromscratch.org/BLFS/trunk/BOOK SVN = svn://svn.linuxfromscratch.org/BLFS/trunk/BOOK
ALLXML := $(filter-out $(RENDERTMP)/%, \ ALLXML := $(filter-out $(RENDERTMP)/%, \
$(shell if [ -d $(BLFS_XML) ]; then \ $(shell if [ -d $(BLFS_XML) ]; then \
find $(BLFS_XML) -name \*.xml; \ find $(BLFS_XML) -name \*.xml; \
fi)) fi))
ALLXMLLFS:= $(filter-out $(LFSTMP)/%, \
$(shell if [ -d $(LFS_XML) ]; then \
find $(LFS_XML) -name \*.xml; \
fi))
ALLXSL := $(filter-out $(RENDERTMP)/%, \ ALLXSL := $(filter-out $(RENDERTMP)/%, \
$(shell if [ -d $(BLFS_XML) ]; then \ $(shell if [ -d $(BLFS_XML) ]; then \
find $(BLFS_XML) -name \*.xsl; \ find $(BLFS_XML) -name \*.xsl; \
fi)) fi))
ALLXSLLFS := $(filter-out $(LFSTMP)/%, \
$(shell if [ -d $(LFS_XML) ]; then \
find $(LFS_XML) -name \*.xsl; \
fi))
# Try to set the REV variable according to previous runs, except when # Try to set the REV variable according to previous runs, except when
# set on the command line: # set on the command line:
@ -97,8 +109,9 @@ $(MENU)/mconf:
$(CONFIG_CONFIG_IN): $(PACK_LIST) $(XSLDIR)/gen_config.xsl $(CONFIG_CONFIG_IN): $(PACK_LIST) $(XSLDIR)/gen_config.xsl
$(Q)xsltproc --nonet -o $@ $(XSLDIR)/gen_config.xsl $(PACK_LIST) $(Q)xsltproc --nonet -o $@ $(XSLDIR)/gen_config.xsl $(PACK_LIST)
$(PACK_LIST): $(XSLDIR)/gen_pkg_list.xsl $(XSLDIR)/specialCases.xsl $(TRACKFILE) $(PACK_LIST): $(XSLDIR)/gen_pkg_list.xsl $(XSLDIR)/specialCases.xsl $(TRACKFILE) $(LFS_FULL)
$(Q)xsltproc --stringparam installed-packages $(TRACKFILE) \ $(Q)xsltproc --stringparam installed-packages $(TRACKFILE) \
--stringparam lfs-full $(LFS_FULL) \
-o $@.tmp $(XSLDIR)/gen_pkg_list.xsl $(BLFS_FULL) -o $@.tmp $(XSLDIR)/gen_pkg_list.xsl $(BLFS_FULL)
$(Q)xmllint --postvalid --format -o $@ $@.tmp $(Q)xmllint --postvalid --format -o $@ $@.tmp
$(Q)rm $@.tmp $(Q)rm $@.tmp
@ -137,28 +150,51 @@ $(XSLDIR)/specialCases.xsl: $(TOPDIR)/gen-special.sh $(BLFS_FULL)
ifneq ($(REV),$(REV1)) ifneq ($(REV),$(REV1))
$(BLFS_FULL): FORCE $(BLFS_FULL): FORCE
$(LFS_FULL): FORCE
endif endif
$(LFS_FULL): $(LFS_XML) $(LFS_XML)/general.ent $(ALLXMLLFS) $(ALLXSLLFS)
@echo "Processing LFS bootscripts..."
$(Q)cd $(LFS_XML) && bash process-scripts.sh
$(Q)[ -d $(LFSTMP) ] || mkdir -p $(LFSTMP)
@echo "Adjusting LFS for revision $(REV)..."
$(Q)xsltproc --nonet --xinclude \
--stringparam profile.revision $(REV) \
--output $(LFSTMP)/lfs-prof.xml \
$(LFS_XML)/stylesheets/lfs-xsl/profile.xsl \
$(LFS_XML)/index.xml
@echo "Validating the LFS book..."
$(Q)xmllint --nonet --noent --postvalid \
-o $@ $(LFSTMP)/lfs-prof.xml
$(Q)rm -f $(LFS_XML)/appendices/*.script
$(Q)cd $(LFS_XML) && ./aux-file-data.sh $@
$(Q)echo $(REV) > $(REVFILE)
$(BLFS_FULL): $(BLFS_XML) $(BLFS_XML)/general.ent $(ALLXML) $(ALLXSL) $(BLFS_FULL): $(BLFS_XML) $(BLFS_XML)/general.ent $(ALLXML) $(ALLXSL)
$(Q)[ -d $(RENDERTMP) ] || mkdir -p $(RENDERTMP) $(Q)[ -d $(RENDERTMP) ] || mkdir -p $(RENDERTMP)
@echo "Adjusting for revision $(REV)..." @echo "Adjusting BLFS for revision $(REV)..."
$(Q)xsltproc --nonet --xinclude \ $(Q)xsltproc --nonet --xinclude \
--stringparam profile.revision $(REV) \ --stringparam profile.revision $(REV) \
--output $(RENDERTMP)/blfs-prof.xml \ --output $(RENDERTMP)/blfs-prof.xml \
$(BLFS_XML)/stylesheets/lfs-xsl/profile.xsl \ $(BLFS_XML)/stylesheets/lfs-xsl/profile.xsl \
$(BLFS_XML)/index.xml $(BLFS_XML)/index.xml
@echo "Validating the book..." @echo "Validating the BLFS book..."
$(Q)xmllint --nonet --noent --postvalid \ $(Q)xmllint --nonet --noent --postvalid \
-o $@ $(RENDERTMP)/blfs-prof.xml -o $@ $(RENDERTMP)/blfs-prof.xml
$(Q)echo $(REV) > $(REVFILE) $(Q)echo $(REV) > $(REVFILE)
all: update $(BOOK_XML) all: update $(BOOK_XML)
update: $(BLFS_XML) update: $(BLFS_XML) $(LFS_XML)
@echo Updating the book sources @echo Updating the book sources
$(Q)cd $(LFS_XML) && svn up
$(Q)cd $(BLFS_XML) && svn up $(Q)cd $(BLFS_XML) && svn up
$(LFS_XML):
@echo Getting the LFS book sources...
$(Q)svn co $(LFS-SVN) $@
$(BLFS_XML): $(BLFS_XML):
@echo Getting the book sources... @echo Getting the BLFS book sources...
$(Q)svn co $(SVN) $@ $(Q)svn co $(SVN) $@
# Clean up # Clean up

View file

@ -5,10 +5,12 @@
of packages obeying packdesc.dtd + looks for already of packages obeying packdesc.dtd + looks for already
installed packages in the tracking file (stringparam installed packages in the tracking file (stringparam
'installed-packages') --> 'installed-packages') -->
<!-- Extract also a list of LFS packages from stringparam lfs-full -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"> version="1.0">
<xsl:param name="lfs-full" select="'./lfs-xml/lfs-full.xml'"/>
<xsl:param name="installed-packages" select="'../lib/instpkg.xml'"/> <xsl:param name="installed-packages" select="'../lib/instpkg.xml'"/>
<xsl:output method="xml" <xsl:output method="xml"
@ -22,13 +24,103 @@
<xsl:template match="/"> <xsl:template match="/">
<princList> <princList>
<xsl:text>&#xA;&#xA;</xsl:text> <xsl:text>&#xA;&#xA; </xsl:text>
<list>
<xsl:attribute name="id">lfs</xsl:attribute>
<xsl:text>&#xA; </xsl:text>
<name>LFS Packages</name>
<xsl:text>&#xA; </xsl:text>
<sublist>
<xsl:attribute name="id">lfs-6</xsl:attribute>
<xsl:text>&#xA; </xsl:text>
<name>LFS Chapter 6</name>
<xsl:apply-templates
select='document($lfs-full)//
chapter[@id="chapter-building-system"]/
sect1/sect1info'/>
<xsl:text>&#xA; </xsl:text>
</sublist>
<sublist>
<xsl:attribute name="id">lfs-8</xsl:attribute>
<xsl:text>&#xA; </xsl:text>
<name>LFS Chapter 8</name>
<xsl:apply-templates select='document($lfs-full)//chapter[@id="chapter-bootable"]/sect1/sect1info[./productname="linux"]'/>
<xsl:text>&#xA; </xsl:text>
</sublist>
<sublist>
<xsl:attribute name="id">lfs-9</xsl:attribute>
<xsl:text>&#xA; </xsl:text>
<name>LFS Chapter 9</name>
<xsl:apply-templates select='document($lfs-full)//sect1[@id="ch-finish-theend"]//userinput[starts-with(string(),"echo")]'/>
<xsl:text>&#xA; </xsl:text>
</sublist>
<xsl:text>&#xA;&#xA; </xsl:text>
</list>
<!-- How to have blfs-bootscripts versionned? Do not know, so <!-- How to have blfs-bootscripts versionned? Do not know, so
avoid it (TODO ?) --> avoid it (TODO ?) -->
<xsl:apply-templates select="//part[not(@id='introduction')]"/> <xsl:apply-templates select="//part[not(@id='introduction')]"/>
</princList> </princList>
</xsl:template> </xsl:template>
<xsl:template match="userinput">
<!-- Only used in lFS chapter 9, to retrieve book version -->
<package>
<name>LFS-Release</name>
<xsl:element name="version">
<xsl:copy-of select="substring-after(substring-before(string(),' &gt;'),'echo ')"/>
</xsl:element>
<xsl:if
test="document($installed-packages)//package[name='LFS-Release']">
<xsl:text>&#xA; </xsl:text>
<xsl:element name="inst-version">
<xsl:value-of
select="document(
$installed-packages
)//package[name='LFS-Release']/version"/>
</xsl:element>
</xsl:if>
</package>
</xsl:template>
<xsl:template match="sect1info">
<xsl:text> </xsl:text>
<xsl:choose>
<!-- Never update linux headers -->
<xsl:when test="./productname='linux'
and ancestor::chapter[@id='chapter-building-system']"/>
<!-- Gcc version is taken from BLFS -->
<xsl:when test="./productname='gcc'"/>
<!-- Shadow version is taken from BLFS -->
<xsl:when test="./productname='shadow'"/>
<!-- Dbus version is taken from BLFS -->
<xsl:when test="./productname='dbus'"/>
<!-- Systemd version is taken from BLFS -->
<xsl:when test="./productname='systemd'"/>
<xsl:otherwise>
<package><xsl:text>&#xA; </xsl:text>
<xsl:element name="name">
<xsl:value-of select="./productname"/>
</xsl:element>
<xsl:text>&#xA; </xsl:text>
<xsl:element name="version">
<xsl:value-of select="./productnumber"/>
</xsl:element>
<xsl:if
test="document($installed-packages)//package[name=current()/productname]">
<xsl:text>&#xA; </xsl:text>
<xsl:element name="inst-version">
<xsl:value-of
select="document(
$installed-packages
)//package[name=current()/productname]/version"/>
</xsl:element>
</xsl:if>
</package>
</xsl:otherwise>
</xsl:choose>
<!-- No deps for now: a former version is always installed -->
</xsl:template>
<xsl:template match="part"> <xsl:template match="part">
<xsl:if test="count(.//*[contains(translate(@xreflabel, <xsl:if test="count(.//*[contains(translate(@xreflabel,
'123456789', '123456789',

View file

@ -523,7 +523,7 @@ menu "BOOK Settings"
default "**EDIT ME**" default "**EDIT ME**"
depends on BLFS_WORKING_COPY depends on BLFS_WORKING_COPY
help help
Full path to the BLFS book working copy" Full path to the BLFS book working copy
config BLFS_BRANCH_ID config BLFS_BRANCH_ID
string "BLFS Book Version (mandatory)" string "BLFS Book Version (mandatory)"
@ -561,6 +561,42 @@ menu "BOOK Settings"
The directory name under $BLFS_ROOT where the BLFS The directory name under $BLFS_ROOT where the BLFS
book sources will be copied or checked out. Do not change that book sources will be copied or checked out. Do not change that
unless you know what you are doing... unless you know what you are doing...
choice
prompt "LFS Release"
default LFS_SVN
depends BOOK_BLFS
config LFS_relSVN
bool "LFS SVN"
help
Current development version as in trunk
config LFS_WORKING_COPY
bool "LFS working copy"
help
A local working copy of the LFS book.
config LFS_BRANCH
bool "LFS Branch or stable book"
help
A supported SVN branch or stable book release
endchoice
config BLFS_LFS_BOOK
string "Location of the local LFS working copy (mandatory)"
default "**EDIT ME**"
depends on LFS_WORKING_COPY
help
Full path to the LFS book working copy"
config BLFS_LFS_BRANCH_ID
string "LFS Book Version (mandatory)"
default "**EDIT ME**"
depends on LFS_BRANCH
help
A list of valid branches and stable book IDs is available at
http://wiki.linuxfromscratch.org/alfs/wiki/SupportedBooks.
# End of BLFS parameters # End of BLFS parameters
#--- Custom Tools support #--- Custom Tools support

View file

@ -6,12 +6,14 @@ set -e
Installs a set-up to build BLFS packages. Installs a set-up to build BLFS packages.
You can set these variables: You can set these variables:
TRACKING_DIR : where the installed package file is kept. TRACKING_DIR : where the installed package file is kept.
(default /var/lib/jhalfs/BLFS) (default /var/lib/jhalfs/BLFS)
INITSYS : which books do you want? 'sysv' or 'systemd' (default sysv)
BLFS_ROOT : where the installed tools will be installed, relative to $HOME. BLFS_ROOT : where the installed tools will be installed, relative to $HOME.
Must start with a '/' (default /blfs_root) Must start with a '/' (default /blfs_root)
BLFS_BRANCH_ID: development, branch-xxx, xxx (where xxx is a valid tag) BLFS_BRANCH_ID: development, branch-xxx, xxx (where xxx is a valid tag)
(default development) (default development)
INITSYS : which book do you want? 'sysv' or 'systemd' (default sysv) LFS_BRANCH_ID : development, branch-xxx, xxx (where xxx is a valid tag)
(default development)
Examples: Examples:
1 - If you plan to use the tools to build BLFS on top of LFS, but you did not 1 - If you plan to use the tools to build BLFS on top of LFS, but you did not
use jhalfs, or forgot to include the jhalfs-blfs tools: use jhalfs, or forgot to include the jhalfs-blfs tools:
@ -69,9 +71,16 @@ if [ "$BOOK_BLFS" = y ]; then
[[ "$BRANCH" = y ]] && BLFS_BRANCH_ID=$BRANCH_ID [[ "$BRANCH" = y ]] && BLFS_BRANCH_ID=$BRANCH_ID
[[ "$WORKING_COPY" = y ]] && BLFS_BOOK=$BOOK [[ "$WORKING_COPY" = y ]] && BLFS_BOOK=$BOOK
[[ "$BRANCH_ID" = "**EDIT ME**" ]] && [[ "$BRANCH_ID" = "**EDIT ME**" ]] &&
echo You have not set the book version or branch && exit 1 echo You have not set the BLFS book version or branch && exit 1
[[ "$BOOK" = "**EDIT ME**" ]] && [[ "$BOOK" = "**EDIT ME**" ]] &&
echo You have not set the working copy location && exit 1 echo You have not set the BLFS working copy location && exit 1
[[ "$LFS_relSVN" = y ]] && LFS_BRANCH_ID=development
[[ "$LFS_BRANCH" = y ]] && LFS_BRANCH_ID=$BLFS_LFS_BRANCH_ID
[[ "$LFS_WORKING_COPY" = y ]] && LFS_BOOK=$BLFS_LFS_BOOK
[[ "$LFS_BRANCH_ID" = "**EDIT ME**" ]] &&
echo You have not set the LFS book version or branch && exit 1
[[ "$LFS_BOOK" = "**EDIT ME**" ]] &&
echo You have not set the LFS working copy location && exit 1
fi fi
COMMON_DIR="common" COMMON_DIR="common"
@ -82,15 +91,22 @@ BLFS_ROOT="${BLFS_ROOT:=/blfs_root}"
TRACKING_DIR="${TRACKING_DIR:=/var/lib/jhalfs/BLFS}" TRACKING_DIR="${TRACKING_DIR:=/var/lib/jhalfs/BLFS}"
INITSYS="${INITSYS:=sysv}" INITSYS="${INITSYS:=sysv}"
BLFS_BRANCH_ID=${BLFS_BRANCH_ID:=development} BLFS_BRANCH_ID=${BLFS_BRANCH_ID:=development}
LFS_BRANCH_ID=${LFS_BRANCH_ID:=development}
BLFS_XML=${BLFS_XML:=blfs-xml} BLFS_XML=${BLFS_XML:=blfs-xml}
LFS_XML=${LFS_XML:=lfs-xml}
# Validate the configuration: # Validate the configuration:
PARAMS="BLFS_ROOT TRACKING_DIR INITSYS BLFS_XML" PARAMS="BLFS_ROOT TRACKING_DIR INITSYS BLFS_XML LFS_XML"
if [ "$WORKING_COPY" = y ]; then if [ "$WORKING_COPY" = y ]; then
PARAMS="$PARAMS WORKING_COPY BOOK" PARAMS="$PARAMS WORKING_COPY BLFS_BOOK"
else else
PARAMS="$PARAMS BLFS_BRANCH_ID" PARAMS="$PARAMS BLFS_BRANCH_ID"
fi fi
if [ "$LFS_WORKING_COPY" = y ]; then
PARAMS="$PARAMS LFS_WORKING_COPY LFS_BOOK"
else
PARAMS="$PARAMS LFS_BRANCH_ID"
fi
# Format for displaying parameters: # Format for displaying parameters:
declare -r PARAM_VALS='${config_param}${dotSTR:${#config_param}} ${L_arrow}${BOLD}${!config_param}${OFF}${R_arrow}' declare -r PARAM_VALS='${config_param}${dotSTR:${#config_param}} ${L_arrow}${BOLD}${!config_param}${OFF}${R_arrow}'
@ -120,6 +136,11 @@ case $BLFS_BRANCH_ID in
branch-* ) BLFS_TREE=branches/${BLFS_BRANCH_ID#branch-} ;; branch-* ) BLFS_TREE=branches/${BLFS_BRANCH_ID#branch-} ;;
* ) BLFS_TREE=tags/${BLFS_BRANCH_ID} ;; * ) BLFS_TREE=tags/${BLFS_BRANCH_ID} ;;
esac esac
case $LFS_BRANCH_ID in
development ) LFS_TREE=trunk/BOOK ;;
branch-* ) LFS_TREE=branches/${BLFS_BRANCH_ID#branch-} ;;
* ) LFS_TREE=tags/${BLFS_BRANCH_ID} ;;
esac
# Check for build prerequisites. # Check for build prerequisites.
echo echo
@ -146,6 +167,7 @@ rm -rf ${BUILDDIR}${BLFS_ROOT}/menu/.svn
rm -rf ${BUILDDIR}${BLFS_ROOT}/menu/lxdialog/.svn rm -rf ${BUILDDIR}${BLFS_ROOT}/menu/lxdialog/.svn
# We do not want to keep an old version of the book: # We do not want to keep an old version of the book:
rm -rf ${BUILDDIR}${BLFS_ROOT}/$BLFS_XML rm -rf ${BUILDDIR}${BLFS_ROOT}/$BLFS_XML
rm -rf ${BUILDDIR}${BLFS_ROOT}/$LFS_XML
# Set some harcoded envars to their proper values # Set some harcoded envars to their proper values
sed -i s@tracking-dir@$TRACKING_DIR@ \ sed -i s@tracking-dir@$TRACKING_DIR@ \
@ -159,15 +181,24 @@ mkdir -p $TRACKING_DIR
[[ $VERBOSITY > 0 ]] && echo "... OK" [[ $VERBOSITY > 0 ]] && echo "... OK"
[[ $VERBOSITY > 0 ]] && [[ $VERBOSITY > 0 ]] &&
echo "Retrieving and validating the book (may take some time)"
[[ -z "$BLFS_BOOK" ]] || [[ -z "$BLFS_BOOK" ]] ||
[[ $BLFS_BOOK = $BUILDDIR$BLFS_ROOT/$BLFS_XML ]] || [[ $BLFS_BOOK = $BUILDDIR$BLFS_ROOT/$BLFS_XML ]] || {
echo "Retrieving BLFS working copy (may take some time)" &&
cp -a $BLFS_BOOK $BUILDDIR$BLFS_ROOT/$BLFS_XML cp -a $BLFS_BOOK $BUILDDIR$BLFS_ROOT/$BLFS_XML
}
[[ -z "$LFS_BOOK" ]] ||
[[ $LFS_BOOK = $BUILDDIR$BLFS_ROOT/$LFS_XML ]] || {
echo "Retrieving the LFS working copy (may take some time)" &&
cp -a $LFS_BOOK $BUILDDIR$BLFS_ROOT/$LFS_XML
}
make -j1 -C $BUILDDIR$BLFS_ROOT \ make -j1 -C $BUILDDIR$BLFS_ROOT \
TRACKING_DIR=$TRACKING_DIR \ TRACKING_DIR=$TRACKING_DIR \
REV=$INITSYS \ REV=$INITSYS \
LFS_XML=$BUILDDIR$BLFS_ROOT/$LFS_XML \
LFS-SVN=svn://svn.linuxfromscratch.org/LFS/$LFS_TREE \
BLFS_XML=$BUILDDIR$BLFS_ROOT/$BLFS_XML \ BLFS_XML=$BUILDDIR$BLFS_ROOT/$BLFS_XML \
SVN=svn://svn.linuxfromscratch.org/BLFS/$BLFS_TREE \ SVN=svn://svn.linuxfromscratch.org/BLFS/$BLFS_TREE \
$BUILDDIR$BLFS_ROOT/packages.xml $BUILDDIR$BLFS_ROOT/packages.xml