Add the possibility to choose build and source dirs, and whether subdirs are

used in blfs tools, + various fixes
This commit is contained in:
Pierre Labastie 2017-03-15 21:00:31 +00:00
parent 8010030910
commit 50618eeb88
4 changed files with 81 additions and 31 deletions

View file

@ -10,15 +10,23 @@
#======== Common envars ==========
#--- The sources directory.
# This directory contains sub directories (one for each package), where
# packages are stored, unpacked, and compiled.
export SRC_DIR=/sources
#--- The build directory:
# - If BUILD_SUBDIRS is set, this directory contains sub directories
# (one for each package), where packages are unpacked, and compiled.
# - If BUILD_SUBDIRS is unset, packages are unpacked, and compiled directly
# in $BUILD_ROOT.
export BUILD_ROOT=/sources
export BUILD_SUBDIRS=1
#--- The local repository for packages/file
# Any missing file will be downloaded and archived here,
# if the user has the right priviledges. Can be the same as SRC_DIR
#--- The local repository for packages/file:
# Any missing file will be downloaded and archived either:
# - into a subdirectory (one for each page of the book) fo this directory,
# if SRC_SUBDIRS is set.
# - directly into this directory if SRC_SUBDIRS is unset.
# This directory can be the same as $BUILD_ROOT, provided BUILD_SUBDIRS
# and SRC_SUBDIRS are different.
export SRC_ARCHIVE=/sources
unset SRC_SUBDIRS
#--- Set a well-known working locale when building software
# Note that an UTF-8 locale may be needed for some packages,
@ -27,7 +35,7 @@ export SRC_ARCHIVE=/sources
# sourced at the end of this file.
export LC_ALL=C
#--- Server used if the file isn't found in SRC_ARCHIVE or SRC_DIR,
#--- Server used if the file isn't found in SRC_DIR,
# and cannot be downloaded from upstream.
#
# The server path MUST be set as listed in
@ -35,6 +43,12 @@ export LC_ALL=C
# Note that despite the name of the variable, it can be an http url.
export FTP_SERVER=http://ftp.osuosl.org/pub/blfs/
#--- Keep the buid directory to examine it:
# If KEEP_FILES is unset, the extracted tarball is removed after build.
# Otherwise, the build tree is kept for later study.
#export KEEP_FILES=1
unset KEEP_FILES
### Currently not used in scripts ###
# Use a server close to you for Xorg (see http://wiki.x.org/wiki/Mirrors)
# export FTP_X_SERVER=ftp://mirror.cict.fr/x.org/

View file

@ -78,11 +78,18 @@
"export" it -->
<xsl:text>export PKG_DIR=</xsl:text>
<xsl:value-of select="$filename"/>
<xsl:text>&#xA;</xsl:text>
<xsl:text>
SRC_DIR=${SRC_ARCHIVE}${SRC_SUBDIRS:+/${PKG_DIR}}
BUILD_DIR=${BUILD_ROOT}${BUILD_SUBDIRS:+/${PKG_DIR}}
mkdir -p $SRC_DIR
mkdir -p $BUILD_DIR
</xsl:text>
<!-- Download code and build commands -->
<xsl:apply-templates select="sect2"/>
<!-- Clean-up -->
<xsl:text>cd $SRC_DIR/$PKG_DIR&#xA;</xsl:text>
<xsl:text>cd $BUILD_DIR
[[ -n "$KEEP_FILES" ]] || </xsl:text>
<!-- In some case, some files in the build tree are owned
by root -->
<xsl:if test="$sudo='y'">
@ -105,8 +112,8 @@
<xsl:template match="sect2">
<xsl:choose>
<xsl:when test="@role = 'package'">
<xsl:text>mkdir -p $SRC_DIR/$PKG_DIR&#xA;</xsl:text>
<xsl:text>cd $SRC_DIR/$PKG_DIR&#xA;</xsl:text>
<xsl:text>cd $SRC_DIR
</xsl:text>
<!-- Download information is in bridgehead tags -->
<xsl:apply-templates select="bridgehead[@renderas='sect3']"/>
<xsl:text>&#xA;</xsl:text>
@ -116,6 +123,7 @@
</xsl:when>
<xsl:when test="@role = 'installation'">
<xsl:text>
cd $BUILD_DIR
find . -maxdepth 1 -mindepth 1 -type d | xargs </xsl:text>
<xsl:if test="$sudo='y'">
<xsl:text>sudo </xsl:text>
@ -123,21 +131,21 @@ find . -maxdepth 1 -mindepth 1 -type d | xargs </xsl:text>
<xsl:text>rm -rf
case $PACKAGE in
*.tar.gz|*.tar.bz2|*.tar.xz|*.tgz|*.tar.lzma)
tar -xvf $PACKAGE &gt; unpacked
tar -xvf $SRC_DIR/$PACKAGE &gt; unpacked
UNPACKDIR=`grep '[^./]\+' unpacked | head -n1 | sed 's@^\./@@;s@/.*@@'`
;;
*.tar.lz)
bsdtar -xvf $PACKAGE 2&gt; unpacked
bsdtar -xvf $SRC_DIR/$PACKAGE 2&gt; unpacked
UNPACKDIR=`head -n1 unpacked | cut -d" " -f2 | sed 's@^\./@@;s@/.*@@'`
;;
*.zip)
zipinfo -1 $PACKAGE &gt; unpacked
zipinfo -1 $SRC_DIR/$PACKAGE &gt; unpacked
UNPACKDIR="$(sed 's@/.*@@' unpacked | uniq )"
if test $(wc -w &lt;&lt;&lt; $UNPACKDIR) -eq 1; then
unzip $PACKAGE
unzip $SRC_DIR/$PACKAGE
else
UNPACKDIR=${PACKAGE%.zip}
unzip -d $UNPACKDIR $PACKAGE
unzip -d $UNPACKDIR $SRC_DIR/$PACKAGE
fi
;;
*)
@ -221,7 +229,9 @@ cd $UNPACKDIR&#xA;
<xsl:text>&#xA;if [[ ! -f $</xsl:text>
<xsl:value-of select="$varname"/>
<xsl:text> ]] ; then&#xA;</xsl:text>
<!-- SRC_ARCHIVE may have subdirectories or not -->
<!-- This whole code becomes obsolete because now, it is there or we
download; keeping for now, and we may want to grab it from
SRC_ARCHIVE when SRC_SUBDIRS is set...
<xsl:text> if [[ -f $SRC_ARCHIVE/$PKG_DIR/$</xsl:text>
<xsl:value-of select="$varname"/>
<xsl:text> ]] ; then&#xA;</xsl:text>
@ -237,7 +247,7 @@ cd $UNPACKDIR&#xA;
<xsl:value-of select="$varname"/>
<xsl:text> $</xsl:text>
<xsl:value-of select="$varname"/>
<xsl:text>&#xA; else&#xA;</xsl:text>
<xsl:text>&#xA; 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>
@ -256,10 +266,10 @@ cd $UNPACKDIR&#xA;
<xsl:text>/$</xsl:text>
<xsl:value-of select="$varname"/>
<xsl:text>
cp $</xsl:text>
<!-- cp $</xsl:text>
<xsl:value-of select="$varname"/>
<xsl:text> $SRC_ARCHIVE
fi
fi-->
fi
</xsl:text>
<xsl:if test="string-length($md5) &gt; 10">
@ -268,6 +278,15 @@ fi
<xsl:text>&#x20;&#x20;$</xsl:text>
<xsl:value-of select="$varname"/>
<xsl:text>" | md5sum -c -
</xsl:text>
</xsl:if>
<!-- link additional packages into $BUILD_DIR, because they are supposed to
be there-->
<xsl:if test="string($varname) != 'PACKAGE'">
<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:if>
</xsl:template>

View file

@ -39,10 +39,26 @@ menu "BOOK Settings"
to build BLFS packages.
endchoice
choice
depends BOOK_BLFS
prompt "Init system"
config BLFS_SYSV
bool "BLFS Sys V"
help
Extract the Sys V flavour of the BLFS book
config BLFS_SYSD
bool "BLFS systemd"
help
Extract the systemd flavour of the BLFS book
endchoice
config INITSYS
string
default "sysv" if BOOK_LFS
default "systemd" if BOOK_LFS_SYSD
default "sysv" if BOOK_LFS || BLFS_SYSV
default "systemd" if BOOK_LFS_SYSD || BLFS_SYSD
config PROGNAME
string
@ -874,6 +890,7 @@ depends !BOOK_BLFS
endmenu
menu "System configuration
depends !BOOK_BLFS
#--- FSTAB
config HAVE_FSTAB

View file

@ -11,12 +11,12 @@ BLFS_ROOT : where the installed tools will be installed, relative to $HOME.
Must start with a '/' (default /blfs_root)
BLFS_BRANCH_ID: development, branch-xxx, xxx (where xxx is a valid tag)
(default development)
INIT_SYSTEM : which book do you want? 'sysv' or 'systemd' (default sysv)
INITSYS : which book do you want? 'sysv' or 'systemd' (default sysv)
Examples:
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:
(as root) mkdir -p /var/lib/jhalfs/BLFS && chown -R <user> /var/lib/jhalfs
(as user) INIT_SYSTEM=<your system> ./install-blfs-tools.sh
(as user) INITSYS=<your system> ./install-blfs-tools.sh
2 - To install with only user privileges (default to sysv):
TRACKING_DIR=$HOME/blfs_root/trackdir ./install-blfs-tools.sh
@ -80,12 +80,12 @@ BLFS_TOOL='y'
BUILDDIR=$(cd ~;pwd)
BLFS_ROOT="${BLFS_ROOT:=/blfs_root}"
TRACKING_DIR="${TRACKING_DIR:=/var/lib/jhalfs/BLFS}"
INIT_SYSTEM="${INIT_SYSTEM:=sysv}"
INITSYS="${INITSYS:=sysv}"
BLFS_BRANCH_ID=${BLFS_BRANCH_ID:=development}
BLFS_XML=${BLFS_XML:=blfs-xml}
# Validate the configuration:
PARAMS="BLFS_ROOT TRACKING_DIR INIT_SYSTEM BLFS_XML"
PARAMS="BLFS_ROOT TRACKING_DIR INITSYS BLFS_XML"
if [ "$WORKING_COPY" = y ]; then
PARAMS="$PARAMS WORKING_COPY BOOK"
else
@ -167,7 +167,7 @@ cp -a $BLFS_BOOK $BUILDDIR$BLFS_ROOT/$BLFS_XML
make -j1 -C $BUILDDIR$BLFS_ROOT \
TRACKING_DIR=$TRACKING_DIR \
REV=$INIT_SYSTEM \
REV=$INITSYS \
BLFS_XML=$BUILDDIR$BLFS_ROOT/$BLFS_XML \
SVN=svn://svn.linuxfromscratch.org/BLFS/$BLFS_TREE \
$BUILDDIR$BLFS_ROOT/packages.xml