Compare commits

..

No commits in common. "mihari-dev" and "experimental" have entirely different histories.

152 changed files with 27136 additions and 36384 deletions

5
.gitignore vendored
View file

@ -1,5 +0,0 @@
# configuration*
custom/config/
menu/__pycache__/
# pkgmngt/packInstall.sh
# pkgmngt/packageManager.xml

View file

@ -1,233 +1,40 @@
# From the Build Scripts Written By: Jim Gifford <lfs@jg555.com>
# Modified By: Joe Ciccone <jciccone@linuxfromscratch.org>
# Modified By: Joe Ciccone <jciccone@linuxfromscratch.org
# Additional changes: George Boudreau <georgeb@linuxfromscratch.org>
# Pierre Labastie <pierre.labastie at neuf.fr>
ifdef V
Q =
else
Q = @
endif
# $Id$
# Makefile should reside in a directory where there are two subdirectories
# initially:
TOPDIR = $(shell pwd)
# the stylesheets
XSLDIR = $(TOPDIR)/xsl
# the menu program sources
MENU = $(TOPDIR)/menu
LANG=C
LC_ALL=C
TOPDIR=$(shell pwd)
CONFIG_CONFIG_IN = Config.in
CONFIG = menu
# Those directories and files will be created and populated by make:
# directory of the book sources:
LFS_XML = $(TOPDIR)/lfs-xml
BLFS_XML = $(TOPDIR)/blfs-xml
# contains the REV used in the preceding call:
REVFILE = $(TOPDIR)/revision
# the list of packages:
PACK_LIST = $(TOPDIR)/packages.xml
# the generated menu input:
CONFIG_CONFIG_IN = $(TOPDIR)/Config.in
# menu output:
CONFIG_OUT = $(TOPDIR)/configuration
# the linear book:
BOOK_XML = $(TOPDIR)/book.xml
all: menuconfig
LFSTMP = $(LFS_XML)/tmp
RENDERTMP = $(BLFS_XML)/tmp
LFS_FULL = $(LFSTMP)/lfs-full.xml
BLFS_FULL = $(RENDERTMP)/blfs-full.xml
$(CONFIG)/conf:
$(MAKE) -B -C $(CONFIG) conf
# The right-hand side is updated by jhalfs:
# Where the tracking file resides:
TRACKING_DIR = tracking-dir
$(CONFIG)/mconf:
$(MAKE) -B -C $(CONFIG) ncurses conf mconf
# Will be created by make, if not existent
TRACKFILE = $(TRACKING_DIR)/instpkg.xml
menuconfig: $(CONFIG)/mconf
@./update_book.sh none
@./gen_config.sh
@$(CONFIG)/mconf $(CONFIG_CONFIG_IN)
@./gen_pkg_book.sh
# Initial content of the tracking file
define INITIAL_TRACK
<?xml version="1.0" encoding="ISO-8859-1"?>\n\
\n\
<!DOCTYPE sublist SYSTEM "$(TOPDIR)/packdesc.dtd">\n\
<sublist>\n\
<name>Installed</name>\n\
</sublist>
endef
config: $(CONFIG)/conf
@$(CONFIG)/conf $(CONFIG_CONFIG_IN)
# Git locations and branches
LFS-GIT = https://git.linuxfromscratch.org/lfs.git
LFS-BRANCH = trunk
GIT = https://git.linuxfromscratch.org/blfs.git
BLFS-BRANCH = trunk
ALLXML := $(filter-out $(RENDERTMP)/%, \
$(shell if [ -d $(BLFS_XML) ]; then \
find $(BLFS_XML) -name \*.xml; \
fi))
ALLXMLLFS:= $(filter-out $(LFSTMP)/%, \
$(shell if [ -d $(LFS_XML) ]; then \
find $(LFS_XML) -name \*.xml; \
fi))
ALLXSL := $(filter-out $(RENDERTMP)/%, \
$(shell if [ -d $(BLFS_XML) ]; then \
find $(BLFS_XML) -name \*.xsl; \
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
# set on the command line:
REV1 := $(shell if [ -f $(REVFILE) ] ; then cat $(REVFILE); fi)
ifneq ($(origin REV),command line)
ifdef REV1
REV = $(REV1)
else
REV = not defined
endif
endif
ifneq ($(REV),sysv)
ifneq ($(REV),systemd)
$(error The REV variable is $(REV), but can only be 'sysv' or 'systemd')
endif
endif
$(BOOK_XML): $(CONFIG_OUT)
$(Q)$(TOPDIR)/gen_pkg_book.sh $(TRACKFILE) $(TOPDIR) $(BLFS_FULL) $(LFS_FULL)
$(CONFIG_OUT): $(CONFIG_CONFIG_IN)
$(Q)CONFIG_="" KCONFIG_CONFIG=configuration \
python3 $(MENU)/menuconfig.py $(CONFIG_CONFIG_IN)
$(CONFIG_CONFIG_IN): $(PACK_LIST) $(XSLDIR)/gen_config.xsl
$(Q)xsltproc --nonet -o $@ $(XSLDIR)/gen_config.xsl $(PACK_LIST)
$(PACK_LIST): $(XSLDIR)/gen_pkg_list.xsl $(XSLDIR)/specialCases.xsl $(TRACKFILE) $(LFS_FULL)
$(Q)xsltproc --stringparam installed-packages $(TRACKFILE) \
--stringparam lfs-full $(LFS_FULL) \
-o $@.tmp $(XSLDIR)/gen_pkg_list.xsl $(BLFS_FULL)
$(Q)xmllint --postvalid --format -o $@ $@.tmp
$(Q)rm $@.tmp
# Beware of the echo '$(INITIAL_TRACK)' command below:
# if shell is bash or sh linked to bash, needs echo -e
# if shell is dash or sh linked to dash: echo is enough
# Don't ask me why
# So use /bin/echo (needs -e)
$(TRACKFILE): $(TRACKING_DIR)
$(Q)if ! [ -f $@ ]; then \
echo Initializing $(TRACKFILE) && \
/bin/echo -e '$(INITIAL_TRACK)' > $@; \
fi
$(Q)for track in $(TRACKING_DIR)/*-*; do \
if [ -f $$track ]; then \
pack=$$(echo $$track | sed 's@.*/\(.*\)-[0-9c].*@\1@') && \
version=$$(echo $$track | sed 's@.*-\([0-9c].*\)@\1@') && \
xsltproc --stringparam packages $(PACK_LIST) \
--stringparam package $$pack \
--stringparam version $$version \
-o track.tmp $(XSLDIR)/bump.xsl $@ && \
sed -i 's@PACKDESC@$(TOPDIR)/packdesc.dtd@' track.tmp && \
xmllint --format --postvalid track.tmp > $@; \
fi; \
rm -f $$track; \
done; \
rm -f track.tmp
$(TRACKING_DIR):
@echo Creating $(TRACKING_DIR)
$(Q)mkdir -p $@
$(XSLDIR)/specialCases.xsl: $(TOPDIR)/gen-special.sh $(BLFS_FULL)
$(Q)$(TOPDIR)/gen-special.sh $(BLFS_FULL) $@
ifneq ($(REV),$(REV1))
$(BLFS_FULL): FORCE
$(LFS_FULL): FORCE
endif
$(LFS_FULL): $(LFS_XML) $(LFS_XML)/general.ent $(ALLXMLLFS) $(ALLXSLLFS)
$(Q)cd $(LFS_XML) && if [ -x git-version.sh ] ; then \
echo "Processing LFS version..."; \
./git-version.sh $(REV); \
fi
@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)
$(Q)cd $(BLFS_XML) && if [ -x git-version.sh ] ; then \
echo "Processing BLFS version..."; \
./git-version.sh $(REV); \
fi
$(Q)[ -d $(RENDERTMP) ] || mkdir -p $(RENDERTMP)
@echo "Adjusting BLFS for revision $(REV)..."
$(Q)xsltproc --nonet --xinclude \
--stringparam profile.revision $(REV) \
--output $(RENDERTMP)/blfs-prof.xml \
$(BLFS_XML)/stylesheets/lfs-xsl/profile.xsl \
$(BLFS_XML)/index.xml
@echo "Validating the BLFS book..."
$(Q)xmllint --nonet --noent --postvalid \
-o $@ $(RENDERTMP)/blfs-prof.xml
$(Q)echo $(REV) > $(REVFILE)
all: update $(BOOK_XML)
# If in detached head state, "git pull" returns an error, so switch back to
# trunk before updating, and switch back to the branch/tag afterwards
update: $(BLFS_XML) $(LFS_XML)
@echo Updating the book sources
ifneq (,$(LFS-BRANCH))
$(Q)cd $(LFS_XML) && \
git checkout trunk && \
git pull && \
if [ $(LFS-BRANCH) != trunk ]; then git checkout $(LFS-BRANCH); fi
endif
ifneq (,$(BLFS-BRANCH))
$(Q)cd $(BLFS_XML) && \
git checkout trunk && \
git pull && \
if [ $(BLFS-BRANCH) != trunk ]; then git checkout $(BLFS-BRANCH); fi
endif
$(LFS_XML):
@echo Getting the LFS book sources...
$(Q)git clone $(LFS-GIT) $@
ifneq (,$(LFS-BRANCH))
if [ $(LFS-BRANCH) != trunk ]; then \
cd $@ && \
git checkout $(LFS-BRANCH); \
fi
endif
$(BLFS_XML):
@echo Getting the BLFS book sources...
$(Q)git clone $(GIT) $@
ifneq (,$(BLFS-BRANCH))
$(Q)if [ $(BLFS-BRANCH) != trunk ]; then \
cd $@ && \
git checkout $(BLFS-BRANCH); \
fi
endif
# Clean up
clean:
rm -f $(CONFIG_OUT) $(CONFIG_OUT).old $(TOPDIR)/packages.xml $(XSLDIR)/specialCases.xsl $(CONFIG_CONFIG_IN) book.xml
rm -rf $(TOPDIR)/dependencies $(TOPDIR)/book-html $(TOPDIR)/scripts
rm -f configuration configuration.old error
- $(MAKE) -C $(CONFIG) clean
FORCE:
.PHONY: clean all update $(CONFIG_OUT) version FORCE
clean-target:
rm -f error
- $(MAKE) -C $(CONFIG) clean
.PHONY: all menuconfig config clean clean-target $(CONFIG)/conf $(CONFIG)/mconf

View file

@ -2,6 +2,7 @@
#
# Project TODO list
#
# $Id$
#####
@ -16,25 +17,4 @@
-- Bugs hunting.
-- About dependencies
A. A DEPENDENCY MAY NOT BE INSTALLED EVEN IF NEEDED
Currently (December 10th, 2021), the dependencies are only installed
if either:
- (i) they are not already installed
- (ii) their version is higher than the installed version
If a dependency is not installed, its dependencies are not considered.
But it may happen that a dependency (depB) of a dependency (depA) is in
case (i) or (ii) (most likely), but not depA. In this case, depB is
not considered, although it might happen that it is needed for the
requested package.
So the dependency system should be changed to always compute the full
dependency chain, and another function should be created to remove
packages not in case (i) or (ii) from the list of generated dependencies.
B. CHECKING DEPENDENCIES
There are several kinds of checks we might want to implement, for
example:
- (i) check that a package can be built with only the listed
dependencies, and their dependencies (missing dependency)
- (ii) check that the dependencies do not include dependencies
that are already in the dependency chain (redundant dependency)
- (iii) check that a dependency is really needed (false dependency)
-- Find a better way to define circular dependencies.

91
BLFS/envars.conf Normal file
View file

@ -0,0 +1,91 @@
#####
#
# Configuration file for the BLFS module
#
# $Id$
#
# Set default envars used in the build scripts
#
#####
#======== Common envars ==========
#--- Set a well-known working locale when building software
export LC_ALL=C
#--- The local repository for packages/file
# Any missing file will be downloaded and archived here,
# if the user has the right priviledges.
export SRC_ARCHIVE=$SRC_ARCHIVE
#--- Server used if the file isn't found in SRC_ARCHIVE.
# As a last resort, the file will dowloaded from upstream, if possible.
#
# The server path MUST be set as listed in
# http://www.linuxfromscratch.org/blfs/download.html
export FTP_SERVER=ftp://anduin.linuxfromscratch.org/BLFS/
#--- The sources directory.
# Full path to the top level directory where packages will be stored,
# unpacked, and compiled.
export SRC_DIR=$HOME/sources
#======== Xorg7 envars ===========
#--- Installation prefix
export XORG_PREFIX=/usr
#--- Configure switches
export XORG_CONFIG="--prefix=$XORG_PREFIX --sysconfdir=/etc --mandir=$XORG_PREFIX/share/man --localstatedir=/var"
#======== GNOME envars ===========
#--- Installation prefix
export GNOME_PREFIX=/usr
#--- If you want to install GNOME on a non standart prefix, uncomment
# the next export lines and edit it if needed.
# See also the GNOME Pre-installation Configuration HTML page for
# aditional required commands.
#export PATH=$PATH:$GNOME_PREFIX/bin
#export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$GNOME_PREFIX/lib/pkgconfig
#export GNOME_LIBCONFIG_PATH=/usr/lib:$GNOME_PREFIX/lib
#======== KDE envars =============
#--- Installation prefix
export KDE_PREFIX=/usr
#--- If you want to install KDE on a non standart prefix, uncomment
# the next export lines and edit it if needed.
# See also the KDE Pre-installation Configuration HTML page for
# aditional required commands.
#export PATH=$PATH:$KDE_PREFIX/bin
#export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$KDE_PREFIX/lib/pkgconfig
#======== Optimizations =============
# Global optimization settings can be placed here. This settings can be
# overrided by settings in the packages build scripts.
# WARNING: The use of build optimizations may be dangerous.
# You should know what you are doing and be sure that the
# optimization settings placed below are what you want.
# It there are build issues or the system doesn't work as
# expected, please rebuild without optimizations before
# asking for support.
#export MAKEFLAGS="-j3"
#export CFLAGS="-O3 -pipe"
#export CXXFLAGS=$CFLAGS
#export LDFLAGS="-s"
#export OTHER_CFLAGS=$CFLAGS
#export OTHER_CXXFLAGS=$CXXFLAGS
#export OTHER_LDFLAGS=$LDFLAGS

View file

@ -1,16 +1,14 @@
#!/bin/bash
#
# $Id$
#
set -e
declare TOPDIR='..'
declare ATOPDIR=`cd $TOPDIR; pwd`
# TEMPORARY VARIABLES.. development use only
declare MKFILE=Makefile
declare PREV_PACKAGE=""
declare BUILD_SCRIPTS=${TOPDIR}/scripts
declare TRACKING_FILE=tracking-dir/instpkg.xml
declare XSLDIR=${TOPDIR}/xsl
declare PACK_FILE=${TOPDIR}/packages.xml
declare BUMP=${XSLDIR}/bump.xsl
declare BUILD_SCRIPTS=scripts
declare TRACKING_DIR=tracking-dir
HEADER="# This file is automatically generated by gen-makefile.sh
# YOU MAY NEED TO EDIT THIS FILE MANUALLY
@ -40,7 +38,7 @@ __write_build_cmd() { #
#----------------------------------#
(
cat << EOF
@${BUILD_SCRIPTS}/\$@ >logs/\$@ 2>&1
@source ../envars.conf && ${BUILD_SCRIPTS}/\$@ >logs/\$@ 2>&1
EOF
) >> $MKFILE.tmp
}
@ -48,21 +46,51 @@ EOF
#----------------------------------#
__wrt_touch() { #
#----------------------------------#
local pkg_name="${1#*-?-}"
# For having a unique id, we have added lfs- to bootscripts package.
# We need to remove it now.
case "$pkg_name" in lfs-bootscripts) pkg_name=bootscripts ;; esac
local pkg_name=$1
local pkg_ver=$2
local alsa_ver=$(grep "^alsa[[:space:]]" ../packages | cut -f3)
local kde_core_ver=$(grep "^kde-core[[:space:]]" ../packages | cut -f3)
local xorg7_ver=$(grep "^xorg7[[:space:]]" ../packages | cut -f3)
if [[ -n "$pkg_ver" ]] ; then
(
cat << EOF
@rm -f \$(TRACKING_DIR)/${pkg_name#*-?-}-{0..9}* && \\
touch \$(TRACKING_DIR)/${pkg_name#*-?-}-${pkg_ver}
EOF
) >> $MKFILE.tmp
fi
case $pkg_name in
*-alsa-lib ) #this the unique mandatory package for ALSA support.
(
cat << EOF
@rm -f \$(TRACKING_DIR)/alsa-{0..9}* && \\
touch \$(TRACKING_DIR)/alsa-${alsa_ver}
EOF
) >> $MKFILE.tmp
;;
*-kdebase )
(
cat << EOF
@rm -f \$(TRACKING_DIR)/kde-core-{0..9}* && \\
touch \$(TRACKING_DIR)/kde-core-${kde_core_ver}
EOF
) >> $MKFILE.tmp
;;
*-xorg7-driver ) # xtrerm2 and rman are optional
(
cat << EOF
@rm -f \$(TRACKING_DIR)/xorg7-{0..9}* && \\
touch \$(TRACKING_DIR)/xorg7-${xorg7_ver}
EOF
) >> $MKFILE.tmp
;;
esac
(
cat << EOF
@xsltproc --stringparam packages ${PACK_FILE} \\
--stringparam package "${pkg_name}" \\
-o track.tmp \\
${BUMP} \$(TRACKING_FILE) && \\
sed -i 's@PACKDESC@${ATOPDIR}/packdesc.dtd@' track.tmp && \\
xmllint --format --postvalid track.tmp > \$(TRACKING_FILE) && \\
rm track.tmp && \\
touch \$@ && \\
@touch \$@ && \\
sleep .25 && \\
echo -e "\n\n "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
echo --------------------------------------------------------------------------------\$(WHITE)
@ -75,6 +103,7 @@ EOF
__write_entry() { #
#----------------------------#
local script_name=$1
local pkg_ver=$2
echo -n "${tab_}${tab_} entry for <$script_name>"
@ -89,7 +118,7 @@ __write_entry() { #
# Include a touch of the target name so make can check
# if it's already been made.
__wrt_touch "${script_name}"
__wrt_touch "${script_name}" "${pkg_ver}"
#
#--------------------------------------------------------------------#
# >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
@ -97,6 +126,50 @@ __write_entry() { #
echo " .. OK"
}
#----------------------------#
__write_meta_pkg_touch() { #
#----------------------------#
local meta_pkg=$1
local pkg_ver=$(grep "^${meta_pkg}[[:space:]]" ../packages | cut -f3)
local gnome_core_ver=$(grep "^gnome-core[[:space:]]" ../packages | cut -f3)
local kde_full_ver=$(grep "^kde-full[[:space:]]" ../packages | cut -f3)
(
cat << EOF
999-z-$meta_pkg: $PREV_PACKAGE
@rm -f \$(TRACKING_DIR)/${meta_pkg}-{0..9}* && \\
touch \$(TRACKING_DIR)/${meta_pkg}-${pkg_ver}
EOF
) >> $MKFILE.tmp
case $meta_pkg in
gnome-full )
(
cat << EOF
@rm -f \$(TRACKING_DIR)/gnome-core-{0..9}* && \\
touch \$(TRACKING_DIR)/gnome-core-${gnome_core_ver}
EOF
) >> $MKFILE.tmp
;;
kde-koffice )
(
cat << EOF
@rm -f \$(TRACKING_DIR)/kde-full-{0..9}* && \\
touch \$(TRACKING_DIR)/kde-full-${kde_full_ver}
EOF
) >> $MKFILE.tmp
;;
esac
(
cat << EOF
@touch \$@
EOF
) >> $MKFILE.tmp
}
#----------------------------#
generate_Makefile () { #
#----------------------------#
@ -109,18 +182,36 @@ generate_Makefile () { #
>$MKFILE.tmp
for package_script in ${BUILD_SCRIPTS}/* ; do
for package_script in scripts/* ; do
this_script=`basename $package_script`
pkg_ver=$(grep "^${this_script#*-?-}[[:space:]]" ../packages | cut -f3)
pkg_list="$pkg_list ${this_script}"
__write_entry "${this_script}"
__write_entry "${this_script}" "${pkg_ver}"
PREV_PACKAGE=${this_script}
done
PACKAGE=$(basename $PWD)
# alsa, kde-core and xorg7 are also available dependencies, thus handled
# in another way.
case $PACKAGE in
gnome-core | \
gnome-full | \
kde-full | \
kde-koffice ) pkg_list="$pkg_list 999-z-${PACKAGE}"
__write_meta_pkg_touch "${PACKAGE}"
;;
esac
# Add a header, some variables and include the function file
# to the top of the real Makefile.
(
cat << EOF
$HEADER
TRACKING_FILE= $TRACKING_FILE
PACKAGE= $PACKAGE
TRACKING_DIR= $TRACKING_DIR
BOLD= ""
RED= ""
@ -137,7 +228,7 @@ define echo_message
endef
define end_message
define fin_message
@echo \$(BOLD)
@echo --------------------------------------------------------------------------------
@echo \$(BOLD) Build complete for the package \$(BLUE)\$(PACKAGE)\$(BOLD) and its dependencies
@ -145,7 +236,7 @@ define end_message
endef
all : $pkg_list
@\$(call end_message )
@\$(call fin_message )
EOF
) > $MKFILE
@ -156,24 +247,18 @@ EOF
}
if [[ ! -d ${BUILD_SCRIPTS} ]] ; then
echo -e "\n\tThe '${BUILD_SCRIPTS}' directory has not been found.\n"
if [[ -e Config.in ]] ; then
echo -e "\n\tThis script must be run from inside a target package directory.\n"
exit 1
fi
# Let us make a clean base, but first ensure that we are
# not emptying a useful directory.
MYDIR=$(pwd)
MYDIR=$(basename $MYDIR)
if [ "${MYDIR#work}" = "${MYDIR}" ] ; then
echo -e \\n\\tDirectory ${BOLD}$MYDIR${OFF} does not begin with \"work\"\\n
if [[ ! -d scripts ]] ; then
echo -e "\n\tNo ./scripts/ directory has been found.\n"
exit 1
fi
rm -rf *
generate_Makefile
cp ${TOPDIR}/progress_bar.sh .
cp ../progress_bar.sh .
mkdir -p logs

View file

@ -1,291 +0,0 @@
#!/bin/bash
#-------------------------------------------------------------------------
# generates an xsl stylesheet containing a template for special
# cases in the book:
# - If the version does not begin with a number, it is impossible to know
# where the package name ends and where the version begins. We therefore
# use the ENTITY at the beginning of the validated full-xml.
# - If a package is part of a group of xorg packages (proto, fonts, etc)
# there is no easy way to extract it from the xml. We use the ENTITY at
# the top of each file x7*.xml
# - Some non-versioned packages are needed as dependencies of others: we
# attribute version 1.0.0 to them. It is just used to know if the package
# is installed, by checking inst-version.
# - If a package is versioned but the version is not mentioned in the book
# (currently only udev), we retrieve the version by other means
#-------------------------------------------------------------------------
# Arguments:
# $1 contains the name of the validated xml book
# $2 contains the name of the ouput xsl file
# $3 contains the name of the book sources directory
#-------------------------------------------------------------------------
BLFS_XML=$1
if ! test -f ${BLFS_XML}; then
echo File \`${BLFS_XML}\' does not exist
exit 1
fi
SPECIAL_FILE=$2
if test -z "${SPECIAL_FILE}"; then SPECIAL_FILE=specialCases.xsl;fi
BLFS_DIR=$3
if test -z "${BLFS_DIR}"; then BLFS_DIR=$(cd $(dirname ${BLFS_XML})/.. ; pwd);fi
# Packages whose version does not begin with a number
EXCEPTIONS=$(grep 'ENTITY.*version[ ]*"[^0-9"&.].*[0-9]' ${BLFS_DIR}/packages.ent |
sed 's@^[^"]*"\([^"]*\)".*@\1@')
# Non-versioned packages:
NV_LIST="postlfs-config-profile postlfs-config-random postlfs-config-vimrc \
initramfs xorg-env kde-pre-install-config kf5-intro \
lxqt-pre-install lxqt-post-install ojdk-conf tex-path"
cat >$SPECIAL_FILE << EOF
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match='*' mode="special">
<xsl:choose>
<!-- Although versioned, this page is not a package. But
the sect2 with id "xorg-env" is referred to at several
places in the book. We have added it to the list of non
versioned packages. -->
<xsl:when test="@id='xorg7'">
<xsl:apply-templates select="child::sect2" mode="special"/>
</xsl:when>
EOF
# Non-versionned packages. Add to NV_LIST if you need more.
for nv_id in $NV_LIST; do
cat >>$SPECIAL_FILE << EOF
<xsl:when test="@id='$nv_id'">
<xsl:text> </xsl:text>
<package><xsl:text>&#xA; </xsl:text>
<xsl:element name="name">$nv_id</xsl:element>
<xsl:text>&#xA; </xsl:text>
<xsl:element name="version">1.0.0</xsl:element>
<xsl:if
test="document(\$installed-packages)//package[name=current()/@id]">
<xsl:text>&#xA; </xsl:text>
<xsl:element name="inst-version">
<xsl:value-of
select="document(\$installed-packages
)//package[name=current()/@id]/version"/>
</xsl:element>
</xsl:if>
<!-- Dependencies -->
<xsl:apply-templates select=".//para[@role='required' or
@role='recommended' or
@role='optional']"
mode="dependency"/>
<!-- End dependencies -->
<xsl:text>&#xA; </xsl:text>
</package><xsl:text>&#xA;</xsl:text>
</xsl:when>
EOF
done
# Taking packages inside x7proto etc, as versionned modules.
# We also write a dependency expansion when a dep is of the form
# xorg7-something. Since that is another template, we need
# a temporary file, which we shall concatenate at the end
cat >tmpfile << EOF
<xsl:template name="expand-deps">
<xsl:param name="section"/>
<xsl:param name="status"/>
<xsl:param name="build"/>
<xsl:choose>
EOF
for file in $(ls ${BLFS_DIR}/x/installing/x7* | grep -v x7driver); do
id=$(grep xreflabel $file | sed 's@.*id="\([^"]*\).*@\1@')
cat >>$SPECIAL_FILE << EOF
<xsl:when test="@id='$id'">
<xsl:text> </xsl:text>
<package><xsl:text>&#xA; </xsl:text>
<xsl:element name="name">$id</xsl:element>
<xsl:text>&#xA; </xsl:text>
EOF
cat >> tmpfile << EOF
<xsl:when test="\$section='$id'">
EOF
# We extract the list of packages for an xorg page from
# the version part of the .xml file. Seems that
# the order is not always the same as in the "cat" command.
# So we have to read that command too, since it may be assumed
# that the preceding package is a dependency of the following,
# except the first.
list_cat="$(sed -n '/>cat/,/EOF</p' $file | grep -v 'cat\|EOF\|#' |
awk '{ print $NF }' | sed 's/-&.*//')"
# Rationale for the sed below: the following for breaks words at spaces (unless
# we tweak IFS). So replace spaces with commas in lines so that only newlines
# are separators.
for pack in \
$(grep 'ENTITY.*version' $file | sed 's/[ ]\+/,/g'); do
packname=$(echo $pack | sed s'@.*ENTITY,\(.*\)-version.*@\1@')
packversion=$(echo $pack | sed 's@[^"]*"\([^"]*\).*@\1@')
precpack=NONE
for i in $list_cat; do
if [ "$i" = "$packname" ]; then break; fi
precpack=$i
done
# It may happen that packname is not in list_cat, because its entity
# is commented out in the xml, but we do not check that (too complicated).
# In that case, the whole list is scanned, and $precpack=$i at the end.
# when packname is found in the list $precpack!=$i.
if [ "$precpack" = "$i" ]; then continue; fi
cat >>$SPECIAL_FILE << EOF
<module><xsl:text>&#xA; </xsl:text>
<xsl:element name="name">$packname</xsl:element>
<xsl:element name="version">$packversion</xsl:element>
<xsl:if test="document(\$installed-packages)//package[name='$packname']">
<xsl:element name="inst-version">
<xsl:value-of
select="document(\$installed-packages
)//package[name='$packname']/version"/>
</xsl:element>
</xsl:if>
<!-- Dependencies -->
EOF
if test $precpack != NONE; then
cat >>$SPECIAL_FILE << EOF
<xsl:element name="dependency">
<xsl:attribute name="status">required</xsl:attribute>
<xsl:attribute name="build">before</xsl:attribute>
<xsl:attribute name="name">$precpack</xsl:attribute>
<xsl:attribute name="type">ref</xsl:attribute>
</xsl:element>
EOF
else
cat >>$SPECIAL_FILE << EOF
<xsl:apply-templates select=".//para[@role='required' or
@role='recommended' or
@role='optional']"
mode="dependency"/>
EOF
fi
cat >>$SPECIAL_FILE << EOF
<!-- End dependencies -->
</module>
EOF
# cat >> tmpfile << EOF
# <xsl:element name="dependency">
# <xsl:attribute name="status">
# <xsl:value-of select="\$status"/>
# </xsl:attribute>
# <xsl:attribute name="build">
# <xsl:value-of select="\$build"/>
# </xsl:attribute>
# <xsl:attribute name="name">$packname</xsl:attribute>
# <xsl:attribute name="type">ref</xsl:attribute>
# </xsl:element>
#EOF
precpack=$packname
done
cat >>$SPECIAL_FILE << EOF
</package>
</xsl:when>
EOF
cat >> tmpfile << EOF
<xsl:element name="dependency">
<xsl:attribute name="status">
<xsl:value-of select="\$status"/>
</xsl:attribute>
<xsl:attribute name="build">
<xsl:value-of select="\$build"/>
</xsl:attribute>
<xsl:attribute name="name">$packname</xsl:attribute>
<xsl:attribute name="type">ref</xsl:attribute>
</xsl:element>
</xsl:when>
EOF
done
for ver_ent in $EXCEPTIONS; do
id=$(grep 'xreflabel=".*'$ver_ent $BLFS_XML | sed 's@.*id="\([^"]*\)".*@\1@')
[[ -z $id ]] && continue
cat >>$SPECIAL_FILE << EOF
<xsl:when test="@id='$id'">
<!-- if there is a sect1 ancestor, we have a module -->
<xsl:choose>
<xsl:when test="ancestor::sect1">
<xsl:text> </xsl:text>
<module><xsl:text>&#xA; </xsl:text>
<xsl:element name="name">$id</xsl:element>
<xsl:text>&#xA; </xsl:text>
<xsl:element name="version">$ver_ent</xsl:element>
<xsl:if
test="document(\$installed-packages)//package[name=current()/@id]">
<xsl:text>&#xA; </xsl:text>
<xsl:element name="inst-version">
<xsl:value-of
select="document(\$installed-packages
)//package[name=current()/@id]/version"/>
</xsl:element>
</xsl:if>
<!-- Dependencies -->
<xsl:apply-templates select=".//para[@role='required' or
@role='recommended' or
@role='optional']"
mode="dependency"/>
<!-- End dependencies -->
<xsl:text>&#xA; </xsl:text>
</module><xsl:text>&#xA;</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text> </xsl:text>
<package><xsl:text>&#xA; </xsl:text>
<xsl:element name="name">$id</xsl:element>
<xsl:text>&#xA; </xsl:text>
<xsl:element name="version">$ver_ent</xsl:element>
<xsl:if
test="document(\$installed-packages)//package[name=current()/@id]">
<xsl:text>&#xA; </xsl:text>
<xsl:element name="inst-version">
<xsl:value-of
select="document(\$installed-packages
)//package[name=current()/@id]/version"/>
</xsl:element>
</xsl:if>
<!-- Dependencies -->
<xsl:apply-templates select=".//para[@role='required' or
@role='recommended' or
@role='optional']"
mode="dependency"/>
<!-- End dependencies -->
<xsl:text>&#xA; </xsl:text>
</package><xsl:text>&#xA;</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
EOF
done
cat >>$SPECIAL_FILE << EOF
<xsl:otherwise>
<xsl:apply-templates
select="self::node()[contains(translate(@xreflabel,
'123456789',
'000000000'),
'-0')
]"
mode="normal"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
EOF
cat $SPECIAL_FILE tmpfile > tmpfile1
mv tmpfile1 $SPECIAL_FILE
rm tmpfile
cat >> $SPECIAL_FILE << EOF
<xsl:otherwise>
<xsl:message>
<xsl:text>You should not be seeing this</xsl:text>
</xsl:message>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
EOF

288
BLFS/gen_config.sh Executable file
View file

@ -0,0 +1,288 @@
#!/bin/bash
#
# $Id$
#
export outFile=Config.in # file for reading and writing to.
export inFile=packages # file for reading and writing to.
declare PKG_NAME
declare PKG_XML_FILE
declare PKG_DIR
declare PKG_VER
declare INST_VER
declare INST_STRING
declare SAVE_IFS=${IFS}
declare -a DIR_TREE
declare PREV_DIR1="none"
declare PREV_DIR2="none"
declare MENU_SET1="n"
declare MENU_SET2="n"
> $outFile
#---------------------#
# MAIN #
#---------------------#
: <<enddoc
This script will create a Config.in file from the contents
of the file <packages>.
Packages previously installed will not be included.
enddoc
echo -en "\tGenerating Config.in from package data ..."
while [ 0 ]
do
# read -r || break 1
read || break 1
set -- $REPLY
PKG_NAME=$1
PKG_XML_FILE=$(basename $2)
PKG_DIR=$(dirname $2)
PKG_VER=$3
INST_VER=$4
# These are the META packages.
if [ $PKG_DIR = "." ]; then
SET_COMMENT=y
# Do not include previously installed packages
if [ -n "${PKG_VER}" ] && [[ "x${PKG_VER}" = "x${INST_VER}" ]]; then
continue
fi
# Do not include installed packages newer than the book ones
if [ -n "${PKG_VER}" ] && [[ "x${PKG_VER}" < "x${INST_VER}" ]]; then
continue
fi
# Set installed version for updated meta-packages
[ -n "${INST_VER}" ] && INST_STRING="[installed ${INST_VER}]"
META_PKG=$(echo ${PKG_NAME} | tr [a-z] [A-Z])
(
cat << EOF
config CONFIG_$META_PKG
bool "$META_PKG $PKG_VER $INST_STRING"
default n
menu "$(echo ${PKG_NAME} | tr [a-z] [A-Z]) components"
depends CONFIG_$META_PKG
EOF
) >> $outFile
unset INST_STRING
# Include the dependency data for this meta package
while [ 0 ]; do
read || break 1
PKG_NAME=${REPLY}
PKG_VER=$(grep "^${PKG_NAME}[[:space:]]" $inFile | cut -f3)
INST_VER=$(grep "^${PKG_NAME}[[:space:]]" $inFile | cut -f4)
# Skip installed meta-package components
if [ -n "${PKG_VER}" ] && [[ "x${PKG_VER}" = "x${INST_VER}" ]]; then
continue
fi
# Do not include installed packages newer than the book ones
if [ -n "${PKG_VER}" ] && [[ "x${PKG_VER}" < "x${INST_VER}" ]]; then
continue
fi
# Set installed version for updated meta-packages components
[ -n "${INST_VER}" ] && INST_STRING="[installed ${INST_VER}]"
(
cat << EOF
config DEP_${META_PKG}_${PKG_NAME}
bool "$PKG_NAME ${PKG_VER} ${INST_STRING}"
default y
EOF
) >> $outFile
unset INST_STRING
done <./libs/${PKG_NAME}.dep
echo -e "endmenu" >> $outFile
continue
fi
[[ "${SET_COMMENT}" = "y" ]] && echo "comment \"\"" >>$outFile; unset SET_COMMENT
# Deal with targets that are part of a meta-package but that are in the same
# directory that non meta-package targets
case ${PKG_NAME} in
alsa-* | \
xorg7-* | \
x-config | \
x-setup | \
libXau | \
libxcb | \
libXdmcp | \
luit | \
xbitmaps | \
xcb-proto | \
xkeyboard-config | \
mesalib | \
libdrm ) continue ;;
esac
# Skip installed packages
if [ -n "${PKG_VER}" ] && [[ "x${PKG_VER}" = "x${INST_VER}" ]]; then
continue
fi
# Do not include installed packages newer than the book ones
if [ -n "${PKG_VER}" ] && [[ "x${PKG_VER}" < "x${INST_VER}" ]]; then
continue
fi
# Set installed version for updated packages
[ -n "${INST_VER}" ] && INST_STRING="[installed ${INST_VER}]"
IFS="/"
DIR_TREE=(${PKG_DIR})
IFS="$SAVE_IFS"
# Define a top level menu
if [ "$PREV_DIR1" != "${DIR_TREE[1]}" ]; then
[[ "${DIR_TREE[1]}" = "kde" ]] && continue
[[ "${DIR_TREE[1]}" = "gnome" ]] && continue
if [ $MENU_SET1 = "y" ]; then
# Close out any open secondary menu
if [ $MENU_SET2 = "y" ]; then
echo -e "\tendmenu" >> $outFile
# Reset 'menu open' flag
MENU_SET2="n"
fi
# Close the current top level menu
echo -e "endmenu\n" >> $outFile
fi
# Open a new top level menu
echo -e "menu "$(echo ${DIR_TREE[1]:0:1} | tr [a-z] [A-Z])${DIR_TREE[1]:1}"" >> $outFile
MENU_SET1="y"
fi
# Define a secondary menu
if [ "$PREV_DIR2" != "${DIR_TREE[2]}" ]; then
# Close out the previous open menu structure
if [ $MENU_SET2 = "y" ]; then
echo -e "\tendmenu\n" >> $outFile
fi
# Initialize a new 2nd level menu structure.
echo -e "\tmenu "$(echo ${DIR_TREE[2]:0:1} | tr [a-z] [A-Z])${DIR_TREE[2]:1}"" >> $outFile
MENU_SET2="y"
fi
(
cat << EOF
config CONFIG_$PKG_NAME
bool "$PKG_NAME ${PKG_VER} ${INST_STRING}"
default n
EOF
) >> $outFile
unset INST_STRING
PREV_DIR1=${DIR_TREE[1]}
PREV_DIR2=${DIR_TREE[2]}
done <"$inFile"
if [ $MENU_SET2 = "y" ]; then echo -e "\tendmenu" >> $outFile; fi
if [ $MENU_SET1 = "y" ]; then echo "endmenu" >> $outFile; fi
(
cat << EOF
comment ""
menu "Default packages for resolving dependencies"
choice
prompt "Default print server"
config PS_cups
bool "cups"
config PS_LPRng
bool "LPRng"
endchoice
config PRINT_SERVER
string
default cups if PS_cups
default LPRng if PS_LPRng
choice
prompt "Mail server"
config MS_sendmail
bool "sendmail"
config MS_postfix
bool "postfix"
config MS_exim
bool "exim"
endchoice
config MAIL_SERVER
string
default sendmail if MS_sendmail
default postfix if MS_postfix
default exim if MS_exim
choice
prompt "Postscript package"
config GS_espgs
bool "espgs"
config GS_ghostscript
bool "ghostscript"
endchoice
config GHOSTSCRIPT
string
default espgs if GS_espgs
default ghostscript if GS_ghostscript
choice
prompt "Kerberos 5"
config KER_mitkrb
bool "mitkrb"
config KER_heimdal
bool "heimdal"
endchoice
config KBR5
string
default heimdal if KER_heimdal
default mitkrb if KER_mitkrb
choice
prompt "Window package"
config WIN_xorg7
bool "Xorg7"
config WIN_xfree86
bool "xfree86"
endchoice
config X11
string
default xorg7 if WIN_xorg7
default xfree86 if WIN_xfree86
endmenu
choice
prompt "Dependency level"
default DEPLVL_2
config DEPLVL_1
bool "Required dependencies only"
config DEPLVL_2
bool "Required and recommended dependencies"
config DEPLVL_3
bool "Required, recommended and optional dependencies"
endchoice
config optDependency
int
default 1 if DEPLVL_1
default 2 if DEPLVL_2
default 3 if DEPLVL_3
config SUDO
bool "Build as User"
default y
help
Select if sudo will be used (you want build as a normal user)
otherwise sudo is not needed (you want build as root)
EOF
) >> $outFile
echo "done"

View file

@ -1,62 +1,27 @@
#!/bin/bash
#
# $Id$
#
# Read and parse the configuration parameters..
#
set -e
TRACKFILE=$1
if test -z "$TRACKFILE"; then
TRACKFILE=tracking-dir/instpkg.xml
fi
TOPDIR=$2
if test -z "$TOPDIR"; then
TOPDIR=$(pwd)
fi
BLFS_FULL=$3
if test -z "$BLFS_FULL"; then
BLFS_FULL=${TOPDIR}/blfs-xml/tmp/blfs-full.xml
fi
LFS_FULL=$4
if test -z "$LFS_FULL"; then
LFS_FULL=${TOPDIR}/lfs-xml/tmp/lfs-full.xml
fi
declare -r ConfigFile="${TOPDIR}/configuration"
declare DepDir="${TOPDIR}/dependencies"
declare LibDir="${TOPDIR}/libs"
declare PackFile="${TOPDIR}/packages.xml"
declare BookXml="${TOPDIR}/book.xml"
declare MakeBook="${TOPDIR}/xsl/make_book.xsl"
declare GetVersion="${TOPDIR}/xsl/get_version.xsl"
declare MakeScripts="${TOPDIR}/xsl/scripts.xsl"
declare ListLFS="${TOPDIR}/xsl/list_lfs.xsl"
declare BookHtml="${TOPDIR}/book-html"
declare BLFS_XML="${TOPDIR}/blfs-xml"
declare -a TARGET
declare -r ConfigFile="configuration"
declare TARGET
declare DEP_LEVEL
declare SUDO
declare LANGUAGE
declare WRAP_INSTALL
declare PACK_INSTALL
declare DEL_LA_FILES
declare STATS
declare DEP_CHECK
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
declare PKGXML
declare BLFS_XML
declare VERBOSITY=1
#--------------------------#
parse_configuration() { #
#--------------------------#
local -i cntr=0
local -a optTARGET
local cntr
local optTARGET
while read; do
while [ 0 ]; do
read || break 1
# Garbage collection
case ${REPLY} in
@ -64,78 +29,96 @@ parse_configuration() { #
esac
case "${REPLY}" in
CONFIG_ALSA=* | \
CONFIG_GNOME-CORE=* | \
CONFIG_GNOME-FULL=* | \
CONFIG_KDE-CORE=* | \
CONFIG_KDE-FULL=* | \
CONFIG_KDE-KOFFICE=* | \
CONFIG_XORG7=* ) REPLY=${REPLY%=*} # Strip the trailing '=y' test.. unecessary
echo -n "${REPLY}"
if [[ $((++cntr)) > 1 ]]; then
echo " <<-- ERROR:: SELECT ONLY 1 PACKAGE AT A TIME, META-PACKAGE NOT SELECTED"
else
echo ""
optTARGET=$(echo $REPLY | cut -d "_" -f2 | tr [A-Z] [a-z])
fi
continue ;;
# Create global variables for these parameters.
optDependency=* | \
PRINT_SERVER=* | \
MAIL_SERVER=* | \
WRAP_INSTALL=* | \
PACK_INSTALL=* | \
DEL_LA_FILES=* | \
STATS=* | \
DEP_CHECK=* | \
LANGUAGE=* | \
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..
GHOSTSCRIPT=* | \
KBR5=* | \
X11=* | \
SUDO=* ) eval ${REPLY} # Define/set a global variable..
continue ;;
esac
if [[ "${REPLY}" =~ ^CONFIG_ ]]; then
echo "$REPLY"
optTARGET[$((cntr++))]=$( echo $REPLY | sed -e 's@CONFIG_@@' -e 's@=y@@' )
echo -n "$REPLY"
if [[ $((++cntr)) > 1 ]]; then
echo " <<-- ERROR SELECT ONLY 1 PACKAGE AT A TIME, WILL NOT BUILD"
else
echo ""
optTARGET=$( echo $REPLY | sed -e 's@CONFIG_@@' -e 's@=y@@' )
fi
fi
done < $ConfigFile
done <$ConfigFile
if (( $cntr == 0 )); then
echo -e "\n>>> NO TARGET SELECTED.. application terminated"
echo -e " Run <make> again and select (a) package(s) to build\n"
if [[ $optTARGET = "" ]]; then
echo -e "\n>>> NO TARGET SELECTED.. applicaton terminated"
echo -e " Run <make> again and select a package to build\n"
exit 0
fi
TARGET=(${optTARGET[*]})
TARGET=$optTARGET
DEP_LEVEL=$optDependency
SUDO=${SUDO:-n}
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 PACK_INSTALL DEL_LA_FILES STATS DEP_CHECK SRC_ARCHIVE SRC_SUBDIRS BUILD_ROOT BUILD_SUBDIRS KEEP_FILES JOBS CFG_CFLAGS CFG_CXXFLAGS CFG_LDFLAGS"
local -r PARAM_LIST="TARGET DEP_LEVEL SUDO PRINT_SERVER MAIL_SERVER GHOSTSCRIPT KBR5 X11"
local -r PARAM_VALS='${config_param}${dotSTR:${#config_param}} ${L_arrow}${BOLD}${!config_param}${OFF}${R_arrow}'
local config_param
local -i index
for config_param in ${PARAM_LIST}; do
echo -e "`eval echo $PARAM_VALS`"
done
for (( index=0 ; index < ${#TARGET[*]} ; index ++ )); do
echo -e "TARGET${index}${dotSTR:6} ${L_arrow}${BOLD}${TARGET[${index}]}${OFF}${R_arrow}"
done
}
#
# Generates the root of the dependency tree
# Regenerate the META-package dependencies from the configuration file
#
#--------------------------#
generate_deps() { #
regenerate_deps() { #
#--------------------------#
local -i index
local DepDir=$1
rm -f $DepDir/*.{tree,dep}
for (( index=0 ; index < ${#TARGET[*]} ; index ++ )); do
echo 1 b ${TARGET[${index}]} >> $DepDir/root.dep
rm -f libs/*.dep-MOD
while [ 0 ]; do
read || break 1
case ${REPLY} in
\#* | '') continue ;;
esac
# Drop the "=y"
REPLY=${REPLY%=*}
if [[ "${REPLY}" =~ ^DEP_ ]]; then
META_PACKAGE=$(echo $REPLY | cut -d "_" -f2 | tr [A-Z] [a-z])
DEP_FNAME=$(echo $REPLY | cut -d "_" -f3)
echo "${DEP_FNAME}" >>libs/${META_PACKAGE}.dep-MOD
fi
done <$ConfigFile
#
# Replace to 'old' dependency file with a new one.
#
for dst in `ls ./libs/*.dep-MOD 2>/dev/null`; do
cp -vf $dst ${dst%-MOD}
done
}
@ -148,23 +131,29 @@ generate_deps() { #
clean_configuration() { #
#--------------------------#
tail -n 15 ${ConfigFile} > ${ConfigFile}.tmp
mv ${ConfigFile}.tmp ${ConfigFile}
tail -n 29 configuration > configuration.tmp
mv configuration.tmp configuration
}
#---------------------
# Constants
source ${LibDir}/constants.inc
source libs/constants.inc
[[ $? > 0 ]] && echo -e "\n\tERROR: constants.inc did not load..\n" && exit
#---------------------
# Dependencies module
source ${LibDir}/func_dependencies
source libs/func_dependencies
[[ $? > 0 ]] && echo -e "\n\tERROR: func_dependencies did not load..\n" && exit
#---------------------
# parser module
source libs/func_parser
[[ $? > 0 ]] && echo -e "\n\tERROR: func_parser did not load..\n" && exit
#------- MAIN --------
if [[ ! -f ${PackFile} ]] ; then
if [[ ! -f packages ]] ; then
echo -e "\tNo packages file has been found.\n"
echo -e "\tExecution aborted.\n"
exit 1
@ -181,166 +170,9 @@ if [ x$ANSWER != "xyes" ] ; then
exit 1
fi
echo "${nl_}${SD_BORDER}${nl_}"
rm -rf $DepDir
mkdir $DepDir
generate_deps $DepDir
pushd $DepDir > /dev/null
set +e
generate_subgraph root.dep 1 1 b
echo -e "\n${SD_BORDER}"
echo Graph contains $(ls |wc -l) nodes
echo -e "${SD_BORDER}"
echo Cleaning subgraph...
clean_subgraph
echo done
echo Generating the tree
echo 1 > root.tree
echo 1 >> root.tree
cat root.dep >> root.tree
generate_dependency_tree root.tree 1
echo -e "\n${SD_BORDER}"
echo Generating the ordered full dependency list
FULL_LIST="$(tree_browse root.tree)"
set -e
popd > /dev/null
#echo "$FULL_LIST"
#echo -e \\n provisional end...
#exit
echo Generating the ordered package list
LIST=
while read p; do
if [ "$p" != "${p%-pass1}" ]; then
# If the pass2 is installed, no need for pass1. We get its
# installed version from TRACKFILE; We could use PackFile, but
# the test would be slightly more complicated.
echo Treating $p
pass2_v=$(xsltproc --stringparam package "${p%-pass1}" \
$GetVersion $TRACKFILE | head -n1)
echo Found pass2_v=$pass2_v
if [ -n "$pass2_v" ]; then continue; fi
# We need to get the installed version from TRACKFILE
inst_v=$(xsltproc --stringparam package "$p" $GetVersion $TRACKFILE | \
head -n1)
if [ -z "$inst_v" ]; then inst_v=0; fi
echo Found inst_v=$inst_v
# The available version is taken from PackFile
avail_v=$(xsltproc --stringparam package "${p%-pass1}" \
$GetVersion $PackFile | head -n1)
echo Found avail_v=$avail_v
versions="$avail_v
$inst_v"
echo which gives versions=$versions
else
versions=$(xsltproc --stringparam package "$p" $GetVersion $PackFile)
fi
if [ "$versions" != "$(sort -V <<<$versions)" ]; then
LIST="$LIST $p"
fi
done <<<$FULL_LIST
#echo \""$LIST"\"
#echo -e \\n provisional end...
#exit
rm -f ${BookXml}
echo Making XML book
xsltproc --stringparam list "$LIST" \
--stringparam MTA "$MAIL_SERVER" \
--stringparam lfsbook "$LFS_FULL" \
-o ${BookXml} \
${MakeBook} \
$BLFS_FULL
echo "making HTML book (may take some time...)"
xsltproc -o ${BookHtml}/ \
-stringparam chunk.quietly 1 \
${BLFS_XML}/stylesheets/blfs-chunked.xsl \
${BookXml}
if [ ! -d ${BookHtml}/stylesheets ]
then mkdir -p ${BookHtml}/stylesheets
cp ${BLFS_XML}/stylesheets/lfs-xsl/*.css ${BookHtml}/stylesheets
fi
if [ ! -d ${BookHtml}/images ]
then mkdir -p ${BookHtml}/images
cp ${BLFS_XML}/images/*.png ${BookHtml}/images
fi
for ht in ${BookHtml}/*.html
do sed -i 's@\.\./stylesheets@stylesheets@' $ht
sed -i 's@\.\./images@images@' $ht
done
echo -en "\n\tGenerating the build scripts ...\n"
rm -rf scripts
if test $STATS = y; then
LIST_STAT="${TARGET[*]}"
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 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)" \
--output ./scripts/ \
${MakeScripts} \
${BookXml}
# Make the scripts executable.
chmod -R +x scripts
echo -e "done\n"
if [ -n "$DEP_CHECK" ]; then
if (( ${#TARGET[*]} != 1 )); then
printf "\nWARNING: If dependencies are checked, only one package\n"
printf " shoud be selected. Not generating check code.\n"
exit
fi
LIST_LFS="$(xsltproc $ListLFS $LFS_FULL)"
LIST_NEEDED="$(echo $FULL_LIST)"
LIST_INSTALLED="$(porg -a | sed 's/-[[:digit:]].*//')"
LIST_UNNEEDED=
for p in $LIST_INSTALLED; do
case " $LIST_LFS " in *" $p "*) continue ;; esac
case " $LIST_NEEDED " in *" $p "*) continue ;; esac
LIST_UNNEEDED="$LIST_UNNEEDED $p"
done
cat >head.tmp <<EOF
#!/bin/bash
set -e
# Remove all unneeded packages
VERSIONED_LIST=
for p in $LIST_UNNEEDED; do
VERSIONED_LIST="\$VERSIONED_LIST \$(porg \$p)"
sudo porg -rb \$p
done
# Function to restore packages
restore_pack () {
for p in \$VERSIONED_LIST; do
sudo porgball -e -l /var/lib/packages/\${p}.porg.tar.gz
done
}
trap restore_pack ERR
EOF
cat >tail.tmp <<EOF
restore_pack
exit
EOF
sed -e "1,2d" -e '$d' scripts/*${TARGET} >script.tmp
cat head.tmp script.tmp tail.tmp >scripts/*${TARGET}
rm *.tmp
fi
#clean_configuration
regenerate_deps
generate_dependency_tree
generate_TARGET_xml
generate_target_book
create_build_scripts "${SUDO}"
clean_configuration

105
BLFS/libs/book.xsl Normal file
View file

@ -0,0 +1,105 @@
<?xml version='1.0' encoding='ISO-8859-1'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/1999/xhtml"
version="1.0">
<!-- $Id$ -->
<!-- NOTE: the base dir (blfs-xml) is set to the proper dir
via a sed in ./blfs -->
<xsl:import href="../blfs-xml/stylesheets/blfs-chunked.xsl"/>
<xsl:param name="mail_server" select="sendmail"/>
<xsl:param name="xwindow" select="xorg7"/>
<!-- Template from BLFS_XML/stylesheets/xhtml/lfs-xref.xsl.-->
<xsl:template match="xref" name="xref">
<!-- IDs that need be remaped to the proper file -->
<xsl:variable name="linkend">
<xsl:choose>
<xsl:when test="@linkend = 'alsa'">
<xsl:text>alsa-lib</xsl:text>
</xsl:when>
<xsl:when test="@linkend = 'arts'">
<xsl:text>aRts</xsl:text>
</xsl:when>
<xsl:when test="@linkend = 'kde'">
<xsl:text>kdelibs</xsl:text>
</xsl:when>
<xsl:when test="@linkend = 'server-mail'">
<xsl:value-of select="$mail_server"/>
</xsl:when>
<xsl:when test="@linkend = 'x-window-system'">
<xsl:value-of select="$xwindow"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@linkend"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="targets" select="key('id',$linkend)"/>
<!-- -->
<xsl:variable name="target" select="$targets[1]"/>
<xsl:variable name="refelem" select="local-name($target)"/>
<xsl:variable name="role" select="@role"/>
<xsl:call-template name="check.id.unique">
<xsl:with-param name="linkend" select="$linkend"/>
</xsl:call-template>
<xsl:call-template name="anchor"/>
<xsl:choose>
<!-- Dead links -->
<xsl:when test="count($target) = 0">
<b>
<xsl:value-of select="@linkend"/>
</b>
<tt>
<xsl:text> (in the full book)</xsl:text>
</tt>
</xsl:when>
<!-- -->
<xsl:when test="$target/@xreflabel">
<a>
<xsl:attribute name="href">
<xsl:call-template name="href.target">
<xsl:with-param name="object" select="$target"/>
</xsl:call-template>
</xsl:attribute>
<xsl:call-template name="xref.xreflabel">
<xsl:with-param name="target" select="$target"/>
</xsl:call-template>
</a>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="href">
<xsl:call-template name="href.target">
<xsl:with-param name="object" select="$target"/>
</xsl:call-template>
</xsl:variable>
<xsl:apply-templates select="$target" mode="xref-to-prefix"/>
<a href="{$href}">
<xsl:if test="$target/title or $target/*/title">
<xsl:attribute name="title">
<xsl:apply-templates select="$target" mode="xref-title"/>
</xsl:attribute>
</xsl:if>
<xsl:apply-templates select="$target" mode="xref-to">
<xsl:with-param name="referrer" select="."/>
<xsl:with-param name="role" select="$role"/>
<xsl:with-param name="xrefstyle">
<xsl:value-of select="@xrefstyle"/>
</xsl:with-param>
</xsl:apply-templates>
</a>
<xsl:apply-templates select="$target" mode="xref-to-suffix"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>

View file

@ -2,6 +2,7 @@
#
# common constants
#
# $Id$
#####

View file

@ -0,0 +1,47 @@
<?xml version="1.0"?>
<!-- $Id$ -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="text"/>
<xsl:param name="dependencies" select="2"/>
<xsl:template match="/">
<xsl:apply-templates select="//para[@role='optional']"/>
<xsl:apply-templates select="//para[@role='recommended']"/>
<xsl:apply-templates select="//para[@role='required']"/>
</xsl:template>
<xsl:template match="//text()"/>
<xsl:template match="para[@role='required']">
<xsl:apply-templates select="xref">
<xsl:sort select="position()" data-type="number" order="descending"/>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="para[@role='recommended']">
<xsl:if test="$dependencies != '1'">
<xsl:apply-templates select="xref">
<xsl:sort select="position()" data-type="number" order="descending"/>
</xsl:apply-templates>
</xsl:if>
</xsl:template>
<xsl:template match="para[@role='optional']">
<xsl:if test="$dependencies = '3'">
<xsl:apply-templates select="xref">
<xsl:sort select="position()" data-type="number" order="descending"/>
</xsl:apply-templates>
</xsl:if>
</xsl:template>
<xsl:template match="xref">
<xsl:value-of select="@linkend"/>
<xsl:text>&#xA;</xsl:text>
</xsl:template>
</xsl:stylesheet>

File diff suppressed because it is too large Load diff

231
BLFS/libs/func_packages Normal file
View file

@ -0,0 +1,231 @@
#!/bin/bash
#
# $Id$
#
set -e
#-----------------------#
get_pkg_ver() { # Find package version for a given package ID
#-----------------------#
local pkg_id=$1
case ${pkg_id} in
# ALSA packages version
alsa* ) pkg_id=alsa ;;
# KDE packages version
kdevelop ) : ;;
kde*config ) : ;;
kde* ) pkg_id=kde ;;
# Xorg7 packages version
xorg7-server ) pkg_id=xorg-server ;;
xterm2 ) pkg_id=xterm ;;
xorg7* ) pkg_id=xorg7 ;;
# Others (ID value don't match entity name)
wireless_tools ) pkg_id=wireless-tools ;;
bind-utils ) pkg_id=bind ;;
html-tidy ) pkg_id=tidy ;;
reiserfs ) pkg_id=reiser ;;
xfs ) pkg_id=xfsprogs ;;
esac
xmllint --noent ./${BLFS_XML}/book/bookinfo.xml 2>/dev/null | \
grep -i " ${pkg_id}-version " | cut -d "\"" -f2 | sed "s/ /_/g"
}
#-----------------------#
get_installed_ver() { # Find installed package version for a given package ID
#-----------------------#
local pkg_id=$1
case ${pkg_id} in
html-tidy )
find $TRACKING_DIR -name "${pkg_id}-cvs_[[:digit:]]*" | sed "s/.*${pkg_id}-//"
;;
cdparanoia )
find $TRACKING_DIR -name "${pkg_id}-III-[[:digit:]]*" | sed "s/.*${pkg_id}-//"
;;
ffmpeg )
find $TRACKING_DIR -name "${pkg_id}-svn_[[:digit:]]*" | sed "s/.*${pkg_id}-//"
;;
psutils )
find $TRACKING_DIR -name "${pkg_id}-p[[:digit:]]*" | sed "s/.*${pkg_id}-//"
;;
* )
find $TRACKING_DIR -name "${pkg_id}-[[:digit:]]*" | sed "s/.*${pkg_id}-//" | sed "s/ /_/g"
;;
esac
}
#-----------------------#
generate_packages() { # Master packages file
#-----------------------#
local pkg_id file pkg_ver
local ALSA_VER GNOME_VER GNOME_MINOR_VER KDE_VER KDE_KOFFICE_VER XORG7_VER
> packages.tmp
# Extract Id and path for sect1 files
for file in `find $BLFS_XML -name "*.xml"` ; do
pkg_id=$(grep "sect1 id" $file | sed -e 's/<sect1 id="//;s/".*//')
case ${pkg_id} in
dbus-bindings | \
perl-modules | \
python-modules ) pkg_ver=0.no_version ;;
* ) pkg_ver=$(get_pkg_ver $pkg_id) ;;
esac
installed_ver=$(get_installed_ver $pkg_id)
[[ ! -z "$pkg_id" ]] && echo -e "$pkg_id\t$file\t$pkg_ver\t$installed_ver" >> packages.tmp
done
# IDs clean-up (unuseful pages or commented-out packages, could be more)
sed -i '/template/d;/ntroduction/d;/preface/d;/alsa.xml/d;/xorg.xml/d' packages.tmp
sed -i '/obsolete/d;/ispell\t/d;/postlfs-/d;/-client.xml/d;/xorg7.xml/d' packages.tmp
sed -i '/courier.xml/d;/-other\t/d;/others-/d;/other-/d;/^ash\t/d' packages.tmp
sed -i '/fw-firewall\t/d;/gcc2\t/d;/cvsserver\t/d;/svnserver\t/d' packages.tmp
sed -i '/fam\t/d;/libungif\t/d;/ncpfs\t/d;/slrn\t/d;/konq\t/d;/arts\t/d' packages.tmp
sed -i '/gst-plugins\t/d;/gimp-print\t/d;/openquicktime\t/d;/compressdoc\t/d' packages.tmp
sed -i '/errata\t/d;/foreword\t/d;/organization\t/d;/whoread\t/d' packages.tmp
# Meta-packages version
ALSA_VER=$(get_pkg_ver alsa)
GNOME_VER=$(get_pkg_ver gnome)
GNOME_MINOR_VER=$(get_pkg_ver gnome-minor)
KDE_VER=$(get_pkg_ver kde)
KDE_INST_VER=$(get_installed_ver kde)
KDE_KOFFICE_VER=$(get_pkg_ver koffice)
XORG7_VER=$(get_pkg_ver xorg7)
# Meta-packages installed version
ALSA_INST_VER=$(get_installed_ver alsa)
GNOME_CORE_INST_VER=$(get_installed_ver gnome-core)
GNOME_FULL_INST_VER=$(get_installed_ver gnome-full)
KDE_CORE_INST_VER=$(get_installed_ver kde-core)
KDE_FULL_INST_VER=$(get_installed_ver kde-full)
KDE_KOFFICE_INST_VER=$(get_installed_ver kde-koffice)
XORG7_INST_VER=$(get_installed_ver xorg7)
# Add header with meta-packages pseudo Id
{
cat << EOF
alsa $BLFS_XML $ALSA_VER $ALSA_INST_VER
gnome-core $BLFS_XML $GNOME_VER$GNOME_MINOR_VER $GNOME_CORE_INST_VER
gnome-full $BLFS_XML $GNOME_VER$GNOME_MINOR_VER $GNOME_FULL_INST_VER
kde-core $BLFS_XML $KDE_VER $KDE_CORE_INST_VER
kde-full $BLFS_XML $KDE_VER $KDE_FULL_INST_VER
kde-koffice $BLFS_XML $KDE_KOFFICE_VER $KDE_KOFFICE_INST_VER
xorg7 $BLFS_XML $XORG7_VER $XORG7_INST_VER
EOF
} >> packages.tmp
# Dump packages list
sort packages.tmp -b --key=2 --field-separator=/ --output=packages
# Clean up
rm packages.tmp
}
# Pre-made *.dep files for meta-packages
#--------------------------#
generate_gnome_core() { # GNOME core
#--------------------------#
local line base_xml package
> gnome-core.dep.tmp
for line in `grep "xi:include" $BLFS_XML/gnome/core/core.xml` ; do
base_xml=`echo $line | sed 's/^.*href="//;s/".*//'`
package=`grep "gnome/core/$base_xml" packages | cut -f1`
[[ -n "$package" ]] && echo $package >> gnome-core.dep.tmp
done
# Replace dummy packages with the proper ones
sed -i 's/GNOME-//g' gnome-core.dep.tmp
tac gnome-core.dep.tmp > libs/gnome-core.dep
rm gnome-core.dep.tmp
}
#--------------------------#
generate_gnome_full() { # GNOME full
#--------------------------#
local line base_xml package
echo "gnome-core" > gnome-full.dep.tmp
for line in `grep "xi:include" $BLFS_XML/gnome/add/add.xml` ; do
base_xml=`echo $line | sed 's/^.*href="//;s/".*//'`
package=`grep "gnome/add/$base_xml" packages | cut -f1`
[[ -n "$package" ]] && echo $package >> gnome-full.dep.tmp
done
tac gnome-full.dep.tmp > libs/gnome-full.dep
rm gnome-full.dep.tmp
}
#--------------------------#
generate_kde_core() { # KDE core
#--------------------------#
local line base_xml package
> kde-core.dep.tmp
for line in `grep "xi:include" $BLFS_XML/kde/core/core.xml` ; do
base_xml=`echo $line | sed 's/^.*href="//;s/".*//'`
package=`grep "kde/core/$base_xml" packages | cut -f1`
[[ -n "$package" ]] && echo $package >> kde-core.dep.tmp
done
tac kde-core.dep.tmp > libs/kde-core.dep
rm kde-core.dep.tmp
}
#--------------------------#
generate_kde_full() { # KDE full
#--------------------------#
local line base_xml package
echo "kde-core" > kde-full.dep.tmp
for line in `grep "xi:include" $BLFS_XML/kde/add/add.xml` ; do
base_xml=`echo $line | sed 's/^.*href="//;s/".*//'`
package=`grep "kde/add/$base_xml" packages | cut -f1`
[[ -n "$package" ]] && echo $package >> kde-full.dep.tmp
done
for line in `grep "xi:include" $BLFS_XML/kde/devel/devel.xml` ; do
base_xml=`echo $line | sed 's/^.*href="//;s/".*//'`
package=`grep "kde/devel/$base_xml" packages | cut -f1`
[[ -n "$package" ]] && echo $package >> kde-full.dep.tmp
done
tac kde-full.dep.tmp > libs/kde-full.dep
rm kde-full.dep.tmp
}
#--------------------------#
generate_kde_koffice() { # KDE full + Koffice
#--------------------------#
echo -e "koffice\nkde-full\nkde-core" > libs/kde-koffice.dep
}
#--------------------------#
generate_alsa() { # ALSA packages
#--------------------------#
echo -e "alsa-oss\nalsa-firmware\nalsa-tools\nalsa-utils\n\
alsa-plugins\nalsa-lib" > libs/alsa.dep
}
#--------------------------#
generate_xorg7() { # Xorg7 packages
#--------------------------#
echo -e "x-config\nx-setup\nrman\nxterm2\nxorg7-driver\nxorg7-server\nluit\n\
xkeyboard-config\nxorg7-font\nxorg7-data\nxorg7-app\nmesalib\nlibdrm\nxbitmaps\n\
xorg7-lib\nlibxcb\nxcb-proto\nlibXdmcp\nlibXau\nxorg7-util\nxorg7-proto" > libs/xorg7.dep
}

151
BLFS/libs/func_parser Normal file
View file

@ -0,0 +1,151 @@
#!/bin/bash
#####
#
# Parse the XML documents to create a 'package' book
#
# $Id$
#####
#----------------------------#
generate_TARGET_xml() { #
#----------------------------#
: <<inline_doc
function: Generate the XML document for the TARGET package
input vars: nothing
externals: vars: TARGET
modifies: nothing
returns: nothing
output: file: $TARGET-index.xml
on error: nothing
on success: nothing
inline_doc
local
echo -en "\n\tGenerating $TARGET-index.xml ..."
#---------------------
# Header to $TARGET-index.xml
{
cat << EOF
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" >
<book>
<xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="../$BLFS_XML/book/bookinfo.xml"/>
<preface>
<?dbhtml filename="preface.html" dir="preface"?>
<title>Preface</title>
<xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="../$BLFS_XML/introduction/important/locale-issues.xml"/>
<xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="../$BLFS_XML/introduction/important/bootscripts.xml"/>
</preface>
<chapter>
<?dbhtml filename="chapter.html" dir="installing"?>
<title>Installing $TARGET in Dependencies Build Order</title>
EOF
} > $TARGET-index.xml
#---------------------
# Dump $TARGET-index.xml.tmp in reverse order.
tac $TARGET-index.xml.tmp >> $TARGET-index.xml
rm $TARGET-index.xml.tmp
#---------------------
# Footer of $TARGET-index.xml
{
cat << EOF
</chapter>
<xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="../$BLFS_XML/appendices/creat-comm.xml"/>
<xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="../$BLFS_XML/appendices/ac-free-lic.xml"/>
<index/>
</book>
EOF
} >> $TARGET-index.xml
echo "done"
}
#-------------------------#
generate_target_book() { #
#-------------------------#
: <<inline_doc
function: Create an HTML document of the requested TARGET.
input vars: nothing
externals: vars: TARGET
BLFS_XML
MAIL_SERVER
X11
modifies: nothing
returns: nothing
output: file: NUMEROUS FILES
on error: nothing
on success: nothing
inline_doc
local filename # output filename
echo -en "\n\tGenerating <$TARGET> HTML book from <$BLFS_XML> xml files ..."
xsltproc --xinclude --nonet \
--stringparam mail_server $MAIL_SERVER \
--stringparam xwindow $X11 \
--stringparam base.dir HTML/ \
../libs/book.xsl \
$TARGET-index.xml > xsltproc.log 2>&1
mkdir HTML/{stylesheets,images}
cp ../$BLFS_XML/stylesheets/lfs-xsl/*.css HTML/stylesheets
cp ../$BLFS_XML/images/*.png HTML/images
cd HTML
sed -i -e "s@../stylesheets@stylesheets@g" *.html
sed -i -e "s@../images@images@g" *.html
for filename in `find . -name "*.html"` ; do
tidy -config ../../$BLFS_XML/tidy.conf $filename || true
sh ../../$BLFS_XML/obfuscate.sh $filename
sed -i -e "s@text/html@application/xhtml+xml@g" $filename
done
cd ..
echo "done"
}
#-------------------------#
create_build_scripts() { #
#-------------------------#
: <<inline_doc
function: Create shell scripts of the requested TARGET.
input vars: $1 use sudo n/y
externals: TARGET
modifies: nothing
returns: nothing
output: file: NUMEROUS FILES
on error: nothing
on success: nothing
inline_doc
# Log separator
echo -e "\n\tScripts generation depuration and errors:\n" >> xsltproc.log
echo -en "\n\tGenerating the build scripts ..."
xsltproc --xinclude --nonet \
--stringparam sudo $SUDO \
-o ./scripts/ ../libs/scripts.xsl \
$TARGET-index.xml >> xsltproc.log 2>&1
# Make the scripts executable.
chmod -R +x scripts
cd ..
echo -e "done\n"
}

496
BLFS/libs/scripts.xsl Normal file
View file

@ -0,0 +1,496 @@
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:exsl="http://exslt.org/common"
extension-element-prefixes="exsl"
version="1.0">
<!-- $Id$ -->
<!-- XSLT stylesheet to create shell scripts from "linear build" BLFS books. -->
<!-- Build as user (y) or as root (n)? -->
<xsl:param name="sudo" select="y"/>
<xsl:template match="/">
<xsl:apply-templates select="//sect1"/>
</xsl:template>
<!--=================== Master chunks code ======================-->
<xsl:template match="sect1">
<xsl:if test="(count(descendant::screen/userinput) &gt; 0 and
count(descendant::screen/userinput) &gt;
count(descendant::screen[@role='nodump'])) and
@id != 'locale-issues' and @id != 'xorg7' and
@id != 'x-setup'">
<!-- The file names -->
<xsl:variable name="filename" select="@id"/>
<!-- Package name (use "Download FTP" by default. If empty, use "Download HTTP" -->
<xsl:variable name="package">
<xsl:choose>
<xsl:when
test="string-length(sect2[@role='package']/itemizedlist/listitem[2]/para/ulink/@url)
&gt; '10'">
<xsl:call-template name="package_name">
<xsl:with-param name="url"
select="sect2[@role='package']/itemizedlist/listitem[2]/para/ulink/@url"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="package_name">
<xsl:with-param name="url"
select="sect2[@role='package']/itemizedlist/listitem[1]/para/ulink/@url"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- FTP dir name -->
<xsl:variable name="ftpdir">
<xsl:call-template name="ftp_dir">
<xsl:with-param name="package" select="$package"/>
</xsl:call-template>
</xsl:variable>
<!-- The build order -->
<xsl:variable name="position" select="position()"/>
<xsl:variable name="order">
<xsl:choose>
<xsl:when test="string-length($position) = 1">
<xsl:text>00</xsl:text>
<xsl:value-of select="$position"/>
</xsl:when>
<xsl:when test="string-length($position) = 2">
<xsl:text>0</xsl:text>
<xsl:value-of select="$position"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$position"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- Depuration code -->
<xsl:message>
<xsl:text>SCRIPT is </xsl:text>
<xsl:value-of select="concat($order,'-',$filename)"/>
<xsl:text>&#xA; PACKAGE is </xsl:text>
<xsl:value-of select="$package"/>
<xsl:text>&#xA; FTPDIR is </xsl:text>
<xsl:value-of select="$ftpdir"/>
<xsl:text>&#xA;&#xA;</xsl:text>
</xsl:message>
<!-- Creating the scripts -->
<exsl:document href="{$order}-z-{$filename}" method="text">
<xsl:text>#!/bin/bash&#xA;set -e&#xA;&#xA;</xsl:text>
<xsl:choose>
<!-- Package page -->
<xsl:when test="sect2[@role='package'] and not(@id = 'xorg7-app' or
@id = 'xorg7-data' or @id = 'xorg7-driver' or
@id = 'xorg7-font' or @id = 'xorg7-lib' or
@id = 'xorg7-proto' or @id = 'xorg7-util')">
<!-- Variables -->
<xsl:text>SRC_ARCHIVE=$SRC_ARCHIVE&#xA;</xsl:text>
<xsl:text>FTP_SERVER=$FTP_SERVER&#xA;&#xA;PACKAGE=</xsl:text>
<xsl:value-of select="$package"/>
<xsl:text>&#xA;PKG_DIR=</xsl:text>
<xsl:value-of select="$ftpdir"/>
<xsl:text>&#xA;SRC_DIR=$SRC_DIR&#xA;&#xA;</xsl:text>
<!-- Download code and build commands -->
<xsl:apply-templates select="sect2">
<xsl:with-param name="package" select="$package"/>
<xsl:with-param name="ftpdir" select="$ftpdir"/>
</xsl:apply-templates>
<!-- Clean-up -->
<xsl:if test="not(@id='mesalib')">
<xsl:text>cd $SRC_DIR/$PKG_DIR&#xA;</xsl:text>
<xsl:text>rm -rf $UNPACKDIR unpacked&#xA;&#xA;</xsl:text>
</xsl:if>
<xsl:if test="@id='xorg7-server'">
<xsl:text>cd $SRC_DIR/MesaLib
UNPACKDIR=`head -n1 unpacked | sed 's@^./@@;s@/.*@@'`
rm -rf $UNPACKDIR unpacked&#xA;&#xA;</xsl:text>
</xsl:if>
</xsl:when>
<!-- Xorg7 pseudo-packages -->
<xsl:when test="contains(@id,'xorg7') and not(@id = 'xorg7-server')">
<xsl:text>SRC_DIR=$SRC_DIR
cd $SRC_DIR
mkdir -p xc
cd xc&#xA;</xsl:text>
<xsl:apply-templates select="sect2" mode="xorg7"/>
</xsl:when>
<!-- Non-package page -->
<xsl:otherwise>
<xsl:apply-templates select=".//screen"/>
</xsl:otherwise>
</xsl:choose>
<xsl:text>exit</xsl:text>
</exsl:document>
</xsl:if>
</xsl:template>
<!--======================= Sub-sections code =======================-->
<xsl:template match="sect2">
<xsl:param name="package" select="foo"/>
<xsl:param name="ftpdir" select="foo"/>
<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:apply-templates select="itemizedlist/listitem/para">
<xsl:with-param name="package" select="$package"/>
<xsl:with-param name="ftpdir" select="$ftpdir"/>
</xsl:apply-templates>
<xsl:text>&#xA;</xsl:text>
</xsl:when>
<xsl:when test="@role = 'installation'">
<xsl:text>
if [[ -e unpacked ]] ; then
UNPACKDIR=`head -n1 unpacked | sed 's@^./@@;s@/.*@@'`
[[ -n $UNPACKDIR ]] &amp;&amp; [[ -d $UNPACKDIR ]] &amp;&amp; rm -rf $UNPACKDIR
fi
tar -xvf $PACKAGE > unpacked
UNPACKDIR=`head -n1 unpacked | sed 's@^./@@;s@/.*@@'`
cd $UNPACKDIR&#xA;</xsl:text>
<xsl:apply-templates select=".//screen | .//para/command"/>
<xsl:if test="$sudo = 'y'">
<xsl:text>sudo /sbin/</xsl:text>
</xsl:if>
<xsl:text>ldconfig&#xA;&#xA;</xsl:text>
</xsl:when>
<xsl:when test="@role = 'configuration'">
<xsl:apply-templates select=".//screen"/>
<xsl:text>&#xA;</xsl:text>
</xsl:when>
</xsl:choose>
</xsl:template>
<xsl:template match="sect2" mode="xorg7">
<xsl:choose>
<xsl:when test="@role = 'package'">
<xsl:apply-templates select="itemizedlist/listitem/para" mode="xorg7"/>
</xsl:when>
<xsl:when test="not(@role)">
<xsl:text>SRC_ARCHIVE=$SRC_ARCHIVE
FTP_SERVER=$FTP_SERVER&#xA;</xsl:text>
<xsl:apply-templates select=".//screen" mode="sect-ver"/>
<xsl:text>mkdir -p ${section}&#xA;cd ${section}&#xA;</xsl:text>
<xsl:apply-templates select="../sect2[@role='package']/itemizedlist/listitem/para" mode="xorg7-patch"/>
<xsl:text>for line in $(grep -v '^#' ../${sect_ver}.wget) ; do
if [[ ! -f ${line} ]] ; then
if [[ -f $SRC_ARCHIVE/Xorg/${section}/${line} ]] ; then
cp $SRC_ARCHIVE/Xorg/${section}/${line} ${line}
elif [[ -f $SRC_ARCHIVE/Xorg/${line} ]] ; then
cp $SRC_ARCHIVE/Xorg/${line} ${line}
elif [[ -f $SRC_ARCHIVE/${section}/${line} ]] ; then
cp $SRC_ARCHIVE/${section}/${line} ${line}
elif [[ -f $SRC_ARCHIVE/${line} ]] ; then
cp $SRC_ARCHIVE/${line} ${line}
else
wget ${FTP_SERVER}conglomeration/Xorg/${line} || \
wget http://xorg.freedesktop.org/releases/individual/${section}/${line}
fi
fi
done
md5sum -c ../${sect_ver}.md5
cp ../${sect_ver}.wget ../${sect_ver}.wget.orig
cp ../${sect_ver}.md5 ../${sect_ver}.md5.orig&#xA;</xsl:text>
</xsl:when>
<xsl:when test="@role = 'installation'">
<xsl:text>for package in $(grep -v '^#' ../${sect_ver}.wget) ; do
packagedir=$(echo $package | sed 's/.tar.bz2//')
tar -xf ${package}
cd ${packagedir}&#xA;</xsl:text>
<xsl:apply-templates select=".//screen | .//para/command"/>
<xsl:text> cd ..
rm -rf ${packagedir}
sed -i "/${package}/d" ../${sect_ver}.wget
sed -i "/${package}/d" ../${sect_ver}.md5
done
mv ../${sect_ver}.wget.orig ../${sect_ver}.wget
mv ../${sect_ver}.md5.orig ../${sect_ver}.md5&#xA;</xsl:text>
<xsl:if test="$sudo = 'y'">
<xsl:text>sudo /sbin/</xsl:text>
</xsl:if>
<xsl:text>ldconfig&#xA;&#xA;</xsl:text>
</xsl:when>
<xsl:when test="@role = 'configuration'">
<xsl:apply-templates select=".//screen"/>
<xsl:text>&#xA;</xsl:text>
</xsl:when>
</xsl:choose>
</xsl:template>
<!--==================== Download code =======================-->
<xsl:template name="package_name">
<xsl:param name="url" select="foo"/>
<xsl:param name="sub-url" select="substring-after($url,'/')"/>
<xsl:choose>
<xsl:when test="contains($sub-url,'/')">
<xsl:call-template name="package_name">
<xsl:with-param name="url" select="$sub-url"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="contains($sub-url,'?')">
<xsl:value-of select="substring-before($sub-url,'?')"/>
</xsl:when>
<xsl:when test="contains($sub-url,'.patch')"/>
<xsl:otherwise>
<xsl:value-of select="$sub-url"/>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="ftp_dir">
<xsl:param name="package" select="foo"/>
<!-- A lot of hardcoded dir names. Not full revised yet. -->
<xsl:choose>
<!-- cdparanoia -->
<xsl:when test="contains($package, '-III')">
<xsl:text>cdparanoia</xsl:text>
</xsl:when>
<!-- DobBook 3.1 -->
<xsl:when test="contains($package, 'docbk31')">
<xsl:text>docbk</xsl:text>
</xsl:when>
<!-- gc -->
<xsl:when test="contains($package, 'gc6')">
<xsl:text>gc</xsl:text>
</xsl:when>
<!-- ISO-codes -->
<xsl:when test="contains($package, 'iso-codes')">
<xsl:text>iso-codes</xsl:text>
</xsl:when>
<!-- JPEG -->
<xsl:when test="contains($package, 'jpegsrc')">
<xsl:text>jpeg</xsl:text>
</xsl:when>
<!-- lynx -->
<xsl:when test="contains($package, 'lynx')">
<xsl:text>lynx</xsl:text>
</xsl:when>
<!-- ntp -->
<xsl:when test="contains($package, 'ntp')">
<xsl:text>ntp</xsl:text>
</xsl:when>
<!-- OpenLDAP -->
<xsl:when test="contains($package, 'openldap')">
<xsl:text>openldap</xsl:text>
</xsl:when>
<!-- Open Office -->
<xsl:when test="contains($package, 'OOo')">
<xsl:text>OOo</xsl:text>
</xsl:when>
<!-- pine -->
<xsl:when test="contains($package, 'pine')">
<xsl:text>pine</xsl:text>
</xsl:when>
<!-- portmap -->
<xsl:when test="contains($package, 'portmap')">
<xsl:text>portmap</xsl:text>
</xsl:when>
<!-- psutils -->
<xsl:when test="contains($package, 'psutils')">
<xsl:text>psutils</xsl:text>
</xsl:when>
<!-- qpopper -->
<xsl:when test="contains($package, 'qpopper')">
<xsl:text>qpopper</xsl:text>
</xsl:when>
<!-- QT -->
<xsl:when test="contains($package, 'qt-x')">
<xsl:text>qt-x11-free</xsl:text>
</xsl:when>
<!-- sendmail -->
<xsl:when test="contains($package, 'sendmail')">
<xsl:text>sendmail</xsl:text>
</xsl:when>
<!-- Slib -->
<xsl:when test="contains($package, 'slib')">
<xsl:text>slib</xsl:text>
</xsl:when>
<!-- TCL -->
<xsl:when test="contains($package, 'tcl')">
<xsl:text>tcl</xsl:text>
</xsl:when>
<!-- tcpwrappers -->
<xsl:when test="contains($package, 'tcp_wrappers')">
<xsl:text>tcp_wrappers</xsl:text>
</xsl:when>
<!-- TeTeX -->
<xsl:when test="contains($package, 'tetex')">
<xsl:text>tetex</xsl:text>
</xsl:when>
<!-- Tidy -->
<xsl:when test="contains($package, 'tidy')">
<xsl:text>tidy</xsl:text>
</xsl:when>
<!-- Tk -->
<xsl:when test="contains($package, 'tk8')">
<xsl:text>tk</xsl:text>
</xsl:when>
<!-- unzip -->
<xsl:when test="contains($package, 'unzip')">
<xsl:text>unzip</xsl:text>
</xsl:when>
<!-- wireless_tools -->
<xsl:when test="contains($package, 'wireless_tools')">
<xsl:text>wireless_tools</xsl:text>
</xsl:when>
<!-- whois -->
<xsl:when test="contains($package, 'whois')">
<xsl:text>whois</xsl:text>
</xsl:when>
<!-- XOrg -->
<xsl:when test="contains($package, 'X11R6')">
<xsl:text>Xorg</xsl:text>
</xsl:when>
<!-- zip -->
<xsl:when test="contains($package, 'zip2')">
<xsl:text>zip</xsl:text>
</xsl:when>
<!-- General rule -->
<xsl:otherwise>
<xsl:variable name="cut"
select="translate(substring-after($package, '-'), '0123456789', '0000000000')"/>
<xsl:variable name="package2">
<xsl:value-of select="substring-before($package, '-')"/>
<xsl:text>-</xsl:text>
<xsl:value-of select="$cut"/>
</xsl:variable>
<xsl:value-of select="substring-before($package2, '-0')"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="itemizedlist/listitem/para">
<xsl:param name="package" select="foo"/>
<xsl:param name="ftpdir" select="foo"/>
<xsl:choose>
<!-- This depend on all package pages having both "Download HTTP" and "Download FTP" lines -->
<xsl:when test="contains(string(),'HTTP')">
<xsl:text>if [[ ! -f $PACKAGE ]] ; then&#xA;</xsl:text>
<!-- SRC_ARCHIVE may have subdirectories or not -->
<xsl:text> if [[ -f $SRC_ARCHIVE/$PKG_DIR/$PACKAGE ]] ; then&#xA;</xsl:text>
<xsl:text> cp $SRC_ARCHIVE/$PKG_DIR/$PACKAGE $PACKAGE&#xA;</xsl:text>
<xsl:text> elif [[ -f $SRC_ARCHIVE/$PACKAGE ]] ; then&#xA;</xsl:text>
<xsl:text> cp $SRC_ARCHIVE/$PACKAGE $PACKAGE&#xA; else&#xA;</xsl:text>
<!-- The FTP_SERVER mirror -->
<xsl:text> wget ${FTP_SERVER}conglomeration/$PKG_DIR/$PACKAGE</xsl:text>
<!-- Upstream HTTP URL -->
<xsl:if test="string-length(ulink/@url) &gt; '10'">
<xsl:text> || \&#xA; wget </xsl:text>
<xsl:choose>
<xsl:when test="contains(ulink/@url,'?')">
<xsl:value-of select="substring-before(ulink/@url,'?')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="ulink/@url"/>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:when>
<xsl:when test="contains(string(),'FTP')">
<!-- Upstream FTP URL -->
<xsl:if test="string-length(ulink/@url) &gt; '10'">
<xsl:text> || \&#xA; wget </xsl:text>
<xsl:value-of select="ulink/@url"/>
</xsl:if>
<xsl:text>&#xA; fi&#xA;fi&#xA;</xsl:text>
</xsl:when>
<xsl:when test="contains(string(),'MD5')">
<xsl:text>echo "</xsl:text>
<xsl:value-of select="substring-after(string(),'sum: ')"/>
<xsl:text>&#x20;&#x20;$PACKAGE" | md5sum -c -&#xA;</xsl:text>
</xsl:when>
<!-- Patches -->
<xsl:when test="contains(string(ulink/@url),'.patch')">
<xsl:text>wget </xsl:text>
<xsl:value-of select="ulink/@url"/>
<xsl:text>&#xA;</xsl:text>
</xsl:when>
</xsl:choose>
</xsl:template>
<xsl:template match="itemizedlist/listitem/para" mode="xorg7">
<xsl:if test="contains(string(ulink/@url),'.md5') or
contains(string(ulink/@url),'.wget')">
<xsl:text>wget </xsl:text>
<xsl:value-of select="ulink/@url"/>
<xsl:text>&#xA;</xsl:text>
</xsl:if>
</xsl:template>
<xsl:template match="itemizedlist/listitem/para" mode="xorg7-patch">
<xsl:if test="contains(string(ulink/@url),'.patch')">
<xsl:text>wget </xsl:text>
<xsl:value-of select="ulink/@url"/>
<xsl:text>&#xA;</xsl:text>
</xsl:if>
</xsl:template>
<!--======================== Commands code ==========================-->
<xsl:template match="screen">
<xsl:if test="child::* = userinput and not(@role = 'nodump')">
<xsl:if test="@role = 'root' and $sudo = 'y'">
<xsl:text>sudo sh -c '</xsl:text>
</xsl:if>
<xsl:apply-templates select="userinput"/>
<xsl:if test="@role = 'root' and $sudo = 'y'">
<xsl:text>'</xsl:text>
</xsl:if>
<xsl:text>&#xA;</xsl:text>
</xsl:if>
</xsl:template>
<xsl:template match="screen" mode="sect-ver">
<xsl:text>section=</xsl:text>
<xsl:value-of select="substring-before(substring-after(string(),'mkdir '),' &amp;')"/>
<xsl:text>&#xA;sect_ver=</xsl:text>
<xsl:value-of select="substring-before(substring-after(string(),'-c ../'),'.md5')"/>
<xsl:text>&#xA;</xsl:text>
</xsl:template>
<xsl:template match="para/command">
<xsl:if test="(contains(string(),'test') or
contains(string(),'check'))">
<xsl:text>#</xsl:text>
<xsl:value-of select="substring-before(string(),'make')"/>
<xsl:text>make -k</xsl:text>
<xsl:value-of select="substring-after(string(),'make')"/>
<xsl:text> || true&#xA;</xsl:text>
</xsl:if>
</xsl:template>
<xsl:template match="userinput">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="replaceable">
<xsl:choose>
<xsl:when test="ancestor::sect1[@id='xorg7-server']">
<xsl:text>$SRC_DIR/MesaLib</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>**EDITME</xsl:text>
<xsl:apply-templates/>
<xsl:text>EDITME**</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>

View file

@ -1,23 +0,0 @@
<!-- Top level element -->
<!ELEMENT princList (list+)>
<!-- list corresponds to parts of the book -->
<!ELEMENT list (name,sublist+)>
<!ATTLIST list id ID #IMPLIED>
<!-- sublist corresponds to chapters of the book -->
<!ELEMENT sublist (name,package*)>
<!ATTLIST sublist id ID #IMPLIED>
<!-- information on package -->
<!ELEMENT package (name,((version,inst-version?,dependency*)|module+))>
<!ELEMENT name (#PCDATA)>
<!ELEMENT version (#PCDATA)>
<!ELEMENT inst-version (#PCDATA)>
<!-- Modules -->
<!ELEMENT module (name,version,inst-version?,dependency*)>
<!-- dependencies -->
<!ELEMENT dependency (dependency*)>
<!-- subdependencies of a dependency are defined for example in Perl
modules -->
<!ATTLIST dependency status (required|recommended|optional) "recommended"
build (before|after|first) "before"
name CDATA #REQUIRED
type (ref|link) "ref">

View file

@ -1,148 +0,0 @@
#!/bin/bash
# Fills the tracking file with versions of LFS packages taken from an
# SVN repository, at either a given date or a given tag (argument $1).
#------
# Argument $1:
# $1 contains a tag or a date, to indicate which version of the LFS book
# to use. It may be empty, meaning to use whatever version is presently in
# lfs-xml.
#
# It is recognized as a tag if it begins with x.y, where 'x' is one or more
# digit(s), the '.' (dot) is mandatory, an 'y' is one or more digits. Anything
# after y is allowed (for example 7.6-systemd or 8.1-rc1).
#
# It is recognized as a date if it is exactly 8 digits. Then it is assumed that
# the format is YYYYMMDD.
#
# Note that there is no check that the tag or the date are valid. Svn errors
# out if the tag is not valid, and if the date is impossible (that is MM>12
# or DD>31), but it happily accepts YYYY=3018 (and updates to HEAD).
#------
# The tracking file is taken from Makefile in the same directory.
MYDIR=$( cd $(dirname $0); pwd )
LFS_XML=${MYDIR}/lfs-xml
if [ -z "$1" ]; then # use lfs-xml as is
DO_COMMANDS=n
elif [ "$(echo $1 | sed 's/^[[:digit:]]\+\.[[:digit:]]\+//')" != "$1" ]
then # tag
DO_COMMANDS=y
CURR_SVN=$(cd $LFS_XML; LANG=C svn info | sed -n 's/Relative URL: //p')
CURR_REV=$(cd $LFS_XML; LANG=C svn info | sed -n 's/Revision: //p')
BEG_COMMAND="(cd $LFS_XML; svn switch ^/tags/$1)"
END_COMMAND="(cd $LFS_XML; svn switch $CURR_SVN@$CURR_REV)"
elif [ "$(echo $1 | sed 's/^[[:digit:]]\{8\}$//')" != "$1" ]; then # date
DO_COMMANDS=y
CURR_REV=$(cd $LFS_XML; LANG=C svn info | sed -n 's/Revision: //p')
BEG_COMMAND="(cd $LFS_XML; svn update -r\\{$1\\})"
END_COMMAND="(cd $LFS_XML; svn update -r$CURR_REV)"
else
echo Bad format in $1: must be a x.y[-aaa] tag or a YYYYMMDD date
exit 1
fi
if [ -f $MYDIR/Makefile ]; then
TRACKING_DIR=$(sed -n 's/TRACKING_DIR[ ]*=[ ]*//p' $MYDIR/Makefile)
TRACKFILE=${TRACKING_DIR}/instpkg.xml
else
echo The directory where $0 resides does not contain a Makefile
exit 1
fi
# We need to know the revision to generate the correct lfs-full...
if [ ! -r $MYDIR/revision ]; then
echo $MYDIR/revision is not available
exit 1
fi
REVISION=$(cat $MYDIR/revision)
#Debug
#echo BEG_COMMAND = $BEG_COMMAND
#echo Before BEG_COMMAND
#( cd $LFS_XML; LANG=C svn info )
#End debug
if [ "$DO_COMMANDS"=y ]; then
echo Running: $BEG_COMMAND
eval $BEG_COMMAND
fi
# Update code
LFS_FULL=/tmp/lfs-full.xml
echo Creating $LFS_FULL with information from $LFS_XML
echo "Processing LFS bootscripts..."
( cd $LFS_XML && bash process-scripts.sh )
echo "Adjusting LFS for revision $REVISION..."
xsltproc --nonet --xinclude \
--stringparam profile.revision $REVISION \
--output /tmp/lfs-prof.xml \
$LFS_XML/stylesheets/lfs-xsl/profile.xsl \
$LFS_XML/index.xml
echo "Validating the LFS book..."
xmllint --nonet --noent --postvalid \
-o $LFS_FULL /tmp/lfs-prof.xml
rm -f $LFS_XML/appendices/*.script
( cd $LFS_XML && ./aux-file-data.sh $LFS_FULL )
echo Updating ${TRACKFILE} with information taken from $LFS_FULL
echo -n "Is it OK? yes/no (no): "
read ANSWER
#Debug
echo You answered $ANSWER
#End debug
if [ x$ANSWER = "xyes" ] ; then
for pack in $(grep '<productname' $LFS_FULL |
sed 's/.*>\([^<]*\)<.*/\1/' |
sort | uniq); do
case "x$pack" in
xgcc* | *pass[12] | xvim | \
xshadow | xPython | xlinux-headers | xdbus | xsystemd )
continue ;;
esac
VERSION=$(grep -A1 ">$pack</product" $LFS_FULL |
head -n2 |
sed -n '2s/.*>\([^<]*\)<.*/\1/p')
#Debug
echo $pack: $VERSION
#End debug
xsltproc --stringparam packages $MYDIR/packages.xml \
--stringparam package $pack \
--stringparam version $VERSION \
-o track.tmp \
$MYDIR/xsl/bump.xsl ${TRACKFILE}
sed -i "s@PACKDESC@$MYDIR/packdesc.dtd@" track.tmp
xmllint --format --postvalid track.tmp > ${TRACKFILE}
rm track.tmp
done
VERSION=$(grep 'echo.*lfs-release' $LFS_FULL |
sed 's/.*echo[ ]*\([^ ]*\).*/\1/')
#Debug
echo LFS-Release: $VERSION
#End debug
xsltproc --stringparam packages $MYDIR/packages.xml \
--stringparam package LFS-Release \
--stringparam version $VERSION \
-o track.tmp \
$MYDIR/xsl/bump.xsl ${TRACKFILE}
sed -i "s@PACKDESC@$MYDIR/packdesc.dtd@" track.tmp
xmllint --format --postvalid track.tmp > ${TRACKFILE}
rm track.tmp
fi
#Debug
#echo After BEG_COMMAND\; before END_COMMAND
#( cd $LFS_XML; LANG=C svn info )
#End debug
if [ "$DO_COMMANDS"=y ]; then
echo Running: $END_COMMAND
eval $END_COMMAND
fi
#Debug
#echo After END_COMMAND
#( cd $LFS_XML; LANG=C svn info )
#End debug

108
BLFS/update_book.sh Executable file
View file

@ -0,0 +1,108 @@
#!/bin/bash
#
# $Id$
#
set -e
declare -r SVN="svn://svn.linuxfromscratch.org"
DOC_MODE=$1 # Action to take, update, get or none
BLFS_XML=$2 # Book directory
TREE=$3 # SVN tree for the BLFS book version
[[ -z $BLFS_XML ]] && BLFS_XML=blfs-xml
[[ -z $DOC_MODE ]] && DOC_MODE=update
[[ -z $TREE ]] && TREE=trunk/BOOK
TRACKING_DIR=tracking-dir
#---------------------
# packages module
source libs/func_packages
[[ $? > 0 ]] && echo -e "\n\tERROR: func_packages did not load..\n" && exit
#----------------------------#
BOOK_Source() { #
#----------------------------#
: <<inline_doc
function: Retrieve or upate a copy of the BLFS book
input vars: $1 BLFS_XML book sources directory
$2 DOC_MODE action get/update
$3 TREE SVN tree when $2=get
externals: none
modifies: $BLFS_XML directory tree
returns: nothing
output:
on error: exit
on success: text messages
inline_doc
case $DOC_MODE in
update )
if [[ ! -d $BLFS_XML ]] ; then
echo -e "\n\t$BLFS_XML is not a directory\n"
exit 1
fi
if [[ ! -f $BLFS_XML/x/x.xml ]] ; then
echo -e "\n\tLooks like $BLFS_XML is not a BLFS book sources directory\n"
exit 1
fi
if [[ -d $BLFS_XML/.svn ]] ; then
echo -e "\n\tUpdating the $BLFS_XML book sources ...\n"
pushd $BLFS_XML 1> /dev/null
svn up
popd 1> /dev/null
echo -e "\n\tBook sources updated."
else
echo -e "\n\tLooks like $BLFS_XML is not a svn working copy."
echo -e "\tSkipping BLFS sources update.\n"
fi
;;
get )
[[ ! -d $BLFS_XML ]] && mkdir -pv $BLFS_XML
svn co $SVN/BLFS/$TREE $BLFS_XML 2>&1
;;
* )
echo -e "\n\tUnknown option ${DOC_MODE} ignored.\n"
;;
esac
}
[ "${DOC_MODE}" != "none" ] && BOOK_Source
if [ "${DOC_MODE}" = "none" ] ; then
echo -en "\n\tGenerating packages database file ..."
generate_packages
echo "done."
echo -en "\tGenerating alsa dependencies list ..."
generate_alsa
echo "done."
echo -en "\tGenerating gnome-core dependencies list ..."
generate_gnome_core
echo "done."
echo -en "\tGenerating gnome-full dependencies list ..."
generate_gnome_full
echo "done."
echo -en "\tGenerating kde-core dependencies list ..."
generate_kde_core
echo "done."
echo -en "\tGenerating kde-full dependencies list ..."
generate_kde_full
echo -e "done."
echo -en "\tGenerating kde-koffice dependencies list ..."
generate_kde_koffice
echo -e "done."
echo -en "\tGenerating xorg7 dependencies list ..."
generate_xorg7
echo "done."
fi

View file

@ -1,66 +0,0 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:param name="packages" select="'packages.xml'"/>
<xsl:param name="package" select="''"/>
<xsl:param name="version" select="'N'"/>
<xsl:variable name="realpackage">
<xsl:choose>
<xsl:when test="contains($package, '-pass1')">
<xsl:copy-of select="substring-before($package, '-pass1')"/>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="$package"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="vers">
<xsl:choose>
<xsl:when test="$version='N'">
<xsl:value-of select=
"document($packages)//*[self::package or self::module]
[string(name)=$realpackage]/version"/>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="$version"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:output
method="xml"
encoding="ISO-8859-1"
doctype-system="PACKDESC"/>
<xsl:template match="/">
<sublist>
<xsl:copy-of select="./sublist/name"/>
<xsl:apply-templates select=".//package"/>
<xsl:if test="not(.//package[string(name)=$package])">
<package>
<name><xsl:copy-of select="$package"/></name>
<version><xsl:copy-of select="$vers"/></version>
</package>
</xsl:if>
</sublist>
</xsl:template>
<xsl:template match="package">
<xsl:choose>
<xsl:when test="string(name)=$package">
<package>
<name><xsl:copy-of select="$package"/></name>
<version><xsl:copy-of select="$vers"/></version>
</package>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select='.'/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>

View file

@ -1,172 +0,0 @@
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="text"/>
<xsl:param name="MTA" select="'sendmail'"/>
<xsl:param name="idofdep" select="'dbus'"/>
<xsl:key name="depnode"
match="package|module"
use="name"/>
<xsl:template match="/">
<xsl:apply-templates select="key('depnode',$idofdep)"/>
</xsl:template>
<xsl:template match="package">
<xsl:apply-templates select="./dependency"/>
</xsl:template>
<xsl:template match="module">
<xsl:apply-templates select="./dependency"/>
</xsl:template>
<xsl:template match="dependency">
<xsl:variable name="depname">
<xsl:choose>
<xsl:when test="@name='x-window-system'">xinit</xsl:when>
<xsl:when test="@name='xorg7'">xinit</xsl:when>
<xsl:when test="@name='server-mail'">
<xsl:value-of select="$MTA"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@name"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!--
<xsl:variable name="install_it">
<xsl:choose>
<xsl:when test="@type='link'">
<!- - No way to track versions: install ! - ->
1
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="compare-versions">
<xsl:with-param name="version" select="key('depnode',$depname)/version"/>
<xsl:with-param name="inst-version" select="key('depnode',$depname)/inst-version"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
-->
<xsl:apply-templates select="dependency"/>
<!--
<xsl:if test="number($install_it)">
-->
<xsl:choose>
<xsl:when test="@type='link'">
<xsl:text>4</xsl:text>
</xsl:when>
<xsl:when test="@status='required'">
<xsl:text>1</xsl:text>
</xsl:when>
<xsl:when test="@status='recommended'">
<xsl:text>2</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>3</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:text> </xsl:text>
<xsl:choose>
<xsl:when test="@build='first'">
<xsl:text>f</xsl:text>
</xsl:when>
<xsl:when test="@build='before'">
<xsl:text>b</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>a</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:text> </xsl:text>
<xsl:value-of select="$depname"/>
<xsl:text>&#xA;</xsl:text>
<!--
</xsl:if>
-->
</xsl:template>
<!-- lexicographic Comparison of strings. There is no way to directly
compare strings in XPath. So find the position of the character
in the following string. On the other hand, for numeric form style
xx.yy.zz, we have to compare xx and x'x', which is not always
lexicographic: think of 2.2 vs 2.10 -->
<xsl:variable name="char-table" select="' abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
<xsl:variable name= "dot-table" select="'.....................................................'"/>
<xsl:template name="compare-versions">
<!-- returns non-zero if version is greater than inst-version -->
<xsl:param name="version"/>
<xsl:param name="inst-version"/>
<!-- first make all separators (-_) into dots -->
<xsl:variable name="mod-ver" select="translate($version,'-_','..')"/>
<xsl:variable name="mod-inst-ver" select="translate($inst-version,'-_','..')"/>
<!-- Then let us find the position of the first chars in char-table (0 if numeric or dot) -->
<xsl:variable name="pos-ver" select="string-length(substring-before($char-table,substring($version,1,1)))"/>
<xsl:variable name="pos-inst-ver" select="string-length(substring-before($char-table,substring($inst-version,1,1)))"/>
<xsl:choose>
<xsl:when test="string-length($inst-version)=0">
<xsl:value-of select="string-length($version)"/>
</xsl:when>
<xsl:when test="string-length($version)=0">
0
</xsl:when>
<xsl:when test="$pos-ver != 0">
<xsl:choose>
<xsl:when test="$pos-ver = $pos-inst-ver">
<xsl:call-template name="compare-versions">
<xsl:with-param name="version" select="substring($version,2)"/>
<xsl:with-param name="inst-version" select="substring($inst-version,2)"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="number($pos-ver &gt; $pos-inst-ver)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="substring($mod-ver,1,1)='.'">
<xsl:choose>
<xsl:when test="substring($mod-inst-ver,1,1)='.'">
<xsl:call-template name="compare-versions">
<xsl:with-param name="version" select="substring($version,2)"/>
<xsl:with-param name="inst-version" select="substring($inst-version,2)"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
0
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="$pos-inst-ver &gt; 0 or substring($mod-inst-ver,1,1)='.'">
<!-- do not know what to do: do not install -->
0
</xsl:when>
<xsl:otherwise>
<xsl:variable name="tok" select="substring-before(concat(translate($mod-ver,$char-table,$dot-table),'.'),'.')"/>
<xsl:variable name="inst-tok" select="substring-before(concat(translate($mod-inst-ver,$char-table,$dot-table),'.'),'.')"/>
<xsl:choose>
<xsl:when test="number($tok)=number($inst-tok)">
<xsl:call-template name="compare-versions">
<xsl:with-param name="version" select="substring($version,string-length($tok)+1)"/>
<xsl:with-param name="inst-version" select="substring($inst-version,string-length($inst-tok)+1)"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="number(number($tok) &gt; number($inst-tok))"/>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>

View file

@ -1,326 +0,0 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="text"
encoding='ISO-8859-1'/>
<xsl:template match="/">
<xsl:apply-templates select="//list"/>
<xsl:text>comment ""
menu "Build settings"
choice
prompt "Mail server for resolving the MTA dependency"
config MS_sendmail
bool "sendmail"
config MS_postfix
bool "postfix"
config MS_exim
bool "exim"
endchoice
config MAIL_SERVER
string
default "sendmail" if MS_sendmail
default "postfix" if MS_postfix
default "exim" if MS_exim
choice
prompt "Dependency level"
default DEPLVL_2
help
Packages included in the dependency graph. Note that the graph
itself contains all the dependency information relating those
packages.
config DEPLVL_1
bool "Required dependencies only"
config DEPLVL_2
bool "Required plus recommended dependencies"
config DEPLVL_3
bool "Req/rec plus optional dependencies of requested package(s)"
config DEPLVL_4
bool "All non external dependencies"
endchoice
config optDependency
int
default 1 if DEPLVL_1
default 2 if DEPLVL_2
default 3 if DEPLVL_3
default 4 if DEPLVL_4
config LANGUAGE
string "LANG variable in the form ll_CC.charmap[@modifiers]"
default "en_US.UTF-8"
help
Because of the book layout, the 3 fields, ll, CC and charmap are
mandatory. The @modifier is honoured if present.
config SUDO
bool "Build as User"
default y
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
config PACK_INSTALL
string "Location of the packInstall.sh script"
default "/blfs_root/packInstall.sh" if !SUDO
default "$HOME/blfs_root/packInstall.sh" if SUDO
depends on WRAP_INSTALL
help
This script is needed for the proper operation of the
`porg style' package management. Provide an absolute
path.
config DEL_LA_FILES
bool "Remove libtool .la files after package installation"
default y
help
This option should be active on any system mixing libtool
and meson build systems. ImageMagick .la files are preserved.
config STATS
bool "Generate statistics for the requested package(s)"
default n
help
If you want timing and memory footprint statistics to be
generated for the packages you build (not their dependencies),
set this option to y. Due to the book layout, several scripts
are not functional in this case. Please review them.
config DEP_CHECK
bool "Check dependencies of the requested package(s)"
default n
depends on WRAP_INSTALL
help
Setting this option does not work if more than one package
is selected. It will do the following:
- Build the dependency tree and generate a build ordered list
disregarding already installed packages
- Generate the scripts for the dependencies not already
installed (as usual)
- Generate a stript that:
+ removes all unneeded packages using porg
(at this point the blfs_tools cannot be used anymore,
and your system may be non functional, so use a console
for that, not a graphical environment)
+ installs the package
+ restores all the previously removed packages
Note that this script may not be the last one, if there are runtime
dependencies
endmenu
menu "Build Layout"
config SRC_ARCHIVE
string "Directory of sources"
default "/sources"
config SRC_SUBDIRS
bool "Downloads sources to subdirectories"
default n
help
If this option is set, the sources will be downloaded and archived
into a subdirectory of the source directory, one for each page
of the book. Otherwise they are downloaded and archived directly
into the source directory
config BUILD_ROOT
string "Build directory"
default "/sources"
help
Directory where the build occurs. It can be the same as the
source directory, provided the setting of subdirectories is
different
config BUILD_SUBDIRS
bool "Build into subdirectories"
default y
help
If this option is set, the sources will be extracted into
subdirectories of the build directory. Otherwise, they will be
directly extracted into the build directory
config KEEP_FILES
bool "Keep source directory"
default n
help
Set this option if you want to keep the build directories
for further examination after installing the package
endmenu
menu "Optimization"
config JOBS
int "Number of parallel jobs"
default 0
help
This number will get passed to make or ninja, unless set
to 0, in which case, it is set to the number of processors
on line. Note that some packages do not respect this setting.
Also, "-j1" is always passed to make for install (and nothing
to ninja).
config CFG_CFLAGS
string "Content of variable CFLAGS"
default "EMPTY"
help
If set to the special string "EMPTY", then CFLAGS will be
unset before starting the script. Otherwise, there is no
content check for this variable. Double check for typos!
config CFG_CXXFLAGS
string "Content of variable CXXFLAGS"
default "EMPTY"
help
If set to the special string "EMPTY", then CXXFLAGS will be
unset before starting the script. Otherwise, there is no
content check for this variable. Double check for typos!
config CFG_LDFLAGS
string "Content of variable LDFLAGS"
default "EMPTY"
help
If set to the special string "EMPTY", then LDFLAGS will be
unset before starting the script. Otherwise, there is no
content check for this variable. Double check for typos!
endmenu
</xsl:text>
</xsl:template>
<xsl:template match="list">
<xsl:if
test=".//*[self::package or self::module]
[(version and not(inst-version)) or
string(version) != string(inst-version)]">
<xsl:text>menuconfig&#9;MENU_</xsl:text>
<xsl:value-of select="@id"/>
<xsl:text>
bool&#9;"</xsl:text>
<xsl:value-of select="name"/>
<xsl:text>"
default&#9;n
if&#9;MENU_</xsl:text>
<xsl:value-of select="@id"/>
<xsl:text>
</xsl:text>
<xsl:apply-templates select="sublist"/>
<xsl:text>endif
</xsl:text>
</xsl:if>
</xsl:template>
<xsl:template match="sublist">
<xsl:if
test=".//*[self::package or self::module]
[(version and not(inst-version)) or
string(version) != string(inst-version)]">
<xsl:text>&#9;menuconfig&#9;MENU_</xsl:text>
<xsl:value-of select="@id"/>
<xsl:text>
&#9;bool&#9;"</xsl:text>
<xsl:value-of select="name"/>
<xsl:text>"
&#9;default&#9;n
&#9;if&#9;MENU_</xsl:text>
<xsl:value-of select="@id"/>
<xsl:text>
</xsl:text>
<xsl:apply-templates select="package"/>
<xsl:text>&#9;endif
</xsl:text>
</xsl:if>
</xsl:template>
<xsl:template match="package">
<xsl:if
test="(version and not(inst-version)) or
string(version) != string(inst-version)">
<xsl:text>&#9;&#9;config&#9;CONFIG_</xsl:text>
<xsl:value-of select="name"/>
<xsl:text>
&#9;&#9;bool&#9;"</xsl:text>
<xsl:value-of select="name"/>
<xsl:text> </xsl:text>
<xsl:value-of select="version"/>
<xsl:if test="inst-version">
<xsl:text> [Installed </xsl:text>
<xsl:value-of select="inst-version"/>
<xsl:text>]</xsl:text>
</xsl:if>
<xsl:text>"
&#9;&#9;default&#9;n
</xsl:text>
</xsl:if>
<xsl:if
test="not(version) and ./module[not(inst-version) or
string(version) != string(inst-version)]">
<xsl:text>&#9;&#9;menuconfig&#9;MENU_</xsl:text>
<xsl:value-of select="translate(name,' ()','___')"/>
<xsl:text>
&#9;&#9;bool&#9;"</xsl:text>
<xsl:value-of select="name"/>
<xsl:text>"
&#9;&#9;default&#9;n
&#9;&#9;if&#9;MENU_</xsl:text>
<xsl:value-of select="translate(name,' ()','___')"/>
<xsl:text>
</xsl:text>
<xsl:apply-templates select="module"/>
<xsl:text>&#9;&#9;endif
</xsl:text>
</xsl:if>
</xsl:template>
<xsl:template match="module">
<xsl:if
test="not(inst-version) or
string(version) != string(inst-version)">
<xsl:text>&#9;&#9;&#9;config&#9;CONFIG_</xsl:text>
<xsl:value-of select="name"/>
<xsl:text>
&#9;&#9;&#9;bool&#9;"</xsl:text>
<xsl:value-of select="name"/>
<xsl:text> </xsl:text>
<xsl:value-of select="version"/>
<xsl:if test="inst-version">
<xsl:text> [Installed </xsl:text>
<xsl:value-of select="inst-version"/>
<xsl:text>]</xsl:text>
</xsl:if>
<xsl:text>"
&#9;&#9;&#9;default&#9;</xsl:text>
<xsl:choose>
<xsl:when test="contains(../name,'xorg')">
<xsl:text>y
</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>n
</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:template>
</xsl:stylesheet>

View file

@ -1,503 +0,0 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- Takes the blfs-full.xml file and extract a list
of packages obeying packdesc.dtd + looks for already
installed packages in the tracking file (stringparam
'installed-packages') -->
<!-- Extract also a list of LFS packages from stringparam lfs-full -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:param name="lfs-full" select="'./lfs-xml/lfs-full.xml'"/>
<xsl:param name="installed-packages" select="'../lib/instpkg.xml'"/>
<xsl:output method="xml"
encoding='ISO-8859-1'
doctype-system="./packdesc.dtd"/>
<!-- specialCases.xsl is generated by a shell script:
allows for cases where version begins with a letter
and when there is no version (such as xorg7 packages) -->
<xsl:include href="./specialCases.xsl"/>
<xsl:template match="/">
<princList>
<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-system</xsl:attribute>
<xsl:text>&#xA; </xsl:text>
<name>LFS Final System</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-conf</xsl:attribute>
<xsl:text>&#xA; </xsl:text>
<name>LFS Configuration files</name>
<xsl:apply-templates
select='document($lfs-full)//
chapter[@id="chapter-config"]/
sect1/sect1info[./productname="bootscripts"]'/>
<xsl:text>&#xA; </xsl:text>
</sublist>
<sublist>
<xsl:attribute name="id">lfs-boot</xsl:attribute>
<xsl:text>&#xA; </xsl:text>
<name>LFS Making Bootable</name>
<xsl:apply-templates select='document($lfs-full)//chapter[@id="chapter-bootable"]/sect1/sect1info[./productname="kernel"]'/>
<xsl:text>&#xA; </xsl:text>
</sublist>
<sublist>
<xsl:attribute name="id">lfs-theend</xsl:attribute>
<xsl:text>&#xA; </xsl:text>
<name>LFS The end</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
avoid it (TODO ?) -->
<xsl:apply-templates select="//part[not(@id='introduction')]"/>
</princList>
</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-headers'"/>
<!-- Gcc version is taken from BLFS -->
<xsl:when test="./productname='gcc'"/>
<!-- Shadow version is taken from BLFS -->
<xsl:when test="./productname='shadow'"/>
<!-- Vim version is taken from BLFS -->
<xsl:when test="./productname='vim'"/>
<!-- Dbus version is taken from BLFS -->
<xsl:when test="./productname='dbus'"/>
<!-- Systemd version is taken from BLFS -->
<xsl:when test="./productname='systemd'"/>
<!-- Same for python3 -->
<xsl:when test="./productname='Python'"/>
<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:if test="count(.//*[contains(translate(@xreflabel,
'123456789',
'000000000'),
'-0')
]) &gt; 0">
<xsl:text> </xsl:text>
<list>
<xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
<xsl:text>&#xA; </xsl:text>
<xsl:element name="name">
<xsl:value-of select="normalize-space(title)"/>
</xsl:element>
<xsl:text>&#xA;&#xA;</xsl:text>
<xsl:apply-templates select="chapter"/>
<xsl:text> </xsl:text>
</list>
<xsl:text>&#xA;&#xA;</xsl:text>
</xsl:if>
</xsl:template>
<xsl:template match="chapter">
<xsl:if test="count(.//*[contains(translate(@xreflabel,
'123456789',
'000000000'),
'-0')
]) &gt; 0 or @id='postlfs-config'">
<!-- With the removal of lsb-release, there are no more versioned package
in the After LFS configuration issue chapter, so test explicitly -->
<xsl:text> </xsl:text>
<sublist>
<xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
<xsl:text>&#xA; </xsl:text>
<xsl:element name="name">
<xsl:value-of select="normalize-space(title)"/>
</xsl:element>
<xsl:text>&#xA;</xsl:text>
<xsl:apply-templates select=".//sect1">
<xsl:sort select="@id"/>
</xsl:apply-templates>
<xsl:text> </xsl:text>
</sublist><xsl:text>&#xA;&#xA;</xsl:text>
</xsl:if>
</xsl:template>
<xsl:template match="sect1">
<xsl:choose>
<!-- This test is to find sections containing modules (PERL, Python
DBus,...) -->
<xsl:when
test="not(contains(translate(@xreflabel,
'123456789',
'000000000'),
'-0')) and
count(descendant::node()[contains(translate(@xreflabel,
'123456789',
'000000000'),
'-0')
]) &gt; 0">
<xsl:text> </xsl:text>
<package><xsl:text>&#xA; </xsl:text>
<xsl:element name="name">
<xsl:value-of select="normalize-space(title)"/>
</xsl:element>
<xsl:text>&#xA;</xsl:text>
<!-- Do not use .//*, which would include self.
Even a module can be a special case, so
call the template of specialCases.xsl,
which calls the "normal" template when the
case is normal. -->
<xsl:apply-templates select="descendant::*" mode="special">
<xsl:sort select="@id"/>
</xsl:apply-templates>
<xsl:text> </xsl:text>
</package><xsl:text>&#xA;&#xA;</xsl:text>
</xsl:when>
<xsl:otherwise>
<!-- Calls the template of specialCases.xsl,
which calls the "normal" template when the
case is normal. -->
<xsl:apply-templates select='.' mode="special">
<xsl:sort select="@id"/>
</xsl:apply-templates>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="*" mode="normal">
<xsl:variable name="version">
<xsl:call-template name="version">
<xsl:with-param name="label" select="./@xreflabel"/>
</xsl:call-template>
</xsl:variable>
<xsl:choose>
<!-- If there is a "sect1" ancestor, this means that
we have a module -->
<xsl:when test="ancestor::sect1">
<xsl:text> </xsl:text>
<module><xsl:text>&#xA; </xsl:text>
<xsl:element name="name">
<xsl:value-of select="./@id"/>
</xsl:element>
<xsl:text>&#xA; </xsl:text>
<xsl:element name="version">
<xsl:value-of select="$version"/>
</xsl:element>
<xsl:if
test="document($installed-packages)//package[name=current()/@id]">
<xsl:text>&#xA; </xsl:text>
<xsl:element name="inst-version">
<xsl:value-of
select="document(
$installed-packages
)//package[name=current()/@id]/version"/>
</xsl:element>
</xsl:if>
<!-- Dependencies -->
<!-- First the case of python modules or d-bus bindings -->
<xsl:if test="self::sect2">
<!-- dependencies -->
<xsl:apply-templates select=".//para[@role='required' or
@role='recommended' or
@role='optional']"
mode="dependency"/>
</xsl:if>
<!-- For python modules, the preceding module is an optional dep -->
<xsl:if test="ancestor::sect1[@id='python-modules']">
<xsl:apply-templates
select="preceding-sibling::sect2[@role='package']
//listitem[para/xref/@linkend=current()/@id]"
mode="prec-dep"/>
</xsl:if>
<!-- Now the case of perl modules: let us test our XSLT abilities.
Well, "use the sibling, Luke" -->
<xsl:if test="self::bridgehead">
<xsl:apply-templates select="following-sibling::itemizedlist[1]
/listitem/itemizedlist/listitem"
mode="perlmod-dep">
<xsl:sort select="position()"
data-type="number"
order="descending"/>
</xsl:apply-templates>
</xsl:if>
<!-- End dependencies -->
<xsl:text>&#xA; </xsl:text>
</module><xsl:text>&#xA;</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text> </xsl:text>
<package><xsl:text>&#xA; </xsl:text>
<xsl:element name="name">
<xsl:value-of select="./@id"/>
</xsl:element>
<xsl:text>&#xA; </xsl:text>
<xsl:element name="version">
<xsl:value-of select="$version"/>
</xsl:element>
<xsl:if
test="document($installed-packages)//package[name=current()/@id]">
<xsl:text>&#xA; </xsl:text>
<xsl:element name="inst-version">
<xsl:value-of
select="document(
$installed-packages
)//package[name=current()/@id]/version"/>
</xsl:element>
</xsl:if>
<!-- Dependencies -->
<!-- If in Xorg (not anymore) or KDE chapter, consider that the preceding
package is the first dependency (not always noted in the book)-->
<xsl:if test="ancestor::chapter[@id='kde4-core'
or @id='xfce-core'
or @id='lxqt-desktop'
or @id='lxde-desktop']
and preceding-sibling::sect1[1]">
<xsl:text>
</xsl:text>
<xsl:element name="dependency">
<xsl:attribute name="status">required</xsl:attribute>
<xsl:attribute name="build">before</xsl:attribute>
<xsl:attribute name="name">
<xsl:value-of select="preceding-sibling::sect1[1]/@id"/>
</xsl:attribute>
<xsl:attribute name="type">ref</xsl:attribute>
</xsl:element>
</xsl:if>
<xsl:apply-templates select=".//para[@role='required' or
@role='recommended' or
@role='optional']"
mode="dependency"/>
<!-- End dependencies -->
<xsl:text>&#xA; </xsl:text>
</package><xsl:text>&#xA;</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="version">
<xsl:param name="label" select="abc-2"/>
<xsl:variable name="start" select="string-length(substring-before(translate($label,'123456789','000000000'),'-0'))+2"/>
<xsl:variable name="prelim-ver" select="substring($label,$start)"/>
<xsl:choose>
<xsl:when test="contains($prelim-ver,'onfiguration')"/>
<xsl:when test="contains($prelim-ver,'escription')"/>
<xsl:when test="contains($prelim-ver,'EggDBus')">
<xsl:value-of select="substring-before($prelim-ver,' (EggDBus)')"/>
</xsl:when>
<xsl:when test="contains($label,'JDK')">
<xsl:value-of select="translate($prelim-ver,' ','_')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$prelim-ver"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="para" mode="dependency">
<xsl:variable name="status" select="./@role"/>
<!-- First internal dependencies -->
<xsl:for-each select=".//xref">
<xsl:choose>
<!-- Avoid depending of myself -->
<xsl:when test="ancestor::*[@id=current()/@linkend]"/>
<!-- do not depend on something which is not a dependency -->
<xsl:when test="@role='nodep'"/>
<!-- Call list expansion when we have an xorg7 series of packages -->
<xsl:when test="contains(@linkend,'xorg7-')">
<xsl:call-template name="expand-deps">
<xsl:with-param name="section">
<xsl:value-of select="@linkend"/>
</xsl:with-param>
<xsl:with-param name="status">
<xsl:value-of select="$status"/>
</xsl:with-param>
<xsl:with-param name="build">
<xsl:choose>
<xsl:when test="@role='runtime'">after</xsl:when>
<xsl:when test="@role='first'">first</xsl:when>
<xsl:otherwise>before</xsl:otherwise>
</xsl:choose>
</xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:text>
</xsl:text>
<xsl:element name="dependency">
<xsl:attribute name="status">
<xsl:value-of select="$status"/>
</xsl:attribute>
<xsl:attribute name="build">
<xsl:choose>
<xsl:when test="@role='runtime'">after</xsl:when>
<xsl:when test="@role='first'">first</xsl:when>
<xsl:otherwise>before</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:attribute name="name">
<xsl:value-of select="@linkend"/>
</xsl:attribute>
<xsl:attribute name="type">ref</xsl:attribute>
</xsl:element>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
<!-- then external dependencies -->
<xsl:for-each select=".//ulink">
<xsl:choose>
<!-- do not depend on something which is not a dependency -->
<xsl:when test="@role='nodep'"/>
<xsl:otherwise>
<xsl:text>
</xsl:text>
<xsl:element name="dependency">
<xsl:attribute name="status">
<xsl:value-of select="$status"/>
</xsl:attribute>
<xsl:attribute name="build">
<xsl:choose>
<xsl:when test="@role='runtime'">after</xsl:when>
<xsl:when test="@role='first'">first</xsl:when>
<xsl:otherwise>before</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:attribute name="name">
<xsl:value-of select="translate(normalize-space(text()),' /,()','-----')"/>
</xsl:attribute>
<xsl:attribute name="type">link</xsl:attribute>
</xsl:element>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:template>
<xsl:template match="listitem" mode="prec-dep">
<xsl:if test="preceding-sibling::listitem">
<xsl:text>
</xsl:text>
<xsl:element name="dependency">
<!-- the dep on the preceding package used to be required for python.
It seems optional now -->
<xsl:attribute name="status">optional</xsl:attribute>
<xsl:attribute name="build">before</xsl:attribute>
<xsl:attribute name="name">
<xsl:value-of select="preceding-sibling::listitem[1]//@linkend"/>
</xsl:attribute>
<xsl:attribute name="type">ref</xsl:attribute>
</xsl:element>
</xsl:if>
</xsl:template>
<xsl:template match="listitem" mode="perlmod-dep">
<xsl:param name="glue" select="'&#xA; '"/>
<xsl:choose>
<xsl:when test="para/xref[not(@role) or @role != 'nodep']|para[@id]/ulink">
<xsl:value-of select="$glue"/>
<xsl:element name="dependency">
<xsl:attribute name="status">
<xsl:choose>
<xsl:when
test="count(./para/text()[contains(string(),
'ptional')
]
)&gt;0">optional</xsl:when>
<xsl:otherwise>required</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:attribute name="build">
<xsl:choose>
<xsl:when test="para/xref/@role='runtime'">after</xsl:when>
<xsl:when test="para/ulink/@role='runtime'">after</xsl:when>
<xsl:otherwise>before</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:attribute name="name">
<xsl:if test="para/xref">
<xsl:value-of select="para/xref/@linkend"/>
</xsl:if>
<xsl:if test="para/ulink">
<xsl:value-of select="para/@id"/>
</xsl:if>
</xsl:attribute>
<xsl:attribute name="type">
<xsl:if test="para/xref">ref</xsl:if>
<xsl:if test="para/ulink">link</xsl:if>
</xsl:attribute>
<xsl:apply-templates select="itemizedlist/listitem"
mode="perlmod-dep">
<xsl:sort select="position()"
data-type="number"
order="descending"/>
<xsl:with-param name="glue" select="concat($glue,' ')"/>
</xsl:apply-templates>
</xsl:element>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="itemizedlist/listitem"
mode="perlmod-dep">
<xsl:sort select="position()"
data-type="number"
order="descending"/>
<xsl:with-param name="glue" select="$glue"/>
</xsl:apply-templates>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>

View file

@ -1,31 +0,0 @@
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="text"/>
<xsl:param name="package" select="'gcc'"/>
<xsl:key name="depnode"
match="package|module"
use="name"/>
<xsl:template match="/">
<xsl:apply-templates select="key('depnode',$package)"/>
</xsl:template>
<xsl:template match="package|module">
<xsl:value-of select="./version"/>
<xsl:text>&#xA;</xsl:text>
<xsl:choose>
<xsl:when test="./inst-version">
<xsl:value-of select="./inst-version"/>
</xsl:when>
<xsl:otherwise>
<xsl:text>0</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>

View file

@ -1,236 +0,0 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:key name="idlfs" match="sect1" use="sect1info/productname"/>
<xsl:template name="detect-lfs">
<xsl:param name="package"/>
<xsl:param name="lfsbook"/>
<xsl:choose>
<xsl:when test="$package='gcc' or
$package='dbus' or
$package='vim' or
$package='systemd' or
$package='Python' or
$package='shadow'"/>
<xsl:when test="$package='bootscripts'">true</xsl:when>
<xsl:when test="$package='kernel'">true</xsl:when>
<xsl:when test="$package='LFS-Release'">true</xsl:when>
<xsl:otherwise>
<xsl:for-each select="document($lfsbook)">
<xsl:copy-of select="boolean(key('idlfs',$package)/ancestor::chapter[@id='chapter-building-system'])"/>
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="process-lfs">
<xsl:param name="package"/>
<xsl:param name="lfsbook"/>
<xsl:choose>
<xsl:when test="$package='gcc' or
$package='dbus' or
$package='vim' or
$package='systemd' or
$package='Python' or
$package='shadow'"/>
<xsl:when test="$package='bootscripts'">
<xsl:for-each select="document($lfsbook)">
<xsl:apply-templates select="key('idlfs',$package)[ancestor::chapter/@id='chapter-config']" mode="lfs"/>
</xsl:for-each>
</xsl:when>
<xsl:when test="$package='kernel'">
<xsl:for-each select="document($lfsbook)">
<xsl:apply-templates select="key('idlfs',$package)[ancestor::chapter/@id='chapter-bootable']" mode="lfs"/>
</xsl:for-each>
</xsl:when>
<xsl:when test="$package='LFS-Release'">
<sect1 id="LFS-Release">
<xsl:apply-templates select="document($lfsbook)//sect1[@id='ch-finish-theend']/*" mode="lfs-remap"/>
</sect1>
</xsl:when>
<xsl:otherwise>
<xsl:for-each select="document($lfsbook)">
<xsl:apply-templates select="key('idlfs',$package)[ancestor::chapter/@id='chapter-building-system']" mode="lfs"/>
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="*" mode="lfs">
<xsl:choose>
<!--variablelist may contain id attributes equal to the name of the package,
which generates non-unique id. They are of not much use (short descriptions)
here. So just remove them-->
<xsl:when test="self::variablelist"/>
<!--The id's in lfs are of the form ch-xxx-package. We do not want to
use that for file names and the like. So change the id-->
<xsl:when test="self::sect1">
<xsl:element name="sect1">
<xsl:attribute name="id">
<xsl:choose>
<xsl:when
test="./sect1info/productname=
'bootscripts'">lfs-bootscripts</xsl:when>
<xsl:otherwise>
<xsl:value-of select="./sect1info/productname"/>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:apply-templates mode="lfs"/>
</xsl:element>
</xsl:when>
<xsl:when test=".//sect2">
<xsl:element name="{name()}">
<xsl:for-each select="attribute::*">
<xsl:attribute name="{name()}">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:for-each>
<xsl:apply-templates mode="lfs"/>
</xsl:element>
</xsl:when>
<xsl:when test="self::sect2[@role='package']">
<xsl:variable name="url" select="../sect1info/address/text()"/>
<xsl:variable name="md5" select="//sect1[@id='materials-packages']//ulink[@url=$url]/../following-sibling::para/literal/text()"/>
<xsl:variable name="patch">
<xsl:call-template name="find-patch"/>
</xsl:variable>
<sect2 role="package">
<xsl:copy-of select="./*"/>
<bridgehead renderas="sect3">Package Information</bridgehead>
<itemizedlist spacing="compact">
<listitem>
<para>
Download (HTTP): <!--<xsl:element name="ulink">
<xsl:attribute name="url">
<xsl:value-of select="$url"/>
</xsl:attribute>
</xsl:element>--><ulink url="{$url}"/>
</para>
</listitem>
<listitem>
<para>
Download (FTP): <ulink url=" "/>
</para>
</listitem>
<listitem>
<para>
Download MD5 sum: <xsl:value-of select="$md5"/>
</para>
</listitem>
</itemizedlist>
<xsl:if test="string-length($patch)&gt;10">
<bridgehead renderas="sect3">Additional Downloads</bridgehead>
<itemizedlist spacing="compact">
<listitem>
<para>
Required patch:
<ulink url="{$patch}"/>
</para>
</listitem>
</itemizedlist>
</xsl:if>
</sect2>
</xsl:when>
<xsl:when test="self::sect2[@role='installation']">
<sect2 role="installation">
<xsl:apply-templates mode="lfs-remap"/>
</sect2>
</xsl:when>
<xsl:when test="self::sect2[@role='configuration']">
<sect2 role="configuration">
<xsl:apply-templates mode="lfs-remap"/>
</sect2>
</xsl:when>
<xsl:when test="self::sect2">
<xsl:element name="sect2">
<xsl:for-each select="attribute::*">
<xsl:attribute name="{name()}">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:for-each>
<xsl:apply-templates mode="lfs"/>
</xsl:element>
</xsl:when>
<xsl:otherwise><!--
<xsl:element name="{name()}">
<xsl:for-each select="attribute::*">
<xsl:attribute name="{name()}">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:for-each>
<xsl:apply-templates/>
</xsl:element>-->
<xsl:copy-of select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="find-patch">
<xsl:variable name="patch-command" select="..//userinput[contains(string(),'patch -Np1')]/text()"/>
<xsl:variable name="patch" select="substring-after($patch-command,'../')"/>
<xsl:if test="string-length($patch) &gt; 10">
<xsl:value-of select="//sect1[@id='materials-patches']//ulink/@url[contains(string(),$patch)]"/>
</xsl:if>
</xsl:template>
<xsl:template match="*" mode="lfs-remap">
<xsl:choose>
<xsl:when test=".//screen">
<xsl:element name="{name()}">
<xsl:for-each select="attribute::*">
<xsl:attribute name="{name()}">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:for-each>
<xsl:apply-templates mode="lfs-remap"/>
</xsl:element>
</xsl:when>
<xsl:when test="self::screen">
<xsl:choose>
<!-- Since we are using the *-full.xml files, revisions have already been
selected, so no need to bother about revision attributes-->
<xsl:when test="@role='nodump'">
<xsl:copy-of select="."/>
</xsl:when>
<xsl:when test="contains(string(),'&lt;your name here&gt;')">
<screen role="root"><userinput>
<xsl:copy-of
select="substring-before(string(),'&lt;your name here&gt;')"/>
<xsl:text>jhalfs</xsl:text>
<xsl:copy-of
select="substring-after(string(),'&lt;your name here&gt;')"/>
</userinput></screen>
</xsl:when>
<xsl:when test="./userinput[@remap='install' or not(@remap)]">
<screen role="root">
<xsl:copy-of select="./*"/>
</screen>
</xsl:when>
<xsl:when test="./userinput[@remap='test']">
<para><command>
<xsl:copy-of select="./userinput/text()"/>
</command></para>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise><!--
<xsl:copy-of select="."/>-->
<xsl:element name="{name()}">
<xsl:for-each select="attribute::*">
<xsl:attribute name="{name()}">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:for-each>
<xsl:apply-templates mode="sect1"/>
</xsl:element>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>

View file

@ -1,25 +0,0 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="text"/>
<xsl:template match="/">
<xsl:text>bootscripts </xsl:text>
<xsl:text>lfs-bootscripts </xsl:text>
<xsl:text>kernel </xsl:text>
<xsl:text>porg </xsl:text>
<xsl:text>tzdata </xsl:text>
<!-- the next two packages are not in LFS, but jhalfs needs them -->
<xsl:text>sudo </xsl:text>
<xsl:text>wget </xsl:text>
<xsl:apply-templates select=".//chapter[@id='chapter-building-system']/sect1/sect1info/productname"/>
</xsl:template>
<xsl:template match="productname">
<xsl:copy-of select="text()"/>
<xsl:text> </xsl:text>
</xsl:template>
</xsl:stylesheet>

View file

@ -1,697 +0,0 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:param name="list" select="''"/>
<xsl:param name="MTA" select="'sendmail'"/>
<xsl:param name="lfsbook" select="'lfs-full.xml'"/>
<!-- Check whether the book is sysv or systemd -->
<xsl:variable name="rev">
<xsl:choose>
<xsl:when test="//bookinfo/title/phrase[@revision='systemd']">
<xsl:text>systemd</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>sysv</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:output
method="xml"
encoding="ISO-8859-1"
doctype-system="http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd"/>
<xsl:include href="lfs_make_book.xsl"/>
<xsl:template match="/">
<book>
<xsl:copy-of select="/book/bookinfo"/>
<preface>
<?dbhtml filename="preface.html"?>
<title>Preface</title>
<xsl:choose>
<xsl:when test="$rev='sysv'">
<xsl:copy-of select="id('bootscripts')"/>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="id('systemd-units')"/>
</xsl:otherwise>
</xsl:choose>
</preface>
<chapter>
<?dbhtml filename="chapter.html"?>
<title>Installing packages in dependency build order</title>
<xsl:call-template name="apply-list">
<xsl:with-param name="list" select="normalize-space($list)"/>
</xsl:call-template>
</chapter>
<xsl:copy-of select="id('CC')"/>
<xsl:copy-of select="id('MIT')"/>
<index/>
</book>
</xsl:template>
<!-- apply-templates for each item in the list.
Normally, those items are id of nodes.
Those nodes can be sect1 (normal case),
sect2 (python modules or DBus bindings)
bridgehead (perl modules)
para (dependency of perl modules).
The templates after this one treat each of those cases.
However, some items are xorg package names, and not id.
We need special instructions in that case.
The difficulty is that some of those names *are* id's,
because they are referenced in the index.
Hopefully, none of those id's are sect{1,2}, bridgehead or para...-->
<xsl:template name="apply-list">
<xsl:param name="list" select="''"/>
<xsl:if test="string-length($list) &gt; 0">
<xsl:choose>
<xsl:when test="contains($list,' ')">
<xsl:call-template name="apply-list">
<xsl:with-param name="list"
select="substring-before($list,' ')"/>
</xsl:call-template>
<xsl:call-template name="apply-list">
<xsl:with-param name="list"
select="substring-after($list,' ')"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="contains($list,'groupxx')"/>
<xsl:otherwise>
<xsl:variable name="is-lfs">
<xsl:call-template name="detect-lfs">
<xsl:with-param name="package" select="$list"/>
<xsl:with-param name="lfsbook" select="$lfsbook"/>
</xsl:call-template>
</xsl:variable>
<xsl:choose>
<xsl:when test="$is-lfs='true'">
<xsl:message>
<xsl:value-of select="$list"/>
<xsl:text> is an lfs package</xsl:text>
</xsl:message>
<xsl:call-template name="process-lfs">
<xsl:with-param name="package" select="$list"/>
<xsl:with-param name="lfsbook" select="$lfsbook"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="contains(concat($list,' '),'-pass1 ')">
<!-- We need to do it only for sect1 and sect2, because of libva -->
<xsl:variable
name="real-id"
select="substring-before(concat($list,' '),'-pass1 ')"/>
<xsl:if test="id($real-id)[self::sect1]">
<xsl:apply-templates select="id($real-id)" mode="pass1"/>
</xsl:if>
<xsl:if test="id($real-id)[self::sect2]">
<xsl:apply-templates select="id($real-id)" mode="pass1-sect2"/>
</xsl:if>
</xsl:when>
<xsl:when test="not(id($list)[self::sect1 or self::sect2 or self::para or self::bridgehead])">
<xsl:apply-templates
select="//sect1[contains(@id,'xorg7')
and contains(string(.//userinput),
concat($list,'-'))]"
mode="xorg">
<xsl:with-param name="package" select="$list"/>
</xsl:apply-templates>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="id($list)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:template>
<!-- The normal case : just copy to the book. Exceptions are if there
is a xref, so use a special "mode" template -->
<xsl:template match="sect1">
<xsl:apply-templates select="." mode="sect1"/>
</xsl:template>
<xsl:template match="*" mode="pass1">
<xsl:choose>
<xsl:when test="self::xref">
<xsl:choose>
<xsl:when test="contains(concat(' ',normalize-space($list),' '),
concat(' ',@linkend,' '))">
<xsl:choose>
<xsl:when test="@linkend='x-window-system' or @linkend='xorg7'">
<xref linkend="xorg7-server"/>
</xsl:when>
<xsl:when test="@linkend='server-mail'">
<xref linkend="{$MTA}"/>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="@linkend='bootscripts' or
@linkend='systemd-units'">
<xsl:copy-of select="."/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@linkend"/> (in full book)
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="@id">
<xsl:element name="{name()}">
<xsl:for-each select="attribute::*">
<xsl:attribute name="{name()}">
<xsl:value-of select="."/>
<xsl:if test="name() = 'id'">-pass1</xsl:if>
</xsl:attribute>
</xsl:for-each>
<xsl:apply-templates mode="pass1"/>
</xsl:element>
</xsl:when>
<xsl:when test=".//xref | .//@id">
<xsl:element name="{name()}">
<xsl:for-each select="attribute::*">
<xsl:attribute name="{name()}">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:for-each>
<xsl:apply-templates mode="pass1"/>
</xsl:element>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="*" mode="pass1-sect2">
<xsl:choose>
<xsl:when test="self::sect2">
<xsl:element name="sect1">
<xsl:attribute name="id"><xsl:value-of select="@id"/>-pass1</xsl:attribute>
<xsl:attribute name="xreflabel"><xsl:value-of select="@xreflabel"/></xsl:attribute>
<xsl:processing-instruction name="dbhtml">filename="<xsl:value-of
select="@id"/>-pass1.html"</xsl:processing-instruction>
<xsl:apply-templates mode="pass1-sect2"/>
</xsl:element>
</xsl:when>
<xsl:when test="self::sect3">
<xsl:element name="sect2">
<xsl:attribute name="role">
<xsl:value-of select="@role"/>
</xsl:attribute>
<xsl:apply-templates mode="pass1-sect2"/>
</xsl:element>
</xsl:when>
<xsl:when test="self::bridgehead">
<xsl:element name="bridgehead">
<xsl:attribute name="renderas">
<xsl:if test="@renderas='sect4'">sect3</xsl:if>
<xsl:if test="@renderas='sect5'">sect4</xsl:if>
</xsl:attribute>
<xsl:value-of select='.'/>
</xsl:element>
</xsl:when>
<xsl:when test="self::xref">
<xsl:choose>
<xsl:when test="contains(concat(' ',normalize-space($list),' '),
concat(' ',@linkend,' '))">
<xsl:choose>
<xsl:when test="@linkend='x-window-system' or @linkend='xorg7'">
<xref linkend="xorg7-server"/>
</xsl:when>
<xsl:when test="@linkend='server-mail'">
<xref linkend="{$MTA}"/>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="@linkend='bootscripts' or
@linkend='systemd-units'">
<xsl:copy-of select="."/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@linkend"/> (in full book)
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="@id">
<xsl:element name="{name()}">
<xsl:for-each select="attribute::*">
<xsl:attribute name="{name()}">
<xsl:value-of select="."/>
<xsl:if test="name() = 'id'">-pass1</xsl:if>
</xsl:attribute>
</xsl:for-each>
<xsl:apply-templates mode="pass1-sect2"/>
</xsl:element>
</xsl:when>
<xsl:when test=".//xref | .//@id">
<xsl:element name="{name()}">
<xsl:for-each select="attribute::*">
<xsl:attribute name="{name()}">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:for-each>
<xsl:apply-templates mode="pass1-sect2"/>
</xsl:element>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="processing-instruction()" mode="pass1">
<xsl:variable name="pi-full" select="string()"/>
<xsl:variable name="pi-value"
select="substring-after($pi-full,'filename=')"/>
<xsl:variable name="filename"
select="substring-before(substring($pi-value,2),'.html')"/>
<xsl:processing-instruction name="dbhtml">filename="<xsl:copy-of
select="$filename"/>-pass1.html"</xsl:processing-instruction>
</xsl:template>
<xsl:template match="processing-instruction()" mode="sect1">
<xsl:copy-of select="."/>
</xsl:template>
<!-- Any node which has no xref descendant is copied verbatim. If there
is an xref descendant, output the node and recurse. -->
<xsl:template match="*" mode="sect1">
<xsl:choose>
<xsl:when test="self::xref">
<xsl:choose>
<xsl:when test="contains(concat(' ',normalize-space($list),' '),
concat(' ',@linkend,' '))">
<xsl:choose>
<xsl:when test="@linkend='x-window-system' or @linkend='xorg7'">
<xref linkend="xorg7-server"/>
</xsl:when>
<xsl:when test="@linkend='server-mail'">
<xref linkend="{$MTA}"/>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="@linkend='bootscripts' or
@linkend='systemd-units'">
<xsl:copy-of select="."/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@linkend"/> (in full book)
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test=".//xref">
<xsl:element name="{name()}">
<xsl:for-each select="attribute::*">
<xsl:attribute name="{name()}">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:for-each>
<xsl:apply-templates mode="sect1"/>
</xsl:element>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- Python modules and DBus bindings -->
<xsl:template match="sect2">
<xsl:apply-templates select='.' mode="sect2"/>
</xsl:template>
<xsl:template match="*" mode="sect2">
<xsl:choose>
<xsl:when test="self::sect2">
<xsl:element name="sect1">
<xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
<xsl:attribute name="xreflabel"><xsl:value-of select="@xreflabel"/></xsl:attribute>
<xsl:processing-instruction name="dbhtml">filename="<xsl:value-of
select="@id"/>.html"</xsl:processing-instruction>
<xsl:apply-templates mode="sect2"/>
</xsl:element>
</xsl:when>
<xsl:when test="self::sect3">
<xsl:element name="sect2">
<xsl:attribute name="role">
<xsl:value-of select="@role"/>
</xsl:attribute>
<xsl:apply-templates mode="sect2"/>
</xsl:element>
</xsl:when>
<xsl:when test="self::bridgehead">
<xsl:element name="bridgehead">
<xsl:attribute name="renderas">
<xsl:if test="@renderas='sect4'">sect3</xsl:if>
<xsl:if test="@renderas='sect5'">sect4</xsl:if>
</xsl:attribute>
<xsl:value-of select='.'/>
</xsl:element>
</xsl:when>
<xsl:when test="self::xref">
<xsl:choose>
<xsl:when test="contains(concat(' ',normalize-space($list),' '),
concat(' ',@linkend,' '))">
<xsl:choose>
<xsl:when test="@linkend='x-window-system' or @linkend='xorg7'">
<xref linkend="xorg7-server"/>
</xsl:when>
<xsl:when test="@linkend='server-mail'">
<xref linkend="{$MTA}"/>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@linkend"/> (in full book)
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test=".//xref">
<xsl:element name="{name()}">
<xsl:for-each select="attribute::*">
<xsl:attribute name="{name()}">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:for-each>
<xsl:apply-templates mode="sect2"/>
</xsl:element>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- Perl modules : transform them to minimal sect1. Use a template
for installation instructions -->
<xsl:template match="bridgehead">
<xsl:if test="ancestor::sect1[@id='perl-modules']">
<xsl:element name="sect1">
<xsl:attribute name="id"><xsl:value-of select="./@id"/></xsl:attribute>
<xsl:attribute name="xreflabel"><xsl:value-of select="./@xreflabel"/></xsl:attribute>
<xsl:processing-instruction name="dbhtml">
filename="<xsl:value-of select="@id"/>.html"</xsl:processing-instruction>
<title><xsl:value-of select="./@xreflabel"/></title>
<sect2 role="package">
<title>Introduction to <xsl:value-of select="@id"/></title>
<bridgehead renderas="sect3">Package Information</bridgehead>
<itemizedlist spacing="compact">
<listitem>
<para>Download (HTTP): <xsl:copy-of select="./following-sibling::itemizedlist[1]/listitem/para/ulink"/></para>
</listitem>
<listitem>
<para>Download (FTP): <ulink url=" "/></para>
</listitem>
</itemizedlist>
</sect2>
<xsl:choose>
<xsl:when test="following-sibling::itemizedlist[1]//xref[@linkend='perl-standard-install'] | following-sibling::itemizedlist[1]/preceding-sibling::para//xref[@linkend='perl-standard-install']">
<xsl:apply-templates mode="perl-install" select="id('perl-standard-install')"/>
</xsl:when>
<xsl:otherwise>
<sect2 role="installation">
<title>Installation of <xsl:value-of select="@xreflabel"/></title>
<para>Run the following commands:</para>
<for-each select="following-sibling::bridgehead/preceding-sibling::screen[not(@role)]">
<xsl:copy-of select="."/>
</for-each>
<para>Now, as the <systemitem class="username">root</systemitem> user:</para>
<for-each select="following-sibling::bridgehead/preceding-sibling::screen[@role='root']">
<xsl:copy-of select="."/>
</for-each>
</sect2>
</xsl:otherwise>
</xsl:choose>
</xsl:element>
</xsl:if>
</xsl:template>
<!-- The case of depdendencies of perl modules. Same treatment
as for perl modules. Just easier because always perl standard -->
<xsl:template match="para">
<xsl:element name="sect1">
<xsl:attribute name="id"><xsl:value-of select="./@id"/></xsl:attribute>
<xsl:attribute name="xreflabel"><xsl:value-of select="./@xreflabel"/></xsl:attribute>
<xsl:processing-instruction name="dbhtml">filename="<xsl:value-of
select="@id"/>.html"</xsl:processing-instruction>
<title><xsl:value-of select="./@xreflabel"/></title>
<sect2 role="package">
<title>Introduction to <xsl:value-of select="@id"/></title>
<bridgehead renderas="sect3">Package Information</bridgehead>
<itemizedlist spacing="compact">
<listitem>
<para>Download (HTTP): <xsl:copy-of select="./ulink"/></para>
</listitem>
<listitem>
<para>Download (FTP): <ulink url=" "/></para>
</listitem>
</itemizedlist>
</sect2>
<xsl:apply-templates mode="perl-install" select="id('perl-standard-install')"/>
</xsl:element>
</xsl:template>
<!-- copy of the perl standard installation instructions:
suppress id (otherwise not unique) and note (which we
do not want to apply -->
<xsl:template match="sect2" mode="perl-install">
<sect2 role="installation">
<xsl:for-each select="./*">
<xsl:if test="not(self::note)">
<xsl:copy-of select="."/>
</xsl:if>
</xsl:for-each>
</sect2>
</xsl:template>
<!-- we have got an xorg package. We are at the installation page
but now we need to make an autonomous page from the global
one -->
<xsl:template match="sect1" mode="xorg">
<xsl:param name="package"/>
<xsl:variable name="tarball">
<xsl:call-template name="tarball">
<xsl:with-param name="package" select="concat(' ',$package,'-')"/>
<xsl:with-param name="cat-md5"
select="string(.//userinput[starts-with(string(),'cat ')])"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="md5sum">
<xsl:call-template name="md5sum">
<xsl:with-param name="package" select="concat(' ',$package,'-')"/>
<xsl:with-param name="cat-md5"
select=".//userinput[starts-with(string(),'cat ')]"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="download-dir">
<xsl:call-template name="download-dir">
<xsl:with-param name="package" select="concat(' ',$package,'-')"/>
<xsl:with-param name="cat-md5"
select=".//userinput[starts-with(string(),'cat ')]"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="install-instructions">
<xsl:call-template name="inst-instr">
<xsl:with-param name="inst-instr"
select=".//userinput[starts-with(string(),'for ')]"/>
</xsl:call-template>
</xsl:variable>
<xsl:element name="sect1">
<xsl:attribute name="id"><xsl:value-of select="$package"/></xsl:attribute>
<xsl:processing-instruction name="dbhtml">
filename="<xsl:value-of select='$package'/>.html"
</xsl:processing-instruction>
<title><xsl:value-of select="$package"/></title>
<sect2 role="package">
<title>Introduction to <xsl:value-of select="$package"/></title>
<bridgehead renderas="sect3">Package Information</bridgehead>
<itemizedlist spacing="compact">
<listitem>
<para>Download (HTTP): <xsl:element name="ulink">
<xsl:attribute name="url">
<xsl:value-of
select=".//para[contains(string(),'(HTTP)')]/ulink/@url"/>
<xsl:value-of select="$download-dir"/>
<xsl:value-of select="$tarball"/>
</xsl:attribute>
</xsl:element>
</para>
</listitem>
<listitem>
<para>Download (FTP): <xsl:element name="ulink">
<xsl:attribute name="url">
<xsl:value-of
select=".//para[contains(string(),'(FTP)')]/ulink/@url"/>
<xsl:value-of select="$download-dir"/>
<xsl:value-of select="$tarball"/>
</xsl:attribute>
</xsl:element>
</para>
</listitem>
<listitem>
<para>
Download MD5 sum: <xsl:value-of select="$md5sum"/>
</para>
</listitem>
</itemizedlist>
<!-- If there is an additional download, we need to output that -->
<xsl:if test=".//bridgehead[contains(string(),'Additional')]">
<xsl:copy-of
select=".//bridgehead[contains(string(),'Additional')]"/>
<xsl:copy-of
select=".//bridgehead[contains(string(),'Additional')]
/following-sibling::itemizedlist[1]"/>
</xsl:if>
</sect2>
<sect2 role="installation">
<title>Installation of <xsl:value-of select="$package"/></title>
<para>
Install <application><xsl:value-of select="$package"/></application>
by running the following commands:
</para>
<screen><userinput>packagedir=<xsl:value-of
select="substring-before($tarball,'.tar.')"/>
<xsl:text>&#xA;</xsl:text>
<xsl:value-of select="substring-before($install-instructions,
'as_root')"/>
</userinput></screen>
<para>
Now as the <systemitem class="username">root</systemitem> user:
</para>
<screen role='root'>
<userinput><xsl:value-of select="substring-after(
$install-instructions,
'as_root')"/>
</userinput>
</screen>
</sect2>
</xsl:element><!-- sect1 -->
</xsl:template>
<!-- get the tarball name from the text that comes from the .md5 file -->
<xsl:template name="tarball">
<xsl:param name="package"/>
<xsl:param name="cat-md5"/>
<!-- DEBUG
<xsl:message><xsl:text>Entering "tarball" template:
package is: </xsl:text>
<xsl:value-of select="$package"/><xsl:text>
cat-md5 is: </xsl:text>
<xsl:value-of select="$cat-md5"/>
</xsl:message>
END DEBUG -->
<xsl:choose>
<xsl:when test="contains(substring-before($cat-md5,$package),'&#xA;')">
<xsl:call-template name="tarball">
<xsl:with-param name="package" select="$package"/>
<xsl:with-param name="cat-md5"
select="substring-after($cat-md5,'&#xA;')"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="contains(substring-before($cat-md5,$package),' ')">
<xsl:call-template name="tarball">
<xsl:with-param name="package" select="$package"/>
<xsl:with-param name="cat-md5"
select="substring-after($cat-md5,' ')"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="substring-after(
substring-before($cat-md5,'&#xA;'),' ')"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- get the download dirname from the text that comes from the .md5 file -->
<xsl:template name="download-dir">
<xsl:param name="package"/>
<xsl:param name="cat-md5"/>
<xsl:choose>
<xsl:when test="not(@id='xorg7-legacy')">
<xsl:copy-of select="''"/>
</xsl:when>
<xsl:when test="contains(substring-before($cat-md5,$package),'&#xA;')">
<xsl:call-template name="download-dir">
<xsl:with-param name="package" select="$package"/>
<xsl:with-param name="cat-md5"
select="substring-after($cat-md5,'&#xA;')"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="contains(substring-before($cat-md5,$package),' ')">
<xsl:call-template name="download-dir">
<xsl:with-param name="package" select="$package"/>
<xsl:with-param name="cat-md5"
select="substring-after($cat-md5,' ')"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="substring-before($cat-md5,' ')"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- same for md5sum -->
<xsl:template name="md5sum">
<xsl:param name="package"/>
<xsl:param name="cat-md5"/>
<xsl:choose>
<xsl:when test="contains(substring-before($cat-md5,$package),'&#xA;')">
<xsl:call-template name="md5sum">
<xsl:with-param name="package" select="$package"/>
<xsl:with-param name="cat-md5"
select="substring-after($cat-md5,'&#xA;')"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="substring-before($cat-md5,' ')"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="inst-instr">
<xsl:param name="inst-instr"/>
<xsl:choose>
<xsl:when test="contains($inst-instr,'pushd')">
<xsl:call-template name="inst-instr">
<xsl:with-param name="inst-instr"
select="substring-after(
substring-after($inst-instr,'pushd'),
'&#xA;')"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="substring-before($inst-instr,'popd')"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>

View file

@ -1,583 +0,0 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE stylesheet [
<!ENTITY detect-config
"contains(string($current-instr),'useradd') or
contains(string($current-instr),'groupadd') or
contains(string($current-instr),'usermod') or
contains(string($current-instr),'icon-cache') or
contains(string($current-instr),'desktop-database') or
contains(string($current-instr),'compile-schemas') or
contains(string($current-instr),'query-loaders') or
contains(string($current-instr),'pam.d') or
contains(string($current-instr),'/opt/rustc') or
contains(string($current-instr),'libQt5WebEngine') or
contains(string($current-instr),'desktop-file-edit') or
contains(string($current-instr),'.old') or
contains(string($current-instr),'tracker-miner') or
contains(string($current-instr),'gtweak') or
contains(string($current-instr),'query-immodules') or
contains(string($current-instr),'chgrp -v mail') or
contains(string($current-instr),'gnome-control-center')">
]>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template name="process-install">
<xsl:param name="instruction-tree"/>
<xsl:param name="want-stats"/>
<xsl:param name="root-seen"/>
<xsl:param name="install-seen"/>
<xsl:param name="test-seen"/>
<xsl:param name="doc-seen"/>
<!-- Isolate the current instruction -->
<xsl:variable name="current-instr" select="$instruction-tree[1]"/>
<xsl:choose>
<!--============================================================-->
<!-- First, if we have an empty tree, close everything and exit -->
<xsl:when test="not($current-instr)">
<xsl:if test="$install-seen">
<xsl:call-template name="end-install"/>
</xsl:if>
<xsl:if test="$root-seen">
<xsl:call-template name="end-root"/>
</xsl:if>
<xsl:if test="$doc-seen and not($root-seen)">
<xsl:call-template name="end-doc">
<xsl:with-param name="want-stats" select="$want-stats"/>
</xsl:call-template>
</xsl:if>
<xsl:if test="$test-seen">
<xsl:call-template name="end-test">
<xsl:with-param name="want-stats" select="$want-stats"/>
</xsl:call-template>
</xsl:if>
</xsl:when><!-- end empty tree -->
<!--============================================================-->
<xsl:when test="$current-instr[@role='root' and @remap='test']">
<xsl:if test="$install-seen">
<xsl:call-template name="end-install"/>
</xsl:if>
<xsl:if test="$root-seen">
<xsl:call-template name="end-root"/>
</xsl:if>
<xsl:if test="$doc-seen and not($root-seen)">
<xsl:call-template name="end-doc">
<xsl:with-param name="want-stats" select="$want-stats"/>
</xsl:call-template>
</xsl:if>
<xsl:if test="not($test-seen)">
<xsl:call-template name="begin-test">
<xsl:with-param name="want-stats" select="$want-stats"/>
</xsl:call-template>
</xsl:if>
<xsl:call-template name="begin-root"/>
<!-- We first apply mode="root" templates, and save the result in a variable -->
<xsl:variable name="processed-instr">
<xsl:apply-templates select="$current-instr" mode="root"/>
</xsl:variable>
<!-- We then process as a test instruction -->
<xsl:call-template name="process-test">
<xsl:with-param name="test-instr" select="$processed-instr"/>
<xsl:with-param name="want-stats" select="$want-stats"/>
</xsl:call-template>
<xsl:call-template name="process-install">
<xsl:with-param
name="instruction-tree"
select="$instruction-tree[position()>1]"/>
<xsl:with-param name="want-stats" select="$want-stats"/>
<xsl:with-param name="root-seen" select="boolean(1)"/>
<xsl:with-param name="install-seen" select="boolean(0)"/>
<xsl:with-param name="test-seen" select="boolean(1)"/>
<xsl:with-param name="doc-seen" select="boolean(0)"/>
</xsl:call-template>
</xsl:when><!-- end role="root" and remap="test" -->
<!--============================================================-->
<xsl:when test="$current-instr[@role='root' and @remap='doc']">
<xsl:if test="$test-seen">
<xsl:call-template name="end-test">
<xsl:with-param name="want-stats" select="$want-stats"/>
</xsl:call-template>
</xsl:if>
<xsl:if test="$doc-seen and not($root-seen)">
<xsl:call-template name="end-doc">
<xsl:with-param name="want-stats" select="$want-stats"/>
</xsl:call-template>
</xsl:if>
<xsl:if test="not($root-seen)">
<xsl:call-template name="begin-root"/>
</xsl:if>
<xsl:if test="not($install-seen)">
<xsl:call-template name="begin-install"/>
</xsl:if>
<!-- We first apply mode="install" templates, and save the result in a
variable -->
<xsl:variable name="processed-instr">
<xsl:apply-templates select="$current-instr" mode="install"/>
</xsl:variable>
<!-- Then comment it out -->
<xsl:call-template name="output-comment-out">
<xsl:with-param name="out-string" select="$processed-instr"/>
</xsl:call-template>
<!-- The above template ends with a commented line, so that if end-install
adds a closing single quote, it will not be seen. Add a CR to prevent
that -->
<xsl:text>
</xsl:text>
<xsl:call-template name="process-install">
<xsl:with-param
name="instruction-tree"
select="$instruction-tree[position()>1]"/>
<xsl:with-param name="want-stats" select="$want-stats"/>
<xsl:with-param name="root-seen" select="boolean(1)"/>
<xsl:with-param name="install-seen" select="boolean(1)"/>
<xsl:with-param name="test-seen" select="boolean(0)"/>
<xsl:with-param name="doc-seen" select="boolean(1)"/>
</xsl:call-template>
</xsl:when><!-- end role="root" and remap="doc" -->
<!--============================================================-->
<xsl:when test="$current-instr[@role='root']">
<!-- We have two cases, depending on the content: either a config instruction,
that we do not record with porg (first case below), or a true install
instruction (otherwise below) -->
<xsl:choose>
<!--____________________________________________________________ -->
<xsl:when test="&detect-config;">
<xsl:if test="$install-seen">
<xsl:call-template name="end-install"/>
</xsl:if>
<xsl:if test="$test-seen">
<xsl:call-template name="end-test">
<xsl:with-param name="want-stats" select="$want-stats"/>
</xsl:call-template>
</xsl:if>
<xsl:if test="$doc-seen and not($root-seen)">
<xsl:call-template name="end-doc">
<xsl:with-param name="want-stats" select="$want-stats"/>
</xsl:call-template>
</xsl:if>
<xsl:if test="not($root-seen)">
<xsl:call-template name="begin-root"/>
</xsl:if>
<xsl:apply-templates select="$current-instr" mode="root"/>
<xsl:call-template name="process-install">
<xsl:with-param
name="instruction-tree"
select="$instruction-tree[position()>1]"/>
<xsl:with-param name="want-stats" select="$want-stats"/>
<xsl:with-param name="root-seen" select="boolean(1)"/>
<xsl:with-param name="install-seen" select="boolean(0)"/>
<xsl:with-param name="test-seen" select="boolean(0)"/>
<xsl:with-param name="doc-seen" select="boolean(0)"/>
</xsl:call-template>
</xsl:when><!-- end config as root -->
<!--____________________________________________________________ -->
<xsl:otherwise><!-- we have a true install instruction -->
<xsl:if test="$test-seen">
<xsl:call-template name="end-test">
<xsl:with-param name="want-stats" select="$want-stats"/>
</xsl:call-template>
</xsl:if>
<xsl:if test="$doc-seen and not($root-seen)">
<xsl:call-template name="end-doc">
<xsl:with-param name="want-stats" select="$want-stats"/>
</xsl:call-template>
</xsl:if>
<xsl:if test="$want-stats and not($install-seen)">
<xsl:if test="$root-seen">
<xsl:call-template name="end-root"/>
</xsl:if>
<xsl:text>
echo Time before install: ${SECONDS} >> $INFOLOG</xsl:text>
<xsl:apply-templates
select="$instruction-tree[@role='root']/userinput"
mode="destdir"/>
<xsl:text>
echo Time after install: ${SECONDS} >> $INFOLOG
echo Size after install: $(sudo du -skx --exclude home $BUILD_DIR) >> $INFOLOG
</xsl:text>
<xsl:if test="$root-seen">
<xsl:call-template name="begin-root"/>
</xsl:if>
</xsl:if>
<xsl:if test="not($root-seen)">
<xsl:call-template name="begin-root"/>
</xsl:if>
<xsl:if test="not($install-seen)">
<xsl:call-template name="begin-install"/>
</xsl:if>
<xsl:apply-templates select="$current-instr" mode="install"/>
<xsl:call-template name="process-install">
<xsl:with-param
name="instruction-tree"
select="$instruction-tree[position()>1]"/>
<xsl:with-param name="want-stats" select="$want-stats"/>
<xsl:with-param name="root-seen" select="boolean(1)"/>
<xsl:with-param name="install-seen" select="boolean(1)"/>
<xsl:with-param name="test-seen" select="boolean(0)"/>
<xsl:with-param name="doc-seen" select="boolean(0)"/>
</xsl:call-template>
</xsl:otherwise><!-- end true install instruction -->
<!--____________________________________________________________ -->
</xsl:choose>
</xsl:when><!-- role="root" and no remap -->
<!--============================================================-->
<xsl:when test="$current-instr[@remap='test'] or
$current-instr/self::command">
<xsl:if test="$install-seen">
<xsl:call-template name="end-install"/>
</xsl:if>
<xsl:if test="$root-seen">
<xsl:call-template name="end-root"/>
</xsl:if>
<xsl:if test="$doc-seen and not($root-seen)">
<xsl:call-template name="end-doc">
<xsl:with-param name="want-stats" select="$want-stats"/>
</xsl:call-template>
</xsl:if>
<xsl:if test="not($test-seen)">
<xsl:if test="not($doc-seen)">
<xsl:call-template name="end-make">
<xsl:with-param name="want-stats" select="$want-stats"/>
</xsl:call-template>
</xsl:if>
<xsl:call-template name="begin-test">
<xsl:with-param name="want-stats" select="$want-stats"/>
</xsl:call-template>
</xsl:if>
<!-- We first apply normal templates, and save the result in a variable -->
<xsl:variable name="processed-instr">
<xsl:apply-templates select="$current-instr"/>
</xsl:variable>
<!-- We then process as a test instruction -->
<xsl:call-template name="process-test">
<xsl:with-param name="test-instr" select="$processed-instr"/>
<xsl:with-param name="want-stats" select="$want-stats"/>
</xsl:call-template>
<xsl:call-template name="process-install">
<xsl:with-param
name="instruction-tree"
select="$instruction-tree[position()>1]"/>
<xsl:with-param name="want-stats" select="$want-stats"/>
<xsl:with-param name="root-seen" select="boolean(0)"/>
<xsl:with-param name="install-seen" select="boolean(0)"/>
<xsl:with-param name="test-seen" select="boolean(1)"/>
<xsl:with-param name="doc-seen" select="boolean(0)"/>
</xsl:call-template>
</xsl:when><!-- end no role, remap=test -->
<!--============================================================-->
<xsl:when test="$current-instr[@remap='doc']">
<xsl:if test="$install-seen">
<xsl:call-template name="end-install"/>
</xsl:if>
<xsl:if test="$root-seen">
<xsl:call-template name="end-root"/>
</xsl:if>
<xsl:if test="$test-seen">
<xsl:call-template name="end-test">
<xsl:with-param name="want-stats" select="$want-stats"/>
</xsl:call-template>
</xsl:if>
<xsl:if test="not($doc-seen) or $root-seen">
<xsl:if test="not($test-seen) and not($root-seen)">
<xsl:call-template name="end-make">
<xsl:with-param name="want-stats" select="$want-stats"/>
</xsl:call-template>
</xsl:if>
<xsl:call-template name="begin-doc">
<xsl:with-param name="want-stats" select="$want-stats"/>
</xsl:call-template>
</xsl:if>
<!-- We first apply normal templates, and save the result in a variable -->
<xsl:variable name="processed-instr">
<xsl:apply-templates select="$current-instr"/>
</xsl:variable>
<!-- We then process as a doc instruction -->
<xsl:call-template name="process-doc">
<xsl:with-param name="doc-instr" select="$processed-instr"/>
<xsl:with-param name="want-stats" select="$want-stats"/>
</xsl:call-template>
<xsl:call-template name="process-install">
<xsl:with-param
name="instruction-tree"
select="$instruction-tree[position()>1]"/>
<xsl:with-param name="want-stats" select="$want-stats"/>
<xsl:with-param name="root-seen" select="boolean(0)"/>
<xsl:with-param name="install-seen" select="boolean(0)"/>
<xsl:with-param name="test-seen" select="boolean(0)"/>
<xsl:with-param name="doc-seen" select="boolean(1)"/>
</xsl:call-template>
</xsl:when><!-- no role, remap="doc" -->
<!--============================================================-->
<xsl:otherwise><!-- no role no remap -->
<xsl:if test="$install-seen">
<xsl:call-template name="end-install"/>
</xsl:if>
<xsl:if test="$root-seen">
<xsl:call-template name="end-root"/>
</xsl:if>
<xsl:if test="$doc-seen and not($root-seen)">
<xsl:call-template name="end-doc">
<xsl:with-param name="want-stats" select="$want-stats"/>
</xsl:call-template>
</xsl:if>
<xsl:if test="$test-seen">
<xsl:call-template name="end-test">
<xsl:with-param name="want-stats" select="$want-stats"/>
</xsl:call-template>
</xsl:if>
<xsl:apply-templates select="$current-instr"/>
<xsl:call-template name="process-install">
<xsl:with-param
name="instruction-tree"
select="$instruction-tree[position()>1]"/>
<xsl:with-param name="want-stats" select="$want-stats"/>
<xsl:with-param name="root-seen" select="boolean(0)"/>
<xsl:with-param name="install-seen" select="boolean(0)"/>
<xsl:with-param name="test-seen" select="boolean(0)"/>
<xsl:with-param name="doc-seen" select="boolean(0)"/>
</xsl:call-template>
</xsl:otherwise><!-- no role, no remap -->
<!--============================================================-->
</xsl:choose>
</xsl:template>
<xsl:template match="userinput" mode="install">
<xsl:text>
</xsl:text>
<xsl:call-template name="output-install">
<xsl:with-param name="out-string" select="string()"/>
</xsl:call-template>
</xsl:template>
<!-- userinput templates for mode="root" and normal are in scripts.xsl -->
<xsl:template name="process-test">
<xsl:param name="test-instr"/>
<xsl:param name="want-stats"/>
<xsl:choose>
<!-- the string may begin with a linefeed -->
<xsl:when test="substring($test-instr,1,1)='&#xA;'">
<xsl:text>
</xsl:text>
<xsl:call-template name="process-test">
<xsl:with-param name="test-instr"
select="substring-after($test-instr,'&#xA;')"/>
<xsl:with-param name="want-stats" select="$want-stats"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="contains($test-instr,'&#xA;')">
<xsl:call-template name="process-test">
<xsl:with-param name="test-instr"
select="substring-before($test-instr,'&#xA;')"/>
<xsl:with-param name="want-stats" select="$want-stats"/>
</xsl:call-template>
<xsl:text>
</xsl:text>
<xsl:call-template name="process-test">
<xsl:with-param name="test-instr"
select="substring-after($test-instr,'&#xA;')"/>
<xsl:with-param name="want-stats" select="$want-stats"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:if test="not($want-stats)">
<xsl:text>#</xsl:text>
</xsl:if>
<xsl:choose>
<xsl:when test="contains($test-instr,'make')
and not(contains($test-instr,'make -k'))">
<xsl:copy-of select="substring-before($test-instr,'make')"/>
<xsl:text>make -k</xsl:text>
<xsl:copy-of select="substring-after($test-instr,'make')"/>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="$test-instr"/>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="substring($test-instr,
string-length($test-instr),
1)!='\'">
<xsl:if test="$want-stats">
<xsl:text> &gt;&gt; $TESTLOG 2>&amp;1</xsl:text>
</xsl:if>
<xsl:text> || true</xsl:text>
</xsl:if>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="process-doc">
<xsl:param name="doc-instr"/>
<xsl:param name="want-stats"/>
<xsl:choose>
<xsl:when test="$want-stats">
<xsl:copy-of select="$doc-instr"/>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="output-comment-out">
<xsl:with-param name="out-string" select="$doc-instr"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="output-comment-out">
<!-- Output instructions with each line commented out. -->
<xsl:param name="out-string"/>
<xsl:choose>
<!-- the string may begin with a linefeed -->
<xsl:when test="substring($out-string,1,1)='&#xA;'">
<xsl:text>
</xsl:text>
<xsl:call-template name="output-comment-out">
<xsl:with-param name="out-string"
select="substring-after($out-string,'&#xA;')"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="contains($out-string,'&#xA;')">
<xsl:text>#</xsl:text>
<xsl:copy-of select="substring-before($out-string,'&#xA;')"/>
<xsl:text>
</xsl:text>
<xsl:call-template name="output-comment-out">
<xsl:with-param name="out-string"
select="substring-after($out-string,'&#xA;')"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:text>#</xsl:text>
<xsl:copy-of select="$out-string"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="end-make">
<xsl:param name="want-stats"/>
<xsl:if test="$want-stats">
<xsl:text>
echo Time after make: ${SECONDS} >> $INFOLOG
echo Size after make: $(sudo du -skx --exclude home $BUILD_DIR) >> $INFOLOG</xsl:text>
</xsl:if>
</xsl:template>
<xsl:template name="begin-doc">
<xsl:param name="want-stats"/>
<xsl:if test="$want-stats">
<xsl:text>
echo Time before doc: ${SECONDS} >> $INFOLOG
</xsl:text>
</xsl:if>
</xsl:template>
<xsl:template name="begin-test">
<xsl:param name="want-stats"/>
<xsl:if test="$want-stats">
<xsl:text>
echo Time before test: ${SECONDS} >> $INFOLOG
</xsl:text>
</xsl:if>
</xsl:template>
<xsl:template name="begin-root">
<xsl:if test="$sudo='y'">
<xsl:text>
sudo -E sh -e &lt;&lt; ROOT_EOF
PATH=$PATH:/usr/sbin</xsl:text>
</xsl:if>
</xsl:template>
<xsl:template name="begin-install">
<xsl:if test="$wrap-install = 'y'">
<xsl:text>
if [ -r "$JH_PACK_INSTALL" ]; then
source $JH_PACK_INSTALL
export -f wrapInstall
export -f packInstall
fi
wrapInstall '</xsl:text>
</xsl:if>
</xsl:template>
<xsl:template name="end-doc">
<xsl:param name="want-stats"/>
<xsl:if test="$want-stats">
<xsl:text>
echo Time after doc: ${SECONDS} >> $INFOLOG
echo Size after doc: $(sudo du -skx --exclude home $BUILD_DIR) >> $INFOLOG</xsl:text>
</xsl:if>
</xsl:template>
<xsl:template name="end-test">
<xsl:param name="want-stats"/>
<xsl:if test="$want-stats">
<xsl:text>
echo Time after test: ${SECONDS} >> $INFOLOG
echo Size after test: $(sudo du -skx --exclude home $BUILD_DIR) >> $INFOLOG</xsl:text>
</xsl:if>
</xsl:template>
<xsl:template name="end-root">
<xsl:if test="$sudo='y'">
<xsl:text>
ROOT_EOF</xsl:text>
</xsl:if>
</xsl:template>
<xsl:template name="end-install">
<xsl:if test="$del-la-files = 'y'">
<xsl:call-template name="output-root">
<xsl:with-param name="out-string" select="$la-files-instr"/>
</xsl:call-template>
</xsl:if>
<xsl:if test="$wrap-install = 'y'">
<xsl:text>'&#xA;packInstall</xsl:text>
</xsl:if>
</xsl:template>
<xsl:template name="output-install">
<xsl:param name="out-string" select="''"/>
<xsl:choose>
<xsl:when test="starts-with($out-string, 'make ') or
contains($out-string,' make ') or
contains($out-string,'&#xA;make')">
<xsl:call-template name="output-install">
<xsl:with-param
name="out-string"
select="substring-before($out-string,'make ')"/>
</xsl:call-template>
<xsl:text>make -j1 </xsl:text>
<xsl:call-template name="output-install">
<xsl:with-param
name="out-string"
select="substring-after($out-string,'make ')"/>
</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-install">
<xsl:with-param name="out-string"
select="substring-after($out-string,string($APOS))"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="output-root">
<xsl:with-param name="out-string" select="$out-string"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>

View file

@ -1,165 +0,0 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<!--===================================================================-->
<!-- Localization in the form ll_CC.charmap@modifier (to be used in
bash shell startup scripts). ll, CC, and charmap must be present:
no way to use "C" or "POSIX". -->
<xsl:param name="language" select="'en_US.UTF-8'"/>
<!-- Break it in pieces -->
<xsl:variable name="lang-ll">
<xsl:copy-of select="substring-before($language,'_')"/>
</xsl:variable>
<xsl:variable name="lang-CC">
<xsl:copy-of
select="substring-before(substring-after($language,'_'),'.')"/>
</xsl:variable>
<xsl:variable name="lang-charmap">
<xsl:choose>
<xsl:when test="contains($language,'@')">
<xsl:copy-of
select="substring-before(substring-after($language,'.'),'@')"/>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="substring-after($language,'.')"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="lang-modifier">
<xsl:choose>
<xsl:when test="contains($language,'@')">
<xsl:copy-of select="concat('@',substring-after($language,'@'))"/>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="''"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- end of language variables -->
<!--===================================================================-->
<!-- to be used at places where we need the domain- or host- name -->
<xsl:param name="fqdn" select="'belgarath.example.org'"/>
<!-- make various useful variables -->
<xsl:variable name="hostname" select="substring-before($fqdn,'.')"/>
<xsl:variable name="domainname" select="substring-after($fqdn,'.')"/>
<xsl:variable name="DOMAINNAME" select="translate($domainname,
'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
<!-- end of host/domain name variables -->
<!--===================================================================-->
<!-- keyboard layout for the gdm page (as of BLFS 9.0) -->
<xsl:param name="xkblayout" select="'us'"/>
<!--===================================================================-->
<!-- the main template: to be adjusted depending on the book -->
<xsl:template match="replaceable">
<xsl:choose>
<!-- When adding a user to a group, the book uses "username" in a replaceable
tag. Replace by the user name only if not running as root -->
<xsl:when test="contains(string(),'username') and $sudo='y'">
<xsl:text>$USER</xsl:text>
</xsl:when>
<!-- The next three entries are for gpm. I guess those settings are OK
for a laptop or desktop. -->
<xsl:when test="contains(string(),'yourprotocol')">
<xsl:text>imps2</xsl:text>
</xsl:when>
<xsl:when test="contains(string(),'yourdevice')">
<xsl:text>/dev/input/mice</xsl:text>
</xsl:when>
<xsl:when test="contains(string(),'additional options')"/>
<!-- the book has four fields for language. The language param is
broken into four pieces above. We use the results here. -->
<xsl:when test="contains(string(),'&lt;ll&gt;')">
<xsl:copy-of select="$lang-ll"/>
</xsl:when>
<xsl:when test="contains(string(),'&lt;CC&gt;')">
<xsl:copy-of select="$lang-CC"/>
</xsl:when>
<xsl:when test="contains(string(),'&lt;charmap&gt;')">
<xsl:copy-of select="$lang-charmap"/>
</xsl:when>
<xsl:when test="contains(string(),'@modifier')">
<xsl:copy-of select="$lang-modifier"/>
</xsl:when>
<!-- keyboard layout for X/waylang (only GDM as of BLFS-9.0) -->
<xsl:when test="contains(string(),'layout')">
<xsl:copy-of select="$xkblayout"/>
</xsl:when>
<!-- At several places, the number of jobs is given as "N" in a replaceable
tag. We either detect "N" alone or &lt;N&gt; Replace N with 4. -->
<xsl:when test="contains(string(),'&lt;N&gt;') or string()='N'">
<xsl:text>4</xsl:text>
</xsl:when>
<!-- Mercurial config file uses user_name. Replace only if non root.
Add a bogus mail field. That works for the proposed tests anyway. -->
<xsl:when test="contains(string(),'user_name') and $sudo='y'">
<xsl:text>$USER ${USER}@mail.bogus</xsl:text>
</xsl:when>
<!-- Use the config for Gtk+3 as is -->
<xsl:when test="ancestor::sect1[@id='gtk3' or @id='gtk4']">
<xsl:copy-of select="string()"/>
</xsl:when>
<!-- Give 1Gb to fop. Hopefully, nobody has less RAM nowadays. -->
<xsl:when test="contains(string(),'RAM_Installed')">
<xsl:text>1024</xsl:text>
</xsl:when>
<!-- for MIT-Kerberos config file -->
<xsl:when test="string()='&lt;EXAMPLE.ORG&gt;'">
<xsl:copy-of select="$DOMAINNAME"/>
</xsl:when>
<xsl:when test="string()='&lt;example.org&gt;'">
<xsl:copy-of select="$domainname"/>
</xsl:when>
<xsl:when test="string()='&lt;belgarath.example.org&gt;'">
<xsl:copy-of select="$fqdn"/>
</xsl:when>
<!-- in this case, even root can be used -->
<xsl:when test="string()='&lt;loginname&gt;'">
<xsl:text>$USER</xsl:text>
</xsl:when>
<!-- for xorg environment. Note that libreoffice too uses &lt;PREFIX&gt; -->
<xsl:when test="string()='&lt;PREFIX&gt;' and
ancestor::sect1[@id='xorg-env']">
<xsl:text>/usr</xsl:text>
</xsl:when>
<!-- for libreoffice. Note that xorg environment too uses &lt;PREFIX&gt; -->
<xsl:when test="string()='&lt;PREFIX&gt;' and
ancestor::sect1[@id='libreoffice']">
<xsl:text>/opt/</xsl:text>
<xsl:value-of select="ancestor::sect1/@xreflabel"/>
</xsl:when>
<!-- for abiword -->
<xsl:when test="string()='&lt;lang&gt;'">
<xsl:choose>
<xsl:when test="starts-with($language,'en_US')">
<!-- normal.awt for en_US is already there, copy
the one for en_GB (could be any other) -->
<xsl:text>en_GB</xsl:text>
</xsl:when>
<xsl:otherwise>
<!-- in general, there are normal.awt-ll_CC files-->
<xsl:copy-of select="$lang-ll"/>
<xsl:text>_</xsl:text>
<xsl:copy-of select="$lang-CC"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:text>**EDITME</xsl:text>
<xsl:apply-templates/>
<xsl:text>EDITME**</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="replaceable" mode="root">
<xsl:apply-templates select="."/>
</xsl:template>
</xsl:stylesheet>

File diff suppressed because it is too large Load diff

View file

@ -1,119 +0,0 @@
This file contains examples of menu settings for various tasks.
------------------------------
LFS book, System V, stable (8.2) version.
Download the files to /usr/src (verify you have write access)
Build in /mnt/lfs (should be owned by root, verify you can execute sudo)
Clean the build directory before beginning
Build a kernel, whose configuration is in /home/user/config-4.15-lfs-1
An fstab for the future system is located in /home/user/fstablfs
Run only the critical testsuites
Settings for a French user
Run four make jobs in parallel
-----------------------------
BOOK Settings --->
Use BOOK (Linux From Scratch System V) --->
Release (Branch or stable book) --->
Branch (preceded by "branch-"), stable Version, or tag (8.2)
[ ] Add blfs-tool support (NEW)
[ ] Add custom tools support (NEW)
General Settings --->
Build Directory (/mnt/lfs)
[*] Retrieve source files
Package Archive Directory (/usr/src)
[ ] Retry on 'connection refused' failure (NEW)
Number of retry attempts on download failures (20) (NEW)
Download timeout (in seconds) (30) (NEW)
FTP mirror (http://ftp.osuosl.org) (NEW)
[*] Run the makefile
[*] Rebuild files
Build Settings --->
[*] Run testsuites
Tests level (Only final critical testsuites) --->
Flavour (Don't stop on testsuite failures) --->
[ ] Package management
[ ] Create a log of installed files for each package
[*] Use a custom fstab file
Fstab file (optional) ($HOME/fstablfs)
[*] Build the kernel
Kernel config file ($HOME/config-4.15-lfs-1)
[ ] Strip Installed Binaries/Libraries
[ ] Install non-wide-character ncurses
[ ] DO NOT use/display progress_bar
TimeZone (Europe/Paris)
Language (fr_FR.UTF-8)
[ ] Install the full set of locales
Groff page size (A4) --->
Advanced Features --->
[*] Create SBU and disk usage report
[ ] Run comparison analysis on final stage
[*] Optimization and parallelization
Optimization settings --->
Number of parallel `make' jobs (4)
Optimization level (Both temp tools and final system) --->
Internal Settings (WARNING: for jhalfs developers only) --->
[ ] Rebuild the Makefile (see help)
------------------------------
------------------------------
LFS book, systemd, XML source of the LFS book in /usr/src/lfsbook
Download the files to /usr/src (verify you have write access)
Build in /mnt/lfs (should be owned by root, verify you can execute sudo)
Clean the build directory before beginning
Build a kernel, whose configuration is in /home/user/config-4.15-lfs-systemd
An fstab for the future system si located in /home/user/fstablfs
Run all the testsuites
Settings for an user in California
Run four make jobs in parallel
-----------------------------
BOOK Settings --->
Use BOOK (Linux From Scratch systemd) --->
Release (Working Copy) --->
Loc of working copy (mandatory) (/usr/src/lfsbook)
[ ] Add blfs-tool support (NEW)
[ ] Add custom tools support (NEW)
General Settings --->
Build Directory (/mnt/lfs)
[*] Retrieve source files
Package Archive Directory (/usr/src)
[ ] Retry on 'connection refused' failure (NEW)
Number of retry attempts on download failures (20) (NEW)
Download timeout (in seconds) (30) (NEW)
FTP mirror (http://ftp.osuosl.org) (NEW)
[*] Run the makefile
[*] Rebuild files
Build Settings --->
[*] Run testsuites
Tests level (Both temporary tools and final system testsuites) --->
Flavour (Don't stop on testsuite failures) --->
[ ] Package management
[ ] Create a log of installed files for each package
[*] Use a custom fstab file
Fstab file (optional) ($HOME/fstablfs)
[*] Build the kernel
Kernel config file ($HOME/config-4.15-lfs-systemd
[ ] Strip Installed Binaries/Libraries
[ ] Install non-wide-character ncurses
[ ] DO NOT use/display progress_bar
TimeZone (America/Los_Angeles)
Language (en_US.UTF-8)
[ ] Install the full set of locales
Groff page size (letter) --->
Advanced Features --->
[*] Create SBU and disk usage report
[ ] Run comparison analysis on final stage
[*] Optimization and parallelization
Optimization settings --->
Number of parallel `make' jobs (4)
Optimization level (Both temp tools and final system) --->
Internal Settings (WARNING: for jhalfs developers only) --->
[ ] Rebuild the Makefile (see help)
------------------------------

331
CLFS/clfs.xsl Normal file
View file

@ -0,0 +1,331 @@
<?xml version="1.0"?>
<!DOCTYPE xsl:stylesheet [
<!ENTITY % general-entities SYSTEM "FAKEDIR/general.ent">
%general-entities;
]>
<!-- $Id$ -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:exsl="http://exslt.org/common"
extension-element-prefixes="exsl"
version="1.0">
<!-- XSLT stylesheet to create shell scripts from CLFS books. -->
<!-- Build method used -->
<xsl:param name="method" select="chroot"/>
<!-- Run test suites?
0 = none
1 = only Glibc, GCC and Binutils testsuites
2 = all testsuites
3 = alias to 2
-->
<xsl:param name="testsuite" select="1"/>
<!-- Bomb on test suites failures?
n = no, I want to build the full system and review the logs
y = yes, bomb at the first test suite failure to can review the build dir
-->
<xsl:param name="bomb-testsuite" select="n"/>
<!-- Install vim-lang package? -->
<xsl:param name="vim-lang" select="y"/>
<!-- Time zone -->
<xsl:param name="timezone" select="GMT"/>
<!-- Page size -->
<xsl:param name="page" select="letter"/>
<!-- Locale settings -->
<xsl:param name="lang" select="C"/>
<!-- Sparc64 processor type -->
<xsl:param name="sparc" select="none"/>
<xsl:template match="/">
<xsl:apply-templates select="//sect1"/>
</xsl:template>
<xsl:template match="sect1">
<xsl:choose>
<xsl:when test="../@id='chapter-partitioning' or
../@id='chapter-getting-materials' or
../@id='chapter-final-preps'"/>
<xsl:when test="../@id='chapter-testsuite-tools' and $testsuite='0'"/>
<xsl:when test="../@id='chapter-boot' and $method='chroot'"/>
<xsl:when test="../@id='chapter-chroot' and $method='boot'"/>
<xsl:otherwise>
<xsl:if test="count(descendant::screen/userinput) &gt; 0 and
count(descendant::screen/userinput) &gt;
count(descendant::screen[@role='nodump'])">
<!-- The dirs names -->
<xsl:variable name="pi-dir" select="../processing-instruction('dbhtml')"/>
<xsl:variable name="pi-dir-value" select="substring-after($pi-dir,'dir=')"/>
<xsl:variable name="quote-dir" select="substring($pi-dir-value,1,1)"/>
<xsl:variable name="dirname" select="substring-before(substring($pi-dir-value,2),$quote-dir)"/>
<!-- The file names -->
<xsl:variable name="pi-file" select="processing-instruction('dbhtml')"/>
<xsl:variable name="pi-file-value" select="substring-after($pi-file,'filename=')"/>
<xsl:variable name="filename" select="substring-before(substring($pi-file-value,2),'.html')"/>
<!-- The build order -->
<xsl:variable name="position" select="position()"/>
<xsl:variable name="order">
<xsl:choose>
<xsl:when test="string-length($position) = 1">
<xsl:text>00</xsl:text>
<xsl:value-of select="$position"/>
</xsl:when>
<xsl:when test="string-length($position) = 2">
<xsl:text>0</xsl:text>
<xsl:value-of select="$position"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$position"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- Creating dirs and files -->
<exsl:document href="{$dirname}/{$order}-{$filename}" method="text">
<xsl:choose>
<xsl:when test="@id='ch-chroot-changingowner' or
@id='ch-chroot-creatingdirs' or
@id='ch-chroot-createfiles' or
@id='ch-system-stripping'">
<xsl:text>#!/tools/bin/bash&#xA;set +h&#xA;</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>#!/bin/bash&#xA;set +h&#xA;</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="not(@id='ch-system-stripping')">
<xsl:text>set -e</xsl:text>
</xsl:if>
<xsl:text>&#xA;</xsl:text>
<xsl:if test="sect2[@role='installation'] and
not(@id='ch-system-multiarch-wrapper')">
<xsl:text>cd $PKGDIR&#xA;</xsl:text>
<xsl:if test="@id='ch-system-vim' and $vim-lang = 'y'">
<xsl:text>tar -xvf ../vim-&vim-version;-lang.* --strip-components=1&#xA;</xsl:text>
</xsl:if>
</xsl:if>
<xsl:apply-templates select=".//para/userinput | .//screen"/>
<xsl:if test="not(@id='ch-chroot-chroot')">
<xsl:text>echo -e "\n\nTotalseconds: $SECONDS\n"&#xA;</xsl:text>
</xsl:if>
<xsl:text>exit</xsl:text>
</exsl:document>
</xsl:if>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="screen">
<xsl:if test="child::* = userinput and not(@role = 'nodump')">
<xsl:apply-templates select="userinput" mode="screen"/>
</xsl:if>
</xsl:template>
<xsl:template match="para/userinput">
<xsl:if test="(contains(string(),'test') or
contains(string(),'check')) and
($testsuite = '2' or $testsuite = '3')">
<xsl:choose>
<xsl:when test="$bomb-testsuite = 'n'">
<xsl:value-of select="substring-before(string(),'make')"/>
<xsl:text>make -k</xsl:text>
<xsl:value-of select="substring-after(string(),'make')"/>
<xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates/>
<xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
<xsl:if test="contains(string(),' -k ')">
<xsl:text> || true</xsl:text>
</xsl:if>
<xsl:text>&#xA;</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:template>
<xsl:template match="userinput" mode="screen">
<xsl:choose>
<!-- Estandarized package formats -->
<xsl:when test="contains(string(),'tar.gz')">
<xsl:value-of select="substring-before(string(),'tar.gz')"/>
<xsl:text>tar.*</xsl:text>
<xsl:value-of select="substring-after(string(),'tar.gz')"/>
<xsl:text>&#xA;</xsl:text>
</xsl:when>
<!-- Setting $LANG for /etc/profile -->
<xsl:when test="ancestor::sect1[@id='ch-scripts-profile'] and
contains(string(),'export LANG=')">
<xsl:value-of select="substring-before(string(),'export LANG=')"/>
<xsl:text>export LANG=</xsl:text>
<xsl:value-of select="$lang"/>
<xsl:value-of select="substring-after(string(),'charmap]')"/>
<xsl:text>&#xA;</xsl:text>
</xsl:when>
<!-- Compile the keymap into the kernel has been disabled for 1.0 -->
<xsl:when test="contains(string(),'defkeymap')"/>
<!-- Copying the kernel config file -->
<xsl:when test="string() = 'make mrproper'">
<xsl:text>make mrproper&#xA;</xsl:text>
<xsl:if test="ancestor::sect1[@id='ch-boot-kernel']">
<xsl:text>cp -v ../bootkernel-config .config&#xA;</xsl:text>
</xsl:if>
<xsl:if test="ancestor::sect1[@id='ch-bootable-kernel']">
<xsl:text>cp -v ../kernel-config .config&#xA;</xsl:text>
</xsl:if>
</xsl:when>
<!-- No interactive commands are needed if the .config file is the proper one -->
<xsl:when test="contains(string(),'menuconfig')"/>
<!-- The Coreutils and Module-Init-Tools test suites are optional -->
<xsl:when test="(ancestor::sect1[@id='ch-system-coreutils'] or
ancestor::sect1[@id='ch-system-module-init-tools']) and
(contains(string(),'check') or
contains(string(),'dummy'))">
<xsl:choose>
<xsl:when test="$testsuite = '0' or $testsuite = '1'"/>
<xsl:otherwise>
<xsl:if test="not(contains(string(),'check'))">
<xsl:apply-templates/>
<xsl:text>&#xA;</xsl:text>
</xsl:if>
<xsl:if test="contains(string(),'check')">
<xsl:choose>
<xsl:when test="$bomb-testsuite = 'n'">
<xsl:value-of select="substring-before(string(),'check')"/>
<xsl:text>-k check</xsl:text>
<xsl:value-of select="substring-after(string(),'check')"/>
<xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates/>
<xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
<xsl:if test="contains(string(),' -k ')">
<xsl:text> || true</xsl:text>
</xsl:if>
<xsl:text>&#xA;</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<!-- Fixing toolchain test suites run -->
<xsl:when test="string() = 'make check' or
string() = 'make -k check'">
<xsl:choose>
<xsl:when test="$testsuite != '0'">
<xsl:choose>
<xsl:when test="$bomb-testsuite = 'n'">
<xsl:text>make -k check &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates/>
<xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
<xsl:if test="contains(string(),' -k ')">
<xsl:text> || true</xsl:text>
</xsl:if>
<xsl:text>&#xA;</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
</xsl:choose>
</xsl:when>
<xsl:when test="contains(string(),'glibc-check-log')">
<xsl:choose>
<xsl:when test="$testsuite != '0'">
<xsl:value-of select="substring-before(string(),'&gt;g')"/>
<xsl:choose>
<xsl:when test="$bomb-testsuite = 'n'">
<xsl:text>&gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>&gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
<xsl:if test="contains(string(),' -k ')">
<xsl:text> || true</xsl:text>
</xsl:if>
<xsl:text>&#xA;</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
</xsl:choose>
</xsl:when>
<xsl:when test="contains(string(),'test_summary') or
contains(string(),'expect -c')">
<xsl:choose>
<xsl:when test="$testsuite != '0'">
<xsl:apply-templates/>
<xsl:text> &gt;&gt; $TEST_LOG&#xA;</xsl:text>
</xsl:when>
</xsl:choose>
</xsl:when>
<!-- Don't stop on strip run -->
<xsl:when test="contains(string(),'strip ')">
<xsl:apply-templates/>
<xsl:text> || true&#xA;</xsl:text>
</xsl:when>
<!-- The rest of commands -->
<xsl:otherwise>
<xsl:apply-templates/>
<xsl:text>&#xA;</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="replaceable">
<xsl:choose>
<xsl:when test="ancestor::sect1[@id='ch-system-glibc']">
<xsl:value-of select="$timezone"/>
</xsl:when>
<xsl:when test="ancestor::sect1[@id='ch-system-groff']">
<xsl:value-of select="$page"/>
</xsl:when>
<xsl:when test="ancestor::sect1[@id='ch-cross-tools-flags']">
<xsl:choose>
<xsl:when test="contains(string(),'BUILD32')">
<xsl:choose>
<xsl:when test="$sparc = '1' or $sparc = '2'">
<xsl:text>-m32 -mcpu=ultrasparc -mtune=ultrasparc</xsl:text>
</xsl:when>
<xsl:when test="$sparc = '3'">
<xsl:text>-m32 -mcpu=ultrasparc3 -mtune=ultrasparc3</xsl:text>
</xsl:when>
</xsl:choose>
</xsl:when>
<xsl:when test="contains(string(),'BUILD64')">
<xsl:choose>
<xsl:when test="$sparc = '1' or $sparc = '2'">
<xsl:text>-m64 -mcpu=ultrasparc -mtune=ultrasparc</xsl:text>
</xsl:when>
<xsl:when test="$sparc = '3'">
<xsl:text>-m64 -mcpu=ultrasparc3 -mtune=ultrasparc3</xsl:text>
</xsl:when>
</xsl:choose>
</xsl:when>
<xsl:when test="contains(string(),'GCCTARGET')">
<xsl:choose>
<xsl:when test="$sparc = '1' or $sparc = '2'">
<xsl:text>-mcpu=ultrasparc -mtune=ultrasparc</xsl:text>
</xsl:when>
<xsl:when test="$sparc = '3'">
<xsl:text>-mcpu=ultrasparc3 -mtune=ultrasparc3</xsl:text>
</xsl:when>
</xsl:choose>
</xsl:when>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:text>**EDITME</xsl:text>
<xsl:apply-templates/>
<xsl:text>EDITME**</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>

1002
CLFS/master.sh Normal file

File diff suppressed because it is too large Load diff

153
CLFS2/clfs2.xsl Normal file
View file

@ -0,0 +1,153 @@
<?xml version="1.0"?>
<!DOCTYPE xsl:stylesheet [
<!ENTITY % general-entities SYSTEM "FAKEDIR/general.ent">
%general-entities;
]>
<!-- $Id$ -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:exsl="http://exslt.org/common"
extension-element-prefixes="exsl"
version="1.0">
<!-- XSLT stylesheet to create shell scripts from CLFS2 books. -->
<!-- Install vim-lang package? -->
<xsl:param name="vim-lang" select="y"/>
<!-- Time zone -->
<xsl:param name="timezone" select="GMT"/>
<!-- Page size -->
<xsl:param name="page" select="letter"/>
<!-- Locale settings -->
<xsl:param name="lang" select="C"/>
<xsl:template match="/">
<xsl:apply-templates select="//sect1"/>
</xsl:template>
<xsl:template match="sect1">
<xsl:choose>
<xsl:when test="../@id='chapter-partitioning' or
../@id='chapter-getting-materials' or
../@id='chapter-final-preps'"/>
<xsl:otherwise>
<xsl:if test="count(descendant::screen/userinput) &gt; 0 and
count(descendant::screen/userinput) &gt;
count(descendant::screen[@role='nodump'])">
<!-- The dirs names -->
<xsl:variable name="pi-dir" select="../processing-instruction('dbhtml')"/>
<xsl:variable name="pi-dir-value" select="substring-after($pi-dir,'dir=')"/>
<xsl:variable name="quote-dir" select="substring($pi-dir-value,1,1)"/>
<xsl:variable name="dirname" select="substring-before(substring($pi-dir-value,2),$quote-dir)"/>
<!-- The file names -->
<xsl:variable name="pi-file" select="processing-instruction('dbhtml')"/>
<xsl:variable name="pi-file-value" select="substring-after($pi-file,'filename=')"/>
<xsl:variable name="filename" select="substring-before(substring($pi-file-value,2),'.html')"/>
<!-- The build order -->
<xsl:variable name="position" select="position()"/>
<xsl:variable name="order">
<xsl:choose>
<xsl:when test="string-length($position) = 1">
<xsl:text>00</xsl:text>
<xsl:value-of select="$position"/>
</xsl:when>
<xsl:when test="string-length($position) = 2">
<xsl:text>0</xsl:text>
<xsl:value-of select="$position"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$position"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- Creating dirs and files -->
<exsl:document href="{$dirname}/{$order}-{$filename}" method="text">
<xsl:text>#!/bin/bash&#xA;set +h&#xA;</xsl:text>
<xsl:if test="not(@id='ch-system-stripping')">
<xsl:text>set -e&#xA;</xsl:text>
</xsl:if>
<xsl:text>&#xA;</xsl:text>
<xsl:if test="sect2[@role='installation']">
<xsl:text>cd $PKGDIR&#xA;</xsl:text>
<xsl:if test="@id='ch-system-vim' and $vim-lang = 'y'">
<xsl:text>tar -xvf ../vim-&vim-version;-lang.* --strip-components=1&#xA;</xsl:text>
</xsl:if>
</xsl:if>
<xsl:apply-templates select=".//para/userinput | .//screen"/>
<xsl:text>exit</xsl:text>
</exsl:document>
</xsl:if>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="screen">
<xsl:if test="child::* = userinput and not(@role = 'nodump')">
<xsl:apply-templates select="userinput" mode="screen"/>
</xsl:if>
</xsl:template>
<xsl:template match="para/userinput"/>
<xsl:template match="userinput" mode="screen">
<xsl:choose>
<!-- Estandarized package formats -->
<xsl:when test="contains(string(),'tar.gz')">
<xsl:value-of select="substring-before(string(),'tar.gz')"/>
<xsl:text>tar.*</xsl:text>
<xsl:value-of select="substring-after(string(),'tar.gz')"/>
<xsl:text>&#xA;</xsl:text>
</xsl:when>
<!-- Setting $LANG for /etc/profile -->
<xsl:when test="ancestor::sect1[@id='ch-scripts-profile'] and
contains(string(),'export LANG=')">
<xsl:value-of select="substring-before(string(),'export LANG=')"/>
<xsl:text>export LANG=</xsl:text>
<xsl:value-of select="$lang"/>
<xsl:value-of select="substring-after(string(),'charmap]')"/>
<xsl:text>&#xA;</xsl:text>
</xsl:when>
<!-- Compile the keymap into the kernel has been disabled -->
<xsl:when test="contains(string(),'defkeymap')"/>
<!-- Copying the kernel config file -->
<xsl:when test="string() = 'make mrproper'">
<xsl:text>make mrproper&#xA;</xsl:text>
<xsl:text>cp -v ../kernel-config .config&#xA;</xsl:text>
</xsl:when>
<!-- No interactive commands are needed if the .config file is the proper one -->
<xsl:when test="contains(string(),'menuconfig')"/>
<!-- Don't stop on strip run -->
<xsl:when test="contains(string(),'strip ')">
<xsl:apply-templates/>
<xsl:text> || true&#xA;</xsl:text>
</xsl:when>
<!-- The rest of commands -->
<xsl:otherwise>
<xsl:apply-templates/>
<xsl:text>&#xA;</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="replaceable">
<xsl:choose>
<xsl:when test="ancestor::sect1[@id='ch-cross-tools-glibc']">
<xsl:value-of select="$timezone"/>
</xsl:when>
<xsl:when test="ancestor::sect1[@id='ch-cross-tools-groff'] or
ancestor::sect1[@id='ch-system-groff']">
<xsl:value-of select="$page"/>
</xsl:when>
<xsl:otherwise>
<xsl:text>**EDITME</xsl:text>
<xsl:apply-templates/>
<xsl:text>EDITME**</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>

536
CLFS2/master.sh Normal file
View file

@ -0,0 +1,536 @@
#!/bin/bash
# $Id$
###################################
### FUNCTIONS ###
###################################
#----------------------------#
host_prep_Makefiles() { # Initialization of the system
#----------------------------#
local CLFS_HOST
echo "${tab_}${GREEN}Processing... ${L_arrow}host prep files ( SETUP ) ${R_arrow}"
# defined here, only for ease of reading
CLFS_HOST="$(echo $MACHTYPE | sed "s/$(echo $MACHTYPE | cut -d- -f2)/cross/")"
(
cat << EOF
025-addinguser:
@\$(call echo_message, Building)
@if [ ! -d \$(LUSER_HOME) ]; then \\
groupadd \$(LGROUP); \\
useradd -s /bin/bash -g \$(LGROUP) -m -k /dev/null \$(LUSER); \\
else \\
touch luser-exist; \\
fi;
@\$(call housekeeping)
026-settingenvironment: 025-addinguser
@\$(call echo_message, Building)
@if [ -f \$(LUSER_HOME)/.bashrc -a ! -f \$(LUSER_HOME)/.bashrc.XXX ]; then \\
mv \$(LUSER_HOME)/.bashrc \$(LUSER_HOME)/.bashrc.XXX; \\
fi;
@if [ -f \$(LUSER_HOME)/.bash_profile -a ! -f \$(LUSER_HOME)/.bash_profile.XXX ]; then \\
mv \$(LUSER_HOME)/.bash_profile \$(LUSER_HOME)/.bash_profile.XXX; \\
fi;
@echo "set +h" > \$(LUSER_HOME)/.bashrc && \\
echo "umask 022" >> \$(LUSER_HOME)/.bashrc && \\
echo "CLFS=\$(MOUNT_PT)" >> \$(LUSER_HOME)/.bashrc && \\
echo "LC_ALL=POSIX" >> \$(LUSER_HOME)/.bashrc && \\
echo "PATH=\$(MOUNT_PT)/cross-tools/bin:/bin:/usr/bin" >> \$(LUSER_HOME)/.bashrc && \\
echo "export CLFS LC_ALL PATH" >> \$(LUSER_HOME)/.bashrc && \\
echo "" >> \$(LUSER_HOME)/.bashrc && \\
echo "unset CFLAGS" >> \$(LUSER_HOME)/.bashrc && \\
echo "unset CXXFLAGS" >> \$(LUSER_HOME)/.bashrc && \\
echo "" >> \$(LUSER_HOME)/.bashrc && \\
echo "export CLFS_HOST=\"${CLFS_HOST}\"" >> \$(LUSER_HOME)/.bashrc && \\
echo "export CLFS_TARGET=\"${TARGET}\"" >> \$(LUSER_HOME)/.bashrc && \\
echo "source $JHALFSDIR/envars" >> \$(LUSER_HOME)/.bashrc
@chown \$(LUSER):\$(LGROUP) \$(LUSER_HOME)/.bashrc && \\
touch envars && \\
chown \$(LUSER):\$(LGROUP) envars
@\$(call housekeeping)
027-create-directories: 026-settingenvironment
@\$(call echo_message, Building)
@mkdir -p \$(MOUNT_PT)/{bin,boot,dev,{etc/,}opt,home,lib,mnt}
@mkdir -p \$(MOUNT_PT)/{proc,media/{floppy,cdrom},sbin,srv,sys}
@mkdir -p \$(MOUNT_PT)/var/{lock,log,mail,run,spool}
@mkdir -p \$(MOUNT_PT)/var/{opt,cache,lib/{misc,locate},local}
@install -d -m 0750 \$(MOUNT_PT)/root
@install -d -m 1777 \$(MOUNT_PT){/var,}/tmp
@mkdir -p \$(MOUNT_PT)/usr/{,local/}{bin,include,lib,sbin,src}
@mkdir -p \$(MOUNT_PT)/usr/{,local/}share/{doc,info,locale,man}
@mkdir -p \$(MOUNT_PT)/usr/{,local/}share/{misc,terminfo,zoneinfo}
@mkdir -p \$(MOUNT_PT)/usr/{,local/}share/man/man{1,2,3,4,5,6,7,8}
@for dir in \$(MOUNT_PT)/usr{,/local}; do \\
ln -s share/{man,doc,info} \$\$dir ; \\
done
@\$(call housekeeping)
028-creating-sysfile: 027-create-directories
@\$(call echo_message, Building)
@touch \$(MOUNT_PT)/etc/mtab
@echo "root::0:0:root:/root:/bin/bash" >> \$(MOUNT_PT)/etc/passwd
@echo "root:x:0:" >> \$(MOUNT_PT)/etc/group
@echo "bin:x:1:" >> \$(MOUNT_PT)/etc/group
@echo "sys:x:2:" >> \$(MOUNT_PT)/etc/group
@echo "kmem:x:3" >> \$(MOUNT_PT)/etc/group
@echo "tty:x:4:" >> \$(MOUNT_PT)/etc/group
@echo "tape:x:5:" >> \$(MOUNT_PT)/etc/group
@echo "daemon:x:6:" >> \$(MOUNT_PT)/etc/group
@echo "floppy:x:7:" >> \$(MOUNT_PT)/etc/group
@echo "disk:x:8:" >> \$(MOUNT_PT)/etc/group
@echo "lp:x:9:" >> \$(MOUNT_PT)/etc/group
@echo "dialout:x:10:" >> \$(MOUNT_PT)/etc/group
@echo "audio:x:11:" >> \$(MOUNT_PT)/etc/group
@echo "video:x:12:" >> \$(MOUNT_PT)/etc/group
@echo "utmp:x:13:" >> \$(MOUNT_PT)/etc/group
@echo "usb:x:14:" >> \$(MOUNT_PT)/etc/group
@echo "cdrom:x:15:" >> \$(MOUNT_PT)/etc/group
@touch \$(MOUNT_PT)/var/run/utmp \$(MOUNT_PT)/var/log/{btmp,lastlog,wtmp}
@chmod 664 \$(MOUNT_PT)/var/run/utmp \$(MOUNT_PT)/var/log/lastlog
@chown -R \$(LUSER) \$(MOUNT_PT) && \\
chmod -R a+w \$(MOUNT_PT)/\$(SCRIPT_ROOT) && \\
chmod -R a+w \$(SRCSDIR)
@\$(call housekeeping)
EOF
) >> $MKFILE.tmp
host_prep=" 025-addinguser 026-settingenvironment 027-create-directories 028-creating-sysfile"
}
#-----------------------------#
cross_tools_Makefiles() { #
#-----------------------------#
echo "${tab_}${GREEN}Processing... ${L_arrow}cross tools ( LUSER ) ${R_arrow}"
for file in cross-tools/* ; do
# Keep the script file name
this_script=`basename $file`
#
# Skip this script...
case $this_script in
*cflags* | *variables* ) # work done in host_prep_Makefiles
continue ;;
*) ;;
esac
#
# Set the dependency for the first target.
if [ -z $PREV ] ; then PREV=028-creating-sysfile ; fi
# First append each name of the script files to a list (this will become
# the names of the targets in the Makefile
cross_tools="$cross_tools $this_script"
# Grab the name of the target (minus the -headers or -cross in the case of gcc
# and binutils in chapter 5)
name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' \
-e 's@-static@@' \
-e 's@-final@@' \
-e 's@-64@@' \
-e 's@-n32@@'`
case $name in
glibc-headers) name="glibc" ;;
esac
pkg_tarball=$(get_package_tarball_name $name)
#--------------------------------------------------------------------#
# >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
#--------------------------------------------------------------------#
#
# Drop in the name of the target on a new line, and the previous target
# as a dependency. Also call the echo_message function.
LUSER_wrt_target "${this_script}" "$PREV"
#
# If $pkg_tarball isn't empty, we've got a package...
if [ "$pkg_tarball" != "" ] ; then
LUSER_wrt_unpack "$pkg_tarball"
# If using optimizations, write the instructions
[[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
fi
#
LUSER_wrt_RunAsUser "${file}"
#
[[ "$pkg_tarball" != "" ]] && LUSER_RemoveBuildDirs "${name}"
#
# Include a touch of the target name so make can check if it's already been made.
wrt_touch
#
#--------------------------------------------------------------------#
# >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
#--------------------------------------------------------------------#
#
# Keep the script file name for Makefile dependencies.
PREV=$this_script
done # for file in ....
}
#-----------------------------#
final_system_Makefiles() { #
#-----------------------------#
echo "${tab_}${GREEN}Processing... ${L_arrow}final system ( LUSER ) ${R_arrow}"
for file in final-system/* ; do
# Keep the script file name
this_script=`basename $file`
# Test if the stripping phase must be skipped.
# Skip alsp temp-perl for iterative runs
case $this_script in
*stripping*) [[ "$STRIP" = "n" ]] && continue ;;
esac
# Grab the name of the target, strip id number, XXX-script
name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' \
-e 's@temp-@@' \
-e 's@-64bit@@' \
-e 's@-64@@' \
-e 's@64@@' \
-e 's@n32@@'`
# Find the version of the command files, if it corresponds with the building of
# a specific package.
pkg_tarball=$(get_package_tarball_name $name)
# Append each name of the script files to a list (this will become
# the names of the targets in the Makefile
basicsystem="$basicsystem ${this_script}"
#--------------------------------------------------------------------#
# >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
#--------------------------------------------------------------------#
#
# Drop in the name of the target on a new line, and the previous target
# as a dependency. Also call the echo_message function.
LUSER_wrt_target "${this_script}" "$PREV"
#
# If $pkg_tarball isn't empty, we've got a package...
if [ "$pkg_tarball" != "" ] ; then
# Touch timestamp file if installed files logs will be created.
# But only for the firt build when running iterative builds.
if [ "${INSTALL_LOG}" = "y" ] ; then
LUSER_wrt_TouchTimestamp
fi
LUSER_wrt_unpack "$pkg_tarball"
# If using optimizations, write the instructions
[[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
fi
#
LUSER_wrt_RunAsUser "${file}"
#
# Write installed files log and remove the build directory(ies)
# except if the package build fails.
if [ "$pkg_tarball" != "" ] ; then
LUSER_RemoveBuildDirs "${name}"
if [ "${INSTALL_LOG}" = "y" ] ; then
LUSER_wrt_LogNewFiles "$name"
fi
fi
#
# Include a touch of the target name so make can check if it's already been made.
wrt_touch
#
#--------------------------------------------------------------------#
# >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
#--------------------------------------------------------------------#
#
# Keep the script file name for Makefile dependencies.
PREV=${this_script}
done # for file in final-system/* ...
}
#-----------------------------#
bootscripts_Makefiles() { #
#-----------------------------#
echo "${tab_}${GREEN}Processing... ${L_arrow}bootscripts ( LUSER ) ${R_arrow}"
for file in bootscripts/* ; do
# Keep the script file name
this_script=`basename $file`
case $this_script in
*udev) continue ;; # This is not a script but a commentary, we want udev-rules
*console*) continue ;; # Use the files that came with the bootscripts
*network*) continue ;; # Manually create these files
*) ;;
esac
# First append each name of the script files to a list (this will become
# the names of the targets in the Makefile
bootscripttools="$bootscripttools $this_script"
# Grab the name of the target, strip id number, XXX-script
name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
-e 's@-64bit@@' \
-e 's@-64@@' \
-e 's@64@@' \
-e 's@n32@@'`
case $name in
*bootscripts*) name=bootscripts-cross-lfs ;;
*udev-rules) name=udev-cross-lfs ;;
esac
pkg_tarball=$(get_package_tarball_name $name)
#--------------------------------------------------------------------#
# >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
#--------------------------------------------------------------------#
#
# Drop in the name of the target on a new line, and the previous target
# as a dependency. Also call the echo_message function.
LUSER_wrt_target "${this_script}" "$PREV"
#
# If $pkg_tarball isn't empty, we've got a package...
if [ "$pkg_tarball" != "" ] ; then
LUSER_wrt_unpack "$pkg_tarball"
if [ "${INSTALL_LOG}" = "y" ] ; then
LUSER_wrt_TouchTimestamp
fi
fi
#
LUSER_wrt_RunAsUser "${file}"
#
if [ "$pkg_tarball" != "" ] ; then
LUSER_RemoveBuildDirs "${name}"
if [ "${INSTALL_LOG}" = "y" ] ; then
LUSER_wrt_LogNewFiles "$name"
fi
fi
#
# Include a touch of the target name so make can check if it's already been made.
wrt_touch
#
#--------------------------------------------------------------------#
# >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
#--------------------------------------------------------------------#
#
# Keep the script file name for Makefile dependencies.
PREV=$this_script
done # for file in bootscripts/* ...
}
#-----------------------------#
bootable_Makefiles() { #
#-----------------------------#
echo "${tab_}${GREEN}Processing... ${L_arrow}make bootable ( LUSER ) ${R_arrow}"
for file in bootable/* ; do
# Keep the script file name
this_script=`basename $file`
# A little housekeeping on the scripts
case $this_script in
*grub | *aboot | *colo | *silo | *arcload | *lilo | *reboot* ) continue ;;
*fstab) [[ ! -z ${FSTAB} ]] && cp ${FSTAB} $BUILDDIR/sources/fstab ;;
*kernel) # if there is no kernel config file do not build the kernel
[[ -z $CONFIG ]] && continue
# Copy the config file to /sources with a standardized name
cp $CONFIG $BUILDDIR/sources/kernel-config
;;
esac
#
# First append each name of the script files to a list (this will become
# the names of the targets in the Makefile
# NOTE: new makfile format forces the last script, *chowning, into a separate
# phase.
case ${this_script} in
*chowning) chowning=" ${this_script}" ;;
*) bootable="$bootable $this_script" ;;
esac
#
# Grab the name of the target, strip id number and misc words.
name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-build@@' `
case $this_script in
*kernel*) name=linux
;;
esac
pkg_tarball=$(get_package_tarball_name $name)
#--------------------------------------------------------------------#
# >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
#--------------------------------------------------------------------#
#
# Drop in the name of the target on a new line, and the previous target
# as a dependency. Also call the echo_message function.
LUSER_wrt_target "${this_script}" "$PREV"
#
# If $pkg_tarball isn't empty, we've got a package...
if [ "$pkg_tarball" != "" ] ; then
LUSER_wrt_unpack "$pkg_tarball"
if [ "${INSTALL_LOG}" = "y" ] ; then
LUSER_wrt_TouchTimestamp
fi
fi
#
# Select a script execution method
case $this_script in
*fstab*) if [[ -n "$FSTAB" ]]; then
LUSER_wrt_CopyFstab
else
LUSER_wrt_RunAsUser "${file}"
fi
;;
*chowning) wrt_RunAsRoot "${file}"
;;
*) LUSER_wrt_RunAsUser "${file}"
;;
esac
#
# Housekeeping...remove any build directory(ies) except if the package build fails.
if [ "$pkg_tarball" != "" ] ; then
LUSER_RemoveBuildDirs "${name}"
if [ "${INSTALL_LOG}" = "y" ] ; then
LUSER_wrt_LogNewFiles "$name"
fi
fi
#
# Include a touch of the target name so make can check if it's already been made.
wrt_touch
#
#--------------------------------------------------------------------#
# >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
#--------------------------------------------------------------------#
#
# Keep the script file name for Makefile dependencies.
PREV=$this_script
done
}
#-----------------------------#
build_Makefile() { # Construct a Makefile from the book scripts
#-----------------------------#
echo "Creating Makefile... ${BOLD}START${OFF}"
cd $JHALFSDIR/${PROGNAME}-commands
# Start with a clean Makefile.tmp file
>$MKFILE.tmp
host_prep_Makefiles
cross_tools_Makefiles # $cross_tools
final_system_Makefiles # $basicsystem
bootscripts_Makefiles # $bootscripttools
bootable_Makefiles # $bootable
# Add the CUSTOM_TOOLS targets, if needed
[[ "$CUSTOM_TOOLS" = "y" ]] && wrt_CustomTools_target
# Add the BLFS_TOOL targets, if needed.
[[ "$BLFS_TOOL" = "y" ]] && wrt_blfs_tool_targets
# Add a header, some variables and include the function file
# to the top of the real Makefile.
wrt_Makefile_header
# Drop in the main target 'all:' and the chapter targets with each sub-target
# as a dependency.
(
cat << EOF
all: ck_UID mk_SETUP mk_LUSER create-sbu_du-report mk_CUSTOM_TOOLS mk_BLFS_TOOL mk_ROOT
@sudo make restore-luser-env
@sudo make do-housekeeping
@\$(call echo_finished,$VERSION)
ck_UID:
@if [ \`id -u\` = "0" ]; then \\
echo "--------------------------------------------------"; \\
echo "You cannot run this makefile from the root account"; \\
echo "--------------------------------------------------"; \\
exit 1; \\
fi
mk_SETUP:
@\$(call echo_SU_request)
@sudo make BREAKPOINT=\$(BREAKPOINT) SETUP
@touch \$@
mk_LUSER: mk_SETUP
@\$(call echo_SULUSER_request)
@(sudo \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) LUSER" )
@touch \$@
mk_CUSTOM_TOOLS: create-sbu_du-report
@if [ "\$(ADD_CUSTOM_TOOLS)" = "y" ]; then \\
\$(call sh_echo_PHASE,Building CUSTOM_TOOLS); \\
(sudo \$(SU_LUSER) "mkdir -p $BUILDDIR$TRACKING_DIR"); \\
(sudo \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) CUSTOM_TOOLS"); \\
fi;
@touch \$@
mk_BLFS_TOOL: mk_CUSTOM_TOOLS
@if [ "\$(ADD_BLFS_TOOLS)" = "y" ]; then \\
\$(call sh_echo_PHASE,Building BLFS_TOOL); \\
(sudo \$(SU_LUSER) "mkdir -p $BUILDDIR$TRACKING_DIR"); \\
(sudo \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) BLFS_TOOL"); \\
fi;
@touch \$@
mk_ROOT: create-sbu_du-report
@\$(call echo_SU_request)
@echo "$VERSION-sysroot - jhalfs build" > clfs-release && \\
sudo mv clfs-release \$(MOUNT_PT)/etc
@sudo make BREAKPOINT=\$(BREAKPOINT) ROOT
@touch \$@
SETUP: $host_prep
LUSER: $cross_tools $basicsystem $bootscripttools $bootable
CUSTOM_TOOLS: $custom_list
BLFS_TOOL: $blfs_tool
ROOT: $chowning
create-sbu_du-report: mk_LUSER
@\$(call echo_message, Building)
@if [ "\$(ADD_REPORT)" = "y" ]; then \\
./create-sbu_du-report.sh logs $VERSION; \\
\$(call echo_report,$VERSION-SBU_DU-$(date --iso-8601).report); \\
fi;
@touch \$@
restore-luser-env:
@\$(call echo_message, Building)
@if [ -f \$(LUSER_HOME)/.bashrc.XXX ]; then \\
mv -f \$(LUSER_HOME)/.bashrc.XXX \$(LUSER_HOME)/.bashrc; \\
fi;
@if [ -f \$(LUSER_HOME)/.bash_profile.XXX ]; then \\
mv \$(LUSER_HOME)/.bash_profile.XXX \$(LUSER_HOME)/.bash_profile; \\
fi;
@chown \$(LUSER):\$(LGROUP) \$(LUSER_HOME)/.bash* && \\
touch \$@ && \\
echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
echo --------------------------------------------------------------------------------\$(WHITE)
do-housekeeping:
@-if [ ! -f luser-exist ]; then \\
userdel \$(LUSER); \\
rm -rf \$(LUSER_HOME); \\
fi;
EOF
) >> $MKFILE
# Bring over the items from the Makefile.tmp
cat $MKFILE.tmp >> $MKFILE
rm $MKFILE.tmp
echo "Creating Makefile... ${BOLD}DONE${OFF}"
}

154
CLFS3/clfs3.xsl Normal file
View file

@ -0,0 +1,154 @@
<?xml version="1.0"?>
<!DOCTYPE xsl:stylesheet [
<!ENTITY % general-entities SYSTEM "FAKEDIR/general.ent">
%general-entities;
]>
<!-- $Id$ -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:exsl="http://exslt.org/common"
extension-element-prefixes="exsl"
version="1.0">
<!-- XSLT stylesheet to create shell scripts from CLFS2 books. -->
<!-- Endian level -->
<xsl:param name="endian" select="xbig"/>
<!-- Time zone -->
<xsl:param name="timezone" select="GMT"/>
<!-- Page size -->
<xsl:param name="page" select="letter"/>
<!-- Locale settings -->
<xsl:param name="lang" select="C"/>
<xsl:template match="/">
<xsl:apply-templates select="//sect1"/>
</xsl:template>
<xsl:template match="sect1">
<xsl:choose>
<xsl:when test="../@id='chapter-partitioning' or
../@id='chapter-getting-materials' or
../@id='chapter-final-preps'"/>
<xsl:otherwise>
<xsl:if test="count(descendant::screen/userinput) &gt; 0 and
count(descendant::screen/userinput) &gt;
count(descendant::screen[@role='nodump'])">
<!-- The dirs names -->
<xsl:variable name="pi-dir" select="../processing-instruction('dbhtml')"/>
<xsl:variable name="pi-dir-value" select="substring-after($pi-dir,'dir=')"/>
<xsl:variable name="quote-dir" select="substring($pi-dir-value,1,1)"/>
<xsl:variable name="dirname" select="substring-before(substring($pi-dir-value,2),$quote-dir)"/>
<!-- The file names -->
<xsl:variable name="pi-file" select="processing-instruction('dbhtml')"/>
<xsl:variable name="pi-file-value" select="substring-after($pi-file,'filename=')"/>
<xsl:variable name="filename" select="substring-before(substring($pi-file-value,2),'.html')"/>
<!-- The build order -->
<xsl:variable name="position" select="position()"/>
<xsl:variable name="order">
<xsl:choose>
<xsl:when test="string-length($position) = 1">
<xsl:text>00</xsl:text>
<xsl:value-of select="$position"/>
</xsl:when>
<xsl:when test="string-length($position) = 2">
<xsl:text>0</xsl:text>
<xsl:value-of select="$position"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$position"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- Creating dirs and files -->
<exsl:document href="{$dirname}/{$order}-{$filename}" method="text">
<xsl:text>#!/bin/bash&#xA;set +h&#xA;set -e&#xA;&#xA;</xsl:text>
<!-- Set envars needed by uClibc -->
<xsl:if test="@id='ch-cross-tools-uclibc'">
<xsl:copy-of select="//sect1[@id='ch-cross-tools-toolchain']/screen"/>
<xsl:text>&#xA;&#xA;</xsl:text>
</xsl:if>
<xsl:if test="sect2[@role='installation']">
<xsl:text>cd $PKGDIR&#xA;</xsl:text>
</xsl:if>
<xsl:apply-templates select=".//para/userinput | .//screen"/>
<xsl:text>exit</xsl:text>
</exsl:document>
</xsl:if>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="screen">
<xsl:if test="child::* = userinput and not(@role = 'nodump')">
<xsl:apply-templates select="userinput" mode="screen"/>
</xsl:if>
</xsl:template>
<xsl:template match="para/userinput"/>
<xsl:template match="userinput" mode="screen">
<xsl:choose>
<!-- Estandarized package formats -->
<xsl:when test="contains(string(),'tar.gz')">
<xsl:value-of select="substring-before(string(),'tar.gz')"/>
<xsl:text>tar.*</xsl:text>
<xsl:value-of select="substring-after(string(),'tar.gz')"/>
<xsl:text>&#xA;</xsl:text>
</xsl:when>
<!-- Select Endian level for uClibc -->
<xsl:when test="$endian='xbig' and contains(string(),'LITTLE_ENDIAN')"/>
<xsl:when test="$endian='xlittle' and contains(string(),'BIG_ENDIAN')"/>
<!-- Setting $LANG for /etc/profile -->
<xsl:when test="ancestor::sect1[@id='ch-scripts-profile'] and
contains(string(),'export LANG=')">
<xsl:value-of select="substring-before(string(),'export LANG=')"/>
<xsl:text>export LANG=</xsl:text>
<xsl:value-of select="$lang"/>
<xsl:value-of select="substring-after(string(),'charmap]')"/>
<xsl:text>&#xA;</xsl:text>
</xsl:when>
<!-- Compile the keymap into the kernel has been disabled -->
<xsl:when test="contains(string(),'defkeymap')"/>
<!-- Copying the kernel config file -->
<xsl:when test="string() = 'make mrproper'">
<xsl:text>make mrproper&#xA;</xsl:text>
<xsl:text>cp -v ../kernel-config .config&#xA;</xsl:text>
</xsl:when>
<!-- No interactive commands are needed if the .config file is the proper one -->
<xsl:when test="contains(string(),'menuconfig')"/>
<!-- Don't stop on strip run -->
<xsl:when test="contains(string(),'strip ')">
<xsl:apply-templates/>
<xsl:text> || true&#xA;</xsl:text>
</xsl:when>
<!-- The rest of commands -->
<xsl:otherwise>
<xsl:apply-templates/>
<xsl:text>&#xA;</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="replaceable">
<xsl:choose>
<xsl:when test="ancestor::sect1[@id='ch-cross-tools-glibc']">
<xsl:value-of select="$timezone"/>
</xsl:when>
<xsl:when test="ancestor::sect1[@id='ch-cross-tools-groff'] or
ancestor::sect1[@id='ch-system-groff']">
<xsl:value-of select="$page"/>
</xsl:when>
<xsl:otherwise>
<xsl:text>**EDITME</xsl:text>
<xsl:apply-templates/>
<xsl:text>EDITME**</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>

586
CLFS3/master.sh Normal file
View file

@ -0,0 +1,586 @@
#!/bin/bash
# $Id$
###################################
### FUNCTIONS ###
###################################
#----------------------------#
host_prep_Makefiles() { # Initialization of the system
#----------------------------#
local CLFS_HOST
echo "${tab_}${GREEN}Processing... ${L_arrow}host prep files ( SETUP ) ${R_arrow}"
# defined here, only for ease of reading
CLFS_HOST="$(echo $MACHTYPE | sed "s/$(echo $MACHTYPE | cut -d- -f2)/cross/")"
(
cat << EOF
025-addinguser:
@\$(call echo_message, Building)
@if [ ! -d \$(LUSER_HOME) ]; then \\
groupadd \$(LGROUP); \\
useradd -s /bin/bash -g \$(LGROUP) -m -k /dev/null \$(LUSER); \\
else \\
touch luser-exist; \\
fi;
@\$(call housekeeping)
026-settingenvironment: 025-addinguser
@\$(call echo_message, Building)
@if [ -f \$(LUSER_HOME)/.bashrc -a ! -f \$(LUSER_HOME)/.bashrc.XXX ]; then \\
mv \$(LUSER_HOME)/.bashrc \$(LUSER_HOME)/.bashrc.XXX; \\
fi;
@if [ -f \$(LUSER_HOME)/.bash_profile -a ! -f \$(LUSER_HOME)/.bash_profile.XXX ]; then \\
mv \$(LUSER_HOME)/.bash_profile \$(LUSER_HOME)/.bash_profile.XXX; \\
fi;
@echo "set +h" > \$(LUSER_HOME)/.bashrc && \\
echo "umask 022" >> \$(LUSER_HOME)/.bashrc && \\
echo "CLFS=\$(MOUNT_PT)" >> \$(LUSER_HOME)/.bashrc && \\
echo "LC_ALL=POSIX" >> \$(LUSER_HOME)/.bashrc && \\
echo "PATH=\$(MOUNT_PT)/cross-tools/bin:/bin:/usr/bin" >> \$(LUSER_HOME)/.bashrc && \\
echo "export CLFS LC_ALL PATH" >> \$(LUSER_HOME)/.bashrc && \\
echo "" >> \$(LUSER_HOME)/.bashrc && \\
echo "unset CFLAGS" >> \$(LUSER_HOME)/.bashrc && \\
echo "unset CXXFLAGS" >> \$(LUSER_HOME)/.bashrc && \\
echo "" >> \$(LUSER_HOME)/.bashrc && \\
echo "export CLFS_HOST=\"${CLFS_HOST}\"" >> \$(LUSER_HOME)/.bashrc && \\
echo "export CLFS_TARGET=\"${TARGET}\"" >> \$(LUSER_HOME)/.bashrc && \\
echo "export CLFS_MIPS_LEVEL=\"${MIPS_LEVEL}\"" >> \$(LUSER_HOME)/.bashrc && \\
echo "export BUILD=\"${ABI}\"" >> \$(LUSER_HOME)/.bashrc && \\
echo "source $JHALFSDIR/envars" >> \$(LUSER_HOME)/.bashrc
@chown \$(LUSER):\$(LGROUP) \$(LUSER_HOME)/.bashrc && \\
touch envars && \\
chown \$(LUSER):\$(LGROUP) envars
@\$(call housekeeping)
027-create-directories: 026-settingenvironment
@\$(call echo_message, Building)
@mkdir -p \$(MOUNT_PT)/{bin,boot,dev,{etc/,}opt,home,lib,mnt}
@mkdir -p \$(MOUNT_PT)/{proc,media/{floppy,cdrom},sbin,srv,sys}
@mkdir -p \$(MOUNT_PT)/var/{lock,log,mail,run,spool}
@mkdir -p \$(MOUNT_PT)/var/{opt,cache,lib/{misc,locate},local}
@install -d -m 0750 \$(MOUNT_PT)/root
@install -d -m 1777 \$(MOUNT_PT){/var,}/tmp
@mkdir -p \$(MOUNT_PT)/usr/{,local/}{bin,include,lib,sbin,src}
@mkdir -p \$(MOUNT_PT)/usr/{,local/}share/{doc,info,locale,man}
@mkdir -p \$(MOUNT_PT)/usr/{,local/}share/{misc,terminfo,zoneinfo}
@mkdir -p \$(MOUNT_PT)/usr/{,local/}share/man/man{1,2,3,4,5,6,7,8}
@for dir in \$(MOUNT_PT)/usr{,/local}; do \\
ln -s share/{man,doc,info} \$\$dir ; \\
done
@\$(call housekeeping)
028-creating-sysfile: 027-create-directories
@\$(call echo_message, Building)
@touch \$(MOUNT_PT)/etc/mtab
@echo "root::0:0:root:/root:/bin/ash" >> \$(MOUNT_PT)/etc/passwd
@echo "root:x:0:" >> \$(MOUNT_PT)/etc/group
@echo "bin:x:1:" >> \$(MOUNT_PT)/etc/group
@echo "sys:x:2:" >> \$(MOUNT_PT)/etc/group
@echo "kmem:x:3" >> \$(MOUNT_PT)/etc/group
@echo "tty:x:4:" >> \$(MOUNT_PT)/etc/group
@echo "tape:x:5:" >> \$(MOUNT_PT)/etc/group
@echo "daemon:x:6:" >> \$(MOUNT_PT)/etc/group
@echo "floppy:x:7:" >> \$(MOUNT_PT)/etc/group
@echo "disk:x:8:" >> \$(MOUNT_PT)/etc/group
@echo "lp:x:9:" >> \$(MOUNT_PT)/etc/group
@echo "dialout:x:10:" >> \$(MOUNT_PT)/etc/group
@echo "audio:x:11:" >> \$(MOUNT_PT)/etc/group
@echo "video:x:12:" >> \$(MOUNT_PT)/etc/group
@echo "utmp:x:13:" >> \$(MOUNT_PT)/etc/group
@echo "usb:x:14:" >> \$(MOUNT_PT)/etc/group
@echo "cdrom:x:15:" >> \$(MOUNT_PT)/etc/group
@touch \$(MOUNT_PT)/var/run/utmp \$(MOUNT_PT)/var/log/{btmp,lastlog,wtmp}
@chmod 664 \$(MOUNT_PT)/var/run/utmp \$(MOUNT_PT)/var/log/lastlog
@chown -R \$(LUSER) \$(MOUNT_PT) && \\
chmod -R a+w \$(MOUNT_PT)/\$(SCRIPT_ROOT) && \\
chmod -R a+w \$(SRCSDIR)
@\$(call housekeeping)
EOF
) >> $MKFILE.tmp
host_prep=" 025-addinguser 026-settingenvironment 027-create-directories 028-creating-sysfile"
}
#-----------------------------#
systemprep_Makefiles() { #
#-----------------------------#
echo "${tab_}${GREEN}Processing... ${L_arrow}system prep tools ( LUSER ) ${R_arrow}"
for file in systemprep/* ; do
# Keep the script file name
this_script=`basename $file`
# Set the dependency for the first target.
if [ -z $PREV ] ; then PREV=028-creating-sysfile ; fi
# First append each name of the script files to a list (this will become
# the names of the targets in the Makefile)
cross_tools="$cross_tools $this_script"
# Grab the name of the target (minus the -headers or -cross in the case of gcc
# and binutils in chapter 5)
name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'`
pkg_tarball=$(get_package_tarball_name $name)
#--------------------------------------------------------------------#
# >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
#--------------------------------------------------------------------#
#
# Drop in the name of the target on a new line, and the previous target
# as a dependency. Also call the echo_message function.
LUSER_wrt_target "${this_script}" "$PREV"
#
# If $pkg_tarball isn't empty, we've got a package...
if [ "$pkg_tarball" != "" ] ; then
LUSER_wrt_unpack "$pkg_tarball"
fi
#
LUSER_wrt_RunAsUser "${file}"
#
[[ "$pkg_tarball" != "" ]] && LUSER_RemoveBuildDirs "${name}"
#
# Include a touch of the target name so make can check if it's already been made.
wrt_touch
#
#--------------------------------------------------------------------#
# >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
#--------------------------------------------------------------------#
#
# Keep the script file name for Makefile dependencies.
PREV=$this_script
done # for file in ....
}
#-----------------------------#
cross_tools_Makefiles() { #
#-----------------------------#
echo "${tab_}${GREEN}Processing... ${L_arrow}cross tools ( LUSER ) ${R_arrow}"
for file in cross-tools/* ; do
# Keep the script file name
this_script=`basename $file`
#
# Skip this script...
# NOTE.. the book indicated you only needed to install groff or file if the host
# had older versions. The packages would be installed in the target directory
# and not the host.
case $this_script in
*cflags* | *variables* | *abi | *toolchain*) # work done in host_prep_Makefiles
continue ;;
*) ;;
esac
#
# Set the dependency for the first target.
if [ -z $PREV ] ; then PREV=028-creating-sysfile ; fi
# First append each name of the script files to a list (this will become
# the names of the targets in the Makefile)
cross_tools="$cross_tools $this_script"
# Grab the name of the target (minus the -headers or -cross in the case of gcc
# and binutils in chapter 5)
name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' \
-e 's@-static@@' \
-e 's@-final@@' \
-e 's@-64@@' \
-e 's@-n32@@'`
case $name in
uclibc*) name="uClibc" ;;
esac
pkg_tarball=$(get_package_tarball_name $name)
#--------------------------------------------------------------------#
# >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
#--------------------------------------------------------------------#
#
# Drop in the name of the target on a new line, and the previous target
# as a dependency. Also call the echo_message function.
LUSER_wrt_target "${this_script}" "$PREV"
#
# If $pkg_tarball isn't empty, we've got a package...
if [ "$pkg_tarball" != "" ] ; then
LUSER_wrt_unpack "$pkg_tarball"
# Touch timestamp file if installed files logs will be created.
if [ "${INSTALL_LOG}" = "y" ] ; then
LUSER_wrt_TouchTimestamp
fi
# If using optimizations, write the instructions
[[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
fi
#
LUSER_wrt_RunAsUser "${file}"
#
# Write installed files log and remove the build directory(ies)
# except if the package build fails.
if [ "$pkg_tarball" != "" ] ; then
LUSER_RemoveBuildDirs "${name}"
if [ "${INSTALL_LOG}" = "y" ] ; then
LUSER_wrt_LogNewFiles "$name"
fi
fi
#
# Include a touch of the target name so make can check if it's already been made.
wrt_touch
#
#--------------------------------------------------------------------#
# >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
#--------------------------------------------------------------------#
#
# Keep the script file name for Makefile dependencies.
PREV=$this_script
done # for file in ....
}
#-----------------------------#
final_system_Makefiles() { #
#-----------------------------#
echo "${tab_}${GREEN}Processing... ${L_arrow}final system ( LUSER ) ${R_arrow}"
for file in final-system/* ; do
# Keep the script file name
this_script=`basename $file`
# Grab the name of the target, strip id number, XXX-script
name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' \
-e 's@temp-@@' \
-e 's@-64bit@@' \
-e 's@-64@@' \
-e 's@64@@' \
-e 's@n32@@'`
# Find the version of the command files, if it corresponds with the building of
# a specific package.
pkg_tarball=$(get_package_tarball_name $name)
# Append each name of the script files to a list (this will become
# the names of the targets in the Makefile
basicsystem="$basicsystem ${this_script}"
#--------------------------------------------------------------------#
# >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
#--------------------------------------------------------------------#
#
# Drop in the name of the target on a new line, and the previous target
# as a dependency. Also call the echo_message function.
LUSER_wrt_target "${this_script}" "$PREV"
#
# If $pkg_tarball isn't empty, we've got a package...
if [ "$pkg_tarball" != "" ] ; then
# Touch timestamp file if installed files logs will be created.
if [ "${INSTALL_LOG}" = "y" ] ; then
LUSER_wrt_TouchTimestamp
fi
LUSER_wrt_unpack "$pkg_tarball"
# If using optimizations, write the instructions
[[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
fi
#
LUSER_wrt_RunAsUser "${file}"
#
# Write installed files log and remove the build directory(ies)
# except if the package build fails.
if [ "$pkg_tarball" != "" ] ; then
LUSER_RemoveBuildDirs "${name}"
if [ "${INSTALL_LOG}" = "y" ] ; then
LUSER_wrt_LogNewFiles "$name"
fi
fi
#
# Include a touch of the target name so make can check if it's already been made.
wrt_touch
#
#--------------------------------------------------------------------#
# >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
#--------------------------------------------------------------------#
#
# Keep the script file name for Makefile dependencies.
PREV=${this_script}
done # for file in final-system/* ...
}
#-----------------------------#
bootscripts_Makefiles() { #
#-----------------------------#
echo "${tab_}${GREEN}Processing... ${L_arrow}bootscripts ( LUSER ) ${R_arrow}"
for file in bootscripts/* ; do
# Keep the script file name
this_script=`basename $file`
case $this_script in
*console*) continue ;; # Use the files that came with the bootscripts
*network*) continue ;; # Manually create these files
*) ;;
esac
# First append each name of the script files to a list (this will become
# the names of the targets in the Makefile
bootscripttools="$bootscripttools $this_script"
# Grab the name of the target, strip id number, XXX-script
name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
-e 's@-64bit@@' \
-e 's@-64@@' \
-e 's@64@@' \
-e 's@n32@@'`
case $name in
*bootscripts*) name=clfs-embedded-bootscripts ;;
esac
pkg_tarball=$(get_package_tarball_name $name)
#--------------------------------------------------------------------#
# >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
#--------------------------------------------------------------------#
#
# Drop in the name of the target on a new line, and the previous target
# as a dependency. Also call the echo_message function.
LUSER_wrt_target "${this_script}" "$PREV"
#
# If $pkg_tarball isn't empty, we've got a package...
if [ "$pkg_tarball" != "" ] ; then
LUSER_wrt_unpack "$pkg_tarball"
if [ "${INSTALL_LOG}" = "y" ] ; then
LUSER_wrt_TouchTimestamp
fi
fi
#
LUSER_wrt_RunAsUser "${file}"
#
if [ "$pkg_tarball" != "" ] ; then
LUSER_RemoveBuildDirs "${name}"
if [ "${INSTALL_LOG}" = "y" ] ; then
LUSER_wrt_LogNewFiles "$name"
fi
fi
#
# Include a touch of the target name so make can check if it's already been made.
wrt_touch
#
#--------------------------------------------------------------------#
# >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
#--------------------------------------------------------------------#
#
# Keep the script file name for Makefile dependencies.
PREV=$this_script
done # for file in bootscripts/* ...
}
#-----------------------------#
bootable_Makefiles() { #
#-----------------------------#
echo "${tab_}${GREEN}Processing... ${L_arrow}make bootable ( LUSER ) ${R_arrow}"
for file in bootable/* ; do
# Keep the script file name
this_script=`basename $file`
# A little housekeeping on the scripts
case $this_script in
*grub | *aboot | *colo | *silo | *arcload | *lilo | *reboot* ) continue ;;
*fstab) [[ ! -z ${FSTAB} ]] && cp ${FSTAB} $BUILDDIR/sources/fstab ;;
*kernel) # if there is no kernel config file do not build the kernel
[[ -z $CONFIG ]] && continue
# Copy the config file to /sources with a standardized name
cp $CONFIG $BUILDDIR/sources/kernel-config
;;
esac
#
# First append each name of the script files to a list (this will become
# the names of the targets in the Makefile
# NOTE: new makfile format forces the last script, *chowning, into a separate
# phase.
case ${this_script} in
*chowning) chowning=${this_script} ;;
*) bootable="$bootable $this_script" ;;
esac
#
# Grab the name of the target, strip id number and misc words.
name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-build@@' `
case $this_script in
*kernel*) name=linux
;;
esac
pkg_tarball=$(get_package_tarball_name $name)
#--------------------------------------------------------------------#
# >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
#--------------------------------------------------------------------#
#
# Drop in the name of the target on a new line, and the previous target
# as a dependency. Also call the echo_message function.
LUSER_wrt_target "${this_script}" "$PREV"
#
# If $pkg_tarball isn't empty, we've got a package...
if [ "$pkg_tarball" != "" ] ; then
LUSER_wrt_unpack "$pkg_tarball"
if [ "${INSTALL_LOG}" = "y" ] ; then
LUSER_wrt_TouchTimestamp
fi
fi
#
# Select a script execution method
case $this_script in
*fstab*) if [[ -n "$FSTAB" ]]; then
LUSER_wrt_CopyFstab
else
LUSER_wrt_RunAsUser "${file}"
fi
;;
*chowning) wrt_RunAsRoot "${file}"
;;
*) LUSER_wrt_RunAsUser "${file}"
;;
esac
#
# Housekeeping...remove any build directory(ies) except if the package build fails.
if [ "$pkg_tarball" != "" ] ; then
LUSER_RemoveBuildDirs "${name}"
if [ "${INSTALL_LOG}" = "y" ] ; then
LUSER_wrt_LogNewFiles "$name"
fi
fi
#
# Include a touch of the target name so make can check if it's already been made.
wrt_touch
#
#--------------------------------------------------------------------#
# >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
#--------------------------------------------------------------------#
#
# Keep the script file name for Makefile dependencies.
PREV=$this_script
done
}
#-----------------------------#
build_Makefile() { # Construct a Makefile from the book scripts
#-----------------------------#
echo "Creating Makefile... ${BOLD}START${OFF}"
cd $JHALFSDIR/${PROGNAME}-commands
# Start with a clean Makefile.tmp file
>$MKFILE.tmp
host_prep_Makefiles
[[ "${PLATFORM% -*}" = "WRT" ]] && systemprep_Makefiles # $cross_tools
cross_tools_Makefiles # $cross_tools
final_system_Makefiles # $basicsystem
bootscripts_Makefiles # $bootscripttools
bootable_Makefiles # $bootable
# Add the CUSTOM_TOOLS targets, if needed
[[ "$CUSTOM_TOOLS" = "y" ]] && wrt_CustomTools_target
# Add a header, some variables and include the function file
# to the top of the real Makefile.
wrt_Makefile_header
# Drop in the main target 'all:' and the chapter targets with each sub-target
# as a dependency.
(
cat << EOF
all: ck_UID mk_SETUP mk_LUSER create-sbu_du-report mk_CUSTOM_TOOLS mk_ROOT
@sudo make restore-luser-env
@sudo make do-housekeeping
@\$(call echo_finished,$VERSION)
ck_UID:
@if [ \`id -u\` = "0" ]; then \\
echo "--------------------------------------------------"; \\
echo "You cannot run this makefile from the root account"; \\
echo "--------------------------------------------------"; \\
exit 1; \\
fi
mk_SETUP:
@\$(call echo_SU_request)
@sudo make BREAKPOINT=\$(BREAKPOINT) SETUP
@touch \$@
mk_LUSER: mk_SETUP
@\$(call echo_SULUSER_request)
@(sudo \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) LUSER" )
@touch \$@
mk_CUSTOM_TOOLS: create-sbu_du-report
@if [ "\$(ADD_CUSTOM_TOOLS)" = "y" ]; then \\
\$(call sh_echo_PHASE,Building CUSTOM_TOOLS); \\
(sudo \$(SU_LUSER) "mkdir -p $BUILDDIR$TRACKING_DIR"); \\
(sudo \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) CUSTOM_TOOLS"); \\
fi;
@touch \$@
mk_ROOT:
@\$(call echo_SU_request)
@echo "$VERSION-embedded - jhalfs build" > clfs-release && \\
sudo mv clfs-release \$(MOUNT_PT)/etc
@sudo make BREAKPOINT=\$(BREAKPOINT) ROOT
@touch \$@
SETUP: $host_prep
LUSER: $cross_tools $basicsystem $bootscripttools $bootable
CUSTOM_TOOLS: $custom_list
ROOT: $chowning
create-sbu_du-report: mk_LUSER
@\$(call echo_message, Building)
@if [ "\$(ADD_REPORT)" = "y" ]; then \\
./create-sbu_du-report.sh logs $VERSION; \\
\$(call echo_report,$VERSION-SBU_DU-$(date --iso-8601).report); \\
fi;
@touch \$@
restore-luser-env:
@\$(call echo_message, Building)
@if [ -f \$(LUSER_HOME)/.bashrc.XXX ]; then \\
mv -f \$(LUSER_HOME)/.bashrc.XXX \$(LUSER_HOME)/.bashrc; \\
fi;
@if [ -f \$(LUSER_HOME)/.bash_profile.XXX ]; then \\
mv \$(LUSER_HOME)/.bash_profile.XXX \$(LUSER_HOME)/.bash_profile; \\
fi;
@chown \$(LUSER):\$(LGROUP) \$(LUSER_HOME)/.bash* && \\
touch \$@ && \\
echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
echo --------------------------------------------------------------------------------\$(WHITE)
do-housekeeping:
@-if [ ! -f luser-exist ]; then \\
userdel \$(LUSER); \\
rm -rf \$(LUSER_HOME); \\
fi;
EOF
) >> $MKFILE
# Bring over the items from the Makefile.tmp
cat $MKFILE.tmp >> $MKFILE
rm $MKFILE.tmp
echo "Creating Makefile... ${BOLD}DONE${OFF}"
}

1829
Config.in

File diff suppressed because it is too large Load diff

View file

@ -1,282 +0,0 @@
This is the list of functions used in jhalfs, excluding BLFS tool functions
and functions defined in {C,H}LFS/master.sh.
I felt the need for documenting it when trying to add package management.
Functions are listed in alphabetical order, with a short description and the
file where they are defined.
--------------------------------------------------------------------------
install_blfs_tools():
From common/libs/func_install_blfs.
Description: Copy the needed files to `BLFS_ROOT'. Initialize
the package tracking. Generates a `configuration' file from
the tool dependencies settings, and use it to generate
scriptlets from the blfs book. Uses those scriptlets to download the
needed tarballs. Then generates a Makefile for building the dependencies.
Called by: jhalfs
--------------------------------------------------------------------------
get_sources():
From common/libs/func_download_pkgs.
Description: Downloads packages if `GETPKG' is `y'. Writes package name
and md5 checksum to `MISSING_FILES.DMP' if a package cannot be found in
`$SRC_ARCHIVE' and cannot be downloaded, or if md5 checksum does not agree
book's one. If `MISSING_FILES.DMP' is not empty at the end of the process,
disable the excution of the makefile.
Actually, if `$BUILDDIR/sources' does not exist, it is not created if
`GETPKG' is `n'. And an empty or non existent `$BUILDDIR/sources' is
not flagged...
If `GETPKG' is `y', removes `MD5SUMS', `MISSING_FILES.DMP', and `urls.lst'
from `$BUILDDIR/sources' and generates them in the course of the process.
Called by: get_book and extract_commands
--------------------------------------------------------------------------
gs_wrt_message():
From common/libs/func_download_pkgs.
Description: internal function in get_sources. Writes a message to the screen
and a package name to `MISSING_FILES.DMP'.
--------------------------------------------------------------------------
create_urls():
From common/libs/func_download_pkgs.
Description: Runs xsltproc with stylesheet urls.xsl on chapter 3 of the
book. Add BLFS dependencies and custom dependencies if `BLFS_TOOLS' is `y'
and `CUSTOM_TOOLS' is `y' respectively.
Called by: get_sources
--------------------------------------------------------------------------
wrt_CustomTools_target():
From common/libs/func_custom_pkgs.
Description: Add users supplied scripts to `$JHALFSDIR/custom-tools', with
corresponding entry in the Makefile.
TODO: Add package management (instructions to user and Makefile entry)
Called by: All master.sh `build_Makefile'.
--------------------------------------------------------------------------
add_CustomToolsURLS():
From common/libs/func_custom_pkgs.
Description: Add any users supplied scripts URL information to urls.lst
Called by: create_urls
--------------------------------------------------------------------------
wrt_Makefile_header():
From common/libs/func_wrt_Makefile.
Description: Writes the beginning of the Makefile into $MKFILE, which created
or erased before.
Called by: All master.sh `build_Makefile'.
--------------------------------------------------------------------------
get_package_tarball_name():
From common/libs/func_wrt_Makefile.
Arguments: $1 contains the script_name
Description: Retrieves the tarball name from `pkg_tarball_list' by comparing
script-name to the beginning of a line in the list. Writes the name found
to stdout.
Implements the behavior described in README.CUSTOM, that is, if script_name
begins with d-, strip that part.
Called by: various functions in master.sh
--------------------------------------------------------------------------
LUSER_wrt_target():
From common/libs/func_wrt_Makefile.
Arguments: $1 contains target name; $2 contains dependency(ies)
Description: Add lines in the Makefile, which create target and
initialize log file.
LUSER version uses $MOUNT_PT in absolute path names.
Called by: chapter5_Makefiles and chapter6_Makefiles in LFS/master.sh
and other master.sh
--------------------------------------------------------------------------
CHROOT_wrt_target():
From common/libs/func_wrt_Makefile.
Arguments: $1 contains target name; $2 contains dependency(ies)
Description: Add lines in the Makefile, which create target and
initialize log file.
CHROOT version uses / in absolute path names.
Called by: chapter6_Makefiles and chapter78_Makefiles in LFS/master.sh
and other functions in other master.sh
--------------------------------------------------------------------------
LUSER_wrt_unpack():
From common/libs/func_wrt_Makefile.
Arguments: $1 contains tarball name; $2 contains 1 if the existing directory
is to be presserved.
Description: Add lines in the Makefile, which unpack and set 'ROOT' var and
remove existing dir if $2 != 1
LUSER version uses $MOUNT_PT in absolute path names.
Uses: Makefile functions remove_existing_dirs, unpack, get_pkg_root.
--------------------------------------------------------------------------
CHROOT_Unpack():
From common/libs/func_wrt_Makefile.
Arguments: $1 contains tarball name; $2 contains 1 if the existing directory
is to be presserved.
Description: Add lines in the Makefile, which unpack and set 'ROOT' var and
remove existing dir if $2 != 1
CHROOT version uses / in absolute path names.
Uses: Makefile functions remove_existing_dirs2, unpack2, get_pkg_root2.
--------------------------------------------------------------------------
LUSER_wrt_test_log():
From common/libs/func_wrt_Makefile.
Description: Add lines in the Makefile, which initialize testsuite
log file.
LUSER version uses $MOUNT_PT in absolute path names.
--------------------------------------------------------------------------
CHROOT_wrt_test_log():
From common/libs/func_wrt_Makefile.
Description: Add lines in the Makefile, which initialize testsuite
log file.
CHROOT version uses / in absolute path names.
--------------------------------------------------------------------------
wrt_RunAsRoot():
From common/libs/func_wrt_Makefile.
Description: Some scripts must be run as root..
--------------------------------------------------------------------------
LUSER_wrt_RunAsUser():
From common/libs/func_wrt_Makefile.
Description: Calculate time with perl, footer to log file
--------------------------------------------------------------------------
CHROOT_wrt_RunAsRoot():
From common/libs/func_wrt_Makefile.
Description:
--------------------------------------------------------------------------
LUSER_wrt_CopyFstab():
From common/libs/func_wrt_Makefile.
Description:
--------------------------------------------------------------------------
CHROOT_wrt_CopyFstab():
From common/libs/func_wrt_Makefile.
Description:
--------------------------------------------------------------------------
LUSER_wrt_TouchTimestamp():
From common/libs/func_wrt_Makefile.
Description:
--------------------------------------------------------------------------
CHROOT_wrt_TouchTimestamp():
From common/libs/func_wrt_Makefile.
Description:
--------------------------------------------------------------------------
LUSER_wrt_LogNewFiles():
From common/libs/func_wrt_Makefile.
Description:
--------------------------------------------------------------------------
CHROOT_wrt_LogNewFiles():
From common/libs/func_wrt_Makefile.
Description:
--------------------------------------------------------------------------
LUSER_RemoveBuildDirs():
From common/libs/func_wrt_Makefile.
Description:
--------------------------------------------------------------------------
CHROOT_wrt_RemoveBuildDirs():
From common/libs/func_wrt_Makefile.
Description:
--------------------------------------------------------------------------
wrt_touch():
From common/libs/func_wrt_Makefile.
Description:
--------------------------------------------------------------------------
wrt_compare_targets():
From common/libs/func_compare.sh.
Description:
--------------------------------------------------------------------------
wrt_system_build():
From common/libs/func_compare.sh.
Description:
--------------------------------------------------------------------------
wrt_compare_work():
From common/libs/func_compare.sh.
Description:
--------------------------------------------------------------------------
wrt_do_ica_work():
From common/libs/func_compare.sh.
Description:
--------------------------------------------------------------------------
wrt_logs():
From common/libs/func_compare.sh.
Description:
--------------------------------------------------------------------------
validate_config():
From common/libs/func_validate_configs.sh.
Description: Are the config values sane (within reason)
--------------------------------------------------------------------------
write_error_and_die():
From common/libs/func_validate_configs.sh.
Description:
--------------------------------------------------------------------------
validate_file():
From common/libs/func_validate_configs.sh.
Description:
--------------------------------------------------------------------------
validate_dir():
From common/libs/func_validate_configs.sh.
Description:
--------------------------------------------------------------------------
get_book():
From common/libs/func_book_parser.
Description:
--------------------------------------------------------------------------
extract_commands():
From common/libs/func_book_parser.
Description:
--------------------------------------------------------------------------
create_package_list():
From common/libs/func_book_parser.
Description:
--------------------------------------------------------------------------
check_version():
From common/libs/func_check_version.sh.
Description:
--------------------------------------------------------------------------
write_error_and_die():
From common/libs/func_check_version.sh.
Description:
--------------------------------------------------------------------------
check_prerequisites():
From common/libs/func_check_version.sh.
Description:
--------------------------------------------------------------------------
write_or_exit():
From common/progress_bar.sh.
Description:
--------------------------------------------------------------------------
no_empty_builddir():
From common/common-functions.
Description:
--------------------------------------------------------------------------
run_make():
From common/common-functions.
Description:
--------------------------------------------------------------------------
clean_builddir():
From common/common-functions.
Description:
--------------------------------------------------------------------------
simple_error():
From jhalfs.
Description: Basic error trap.... JUST DIE
--------------------------------------------------------------------------
see_ya():
From jhalfs.
Description:
--------------------------------------------------------------------------
chapter4_Makefiles():
From LFS/master.sh.
Description:
--------------------------------------------------------------------------
chapter5_Makefiles():
From LFS/master.sh.
Description:
--------------------------------------------------------------------------
chapter6_Makefiles():
From LFS/master.sh.
Description:
--------------------------------------------------------------------------
chapter78_Makefiles():
From LFS/master.sh.
Description:
--------------------------------------------------------------------------
build_Makefile():
From LFS/master.sh.
Description:
--------------------------------------------------------------------------
validate_opt_settings():
From optimize/optimize_functions.
Description: Show optimize setting and wait user agreement
--------------------------------------------------------------------------
wrt_optimize():
From optimize/optimize_functions.
Description: Apply pkg specific opt's to build
--------------------------------------------------------------------------
wrt_makeflags():
From optimize/optimize_functions.
Description: Apply MAKEFLAGS to build
--------------------------------------------------------------------------

330
HLFS/hlfs.xsl Normal file
View file

@ -0,0 +1,330 @@
<?xml version="1.0"?>
<!DOCTYPE xsl:stylesheet [
<!ENTITY % general-entities SYSTEM "FAKEDIR/general.ent">
%general-entities;
]>
<!-- $Id$ -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:exsl="http://exslt.org/common"
extension-element-prefixes="exsl"
version="1.0">
<!-- XSLT stylesheet to create shell scripts from HLFS books. -->
<!-- What libc implentation must be used? -->
<xsl:param name="model" select="glibc"/>
<!-- What kernel serie must be used? -->
<xsl:param name="kernel" select="2.6"/>
<!-- Is the host kernel using grsecurity? -->
<xsl:param name="grsecurity_host" select="n"/>
<!-- Run test suites?
0 = none
1 = only chapter06 Glibc, GCC and Binutils testsuites
2 = all chapter06 testsuites
3 = alias to 2
-->
<xsl:param name="testsuite" select="1"/>
<!-- Bomb on test suites failures?
n = no, I want to build the full system and review the logs
y = yes, bomb at the first test suite failure to can review the build dir
-->
<xsl:param name="bomb-testsuite" select="n"/>
<!-- Additional features -->
<xsl:param name="features">,ssp,aslr,pax,hardened_tmp,warnings,misc,blowfish,</xsl:param>
<!-- Time zone -->
<xsl:param name="timezone" select="GMT"/>
<!-- Page size -->
<xsl:param name="page" select="letter"/>
<!-- Locale settings -->
<xsl:param name="lang" select="C"/>
<xsl:template match="/">
<xsl:apply-templates select="//sect1"/>
</xsl:template>
<xsl:template match="sect1">
<xsl:if test="(../@id='chapter-temporary-tools' or
../@id='chapter-building-system' or
../@id='chapter-bootable') and
(count(descendant::screen/userinput) &gt; 0 and
count(descendant::screen/userinput) &gt;
count(descendant::screen[@role='nodump'])) and
((@condition=$model or not(@condition)) and
(@vendor=$kernel or not(@vendor)))">
<!-- The dirs names -->
<xsl:variable name="pi-dir" select="../processing-instruction('dbhtml')"/>
<xsl:variable name="pi-dir-value" select="substring-after($pi-dir,'dir=')"/>
<xsl:variable name="quote-dir" select="substring($pi-dir-value,1,1)"/>
<xsl:variable name="dirname" select="substring-before(substring($pi-dir-value,2),$quote-dir)"/>
<!-- The file names -->
<xsl:variable name="pi-file" select="processing-instruction('dbhtml')"/>
<xsl:variable name="pi-file-value" select="substring-after($pi-file,'filename=')"/>
<xsl:variable name="filename" select="substring-before(substring($pi-file-value,2),'.html')"/>
<!-- The build order -->
<xsl:variable name="position" select="position()"/>
<xsl:variable name="order">
<xsl:choose>
<xsl:when test="string-length($position) = 1">
<xsl:text>00</xsl:text>
<xsl:value-of select="$position"/>
</xsl:when>
<xsl:when test="string-length($position) = 2">
<xsl:text>0</xsl:text>
<xsl:value-of select="$position"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$position"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- Creating dirs and files -->
<exsl:document href="{$dirname}/{$order}-{$filename}" method="text">
<xsl:choose>
<xsl:when test="@id='ch-system-creatingdirs' or
@id='ch-system-createfiles' or
@id='ch-system-changingowner' or
@id='ch-system-strippingagain'">
<xsl:text>#!/tools/bin/bash&#xA;set +h&#xA;</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>#!/bin/bash&#xA;set +h&#xA;</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="not(@id='ch-tools-stripping') and
not(@id='ch-system-strippingagain')">
<xsl:text>set -e&#xA;</xsl:text>
</xsl:if>
<xsl:text>&#xA;</xsl:text>
<xsl:if test="(sect2[@role='installation'])">
<xsl:text>cd $PKGDIR&#xA;</xsl:text>
<xsl:if test="@id='ch-system-uclibc'">
<xsl:text>pushd ../; tar -xvf gettext-&gettext-version;.*; popd; &#xA;</xsl:text>
</xsl:if>
<!-- SVN toolchain format, from inside ./sources dir unpack binutils and gcc -->
<xsl:if test="@id='ch-tools-embryo-toolchain' or
@id='ch-tools-cocoon-toolchain' or
@id='ch-system-butterfly-toolchain'">
<xsl:text>tar -xvf gcc-core-&gcc-version;.*; &#xA;</xsl:text>
<xsl:text>tar -xvf binutils-&binutils-version;.*; &#xA;</xsl:text>
</xsl:if>
<xsl:if test="@id='ch-tools-cocoon-toolchain' or
@id='ch-system-butterfly-toolchain'">
<xsl:text>tar -xvf gcc-g++-&gcc-version;.*; &#xA;</xsl:text>
</xsl:if>
<!-- ONLY butterfly has a testsuite -->
<xsl:if test="@id='ch-system-butterfly-toolchain' and $testsuite != '0'">
<xsl:text>tar -xvf gcc-testsuite-&gcc-version;.*; &#xA;</xsl:text>
</xsl:if>
<!-- END SVN toolchain format -->
</xsl:if>
<xsl:apply-templates select=".//para/userinput | .//screen"/>
<xsl:if test="not(@id='ch-system-chroot') and
not(@id='ch-system-revisedchroot')">
<xsl:text>echo -e "\n\nTotalseconds: $SECONDS\n"&#xA;</xsl:text>
</xsl:if>
<xsl:text>exit</xsl:text>
</exsl:document>
</xsl:if>
</xsl:template>
<xsl:template match="screen">
<xsl:if test="(@condition=$model or not(@condition)) and
(@vendor=$kernel or not(@vendor)) and
child::* = userinput and (not(@role) or
(@role and contains($features,concat(',',@role,','))))">
<xsl:apply-templates select="userinput" mode="screen"/>
</xsl:if>
</xsl:template>
<xsl:template match="para/userinput">
<xsl:if test="(contains(string(),'test') or
contains(string(),'check')) and
($testsuite = '2' or $testsuite = '3')">
<xsl:choose>
<xsl:when test="$bomb-testsuite = 'n'">
<xsl:value-of select="substring-before(string(),'make')"/>
<xsl:text>make -k</xsl:text>
<xsl:value-of select="substring-after(string(),'make')"/>
<xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates/>
<xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
<xsl:if test="contains(string(),' -k ')">
<xsl:text> || true</xsl:text>
</xsl:if>
<xsl:text>&#xA;</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:template>
<xsl:template match="userinput" mode="screen">
<xsl:choose>
<!-- grsecurity kernel in the host? -->
<xsl:when test="ancestor::sect1[@id='ch-system-kernfs'] and
contains(string(),'sysctl')
and $grsecurity_host ='n'"/>
<!-- Setting $LANG for /etc/profile -->
<xsl:when test="ancestor::sect1[@id='bootable-profile'] and
contains(string(),'export LANG=')">
<xsl:value-of select="substring-before(string(),'export LANG=')"/>
<xsl:text>export LANG=</xsl:text>
<xsl:value-of select="$lang"/>
<xsl:value-of select="substring-after(string(),'CC]')"/>
<xsl:text>&#xA;</xsl:text>
</xsl:when>
<!-- Copying the kernel config file -->
<xsl:when test="string() = 'make mrproper'">
<xsl:text>make mrproper&#xA;</xsl:text>
<xsl:text>cp -v /sources/kernel-config .config&#xA;</xsl:text>
</xsl:when>
<!-- No interactive commands are needed if the .config file is the proper one -->
<xsl:when test="string() = 'make menuconfig'"/>
<!-- For uClibc we need to set CONFIG_SITE -->
<xsl:when test="contains(string(),'CONFIG_SITE')">
<xsl:value-of select="substring-before(string(),'export')"/>
<xsl:text>echo "export</xsl:text>
<xsl:value-of select="substring-after(string(),'export')"/>
<xsl:text>" &gt;&gt; ~/.bashrc&#xA;</xsl:text>
</xsl:when>
<!-- For uClibc we need to cd to the Gettext package -->
<xsl:when test="contains(string(),'cd gettext-runtime/')">
<xsl:text>cd ../gettext-*/gettext-runtime</xsl:text>
<xsl:value-of select="substring-after(string(),'gettext-runtime')"/>
<xsl:text>&#xA;</xsl:text>
</xsl:when>
<!-- The Coreutils and Module-Init-Tools test suites are optional -->
<xsl:when test="(ancestor::sect1[@id='ch-system-coreutils'] or
ancestor::sect1[@id='ch-system-module-init-tools']) and
(contains(string(),'check') or
contains(string(),'distclean') or
contains(string(),'dummy'))">
<xsl:choose>
<xsl:when test="$testsuite = '0' or $testsuite = '1'"/>
<xsl:otherwise>
<xsl:if test="not(contains(string(),'check'))">
<xsl:apply-templates/>
<xsl:text>&#xA;</xsl:text>
</xsl:if>
<xsl:if test="contains(string(),'check')">
<xsl:choose>
<xsl:when test="$bomb-testsuite = 'n'">
<xsl:value-of select="substring-before(string(),'check')"/>
<xsl:text>-k check</xsl:text>
<xsl:value-of select="substring-after(string(),'check')"/>
<xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates/>
<xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
<xsl:if test="contains(string(),' -k ')">
<xsl:text> || true</xsl:text>
</xsl:if>
<xsl:text>&#xA;</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<!-- Fixing butterfly toolchain test suite run -->
<xsl:when test="ancestor::sect1[@id='ch-system-butterfly-toolchain']
and string() = 'make -k check'">
<xsl:choose>
<xsl:when test="$testsuite != '0'">
<xsl:choose>
<xsl:when test="$bomb-testsuite = 'n'">
<xsl:text>make -k check &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates/>
<xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
<xsl:if test="contains(string(),' -k ')">
<xsl:text> || true</xsl:text>
</xsl:if>
<xsl:text>&#xA;</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
</xsl:choose>
</xsl:when>
<!-- Fixing Glbc test suite -->
<xsl:when test="contains(string(),'rm -v configparms') and
contains(string(),'-fno-stack-protector')">
<xsl:choose>
<xsl:when test="$testsuite != '0'">
<xsl:apply-templates/>
<xsl:text>&#xA;</xsl:text>
</xsl:when>
</xsl:choose>
</xsl:when>
<xsl:when test="contains(string(),'glibc-check-log')">
<xsl:choose>
<xsl:when test="$testsuite != '0'">
<xsl:value-of select="substring-before(string(),'2&gt;&amp;1')"/>
<xsl:text>&gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
</xsl:when>
</xsl:choose>
</xsl:when>
<!-- Fixing Cocoon sanity checks -->
<xsl:when test="contains(string(),'./strcat-overflow')">
<xsl:text>set +e&#xA;</xsl:text>
<xsl:apply-templates/>
<xsl:text>&#xA;set -e&#xA;</xsl:text>
</xsl:when>
<!-- Fixing Butterfly sanity checks -->
<xsl:when test="contains(string(),'./fortify-test')
or contains(string(),'./ssp-test')">
<xsl:text>! </xsl:text>
<xsl:apply-templates/>
<xsl:text>&#xA;</xsl:text>
</xsl:when>
<!-- Don't stop on strip run -->
<xsl:when test="contains(string(),'strip ')">
<xsl:apply-templates/>
<xsl:text> || true&#xA;</xsl:text>
</xsl:when>
<!-- The rest of commands -->
<xsl:otherwise>
<xsl:apply-templates/>
<xsl:text>&#xA;</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="literal">
<xsl:if test="(@condition=$model or not(@condition)) and
(@vendor=$kernel or not(@vendor))">
<xsl:apply-templates/>
</xsl:if>
</xsl:template>
<xsl:template match="replaceable">
<xsl:choose>
<xsl:when test="ancestor::sect1[@id='ch-system-glibc'] or
ancestor::sect1[@id='ch-system-uclibc']">
<xsl:value-of select="$timezone"/>
</xsl:when>
<xsl:when test="ancestor::sect1[@id='ch-system-groff']">
<xsl:value-of select="$page"/>
</xsl:when>
<xsl:otherwise>
<xsl:text>**EDITME</xsl:text>
<xsl:apply-templates/>
<xsl:text>EDITME**</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>

659
HLFS/master.sh Normal file
View file

@ -0,0 +1,659 @@
#!/bin/bash
set -e # Enable error trapping
# $Id$
###################################
### FUNCTIONS ###
###################################
#----------------------------#
process_toolchain() { # embryo,cocoon and butterfly need special handling
#----------------------------#
local toolchain=$1
local this_file=$2
local tc_phase
local binutil_tarball
local gcc_core_tarball
local TC_MountPT
local remove_existing
tc_phase=`echo $toolchain | sed -e 's@[0-9]\{3\}-@@' -e 's@-toolchain@@' -e 's,'$N',,'`
case $tc_phase in
embryo | \
cocoon) # Vars for LUSER phase
remove_existing="remove_existing_dirs"
TC_MountPT="\$(MOUNT_PT)\$(SRC)"
;;
butterfly) # Vars for CHROOT phase
remove_existing="remove_existing_dirs2"
TC_MountPT="\$(SRC)"
;;
esac
#
# Safe method to remove existing toolchain dirs
binutil_tarball=$(get_package_tarball_name "binutils")
gcc_core_tarball=$(get_package_tarball_name "gcc-core")
(
cat << EOF
@\$(call ${remove_existing},$binutil_tarball)
@\$(call ${remove_existing},$gcc_core_tarball)
EOF
) >> $MKFILE.tmp
#
# Manually remove the toolchain directories..
(
cat << EOF
@rm -rf ${TC_MountPT}/${tc_phase}-toolchain && \\
rm -rf ${TC_MountPT}/${tc_phase}-build
EOF
) >> $MKFILE.tmp
(
cat << EOF
@echo "export PKGDIR=${TC_MountPT}" > envars
EOF
) >> $MKFILE.tmp
case ${tc_phase} in
butterfly)
[[ "$TEST" != "0" ]] && CHROOT_wrt_test_log "${toolchain}"
CHROOT_wrt_RunAsRoot "$this_file"
;;
*) LUSER_wrt_RunAsUser "$this_file"
;;
esac
#
(
cat << EOF
@\$(call ${remove_existing},$binutil_tarball)
@\$(call ${remove_existing},$gcc_core_tarball)
EOF
) >> $MKFILE.tmp
#
# Manually remove the toolchain directories..
(
cat << EOF
@rm -rf ${TC_MountPT}/${tc_phase}-toolchain && \\
rm -rf ${TC_MountPT}/${tc_phase}-build
EOF
) >> $MKFILE.tmp
}
#----------------------------#
chapter3_Makefiles() { # Initialization of the system
#----------------------------#
echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter3 ( SETUP ) ${R_arrow}"
# If $LUSER_HOME is already present in the host, we asume that the
# hlfs user and group are also presents in the host, and a backup
# of their bash init files is made.
(
cat << EOF
020-creatingtoolsdir:
@\$(call echo_message, Building)
@mkdir \$(MOUNT_PT)/tools && \\
rm -f /tools && \\
ln -s \$(MOUNT_PT)/tools /
@\$(call housekeeping)
021-addinguser: 020-creatingtoolsdir
@\$(call echo_message, Building)
@if [ ! -d \$(LUSER_HOME) ]; then \\
groupadd \$(LGROUP); \\
useradd -s /bin/bash -g \$(LGROUP) -m -k /dev/null \$(LUSER); \\
else \\
touch luser-exist; \\
fi;
@chown \$(LUSER) \$(MOUNT_PT)/tools && \\
chmod -R a+wt \$(MOUNT_PT)/\$(SCRIPT_ROOT) && \\
chmod a+wt \$(SRCSDIR)
@\$(call housekeeping)
022-settingenvironment: 021-addinguser
@\$(call echo_message, Building)
@if [ -f \$(LUSER_HOME)/.bashrc -a ! -f \$(LUSER_HOME)/.bashrc.XXX ]; then \\
mv \$(LUSER_HOME)/.bashrc \$(LUSER_HOME)/.bashrc.XXX; \\
fi;
@if [ -f \$(LUSER_HOME)/.bash_profile -a ! -f \$(LUSER_HOME)/.bash_profile.XXX ]; then \\
mv \$(LUSER_HOME)/.bash_profile \$(LUSER_HOME)/.bash_profile.XXX; \\
fi;
@echo "set +h" > \$(LUSER_HOME)/.bashrc && \\
echo "umask 022" >> \$(LUSER_HOME)/.bashrc && \\
echo "HLFS=\$(MOUNT_PT)" >> \$(LUSER_HOME)/.bashrc && \\
echo "LC_ALL=POSIX" >> \$(LUSER_HOME)/.bashrc && \\
echo "PATH=/tools/bin:/bin:/usr/bin" >> \$(LUSER_HOME)/.bashrc && \\
echo "export HLFS LC_ALL PATH" >> \$(LUSER_HOME)/.bashrc && \\
echo "" >> \$(LUSER_HOME)/.bashrc && \\
echo "source $JHALFSDIR/envars" >> \$(LUSER_HOME)/.bashrc && \\
chown \$(LUSER):\$(LGROUP) \$(LUSER_HOME)/.bashrc && \\
chmod -R a+wt \$(MOUNT_PT) && \\
touch envars && \\
chown \$(LUSER) envars
@\$(call housekeeping)
EOF
) >> $MKFILE.tmp
chapter3=" 020-creatingtoolsdir 021-addinguser 022-settingenvironment"
}
#----------------------------#
chapter5_Makefiles() { # Bootstrap or temptools phase
#----------------------------#
local file
local this_script
echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter5 ( LUSER ) ${R_arrow}"
for file in chapter05/* ; do
# Keep the script file name
this_script=`basename $file`
# Skip this script depending on jhalfs.conf flags set.
case $this_script in
# If no testsuites will be run, then TCL, Expect and DejaGNU aren't needed
*tcl* ) [[ "$TEST" = "0" ]] && continue; ;;
*expect* ) [[ "$TEST" = "0" ]] && continue; ;;
*dejagnu* ) [[ "$TEST" = "0" ]] && continue; ;;
# Test if the stripping phase must be skipped
*stripping* ) [[ "$STRIP" = "n" ]] && continue ;;
*) ;;
esac
# First append each name of the script files to a list (this will become
# the names of the targets in the Makefile
chapter5="$chapter5 $this_script"
# Grab the name of the target
name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-pass[0-9]\{1\}@@'`
# Adjust 'name'
case $name in
uclibc) name="uClibc" ;;
esac
# Set the dependency for the first target.
if [ -z $PREV ] ; then PREV=022-settingenvironment ; fi
#--------------------------------------------------------------------#
# >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
#--------------------------------------------------------------------#
#
# Drop in the name of the target on a new line, and the previous target
# as a dependency. Also call the echo_message function.
# This is a very special script and requires manual processing
# NO Optimization allowed
if [[ ${name} = "embryo-toolchain" ]] || \
[[ ${name} = "cocoon-toolchain" ]]; then
LUSER_wrt_target "$this_script" "$PREV"
process_toolchain "${this_script}" "${file}"
wrt_touch
PREV=$this_script
continue
fi
#
LUSER_wrt_target "$this_script" "$PREV"
# Find the version of the command files, if it corresponds with the building of
# a specific package. Fix GCC tarball name for 2.4-branch.
case $name in
gcc ) pkg_tarball=$(get_package_tarball_name gcc-core) ;;
* ) pkg_tarball=$(get_package_tarball_name $name) ;;
esac
# If $pkg_tarball isn't empty, we've got a package...
if [ "$pkg_tarball" != "" ] ; then
# Insert instructions for unpacking the package and to set the PKGDIR variable.
LUSER_wrt_unpack "$pkg_tarball"
# If using optimizations, write the instructions
[[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
fi
# Insert date and disk usage at the top of the log file, the script run
# and date and disk usage again at the bottom of the log file.
LUSER_wrt_RunAsUser "${file}"
# Remove the build directory(ies) except if the package build fails
# (so we can review config.cache, config.log, etc.)
if [ "$pkg_tarball" != "" ] ; then
LUSER_RemoveBuildDirs "$name"
fi
# Include a touch of the target name so make can check if it's already been made.
wrt_touch
#
#--------------------------------------------------------------------#
# >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
#--------------------------------------------------------------------#
# Keep the script file name for Makefile dependencies.
PREV=$this_script
done # end for file in chapter05/*
}
#----------------------------#
chapter6_Makefiles() { # sysroot or chroot build phase
#----------------------------#
local file
local this_script
# Set envars and scripts for iteration targets
if [[ -z "$1" ]] ; then
local N=""
else
local N=-build_$1
local chapter6=""
mkdir chapter06$N
cp chapter06/* chapter06$N
for script in chapter06$N/* ; do
# Overwrite existing symlinks, files, and dirs
sed -e 's/ln -s /ln -sf /g' \
-e 's/^mv /&-f /g' \
-e 's/mkdir -v/&p/g' -i ${script}
# Rename the scripts
mv ${script} ${script}$N
done
# Remove Bzip2 binaries before make install
sed -e 's@make install@rm -vf /usr/bin/bz*\n&@' -i chapter06$N/*-bzip2$N
# Fix how Module-Init-Tools do the install target
sed -e 's@make install@make INSTALL=install install@' -i chapter06$N/*-module-init-tools$N
# Don't readd already existing groups
sed -e '/groupadd/d' -i chapter06$N/*-udev$N
fi
echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter6$N ( CHROOT ) ${R_arrow}"
for file in chapter06$N/* ; do
# Keep the script file name
this_script=`basename $file`
# Skip this script depending on jhalfs.conf flags set.
case $this_script in
# We'll run the chroot commands differently than the others, so skip them in the
# dependencies and target creation.
*chroot* ) continue ;;
# Test if the stripping phase must be skipped
*-stripping* ) [[ "$STRIP" = "n" ]] && continue ;;
# Skip linux-headers in iterative builds
*linux-headers*) [[ -n "$N" ]] && continue ;;
esac
# Grab the name of the target
name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's,'$N',,'`
case $name in
uclibc) name="uClibc" ;;
esac
# Find the version of the command files, if it corresponds with the building of
# a specific package. Fix GCC tarball name for 2.4-branch.
case $name in
gcc ) pkg_tarball=$(get_package_tarball_name gcc-core) ;;
* ) pkg_tarball=$(get_package_tarball_name $name) ;;
esac
if [[ "$pkg_tarball" = "" ]] && [[ -n "$N" ]] ; then
case "${this_script}" in
*stripping*) ;;
*) continue ;;
esac
fi
# Append each name of the script files to a list (this will become
# the names of the targets in the Makefile
case "${this_script}" in
*kernfs* ) runasroot=" ${this_script}" ;;
* ) chapter6="$chapter6 ${this_script}" ;;
esac
#--------------------------------------------------------------------#
# >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
#--------------------------------------------------------------------#
#
# Drop in the name of the target on a new line, and the previous target
# as a dependency. Also call the echo_message function.
if [[ ${name} = "butterfly-toolchain" ]]; then
CHROOT_wrt_target "${this_script}" "$PREV"
# Touch timestamp file if installed files logs will be created.
# But only for the firt build when running iterative builds.
if [ "${INSTALL_LOG}" = "y" ] && [ "x${N}" = "x" ] ; then
CHROOT_wrt_TouchTimestamp
fi
process_toolchain "${this_script}" "${file}"
if [ "${INSTALL_LOG}" = "y" ] && [ "x${N}" = "x" ] ; then
CHROOT_wrt_LogNewFiles "$name"
fi
wrt_touch
PREV=$this_script
continue
fi
# kernfs is run in SUDO target
case "${this_script}" in
*kernfs* ) LUSER_wrt_target "${this_script}" "$PREV" ;;
* ) CHROOT_wrt_target "${this_script}" "$PREV" ;;
esac
# If $pkg_tarball isn't empty, we've got a package...
# Insert instructions for unpacking the package and changing directories
if [ "$pkg_tarball" != "" ] ; then
# Touch timestamp file if installed files logs will be created.
# But only for the firt build when running iterative builds.
if [ "${INSTALL_LOG}" = "y" ] && [ "x${N}" = "x" ] ; then
CHROOT_wrt_TouchTimestamp
fi
CHROOT_Unpack "$pkg_tarball"
# If the testsuites must be run, initialize the log file
# butterfly-toolchain tests are enabled in 'process_tookchain' function
# 2.4-branch toolchain is ernabled here.
case $name in
glibc | gcc | binutils)
[[ "$TEST" != "0" ]] && CHROOT_wrt_test_log "${this_script}" ;;
* ) [[ "$TEST" > "1" ]] && CHROOT_wrt_test_log "${this_script}" ;;
esac
# If using optimizations, write the instructions
[[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
fi
# In kernfs we need to set HLFS and not to use chroot.
case "${this_script}" in
*kernfs* ) wrt_RunAsRoot "${file}" ;;
* ) CHROOT_wrt_RunAsRoot "${file}" ;;
esac
#
# Write installed files log and remove the build directory(ies)
# except if the package build fails.
if [ "$pkg_tarball" != "" ] ; then
CHROOT_wrt_RemoveBuildDirs "$name"
if [ "${INSTALL_LOG}" = "y" ] && [ "x${N}" = "x" ] ; then
CHROOT_wrt_LogNewFiles "$name"
fi
fi
#
# Include a touch of the target name so make can check if it's already been made.
wrt_touch
#
#--------------------------------------------------------------------#
# >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
#--------------------------------------------------------------------#
# Keep the script file name for Makefile dependencies.
PREV=${this_script}
# Set system_build envar for iteration targets
system_build=$chapter6
done # end for file in chapter06/*
}
#----------------------------#
chapter7_Makefiles() { # Create a bootable system.. kernel, bootscripts..etc
#----------------------------#
local file
local this_script
echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter7 ( BOOT ) ${R_arrow}"
for file in chapter07/*; do
# Keep the script file name
this_script=`basename $file`
case $this_script in
*grub) continue ;; # Grub must be configured manually.
*console) continue ;; # Use the file generated by lfs-bootscripts
*fstab) [[ ! -z ${FSTAB} ]] && cp ${FSTAB} $BUILDDIR/sources/fstab
;;
*kernel) # If no .config file is supplied, the kernel build is skipped
[[ -z $CONFIG ]] && continue
cp $CONFIG $BUILDDIR/sources/kernel-config
;;
esac
# First append then name of the script file to a list (this will become
# the names of the targets in the Makefile
chapter7="$chapter7 $this_script"
#--------------------------------------------------------------------#
# >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
#--------------------------------------------------------------------#
#
# Drop in the name of the target on a new line, and the previous target
# as a dependency. Also call the echo_message function.
CHROOT_wrt_target "$this_script" "$PREV"
case "${this_script}" in
*bootscripts*)
if [ "${INSTALL_LOG}" = "y" ] ; then
CHROOT_wrt_TouchTimestamp
fi
CHROOT_Unpack $(get_package_tarball_name "lfs-bootscripts")
blfs_bootscripts=$(get_package_tarball_name "blfs-bootscripts" | sed -e 's/.tar.*//' )
echo -e "\t@echo \"\$(MOUNT_PT)\$(SRC)/$blfs_bootscripts\" >> sources-dir" >> $MKFILE.tmp
;;
*kernel)
name="linux"
pkg_tarball=$(get_package_tarball_name $name)
if [ "${INSTALL_LOG}" = "y" ] ; then
CHROOT_wrt_TouchTimestamp
fi
CHROOT_Unpack "$pkg_tarball"
;;
esac
case "${this_script}" in
*fstab*) # Check if we have a real /etc/fstab file
if [[ -n "$FSTAB" ]] ; then
CHROOT_wrt_CopyFstab
else
CHROOT_wrt_RunAsRoot "$file"
fi
;;
*) # All other scripts
CHROOT_wrt_RunAsRoot "${file}"
;;
esac
# Remove the build directory except if the package build fails.
case "${this_script}" in
*bootscripts*)
(
cat << EOF
@ROOT=\`head -n1 \$(SRC)/\$(PKG_LST) | sed 's@^./@@;s@/.*@@'\` && \\
rm -r \$(SRC)/\$\$ROOT
@rm -rf \`cat sources-dir\` && \\
rm sources-dir
EOF
) >> $MKFILE.tmp
if [ "${INSTALL_LOG}" = "y" ] ; then
CHROOT_wrt_LogNewFiles "$name"
fi
;;
*kernel) CHROOT_wrt_RemoveBuildDirs "dummy"
if [ "${INSTALL_LOG}" = "y" ] ; then
CHROOT_wrt_LogNewFiles "$name"
fi ;;
esac
# Include a touch of the target name so make can check if it's already been made.
wrt_touch
#
#--------------------------------------------------------------------#
# >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
#--------------------------------------------------------------------#
# Keep the script file name for Makefile dependencies.
PREV=$this_script
done # for file in chapter07/*
}
#----------------------------#
build_Makefile() { # Construct a Makefile from the book scripts
#----------------------------#
echo "Creating Makefile... ${BOLD}START${OFF}"
cd $JHALFSDIR/${PROGNAME}-commands
# Start with a clean Makefile.tmp file
>$MKFILE.tmp
chapter3_Makefiles
chapter5_Makefiles
chapter6_Makefiles
# Add the iterations targets, if needed
[[ "$COMPARE" = "y" ]] && wrt_compare_targets
chapter7_Makefiles
# Add the CUSTOM_TOOLS targets, if needed
[[ "$CUSTOM_TOOLS" = "y" ]] && wrt_CustomTools_target
# Add the BLFS_TOOL targets, if needed
[[ "$BLFS_TOOL" = "y" ]] && wrt_blfs_tool_targets
# Add a header, some variables and include the function file
# to the top of the real Makefile.
wrt_Makefile_header
# Add chroot commands
CHROOT_LOC="`whereis -b chroot | cut -d " " -f2`"
i=1
for file in chapter06/*chroot* ; do
chroot=`cat $file | \
sed -e "s@chroot@$CHROOT_LOC@" \
-e '/#!\/bin\/bash/d' \
-e '/^export/d' \
-e '/^logout/d' \
-e 's@ \\\@ @g' | \
tr -d '\n' | \
sed -e 's/ */ /g' \
-e 's|\\$|&&|g' \
-e 's|exit||g' \
-e 's|$| -c|' \
-e 's|"$$HLFS"|$(MOUNT_PT)|'\
-e 's|set -e||' \
-e 's|set +h||'`
echo -e "CHROOT$i= $chroot\n" >> $MKFILE
i=`expr $i + 1`
done
# Drop in the main target 'all:' and the chapter targets with each sub-target
# as a dependency.
(
cat << EOF
all: ck_UID mk_SETUP mk_LUSER mk_SUDO mk_CHROOT mk_BOOT create-sbu_du-report mk_CUSTOM_TOOLS mk_BLFS_TOOL
@sudo make do-housekeeping
@echo "$VERSION - jhalfs build" > hlfs-release && \\
sudo install -m444 hlfs-release \$(MOUNT_PT)/etc/hlfs-release
@\$(call echo_finished,$VERSION)
ck_UID:
@if [ \`id -u\` = "0" ]; then \\
echo "--------------------------------------------------"; \\
echo "You cannot run this makefile from the root account"; \\
echo "--------------------------------------------------"; \\
exit 1; \\
fi
mk_SETUP:
@\$(call echo_SU_request)
@sudo make BREAKPOINT=\$(BREAKPOINT) SETUP
@touch \$@
mk_LUSER: mk_SETUP
@\$(call echo_SULUSER_request)
@(sudo \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) LUSER" )
@sudo make restore-luser-env
@touch \$@
mk_SUDO: mk_LUSER
@sudo make SUDO
@touch \$@
mk_CHROOT: mk_SUDO
@if [ ! -e \$(MOUNT_PT)/dev ]; then \\
mkdir \$(MOUNT_PT)/dev && \\
sudo mknod -m 666 \$(MOUNT_PT)/dev/null c 1 3 && \\
sudo mknod -m 600 \$(MOUNT_PT)/dev/console c 5 1 && \\
sudo chown -R 0:0 \$(MOUNT_PT)/dev; \\
fi;
@\$(call echo_CHROOT_request)
@( sudo \$(CHROOT1) "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) CHROOT")
@touch \$@
mk_BOOT: mk_CHROOT
@\$(call echo_CHROOT_request)
@( sudo \$(CHROOT2) "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) BOOT")
@touch \$@
mk_CUSTOM_TOOLS: create-sbu_du-report
@if [ "\$(ADD_CUSTOM_TOOLS)" = "y" ]; then \\
\$(call sh_echo_PHASE,Building CUSTOM_TOOLS); \\
sudo mkdir -p ${BUILDDIR}${TRACKING_DIR}; \\
(sudo \$(CHROOT2) "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) CUSTOM_TOOLS"); \\
fi;
@touch \$@
mk_BLFS_TOOL: mk_CUSTOM_TOOLS
@if [ "\$(ADD_BLFS_TOOLS)" = "y" ]; then \\
\$(call sh_echo_PHASE,Building BLFS_TOOL); \\
sudo mkdir -p $BUILDDIR$TRACKING_DIR; \\
(sudo \$(CHROOT2) "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) BLFS_TOOL"); \\
fi;
@touch \$@
SETUP: $chapter3
LUSER: $chapter5
SUDO: $runasroot
CHROOT: SHELL=/tools/bin/bash
CHROOT: $chapter6
BOOT: $chapter7
CUSTOM_TOOLS: $custom_list
BLFS_TOOL: $blfs_tool
create-sbu_du-report: mk_BOOT
@\$(call echo_message, Building)
@if [ "\$(ADD_REPORT)" = "y" ]; then \\
./create-sbu_du-report.sh logs $VERSION; \\
\$(call echo_report,$VERSION-SBU_DU-$(date --iso-8601).report); \\
fi;
@touch \$@
restore-luser-env:
@\$(call echo_message, Building)
@if [ -f \$(LUSER_HOME)/.bashrc.XXX ]; then \\
mv -f \$(LUSER_HOME)/.bashrc.XXX \$(LUSER_HOME)/.bashrc; \\
fi;
@if [ -f \$(LUSER_HOME)/.bash_profile.XXX ]; then \\
mv \$(LUSER_HOME)/.bash_profile.XXX \$(LUSER_HOME)/.bash_profile; \\
fi;
@chown \$(LUSER):\$(LGROUP) \$(LUSER_HOME)/.bash* && \\
touch \$@ && \\
echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
echo --------------------------------------------------------------------------------\$(WHITE)
do-housekeeping:
@-umount \$(MOUNT_PT)/dev/pts
@-umount \$(MOUNT_PT)/dev/shm
@-umount \$(MOUNT_PT)/dev
@-umount \$(MOUNT_PT)/sys
@-umount \$(MOUNT_PT)/proc
@-rm /tools
@-if [ ! -f luser-exist ]; then \\
userdel \$(LUSER); \\
rm -rf \$(LUSER_HOME); \\
fi;
EOF
) >> $MKFILE
# Bring over the items from the Makefile.tmp
cat $MKFILE.tmp >> $MKFILE
rm $MKFILE.tmp
echo "Creating Makefile... ${BOLD}DONE${OFF}"
}

File diff suppressed because it is too large Load diff

View file

@ -1,211 +1,106 @@
#!/bin/bash
###################################
### FUNCTIONS ###
###################################
# $Id$
#########################################
### LFS MAKEFILE GENERATION FUNCTIONS ###
#########################################
#############################################################
#----------------------------#
chapter4_Makefiles() { #
#----------------------------#
echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter4 ( SETUP ) ${R_arrow}"
# If $LUSER_HOME is already present in the host, we asume that the
# lfs user and group are also presents in the host, and a backup
# of their bash init files is made.
(
cat << EOF
04_02-creatingtoolsdir:
@\$(call echo_message, Building)
@mkdir \$(MOUNT_PT)/tools && \\
rm -f /tools && \\
ln -s \$(MOUNT_PT)/tools /
@\$(call housekeeping)
04_03-addinguser: 04_02-creatingtoolsdir
@\$(call echo_message, Building)
@if [ ! -d \$(LUSER_HOME) ]; then \\
groupadd \$(LGROUP); \\
useradd -s /bin/bash -g \$(LGROUP) -m -k /dev/null \$(LUSER); \\
else \\
touch luser-exist; \\
fi;
@chown \$(LUSER) \$(MOUNT_PT)/tools && \\
chmod -R a+wt \$(MOUNT_PT)/\$(SCRIPT_ROOT) && \\
chmod a+wt \$(SRCSDIR)
@\$(call housekeeping)
04_04-settingenvironment: 04_03-addinguser
@\$(call echo_message, Building)
@if [ -f \$(LUSER_HOME)/.bashrc -a ! -f \$(LUSER_HOME)/.bashrc.XXX ]; then \\
mv \$(LUSER_HOME)/.bashrc \$(LUSER_HOME)/.bashrc.XXX; \\
fi;
@if [ -f \$(LUSER_HOME)/.bash_profile -a ! -f \$(LUSER_HOME)/.bash_profile.XXX ]; then \\
mv \$(LUSER_HOME)/.bash_profile \$(LUSER_HOME)/.bash_profile.XXX; \\
fi;
@echo "set +h" > \$(LUSER_HOME)/.bashrc && \\
echo "umask 022" >> \$(LUSER_HOME)/.bashrc && \\
echo "LFS=\$(MOUNT_PT)" >> \$(LUSER_HOME)/.bashrc && \\
echo "LC_ALL=POSIX" >> \$(LUSER_HOME)/.bashrc && \\
echo "PATH=/tools/bin:/bin:/usr/bin" >> \$(LUSER_HOME)/.bashrc && \\
echo "export LFS LC_ALL PATH" >> \$(LUSER_HOME)/.bashrc && \\
chown \$(LUSER):\$(LGROUP) \$(LUSER_HOME)/.bashrc
@\$(call housekeeping)
EOF
) > $MKFILE.tmp
chapter4=" 04_02-creatingtoolsdir 04_03-addinguser 04_04-settingenvironment"
PREV=04_04-settingenvironment
}
#-------------------------#
chapter_targets() { #
#-------------------------#
# $1 is the chapter number. Pad it with 0 to the left to obtain a 2-digit
# number:
printf -v dir chapter%02d $1
#----------------------------#
chapter5_Makefiles() { #
#----------------------------#
echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter5 ( LUSER ) ${R_arrow}"
# $2 contains the build number if rebuilding for ICA
if [[ -z "$2" ]] ; then
local N=""
else
local N=-build_$2
local CHROOT_TGT=""
mkdir ${dir}$N
cp ${dir}/* ${dir}$N
for script in ${dir}$N/* ; do
# Overwrite existing symlinks, files, and dirs
sed -e 's/ln *-sv/&f/g' \
-e 's/mv *-v/&f/g' \
-e 's/mkdir *-v/&p/g' -i ${script}
# Rename the scripts
mv ${script} ${script}$N
done
# Remove Bzip2 binaries before make install (LFS-6.2 compatibility)
sed -e 's@make install@rm -vf /usr/bin/bz*\n&@' -i ${dir}$N/*-bzip2$N
# Remove openssl-<version> from /usr/share/doc (LFS-9.x), because
# otherwise the mv command creates an openssl directory.
sed -e 's@mv -v@rm -rfv /usr/share/doc/openssl-*\n&@' \
-i ${dir}$N/*-openssl$N
fi
echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter $1$N${R_arrow}"
for file in ${dir}$N/* ; do
for file in chapter05/* ; do
# Keep the script file name
this_script=`basename $file`
# Some scripts need peculiar actions:
# - Stripping at the end of system build: lfs.xsl does not generate
# correct commands if the user does not want to strip, so skip it
# in this case
# - do not reinstall linux-headers when rebuilding
# - grub config: must be done manually; skip it
# - handle fstab and .config. Skip kernel if .config not supplied
# If no testsuites will be run, then TCL, Expect and DejaGNU aren't needed
case "${this_script}" in
*stripping*) [[ "${STRIP}" = "n" ]] && continue ;;
*linux-headers*) [[ -n "$N" ]] && continue ;;
8*grub) (( nb_chaps == 5 )) && continue ;;
10*grub) continue ;;
*fstab) [[ -z "${FSTAB}" ]] ||
[[ ${FSTAB} == $BUILDDIR/sources/fstab ]] ||
cp ${FSTAB} $BUILDDIR/sources/fstab ;;
*kernel) [[ -z ${CONFIG} ]] && continue
[[ ${CONFIG} == $BUILDDIR/sources/kernel-config ]] ||
cp ${CONFIG} $BUILDDIR/sources/kernel-config ;;
*tcl) [[ "${TEST}" = "0" ]] && continue ;;
*expect) [[ "${TEST}" = "0" ]] && continue ;;
*dejagnu) [[ "${TEST}" = "0" ]] && continue ;;
*stripping) [[ "${STRIP}" = "n" ]] && continue ;;
esac
# Grab the name of the target
# This is only used to check the name in "opt_override" or "BLACKLIST"
name=`echo ${this_script} | sed -e 's@[0-9]\{3,4\}-@@' \
-e 's@-pass[0-9]\{1\}@@' \
-e 's@-libstdc++@@' \
-e 's,'$N',,' \
-e 's@-32@@'`
# Find the name of the tarball and the version of the package
# If it doesn't exist, we skip it in iterations rebuilds (except stripping
# and revisedchroot, where .a and .la files are removed).
pkg_tarball=$(sed -n 's/tar -xf \(.*\)/\1/p' $file)
pkg_version=$(sed -n 's/VERSION=\(.*\)/\1/p' $file)
if [[ "$pkg_tarball" = "" ]] && [[ -n "$N" ]] ; then
case "${this_script}" in
*stripping*|*cleanup*|*revised*) ;;
*) continue ;;
esac
fi
# Append the name of the script to a list. The name of the
# list is contained in the variable Makefile_target. We adjust this
# variable at various points. Note that it is initialized to "SETUP"
# in the main function, before calling this function for the first time.
# Append the script name to the chapter dependencies list
# The changingowner script need be run as root into the SUDO target
case "${this_script}" in
*settingenvironment) Makefile_target=LUSER_TGT ;;
*changingowner ) Makefile_target=SUDO_TGT ;;
*creatingdirs ) Makefile_target=CHROOT_TGT ;;
*bootscripts ) Makefile_target=BOOT_TGT ;; # case of sysv book
*network ) Makefile_target=BOOT_TGT ;; # case of systemd book
*changingowner) runasroot="$runasroot ${this_script}" ;;
*) chapter5="$chapter5 ${this_script}" ;;
esac
eval $Makefile_target=\"\$$Makefile_target ${this_script}\"
#--------------------------------------------------------------------#
# >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
#--------------------------------------------------------------------#
#
# Drop in the name of the target on a new line, and the previous target
# as a dependency. Also call the echo_message function.
case $Makefile_target in
CHROOT_TGT) CHROOT_wrt_target "${this_script}" "$PREV" "$pkg_version" ;;
*) LUSER_wrt_target "${this_script}" "$PREV" "$pkg_version" ;;
esac
wrt_target "${this_script}" "$PREV"
# If $pkg_tarball isn't empty, we've got a package...
if [ "$pkg_tarball" != "" ] ; then
# Touch timestamp file if installed files logs shall be created.
# But only for the final install chapter and not when rebuilding it
if [ "${INSTALL_LOG}" = "y" ] &&
(( 1+nb_chaps <= $1 )) &&
[ "x$N" = x ] ; then
CHROOT_wrt_TouchTimestamp
fi
# Always initialize the test log file, since the test instructions may
# be "uncommented" by the user
case $Makefile_target in
CHROOT_TGT) CHROOT_wrt_test_log "${this_script}" "$pkg_version" ;;
LUSER_TGT ) LUSER_wrt_test_log "${this_script}" "$pkg_version" ;;
esac
# If using optimizations, write the instructions
case "${OPTIMIZE}$1${nb_chaps}${this_script}${REALSBU}" in
0* | *binutils-pass1y | 15* | 167* | 177*) ;;
*kernel*) ;; # No CFLAGS for kernel
*) wrt_optimize "$name" ;;
esac
# There is no need to tweak MAKEFLAGS anymore, this is done
# by lfs.xsl. But still, NINJAJOBS needs to be set if
# N_PARALLEL is defined.
if [ -n "N_PARALLEL" ]; then
wrt_makeflags "$name" "$JH_MAKEFLAGS" "$N_PARALLEL"
fi
fi # end of package specific instructions
# Some scriptlet have a special treatment; otherwise standard
# Run the script.
# The changingowner script must be run as root.
case "${this_script}" in
*addinguser)
(
# /var/lib may already exist and be owned by root if blfs tools
# have been installed.
cat << EOF
@if [ -f luser-id ]; then \\
function useradd() { true; }; \\
function groupadd() { true; }; \\
export -f useradd groupadd; \\
fi; \\
export LFS=\$(MOUNT_PT) && \\
\$(CMDSDIR)/`dirname $file`/\$@ >> \$(LOGDIR)/\$@ 2>&1; \\
\$(PRT_DU) >>logs/\$@
@chown \$(LUSER):\$(LGROUP) envars
@if [ -d "\$(MOUNT_PT)/var/lib" ]; then \\
chown \$(LUSER):\$(LGROUP) \$(MOUNT_PT)/var/lib; \\
fi
@chmod -R a+wt $JHALFSDIR
@chmod a+wt \$(SRCSDIR)
EOF
) >> $MKFILE.tmp
;;
*settingenvironment)
(
cat << EOF
@cd && \\
function source() { true; } && \\
export -f source && \\
\$(CMDSDIR)/`dirname $file`/\$@ >> \$(LOGDIR)/\$@ 2>&1 && \\
sed 's|/mnt/lfs|\$(MOUNT_PT)|' -i .bashrc && \\
echo source $JHALFSDIR/envars >> .bashrc
@\$(PRT_DU) >>logs/\$@
EOF
) >> $MKFILE.tmp
;;
*fstab) if [[ -n "$FSTAB" ]]; then
CHROOT_wrt_CopyFstab
else
CHROOT_wrt_RunAsRoot "$file"
fi
;;
*)
# Insert date and disk usage at the top of the log file, the script
# run and date and disk usage again at the bottom of the log file.
case "${Makefile_target}" in
SETUP_TGT | SUDO_TGT) wrt_RunAsRoot "$file" "$pkg_version" ;;
LUSER_TGT) LUSER_wrt_RunAsUser "$file" "$pkg_version" ;;
CHROOT_TGT | BOOT_TGT) CHROOT_wrt_RunAsRoot "$file" "$pkg_version" ;;
esac
;;
*changingowner) wrt_RunAsRoot "$file" ;;
*) wrt_RunScript "$file" ;;
esac
# Write installed files log and remove the build directory(ies)
# except if the package build fails.
if [ "$pkg_tarball" != "" ] ; then
if [ "${INSTALL_LOG}" = "y" ] &&
(( 1+nb_chaps <= $1 )) &&
[ "x${N}" = "x" ] ; then
CHROOT_wrt_LogNewFiles "${this_script}"
fi
fi
# Include a touch of the target name so make can check
# if it's already been made.
# Write the target entry footer.
wrt_touch
#
#--------------------------------------------------------------------#
@ -214,61 +109,193 @@ EOF
# Keep the script file name for Makefile dependencies.
PREV=${this_script}
# Set "system_build" var for iteration targets
if [ -z "$N" ] && (( 1+nb_chaps == $1 )); then
system_build="$system_build $this_script"
done # end for file in chapter05/*
}
#----------------------------#
chapter6_Makefiles() { #
#----------------------------#
# Set envars and scripts for iteration targets
if [[ -z "$1" ]] ; then
local N=""
else
local N=-build_$1
local chapter6=""
mkdir chapter06$N
cp chapter06/* chapter06$N
for script in chapter06$N/* ; do
# Overwrite existing symlinks, files, and dirs
sed -e 's/ln -sv/&f/g' \
-e 's/mv -v/&f/g' \
-e 's/mkdir -v/&p/g' -i ${script}
# Rename the scripts
mv ${script} ${script}$N
done
fi
echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter6$N ( CHROOT ) ${R_arrow}"
for file in chapter06$N/* ; do
# Keep the script file name
this_script=`basename $file`
# Chroot commands are set as envars in the Makefile header.
# Skip linux-headers in iterative builds.
case "${this_script}" in
*chroot) continue ;;
*stripping*) [[ "${STRIP}" = "n" ]] && continue ;;
*linux-headers*) [[ -n "$N" ]] && continue ;;
esac
# If building a package, grab the phase name to be used with INSTALL_LOG
name=`grep "^PKG_PHASE=" ${file} | sed -e 's@PKG_PHASE=@@'`
# Skip scripts not needed for iterations rebuilds
if [[ "$name" = "" ]] && [[ -n "$N" ]] ; then
case "${this_script}" in
*stripping*) ;;
*) continue ;;
esac
fi
done # end for file in $dir/*
# Set "system_build" when rebuilding: note the CHROOT_TGT is local
# in that case.
if [ -n "$N" ]; then
system_build="$CHROOT_TGT"
fi
# Append the script name to the chapter dependencies list
# The kernfs script need be run as root into the SUDO target
case "${this_script}" in
*kernfs) runasroot="$runasroot ${this_script}" ;;
*) chapter6="$chapter6 ${this_script}" ;;
esac
#--------------------------------------------------------------------#
# >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
#--------------------------------------------------------------------#
#
# Drop in the name of the target on a new line, and the previous target
# as a dependency. Also call the echo_message function.
wrt_target "${this_script}" "$PREV"
# Touch timestamp file if installed files logs will be created.
# But only for the firt build when running iterative builds.
if [ "$name" != "" ] && [ "${INSTALL_LOG}" = "y" ] && [ "x${N}" = "x" ] ; then
wrt_TouchTimestamp
fi
# Run the script.
# The kernfs script must be run as root.
case "${this_script}" in
*kernfs) wrt_RunAsRoot "$file" ;;
*) wrt_RunScript "$file" ;;
esac
# Write installed files log
if [ "$name" != "" ] && [ "${INSTALL_LOG}" = "y" ] && [ "x${N}" = "x" ] ; then
wrt_LogNewFiles "$name"
fi
# Write the target entry footer.
wrt_touch
#
#--------------------------------------------------------------------#
# >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
#--------------------------------------------------------------------#
# Keep the script file name for Makefile dependencies.
PREV=${this_script}
# Set system_build envar for iteration targets
system_build=$chapter6
done # end for file in chapter06/*
}
#----------------------------#
chapter78_Makefiles() { #
#----------------------------#
echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter7/8 ( BOOT ) ${R_arrow}"
for file in chapter0{7,8}/* ; do
# Keep the script file name
this_script=`basename $file`
# Grub must be configured manually.
# Handle fstab creation.
# If no .config file is supplied, the kernel build is skipped
case ${this_script} in
*grub) continue ;;
*fstab) [[ -n "${FSTAB}" ]] && cp ${FSTAB} $BUILDDIR/sources/fstab ;;
*kernel) [[ -z "${CONFIG}" ]] && continue
cp ${CONFIG} $BUILDDIR/sources/kernel-config ;;
esac
# If building a package, grab the phase name to be used with INSTALL_LOG
name=`grep "^PKG_PHASE=" ${file} | sed -e 's@PKG_PHASE=@@'`
# Append the script name to the chapter dependencies list
chapter78="$chapter78 ${this_script}"
#--------------------------------------------------------------------#
# >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
#--------------------------------------------------------------------#
#
# Drop in the name of the target on a new line, and the previous target
# as a dependency. Also call the echo_message function.
wrt_target "${this_script}" "$PREV"
# Touch timestamp file if installed files logs will be created.
if [ "$name" != "" ] && [ "${INSTALL_LOG}" = "y" ] ; then
wrt_TouchTimestamp
fi
# Check if we have a real /etc/fstab file and run the scripts
case "${this_script}" in
*fstab) if [[ -n $FSTAB ]]; then
wrt_CopyFstab
else
wrt_RunScript "$file"
fi ;;
*) wrt_RunScript "$file" ;;
esac
# Write installed files log
if [ "$name" != "" ] && [ "${INSTALL_LOG}" = "y" ] ; then
wrt_LogNewFiles "$name"
fi
# Write the target entry footer.
wrt_touch
#
#--------------------------------------------------------------------#
# >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
#--------------------------------------------------------------------#
# Keep the script file name for Makefile dependencies.
PREV=${this_script}
done # for file in chapter0{7,8}/*
}
#----------------------------#
build_Makefile() { #
#----------------------------#
echo "Creating Makefile... ${BOLD}START${OFF}"
cd "$JHALFSDIR/$COMMANDS"
cd $JHALFSDIR/${PROGNAME}-commands
# Start with empty files
# Start with a clean Makefile.tmp file
>$MKFILE
>$MKFILE.tmp
# Ensure the first dependency is empty
unset PREV
# We begin with the SETUP target; successive targets will be assigned in
# the chapter_targets function.
Makefile_target=SETUP_TGT
# We need to know the chapter numbering, which depends on the version
# of the book. Use the number of subdirs to know which version we have
chaps=($(echo chapter*))
nb_chaps=${#chaps[*]} # 5 if classical version, 7 if new version
# DEBUG
# echo chaps: ${chaps[*]}
# echo nb_chaps: $nb_chaps
# end DEBUG
# Make a temporary file with all script targets
for (( i = 4; i < nb_chaps+4; i++ )); do
chapter_targets $i
if (( i == nb_chaps )); then : # we have finished temporary tools
# Add the save target, if needed
[[ "$SAVE_CH5" = "y" ]] && wrt_save_target $Makefile_target
fi
if (( i == 1+nb_chaps )); then : # we have finished final system
# Add the iterations targets, if needed
[[ "$COMPARE" = "y" ]] && wrt_compare_targets $i
fi
done
chapter4_Makefiles
chapter5_Makefiles
chapter6_Makefiles
# Add the iterations targets, if needed
[[ "$COMPARE" = "y" ]] && wrt_compare_targets
chapter78_Makefiles
# Add the CUSTOM_TOOLS targets, if needed
[[ "$CUSTOM_TOOLS" = "y" ]] && wrt_CustomTools_target
# Add the BLFS_TOOL targets, if needed
[[ "$BLFS_TOOL" = "y" ]] && wrt_blfs_tool_targets
# Add a header, some variables and include the function file
# to the top of the real Makefile.
@ -277,74 +304,27 @@ build_Makefile() { #
# Add chroot commands
CHROOT_LOC="`whereis -b chroot | cut -d " " -f2`"
i=1
for file in ../chroot-scripts/*chroot* ; do
chroot=`cat $file | \
perl -pe 's|\\\\\n||g' | \
tr -s [:space:] | \
grep chroot | \
sed -e "s|chroot|$CHROOT_LOC|" \
for file in chapter06/*chroot* ; do
chroot=`cat $file | tr -d '\n' | \
sed -e "s@chroot@$CHROOT_LOC@" \
-e 's@ \\\@ @g' \
-e 's/ */ /g' \
-e 's|\\$|&&|g' \
-e 's|"$$LFS"|$(MOUNT_PT)|'`
-e 's|"$$LFS"|$(MOUNT_PT)|' \
-e 's|$| -c|'`
echo -e "CHROOT$i= $chroot\n" >> $MKFILE
i=`expr $i + 1`
done
# If CPUSET is defined and not equal to "all", then we define a first target
# that calls a script which re-enters make calling target all
if [ -n "$CPUSET" ] && [ "$CPUSET" != all ]; then
(
cat << EOF
all-with-cpuset:
@CPUSPEC="\$(CPUSET)" ./run-in-cgroup.sh \$(MAKE) all
EOF
) >> $MKFILE
fi
# Drop in the main target 'all:' and the chapter targets with each sub-target
# as a dependency. Also prevent running targets in parallel.
# as a dependency.
(
cat << EOF
.NOTPARALLEL:
all: ck_UID ck_terminal mk_SETUP mk_LUSER mk_SUDO mk_CHROOT mk_BOOT create-sbu_du-report mk_BLFS_TOOL mk_CUSTOM_TOOLS
@sudo env LFS=\$(MOUNT_PT) kernfs-scripts/teardown.sh
EOF
) >> $MKFILE
# With systemd, the commands in chapter 9 do not create a
# valid /etc/resolv.conf, so that if blfs_tools are installed, and
# make-ca is run, it cannot connect. In this case, resolv.conf
# from the host has been copied, and we need to remove it now.
if [ "$INITSYS" = systemd ]; then
(
cat << EOF
@sudo rm -v \$(MOUNT_PT)/etc/resolv.conf
EOF
) >> $MKFILE
fi
(
cat << EOF
all: ck_UID mk_SETUP mk_LUSER mk_SUDO mk_CHROOT mk_BOOT create-sbu_du-report mk_CUSTOM_TOOLS mk_BLFS_TOOL
@sudo make do_housekeeping
@echo $VERSION > lfs-release && \\
sudo mv lfs-release \$(MOUNT_PT)/etc && \\
sudo chown root:root \$(MOUNT_PT)/etc/lfs-release
@/bin/echo -e -n \\
DISTRIB_ID=\\"Linux From Scratch\\"\\\\n\\
DISTRIB_RELEASE=\\"$VERSION\\"\\\\n\\
DISTRIB_CODENAME=\\"$(whoami)-jhalfs\\"\\\\n\\
DISTRIB_DESCRIPTION=\\"Linux From Scratch\\"\\\\n\\
> lsb-release && \\
sudo mv lsb-release \$(MOUNT_PT)/etc && \\
sudo chown root:root \$(MOUNT_PT)/etc/lsb-release
@/bin/echo -e -n \\
NAME=\\"Linux From Scratch\\"\\\\n\\
VERSION=\\"$VERSION\\"\\\\n\\
ID=lfs\\\\n\\
PRETTY_NAME=\\"Linux From Scratch $VERSION\\"\\\\n\\
VERSION_CODENAME=\\"$(whoami)-jhalfs\\"\\\\n\\
> os-release && \\
sudo mv os-release \$(MOUNT_PT)/etc && \\
sudo chown root:root \$(MOUNT_PT)/etc/os-release
@echo "$VERSION - jhalfs build" > lfs-release && \\
sudo mv lfs-release \$(MOUNT_PT)/etc
@\$(call echo_finished,$VERSION)
ck_UID:
@ -355,174 +335,89 @@ ck_UID:
exit 1; \\
fi
ck_terminal:
@stty size | ( read L C; \\
if (( L < 24 )) || (( C < 80 )) ; then \\
echo "--------------------------------------------------"; \\
echo "Terminal too small: \$\$C columns x \$\$L lines";\\
echo "Minimum: 80 columns x 24 lines";\\
echo "--------------------------------------------------"; \\
exit 1; \\
fi )
mk_SETUP:
@\$(call echo_SU_request)
@sudo make save-luser
@sudo make BREAKPOINT=\$(BREAKPOINT) SETUP
@touch \$@
mk_LUSER: mk_SETUP
@\$(call echo_SULUSER_request)
@\$(SU_LUSER) "make -C \$(MOUNT_PT)/\$(SCRIPT_ROOT) BREAKPOINT=\$(BREAKPOINT) LUSER"
@sudo make restore-luser
@( sudo \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) LUSER" )
@sudo make restore-luser-env
@touch \$@
mk_SUDO: mk_LUSER
@sudo rm -f envars
@sudo make BREAKPOINT=\$(BREAKPOINT) SUDO
@touch \$@
mk_CHROOT: mk_SUDO devices
mk_CHROOT: mk_SUDO
@\$(call echo_CHROOT_request)
@( sudo \$(CHROOT1) -c "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) CHROOT")
@( sudo \$(CHROOT1) "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) CHROOT")
@touch \$@
mk_BOOT: mk_CHROOT devices
mk_BOOT: mk_CHROOT
@\$(call echo_CHROOT_request)
@( sudo \$(CHROOT1) -c "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) BOOT")
@( sudo \$(CHROOT2) "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) BOOT")
@touch \$@
mk_BLFS_TOOL: create-sbu_du-report devices
@if [ "\$(ADD_BLFS_TOOLS)" = "y" ]; then \\
\$(call sh_echo_PHASE,Building BLFS_TOOL); \\
(sudo \$(CHROOT1) -c "make -C $BLFS_ROOT/work"); \\
fi;
@touch \$@
mk_CUSTOM_TOOLS: mk_BLFS_TOOL devices
mk_CUSTOM_TOOLS: create-sbu_du-report
@if [ "\$(ADD_CUSTOM_TOOLS)" = "y" ]; then \\
\$(call sh_echo_PHASE,Building CUSTOM_TOOLS); \\
sudo mkdir -p ${BUILDDIR}${TRACKING_DIR}; \\
(sudo \$(CHROOT1) -c "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) CUSTOM_TOOLS"); \\
(sudo \$(CHROOT2) "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) CUSTOM_TOOLS"); \\
fi;
@touch \$@
devices: ck_UID
sudo env LFS=\$(MOUNT_PT) kernfs-scripts/devices.sh
EOF
) >> $MKFILE
# With systemd, the commands in chapter 9 do not create a
# valid /etc/resolv.conf, so that if we want to enter chroot,
# and systemd has not yet been run (otherwise /etc/resolv.conf
# exists), we just copy resolv.conf from the host.
if [ "$INITSYS" = systemd ]; then
(
cat << EOF
if ! [ -e \$(MOUNT_PT)/etc/resolv.conf ]; then \\
sudo cp -v /etc/resolv.conf \$(MOUNT_PT)/etc; \\
sudo touch \$(MOUNT_PT)/etc/.host-resolvconf; \\
fi
EOF
) >> $MKFILE
fi
(
cat << EOF
mk_BLFS_TOOL: mk_CUSTOM_TOOLS
@if [ "\$(ADD_BLFS_TOOLS)" = "y" ]; then \\
\$(call sh_echo_PHASE,Building BLFS_TOOL); \\
sudo mkdir -p $BUILDDIR$TRACKING_DIR; \\
(sudo \$(CHROOT2) "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) BLFS_TOOL"); \\
fi;
@touch \$@
teardown:
sudo env LFS=\$(MOUNT_PT) kernfs-scripts/teardown.sh
EOF
) >> $MKFILE
# With systemd, the commands in chapter 9 do not create a
# valid /etc/resolv.conf, so that if we want to enter chroot,
# and systemd has not yet been run (otherwise /etc/resolv.conf
# exists), we just copy resolv.conf from the host.
# We need to remove it now, if it has been created.
if [ "$INITSYS" = systemd ]; then
(
cat << EOF
if [ -e \$(MOUNT_PT)/etc/.host-resolvconf ]; then \\
sudo rm -v \$(MOUNT_PT)/etc/resolv.conf; \\
sudo rm -v \$(MOUNT_PT)/etc/.host-resolvconf; \\
fi
EOF
) >> $MKFILE
fi
(
cat << EOF
chroot1: devices
-sudo \$(CHROOT1)
\$(MAKE) teardown
chroot: devices
-sudo \$(CHROOT1)
\$(MAKE) teardown
SETUP: $SETUP_TGT
LUSER: $LUSER_TGT
SUDO: $SUDO_TGT
EOF
) >> $MKFILE
# With systemd, the commands in chapter 9 do not create a
# valid /etc/resolv.conf, so that if blfs_tools are installed, and
# make-ca is run, it cannot connect. We just copy resolv.conf
# from the host. We'll remove it at the end.
if [ "$INITSYS" = systemd ]; then
(
cat << EOF
@cp -v /etc/resolv.conf \$(MOUNT_PT)/etc
EOF
) >> $MKFILE
fi
(
cat << EOF
CHROOT: SHELL=\$(filter %bash,\$(CHROOT1))
CHROOT: $CHROOT_TGT
BOOT: $BOOT_TGT
SETUP: $chapter4
LUSER: $chapter5
SUDO: $runasroot
CHROOT: SHELL=/tools/bin/bash
CHROOT: $chapter6
BOOT: $chapter78
CUSTOM_TOOLS: $custom_list
BLFS_TOOL: $blfs_tool
create-sbu_du-report: mk_BOOT
@\$(call echo_message, Building)
@if [ "\$(ADD_REPORT)" = "y" ]; then \\
sudo ./create-sbu_du-report.sh logs $VERSION $(date --iso-8601); \\
./create-sbu_du-report.sh logs $VERSION; \\
\$(call echo_report,$VERSION-SBU_DU-$(date --iso-8601).report); \\
fi
fi;
@touch \$@
save-luser:
restore-luser-env:
@\$(call echo_message, Building)
@LUSER_ID=\$\$(grep '^\$(LUSER):' /etc/passwd | cut -d: -f3); \\
if [ -n "\$\$LUSER_ID" ]; then \\
if [ ! -d \$(LUSER_HOME).XXX ]; then \\
mv \$(LUSER_HOME){,.XXX}; \\
mkdir \$(LUSER_HOME); \\
chown \$(LUSER):\$(LGROUP) \$(LUSER_HOME); \\
fi; \\
echo "\$\$LUSER_ID" > luser-id; \\
echo User \$(LUSER) exists with ID \$\$LUSER_ID; \\
else \\
rm -f luser-id; \\
echo User \$(LUSER) does not exist; \\
echo It will be created with book instructions.; \\
fi
@\$(call housekeeping)
restore-luser:
@\$(call echo_message, Building)
@if [ -f luser-id ]; then \\
rm -rf \$(LUSER_HOME); \\
mv \$(LUSER_HOME){.XXX,}; \\
rm luser-id; \\
else \\
userdel \$(LUSER); \\
groupdel \$(LGROUP); \\
rm -rf \$(LUSER_HOME); \\
fi
@if [ -f \$(LUSER_HOME)/.bashrc.XXX ]; then \\
mv -f \$(LUSER_HOME)/.bashrc.XXX \$(LUSER_HOME)/.bashrc; \\
fi;
@if [ -f \$(LUSER_HOME)/.bash_profile.XXX ]; then \\
mv \$(LUSER_HOME)/.bash_profile.XXX \$(LUSER_HOME)/.bash_profile; \\
fi;
@chown \$(LUSER):\$(LGROUP) \$(LUSER_HOME)/.bash*
@\$(call housekeeping)
do_housekeeping:
@-rm -f /tools
@-umount \$(MOUNT_PT)/sys
@-umount \$(MOUNT_PT)/proc
@-umount \$(MOUNT_PT)/dev/shm
@-umount \$(MOUNT_PT)/dev/pts
@-umount \$(MOUNT_PT)/dev
@-rm /tools
@-if [ ! -f luser-exist ]; then \\
userdel \$(LUSER); \\
rm -rf \$(LUSER_HOME); \\
fi;
EOF
) >> $MKFILE

353
LICENSE
View file

@ -1,19 +1,340 @@
Copyright (C) 2005-2019, jhalfs team
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
Preamble
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.

View file

@ -1,23 +1,35 @@
# From the Build Scripts Written By: Jim Gifford <lfs@jg555.com>
# Modified By: Joe Ciccone <jciccone@linuxfromscratch.org
# Additional changes: George Boudreau <georgeb@linuxfromscratch.org>
# Manuel Canales Esparcia
# Pierre Labastie
TOPDIR=$(shell pwd)
CONFIG_CONFIG_IN = Config.in
CONFIG = menu
all: menuconfig
@$$(grep RUN_ME configuration 2>/dev/null | sed -e 's@RUN_ME=\"@@' -e 's@\"@@')
# @clear
@`grep RUN_ME configuration | sed -e 's@RUN_ME=\"@@' -e 's@\"@@' `
menuconfig:
@cp -a configuration configuration.old 2>/dev/null || true
@CONFIG_="" KCONFIG_CONFIG=configuration \
python3 $(CONFIG)/menuconfig.py $(CONFIG_CONFIG_IN)
$(CONFIG)/conf:
$(MAKE) -C $(CONFIG) conf
$(CONFIG)/mconf:
$(MAKE) -C $(CONFIG) ncurses conf mconf
menuconfig: $(CONFIG)/mconf
@$(CONFIG)/mconf $(CONFIG_CONFIG_IN)
config: $(CONFIG)/conf
@$(CONFIG)/conf $(CONFIG_CONFIG_IN)
# Clean up
clean:
rm -f configuration configuration.old error
- $(MAKE) -C $(CONFIG) clean
.PHONY: all menuconfig clean
clean-target:
rm -f error
- $(MAKE) -C $(CONFIG) clean
.PHONY: all menuconfig config clean clean-target

460
README
View file

@ -1,371 +1,208 @@
$Id$
1. INTRODUCTION::
The scripts in this directory implement an automation of the building
of a GNU/LInux system, as described in the Linux From Scratch book series.
The name of the project is jhalfs: in that name, "alfs" stands for
"automated linux from scratch", and the initials "jh" have been kept since
the original "jhalfs-0.2" code developed by Jeremy Huntwork.
This collection of scripts, known as jhalfs, strives to create
accurate makefiles from the Linux From Scratch book series XML files.
This software is an evolution of the original "jhalfs-0.2" code developed
by Jeremy Huntwork.
The list of supported books can be found at
http://wiki.linuxfromscratch.org/alfs/wiki/SupportedBooks (maybe outdated,
current develoment books and latest version are always supported).
The usage of this script assumes you have read and are familiar with
the book(s) and, therefore, the configuration variables found in menuconfig
interface will have meaning to you.
The documentation is split among various README.* files. Here is a list
of what is in which:
- README (this file): instructions to use the LFS book. This should be
enough if you just want to build a base system as per the LFS book. It
is also a required reading for all the other projects.
- README.BLFS: instructions to install an automated build infrastructure
for the BLFS book. There are two ways to do so: (i) install the
tools at the end of an LFS build, or
(ii) install the tools on an already running system. Both methods are
described in that file.
- README.CUSTOM: instructions to run custom commands either during the LFS
build, or at the end of a LFS build. Note that you will not find
instructions on how to write those commands, but some examples are
available.
- README.PACKAGE_MANAGEMENT: instructions to use package management during
the build (Note: the only package manager that is regularly tested is
porg)
The list of supported books can be found at
http://wiki.linuxfromscratch.org/alfs/wiki/SupportedBooks
Other sources of information are the context help in the menu interface,
and the LFS books themselves (both required readings of course!).
NOTES::
*. The resulting Makefile takes considerable time to run to completion.
Lay in a supply of caffeine beverages.
*. It is recommended that you temporarily unpack your linux kernel,
run <make menuconfig>, configure the kernel as per the book and save
the resulting .config file. This suggestion also applies to the
configuration of the uClibc package when building a HLFS system using
uClibc rather than glibc.
*. Read carefully this file and the other README.* files before start
using the tool.
2. PREREQUISITES::
It is strongly advised that you first build manually a complete system
before attempting to automate the build.
To use this tool you MUST:
- have experience building {c,h,b}LFS packages
- know how to edit and write shell scripts
- know how a Makefile works
- be able to trace build failures and to find what is causing it
(user error, package bug, {c,h,b}LFS command bug, or jhalfs code bug)
If you do not have the above skills, please don't use this tool.
Of course the "Host System Requirements" should be fulfilled. Some
supplementary packages are needed for using jhalfs. They are detailed
at the bottom of the page:
https://www.linuxfromscratch.org/alfs/download.html. In short, you need
wget, sudo, libxml2, libxslt, docbook-4.5-xml, and docbook-xsl-nons.
3. INSTALLATION::
No installation is required. You may want to move the files in this
directory to a convenient location, and then follow the instructions below.
No installation is required. System-wide installation is not allowed.
4. CONFIGURATION::
4.1. CONFIGURATION OF THE TOOLS:
There is no configuration of the tools themselves. The various
parameters for the build are set through a menu driven interface. See
the section RUNNING below for details.
4.2. PRELIMINARY TASKS:
This tool has no support at all for creating a partition and a mount
point for the built system. You should follow the book up to the section
"Mounting the new partition". Note that the default name for the
partition mount point is "/mnt/build_dir", instead of /mnt/lfs.
You can change that default to anything you'd like in the menu, so you
may name it /mnt/lfs if you prefer . We'll use the name /mnt/build_dir
in the sequel.
For downloading packages, you can use the tool or download them
yourself. Even if using the tool, it is recommended to set up a source
repository where you store already downloaded packages. The tool will
automatically search a package in this repository before downloading it
if it is not found there. This repository cannot be the same as
/mnt/build_dir/sources. As an example, we'll use /usr/src. You should
arrange for the user running the tool to have write access to this
directory.
If you want to build the kernel as part of the automated build,
a configuration file must be provided. In order to do so, it is
recommended to download the kernel tarball, unpack it, run
<make menuconfig> (or any other *config), configure the kernel as per
the book, and save the resulting .config file to a location where it can
be retrieved later on. It is suggested to put it into the source
repository, with a versioned name, e.g.
/usr/src/config-<arch>-<kernel version>-<config details>.
Another file you may provide is the fstab file. As for the kernel
configuration, this file has to be prepared before running the menu.
You can copy-paste the file from the "Creating the /etc/fstab File"
page, then edit to suit the future lfs system layout, then save the
file. A convenient location and name is /usr/src/fstablfs.
At a more advanced level, you may want to supply custom commands
to be run at the end of LFS build. Scripts containing those commands
are located in the ./custom/config directory. Examples are given in
./custom/examples. A template is provided as ./custom/template. See
README.CUSTOM for more details.
We have installed the familiar menu based configuration tool driven by
GNU make. see the section RUNNING, for details
5. RUNNING::
IMPORTANT::
The command <make> will launch a menu based configuration program. You will
recognize the layout from building the kernel or uClibc/BusyBox. The
underlying menu code was borrowed from BusyBox and slightly modified for
our use.
Help on parameter function is available from the on-line help. Please
make use of that feature for additional information not in this file.
Once you have set the parameters you wish and have saved your work the
jhalfs script is launch. The script verify first that the host can run
it and build the xLFS system, then validate the configuration and present
you with your selections which you may accept or reject.
If you accepted the displayed settings jhalfs will proceed to create the
Makefile, optionally download packages.
::NEWS::
You must be logged as a normal user with sudo privileges to run
the Makefile. Furthermore, you are supposed to have enough privilege
to become any user. If you are not bothered about security issues,
the entry for the user running the tool in /etc/sudoers could be
<user> ALL=(ALL) NOPASSWD:ALL
the Makefile.
The command <make> will launch a menu based configuration program,
similar to the kernel "menuconfig" configuration tool.
NOTE::
If you run the jhalfs script directly the only function you can select
is to display the version number running <./jhalfs -v>
Help on parameter function is available from the on-line help (type the
character `?' after highlighting the parameter). Please do use the help:
it may contain additional information not duplicated in this file.
6. BLFS_TOOL SUPPORT::
MENU "BOOK Settings"
For books that support it, there is an option to install blfs-tool and its
dependencies on the final system. The pre-made build dependencies
scripts has been written based on a LFS build. For CLFS and HLFS
builds you may need to adjust that scripts, that are found into the
common/blfs-tool-deps directory in the jhalfs sources tree.
Use BOOK: You have three choices: LFS System V, LFS systemd, BLFS.
The BLFS part is described in README.BLFS
WARNING:: If you add blfs-tool support on a CLFS Sysroot build
you MUST to edit the dependencies scripts to fix the
installation paths.
Be careful when you modify the scripts as you can
easily disable the host system.
Book version: You have two choices: "Branch" or "Working Copy"
Branch will have the tool clone the book's git repository. The
choice of the branch (actually any git commit) or of the file
location for the working copy is done in the next menu entry.
After booting the new xLFS system some steps are needed to finish
blfs-tool installation:
Multilib: Four choices: Normal LFS, Multilib with i686 libraries,
multilib with x32 libraries, multilib with all libraries.
It is recommended to use "Normal LFS" unless you know what you
are doing
- A user account must be created. You must be logged on that user
account to use blfs-tool.
Build method: two choices: chroot (as in book), boot
Presently, the "boot" method is not implemented, so keep the default.
- Move /blfs-root to that user's home and change ownership of the
directory and files to the user.
Add blfs-tools support (see README.BLFS)
This will install the blfs tools onto the newly built system. It
is not the same thing as choosing the BLFS book in the menu, which
will install the blfs tools on the currently running system.
- Give the user read and write privileges over the $TRACKING_DIR
directory and the files that it contains.
Add custom tools support (see README.CUSTOM)
- If you think that you may need the libxml2/libxslt Python modules,
remove the libxml2 and libxslt trackin files found in $TRACKING_DIR.
MENU "General Settings"
- Configure sudo, adding the needed privileges for the user.
Build Directory: the name of the root of the LFS system
This is the equivalent of the LFS variable in the book. Set it
to "/mnt/lfs" if you have followed the book for creating the LFS
partition and mount point.
We assume that blfs-tool will be used on a running fresh xLFS system.
To use it to build BLFS packages from the chroot jail is also possible,
but is for you to figure out how to do that.
Retrieve source files: Say y to have jhalfs download the packages
If you say no, you must download the packages yourself and put
them into the /mnt/build_dir/sources directory. Follow book's
chapter 3 instructions.
If you say yes, you'll be asked several other questions:
- Package Archive Directory: Repository of downloaded packages
This directory, which is on the host and should be writable
by the user running the tool, is for storing downloaded packages.
If you keep the default "$SRC_ARCHIVE", you can set this variable
to the absolute path of the repository and export it. Or if the
variable is not set, jhalfs downloads the sources directly to
/mnt/build_dir/sources.
Instead of using the SRC_ARCHIVE envar, you can also enter the
path of the repository directory into this field.
- Retry on 'connection refused' failure: self explanatory
- Number of retry attempts on download failures: self explanatory
- Download timeout (in seconds): self explanatory
To know how to blfs-tool works, see README.BLFS.
Run the makefile: start the build immediately after running the tool
This is not the preferred method: it is recommended to rather
run "make -C /mnt/build_dir/jhalfs" after the tool has finished
setting up the build. But this may be handy if you are sure everything
is well, and want to leave the tool and the build run without
supervision.
7. LAYOUT::
Rebuild files: clean up the /mnt/build_dir directory
Say n if you want to rerun the tool (to update generated scripts
for example) without removing what has already been done. Otherwise,
say y. Note that there are some guards against removing a directory
containing useful things, but double check that the /mnt/build_dir
directory is really what you want to erase.
/BLFS (see README.BLFS)
MENU "Build Settings"
/CLFS/master.sh
/clfs.xsl
MENU Parallelism settings
- Use all cores:
If you say y, MAKEFLAGS will be set to "-j$(nproc)" at the
beginning of each script. Other envars are supposed to be passed
from the environment, as done in new books. Note that for old books,
this means the scripts using make or ninja will be run with all
cores, but not when this needs to set special envars like
TESTSUITEFLAGS. You can still define the number of cores used
in next field.
If you say n, you'll be asked for a static number of threads
to use.
- set of cpus to use, or 'all' for all cpus (only if using all cores):
You can define here the cores you want to use. See help for
details. This is the preferred way of reducing the number of cores
rather than using a static thread number.
- Number of parallel `make' jobs (only if not using all cores):
Every occurrence of $(nproc) in new books will be replaced with
the number entered here. Also MAKEFLAGS will be set to "-jN" (where
N is the number entered) at the beginning of each scripts. Furthermore
NINJAJOBS will be set to N in the environment. This allows to run all
books with N threads, except for paarts that need other envars to be
set
- Build Binutils pass1 without parallelism (Real SBU)
The standard SBU is defined as the time to run the binutils-pass1
build with only one thread. Saying y here allows to get a value for
it. If you say n, the value is not meaningful for SBU measurements.
/CLFS2/master.sh
/clfs2.xsl
Run testsuites: say y to run the test suites
You'll have the choice between running all the test suites, or only
those deemed critical (binutils, gmp, mpfr, mpc, and gcc).
/CLFS3/master.sh
/clfs3.xsl
Package management: see README.PACKAGE_MANAGEMENT
Create a log of installed files for each package: self explanatory
Strip Installed Binaries/Libraries: use the book instructions for
stripping
DO NOT use/display progress_bar (self explanatory)
MENU System configuration
Use a custom fstab file:
If you say y, you'll have to provide a file containing the fstab
for the LFS system. See above "preliminary tasks".
Build the kernel:
If you say y, you'll be asked for a file containing the kernel
configuration. See above "preliminary tasks".
Install non-wide-character ncurses (rarely used nowadays):
If you say y, the system will use instructions in the note on the
ncurses page to install those libraries.
TimeZone: set to the result of "tzselect"
Language: set to the result of the instructions on "The Bash Shell
Startup Files" page.
Install the full set of locales: installs all the locales known to
glibc.
Groff page size: choice between "A4" and "Letter".
Hostname: self explanatory
Network configuration: various fields for setting network. Look at
chapter 9 for background.
Console configuration: various fields for setting console, as described
in chapter 9.
MENU Advanced features:
Optimization: Optimization settings are done by editing files in the
"optimize" directory. The menu just allows you to choose between applying
optimizations only to the final chapter or to all the book. Say n for
a normal build
Create SBU and disk usage report: self explanatory
Save temporary system work: self explanatory (see help)
Run comparison analysis on final stage: build the system several times
using the preceding one, to test whether it is able to rebuild itself
identically. Don't use normally...
Internal Settings (WARNING: for jhalfs developers only): says it all
Once you have set the parameters and saved the configuration, the script
is launched. Its aim is to extract instructions from the selected book
to generate scripts, and to generate a Makefile, which allows running
the scripts in the right order. The script verifies first that the host
can run itself and build the xLFS system, then validates the configuration
and lists the parameters. At this point, you may choose to quit or to
continue with the listed parameters. The script will then proceed to
generate the Makefile and the build scripts, optionally download
packages, and eventually verify the host prerequisite. If you have
selected "Run the makefile", the command <make> is launched in the
adequate directory, and the build begins. If not, you'll have to run
"make" manually, for example: "make -C /mnt/build_dir/jhalfs", if you
have used the default parameters (see the layout under $BUILDDIR in the
Q&A below).
NOTE::
If you run the jhalfs script directly the only function you can select
is to display the version number by running <./jhalfs -v>
6. LAYOUT::
/BLFS/* (see README.BLFS)
/HLFS/master.sh
/hlfs.xsl
/LFS/master.sh
/lfs.xsl
/common/chroot.xsl
/common_functions
/create-sbu_du-report.sh
/hostreqs.xsl
/kernfs.xsl
/common/common_functions
/makefile_functions
/packages.xsl
/progress_bar.sh
/urls.xsl
/create-sbu_du-report.sh
/progress_bar.sh
/blfs-tool-deps/9xx-*
/libs/func_*
/custom/examples/*
/config/* (needs to be created after cloning since it is an
empty directory initially)
/template
/custom/template
/config/
/examples/*
/examples_CLFS-E/*
/extras/do_copy_files
/do_ica_prep
/do_ica_work
/menu/*
/farce
/filelist
/optimize/opt_config
/opt_override
/optimize_functions
/opt_config.d/noOpt
/noSymbols
/O2pipe
/O3pipe
/O3pipe_march
/defOpt_fPIC
/pkgmngt/packageManager.xml.dpkg
/packageManager.xml.pacman
/packageManager.xml.porg
/packageManager.xml.template
/packInstall.sh.dpkg
/packInstall.sh.pacman
/packInstall.sh.porg
/packInstall.sh.template
/menu/*
CHEATSHEET
FUNCTION_LIST
LICENSE
README
README.BLFS
README.CLFS
README.HLFS
README.CUSTOM
README.PACKAGE_MANAGEMENT
TODO
LICENSE
Config.in
jhalfs
Makefile
jhalfs
blfs-tool
7. FAQ::
Q. "It doesn't work"
A. There are several reasons why it may be so. One possibility is the
following: jhalfs was designed to work against the development versions
of the LFS series of books. Consequently changes in a book sometimes
break older versions of jhalfs. Before you start pulling out your hair,
download the latest version of jhalfs to see if that solves your
problem. Note that it may be the other way around. If you want to build
an old version of the book, you may have to downgrade your jhalfs
version.
8. FAQ::
Q. "This 'help' file is very sparse"
A. Yes, it is. This tool, jhalfs, is for those who understand the LFS books
and wish to automate the build. 99% of any problems that arise can be
solved by reading the book(s).
Q. "It doesn't work!"
A. Yes it does, try >> make
Remember you must have 'sudo' privileges.
Q. "It still doesn't work"
A. jhalfs was designed to work against the development versions of the LFS
series of books. Consequently changes in a book(s) sometimes breaks older
versions of jhalfs. Before you start pulling out your hair download the
latest version of jhalfs to see if that solves your problem.
Q. "How do I specify the build location?"
A. The original LFS document worked against the well known location
/mnt/lfs. This script automates the build of all of the LFS series of
books and uses a generic location $BUILDDIR with a default value of
/mnt/build_dir. You may change this value to suit your needs.
A. The original LFS document worked against the well known location /mnt/lfs.
This script automates the build of all of the LFS series of books and uses
a generic location $BUILDDIR with a default value of /mnt/build_dir.
You may change this value to suit your needs.
The layout below $BUILDDIR is as follows.
$BUILDDIR/
jhalfs (Makefile, cmd scripts, logs, etc..)
sources (where packages reside)
tools (temporary cross compiler)
tools (temporary bootstrap system)
cross-tools (temporary CLFS only)
...
FHS dir structure
...
@ -373,10 +210,10 @@
Q. "What is the function of the SRC_ARCHIVE variable?"
A. When jhalfs runs and packages download was selected, it creates a local
copy of the necessary packages in $BUILDDIR/sources by downloading the
copy of the necessary packages in BUILDDIR/sources by downloading the
files. If the variable SRC_ARCHIVE is defined the software will first
look in this location for the file and, if found, will copy it to
$BUILDDIR/sources.
BUILDDIR/sources.
If the files are not found in SRC_ARCHIVE _and_ you have write priv to
the directory any downloaded files will be mirrored there.
@ -389,9 +226,37 @@
Q. "Why have 2 copies of the files?"
A. The package files must be visible during the chroot phase and this is a
simple and reliable method of doing so. This method also handles the
boot build method where the final build may be done on a separate
machine.
simple and reliable method of doing so. This method also handles the CLFS
boot build method where the final build may be done on a separate machine.
Q. "What is the function of "User account" and "Group account" menu settings?"
A. If you are running jhalfs from a low or non-privileged account you may not
have the priv to create/delete the user needed to build temporary tools.
These settings allow you to use your own user and group name to do that
build steps.
These variables are adjustable also when invoking make:
$BUILDDIR make LUSER=myaccount LGROUP=mygroup
The only changes to your account will be the creation of a NEW .bashrc
after saving your original to .bashrc.XXX
Q. "When I try to build CLFS the Makefile fails at the mid-point"
A. There could be numerous reasons for the failure but the most likely reason
is you are doing a cross-build using the 'chroot' method and the target is
not compatible with the host. If you choose to build using the chroot
method a test is performed at the end of the temptools phase. If the test
succeeds the build continues inside a chroot jail. However if the test fails
it means the host and target are not compatible an you should use the
'boot' method to create your target code.
As an extreme example: You can build a sparc target on a x86 platform but
only the temptools phase. You must select the 'boot' method and not the
'chroot.' You must transfer the toolchain to a sparc platform, reboot the
sparc box and continue the build.
Of all the LFS series of books Cross-LFS requires the greatest
understanding of host/target hardware combination. Please read the book
carefully and don't skip the easy parts (there are none..)
Q. "How could I stop the build at a predefined chosen point?"
A. Launch the Makefile manually passing the last numbered target to be build
@ -409,4 +274,3 @@
Authors:
George Boudreau
Manuel Canales Esparcia
Pierre Labastie

View file

@ -1,5 +1,11 @@
$Id$
1. INTRODUCTION::
If you want to add blfs-tool support into a xLFS base system build,
read the "BLFS_TOOL SUPPORT" section found in the README and be sure
to follow the after-booting installation intructions.
To automate package builds from the BLFS book instructions is a huge
task. Some of the issues are: the BLFS book isn't linear; some package
pages use a custom layout; there are circular dependencies; several
@ -7,160 +13,30 @@
change based on what dependencies will be used, etc.
That being said, the goal of the blfs-tool is to help you solve package
dependencies, create build scripts and a Makefile. Not all the auto-generated
dependencies, create build scripts and a Makefile. Few of the auto-generated
build scripts and Makefile will work "as is", thus, as a general rule,
you will need to review and edit the scripts while reading the book.
The blfs tools allow also to update packages from the LFS book. LFS
packages which may be updated appear in the menu interface. When selected,
their scriptlet is generated in the same manner as for BLFS packages.
(TODO: presently, when an LFS package needs a patch, you'll have to
donwload it manually to your $SRC_ARCHIVE directory (usually /sources)).
2. PREREQUISITES::
In addition to a full LFS system, the following packages and their
dependencies are needed by this tool:
- required: libxml2, libxslt, DocBook XML DTD
- recommended: wget (to download the package tarballs) and sudo (to build
as a user)
- optional: lynx (allows to read the generated linearized book), GPM (to
cut and paste commands from the book), git (to update the book
sources)
Note that the optional dependencies are recommended for ease of use of the
tool.
To use this tool you MUST:
You should also have the following personal skills:
- Ability to write and debug shell scripts: as said in the introduction,
not all the generated scripts can be used directly. They need to be
edited to produce an error free build.
- Ability to debug build failures, like missing dependencies or
installation directories not known to the system (when you install in
/opt for example).
- Ability to choose the tools you need to configure and administrate
your system: in the BLFS book, nothing is mandatory, nothing is
useless. You are on your own in choosing what to build, but wrong
decisions may lead to a non functional system...
- have experience building BLFS packages
- know how to edit and write shell scripts
- know how a Makefile works
- be able to trace build failures and to find what is causing it
(user error, package bug, BLFS command bug, or jhalfs code bug)
3. INSTALL::
If you do not have the above skills, please don't use this tool.
There are two ways to install the BLFS tools on an LFS system, described
in paragraphs 3.1 and 3.2, respectively:
3.1 INSTALLATION ON A RUNNING SYSTEM
3. USAGE::
Select "Use Book --> Beyond Linux From Scratch" in the jhalfs menu:
The tools are installed in $HOME$BLFS_ROOT (the default for $BLFS_ROOT
is /blfs_root). The BLFS book is downloaded or copied to its directory.
The tracking directory (see below) is created (if it does not already
exist) and initialized. Before running "make", you should ensure the
tracking directory (default location /var/lib/jhalfs/BLFS) can be:
- either created by the user running "make", if it does not exist
- or that it is writable by the user running "make", if it exists.
Due the complexity of the BLFS book, the scripts and Makefile generation
is done in several steps:
After the intallation, you should perform the following additional steps:
- Configure sudo, adding the needed privileges for the user.
- Although it is not strictly necessary, it is recommended to install
the bash shell startup files (as per `3. After LFS Configuration
Issues' of the BLFS book), as some instructions in BLFS rely on
their being present.
- At this point, the tool has no way to know which versions of LFS packages
are installed, so that the menu interface will show all the LFS packages,
as if they were not installed. If you have a released version of LFS, or
the date of your GIT version of LFS is known, you should run the
update-lfs.sh script. If you have updated some
LFS packages since first installation, or have been using a custom
working copy of the LFS book, the only (tedious) way is to create
empty files with names <package>-<installed-version> in the tracking
directory, and run the tool.
- If you have also installed some BLFS packages, they are not in the
tracking file. The only way is to create empty files with names
<package>-<installed-version> in the tracking directory, and run the tool.
3.2 INSTALLATION ON A JUST BUILT LFS SYSTEM
For books that support it (only LFS),
there is an option to install the BLFS tools right after building
the LFS system: just tick `BOOK Settings/Add blfs-tool support' in
jhalfs configuration menu. The tools are installed in $BLFS_ROOT
(default /blfs_root) on the LFS system, and the dependencies are built
at the end of the jhalfs run, before the custom tools.
After booting the new LFS system some steps are needed to finish
the installation of the automated tools:
- A user account must be created. You must be logged on that user
account to use blfs-tool. This is not strictly necessary,
since the packages can be built as root, too, but it is
never a good idea to build packages as root.
- Move /blfs-root to that user's home and change ownership of the
directory and files to the user.
- Give the user read and write privileges over the $TRACKING_DIR
directory and the files that it contains.
- Configure sudo and add the bash shell startup files, as described
above
- Note that the versions of LFS packages are automatically known to
the tool in this case, and there is no need to run the update-lfs.sh
script.
We assume that the BLFS tools will be used on a booted LFS system.
Using them to build BLFS packages in a chroot jail is also possible,
but not supported.
3.3 DIRECTORY LAYOUT IN THE $BLFS_ROOT DIRECTORY
blfs-xml/* GIT tree of the selected BLFS book version
lfs-xml/* GIT tree of the selected LFS book version
lib/constants.inc functions libraries
/func_dependencies for building the dependency tree
menu/* menuconfig source code
xsl/gen_pkg_list.xsl XSL stylesheet to generate the package database
/gen_config.xsl XSL stylesheet to generate the Config.in file
for use in the menuconfig system
/dependencies.xsl XSL stylesheet to generate the dependency list
of a package
/make_book.xsl XSL stylesheet to generate the linear book.xml
/lfs_make_book.xsl XSL stylesheet to incoporate LFS pages into the
linear book.xml
/scripts.xsl XSL stylesheet to generate the scriptlets from
book.xml
/bump.xsl XSL stylesheet to update the tracking file
/process-install.xsl XSL stylesheet included by scripts.xsl, for
outputting cleanly install instructions
/process-replaceable.xsl XSL stylesheet included by scripts.xsl, for
generating correct instructions when a
<replaceable> tag is encountered.
README.BLFS this file
TODO developers notes (well, not updated often)
gen_pkg_book.sh resolves dependencies, generates a linear BLFS
book, and finally generates build scripts
gen-makefile.sh generates the target Makefile
progress_bar.sh the target Makefile progress bar
gen-special.sh Helper script for generating the package
database
Makefile Used by make to update the package database
from the GIT tree, then launch the menuconfig
interface, and run gen_pkg_book.sh based on
configuration settings
packdesc.dtd a simple DTD describing the format of the
package database and the tracking file.
Working files: several files are generated when first running the tool:
packages.xml auto-generated package database
Config.in input file for the menu driven choices
configuration file generated by the menuconfig process
dependencies/* files recording the dependency tree
book.xml the linearized book
book-html/* the linearized book rendered in html
scripts/* the scriptlets
3.4 INSTALLED PACKAGES TRACKING SYSTEM:
3.1 INSTALLED PACKAGES TRACKING SYSTEM
This tool includes a very simple tracking system to log which packages
have been installed using the tool. It is used to skip installed packages
@ -168,208 +44,197 @@
updated in the BLFS book. Do not rely on this feature as a package
management tool.
The tracking system itself is an XML file: instpkg.xml. It is
initialized when <make> is first run in blfs_root. It resides in a
directory, which is created when needed during the process of building
custom tools or blfs dependencies, right after LFS. You can specify
that directory location in the blfs-tools sub-menu of jhalfs. You may
need to update permissions and/or ownership of this directory before
using the blfs tool (see README in jhalfs).
The directory where tracking files will be stored needs to be created
before installing blfs-tool. You can place this directory anywhere, taking
care that the user must have read and write privileges on that directory
and on all files it contains.
The default location of the tracking directory is /var/lib/jhalfs/BLFS.
NB : after the initial build, that directory is only used to contain
instpkg.xml, unless custom tools have been built. In the latter case,
it also contains empty files whose name are "$PKG-$VERSION" for each
versionned package built. The information about those packages is
included into instpkg.xml the next time the tool is run.
To use the default path set in the installation menu, run as root:
4. USAGE::
install -d -m1777 /var/lib/jhalfs/BLFS
3.2 BLFS_TOOL INSTALLATION::
Run "make" to launch the jhalfs menuconfig interface. Select the BLFS
book and version. Then set the installation directory (default
$HOME/blfs_root), the BLFS sources directory (default blfs-xml), and
the installed packages tracking directory (default /var/lib/jhalfs/BLFS).
All required files will be placed in the installation directory and
BLFS XML sources will be installed in the named sub-directory.
Installed files:
blfs-xml/* SVN tree of the selected BLFS book version
lib/* functions libraries, xsl stylesheets, and auto-generated
meta-packages dependencies tree files
menu/* lxdialog and menuconfig source code
README.BLFS this file
TODO developers notes
update_book.sh update the XML book sources and regenerates packages
database and meta-packages dependencies tree
gen_config.sh regenerates Config.in
gen_pkg_book.sh resolves dependencies and generates linear BLFS books
and build scripts
gen-makefile.sh generates the target Makefile
progress_bar.sh the target Makefile progress bar
Makefile run gen_config.sh to update Config.in,
then launch the menuconfig interface, and lastly run
gen_pkg_book.sh based on configuration settings
Config.in menuconfig interface input file
packages auto-generated packages database
envars.conf envars needed when running the target build scripts
From now on, all the work must be done from inside the installation
root directory.
Due to the complexity of the BLFS book, the scripts and Makefile
generation is done in several steps:
When finished the installation, the configuration and target selection
menu is launch.
4.1 UPDATING BOOK SOURCES::
3.3 UPDATING BOOK SOURCES::
If you are using the development book version and you want to update
installed packages to the latest version found in that book, you need to
update the XML sources and packages database. To do that, run
"make update". This is not necessary if you just built LFS, and you
can skip to step 4.2.
update the XML sources and packages database.
To do that run "./update_book.sh"
On the next configuration run, packages already installed but listed
with a new version in the book will be available for target selection
and used to solve dependencies.
4.2 CONFIGURING AND PARSING THE BOOK::
3.4 CONFIGURING AND PARSING THE BOOK::
The next step is to create a book and build scripts in dependency
build order for one or several packages.
build order for a target package. A target can be a package or a
meta-package.
WARNING:
Only one target (meta-package or individual package) must be
selected on each configuration run.
There is no way to solve dependencies properly when more
than one target are selected.
Run <make> to launch the configuration interface. The main menu contains
four blocks: individual package selection, Build settings, Build layout,
and Optimization.
three blocks: meta-package selection, individual package selection, and
build options.
In the package selection block, menus and submenus are organized
as the book's parts, chapters and sections. You can navigate those menus
and select as many targets as you want. But we suggest to not select
too many at a time to be able to sort issues!
When a meta-package is selected, it is possible to unselect unwanted
components. The unselected components will be skipped if no other components
depends on them.
In the "Build settings" submenu, the dependency level and default
packages used to solve alternatives are set (currently, only for the MTA).
You can also select whether the build will be made as a normal user or as
root, whether to use "porg style" package management, whether to remove
".la" files, and wheter statistics for the package are generated (build
time, memory footprint and "DESTDIR" install). If you use package
management, you have to enter the path to the packInstall.sh script too.
In the build options section, the dependencies level and default packages
used to solve alternatives are set. You can also select whether the build will
be made as a normal user or as root. That settings are saved to be reused in
future configuration runs.
In the "Build layout" submenu, you can select where the source tarballs
reside and are downloaded, where the packages are built, and whether to
keep the build tree after installation.
If, for example, your target selection is Xsoft-->Graphweb-->galeon, a
directory named "galeon" will be created. Inside that directory you will
find a directory named "HTML" that contains a galeon-based HTML book with
its dependencies in build order, and a "scripts" directory with build
scripts for that packages.
In the "Optimization" submenu, you can select the number of parallel
jobs, and set the usual CFLAGS, CXXFLAGS, and LDFLAGS. the special
keyword "EMPTY" can be used for those flags to ensure they are unset.
There are also two other directories ("dependencies" and "xincludes")
that contain files generated while resolving dependencies trees.
Note that there are help strings associated to those menus. Please
read them for details!
3.5 EDITING BUILD SCRIPTS
Those settings are saved to be reused in future configuration runs.
When you are done with the menu, a few checks occur, and the dependency
chain is generated. Each dependency appears with its priority (required,
recommended, optional, or external), and it's level. There is a root level
1. The selected packages have level 2. The dependencies of selected packages
have level 3, the dependencies of the dependencies have level 4, and so on.
When circular dependencies are found, they appear with a priority of
"circular". This means that two (or more) dependency chains arrive at the
same package. The algorithm chooses the chain with the highest priority and
reorders dependencies to remove the other chain(s). This is not always the
solution an user would prefer, but we have found no way to do it better.
You end up with a book.xml file which contains the linearized book,
and a rendered HTML, in the directory book-html, which you can browse with
"lynx book-html/index.html" (or with any other browser).
Furthermore, there is a directory "scripts", which contains the generated
scriptlets.
There is yet another directory, "dependencies" that contains files
generated while resolving dependencies.
4.3 EDITING BUILD SCRIPTS::
Now it is time to review the generated book and scripts, making any
changes to the scripts necessary to fix generation bugs or to suit your
needs.
Now it is time to review the generated book and scripts, making any changes
to the scripts necessary to fix generation bugs or to suit your needs.
Scripts for additional packages (i.e., for non-BLFS packages) can be
easily inserted. For example, if you want to install the external dependency
"bar" before "foo" package and the "foo" script is named "064-z-foo", you
just need to create a "064-y-bar" build script.
need to create a "064-y-bar" build script.
Remember, the package tracking system isn't a package management tool
Remember, the package tracking system isn't a package management tool
and knows nothing about packages not in the BLFS book.
4.4 CREATING THE MAKEFILE::
Also, review and edit envars.conf. This file is used to set global envars
needed by the build scripts.
3.6 CREATING THE MAKEFILE
When the build scripts are ready to be run, the Makefile can be
created. Create an empty subdirectory (for example "mkdir work") and cd
to that directory. Then run ../gen-makefile.sh. Note that the directory
is completely emptied before generating the Makefile, so to prevent
erasing useful data, the script ensures that the name of the current
working directory starts with "work".
created. Be sure that you cd into the "package" directory and run
../gen-makefile.sh
Review the Makefile, and, if all looks sane, start the build by running
"make".
Review the Makefile, and, if all looks sane, start the build.
5. GENERATED BUILD SCRIPTS ISSUES::
4. GENERATED BUILD SCRIPTS ISSUES::
In this section, known issues with the generated build scripts are
discussed. They are due to build procedures and/or BLFS layout
particularities that we can't handle. In several cases, editing the
build scripts is mandatory.
You may also need to insert some build scripts created by you to resolve
unhandled dependencies and/or to remove some script installing an unneeded
package (unneeded packages may be pulled in the dependency chain, if
they occur as an "or" with another package).
When there are circular dependencies (only one known in BLFS 8.0 for
recommended dependencies), you may need to move around scripts so that they
run in the order script-A script-B script-A. This involves copying script-A
to another name (using the xxx-a- fields), and possibly renaming the xxx-a-
fields of each involved script.
discussed. They are due to build procedures and/or BLFS layout particularities
that we can't handle. In several cases, editing the build scripts is mandatory.
You may also need to insert some build scripts created by you to resolve
unhandled dependencies and/or to remove some script installing the affected
package by hand.
5.1 BLFS BOOTSCRIPTS::
4.1 BLFS BOOTSCRIPTS
Normally, bootscript installation should work. On the other hand, the
book does not give instruction for running them, so you might have to
manually insert "/etc/init.d/rc.d/<initscript> start" at some place during
the build.
For now, bootscripts installation will fail. You will need to edit
the scripts for packages that install bootscripts and fix their
installation command. That could be fixed in the future.
5.2 PACKAGE CONFIGURATION::
4.2 PACKAGE CONFIGURATION
For those packages that have a "Configuration" section, you should
edit the build script to fit the needs of your system. Sometimes, the
bash startup files are modified. The generated scripts contain a
line 'source /etc/profile', which ensures that the proper environment
variables are used.
edit the build script to fit the needs of your system.
5.3 PAGES WITH TWO OR MORE PACKAGES::
4.4 PDL, Perl modules, and Glib-Bindings.
For example: sane, poppler, audacious, freetts, which, etc.
The generated scripts for these packages are broken and can not
be fixed. You must rename it as the sub-package to be installed and
edit it to use the proper commads for that sub-package.
On the pages for those packages, the BLFS book actually has instructions
You may need to create additional scripts for these sub-package
dependencies, if any.
4.4 GCC, JDK, Sane, and KDE-multimedia, freetype2, MesaLib and others
On the pages for these packages, the BLFS book actually has instructions
to download and install two or more packages. You must edit the scripts to
fix this. A common pitfall is that the variable PACKAGE may be used for
several tarballs. Be sure to save the PACKAGE variable to some other
name (for example PKG1, PKG2, etc) after each download. The unpacking
instructions may need to be repeated for each tarball in turn.
fix this.
5.4 XORG7
We will try to fix some of them, but this may not be possible.
The book has special page layouts for the Xorg7 packages. The tool
breaks those pages into individual pages for each packages in the linear
book. Also, the menu gives the choice to select each package individually.
4.5 XORG7
To build the whole Xorg7 chapter, select xinit. The (recommended)
dependency chain brings in the whole set of Xorg packages.
The generated scripts for Xorg7 pseudo-packages have $SRC_ARCHIVE
support for individual packages, but not for patches nor *.wget and *.md5
files.
5.5 PATCHES
If you have previously downloaded the patches, you must edit
the scripts to use your local packages.
Please, make sure that all scripts have the commands to download/apply
the required patches. Due to book layout issues, some patches may be
missing (as of BLFS 8.0, all the patches seem to be downloaded).
The *.wget and *.md5 files should be downladed always from inside
the scripts to be sure that the most current individual packages are
used. Thus don't reuse previouly existing ones.
5.6 ROOT COMMANDS
In the script for xorg7-font, be sure to move the fonts directories
symlinks creation to after the "for ... done" loop.
4.6 PATCHES
By default, all required patches will be downloaded from the NET.
If you have previously downloaded the patches, you must edit the
scripts to use your local patches.
Also, be sure that all scripts have the commands to download/apply the
required patches. Due to book layout issues, some patches may be missing.
4.7 ROOT COMMANDS
If building as a normal user (the default setting), be sure that all
commands that require root privileges are run using sudo. Also make sure
necessary root privilege commands are visible in your PATH. The scripts
ensure that /usr/sbin is appended to the user's PATH when running
privileged commands.
For commands necessitating root privileges, the generated scripts wrap
them with the construct:
sudo -E sh -e << ROOT_EOF
<commands to be executed as root with `$', ``', and `\' escaped>
ROOT_EOF
The "-e" switch to sh ensures the command block exits with error if an
error occurs. The "-E" switch to sudo ensures the whole environment is
passed to the commands to be run with root privileges. It is effective
only if the /etc/sudoers file contains `Defaults setenv', or SETENV in
the user attributes (this is implicit if the command the user is allowed
to run is `ALL'). If you think it is a security issue, you may forbid
this flag in /etc/sudoers, but then, you have to un-escape `$' for
variables coming from the environment in the instructions. Although this
construct is rather strong, it can fail in some corner cases, so
carefully review those instructions.
necessary root privilege commands are visible in your PATH.
Due to book layout issues, some sudo commands may be missing.
5.7 OTHERS
4.8 OTHERS
There may be other issues that we are not aware of. If you find
any, please report it to <alfs-discuss@linuxfromscratch.org>.

44
README.CLFS Normal file
View file

@ -0,0 +1,44 @@
# $Id$
CLFS-1.x NOTES
None for now.
CLFS SYSROOT METHOD NOTES
.- If you want to install additional custom packages via "Add custom tools
support" and/or select "Add blfs-tool support", be sure to review and edit
their packages build scripts to follow the sysroot build method or you will
end messing your host system. Be very careful with this.
.- If you install additional packages not using the "Add custom tools support"
feature (i,e, you will install it manually after finished the Makefile run)
you will need to run manually the "Changing the Ownership Of The CLFS System"
phase commands found in the book.
CLFS EMBEDDED SYSTEMS NOTES
.- Mips, WRT and ARM builds are broken due a book bug on the uClibc
*ENDIAN* configuration settings.
.- To install CBLFS packages you must to use the "Add custom tools support"
feature. To learn how it works and how to use it, see the section titled
"Adding Post-System Build Configuration Files and Extra Packages"
found in README.CUSTOM. That is also applicable to bootloaders installation.
.- If you install additional packages not using the "Add custom tools support"
feature (i,e, you will install it manually after finished the Makefile run)
you will need to run manually the "Changing the Ownership Of The CLFS System"
phase commands found in the book.
.- If your target is a MIPS wireless router, you must to select "mips" as
your target architecture and "WRT - MIPS based wireless route" as your
hardware platform.
.- The backup & clean-up phases aren't run. This is to allow users to
review the installed files and do a more in-deeper clean-up before creating
the system tarball.

View file

@ -1,21 +1,25 @@
#
# $Id$
#
HOW TO ADD CUSTOM SCRIPTS TO THE JHALFS MAKEFILE
Normally JHALFS creates a Makefile containing only those scripts found in
the {,B}LFS books. An automated construction tool cannot predict the
the {B,C,H}LFS books. An automated construction tool cannot predict the
needs of every individual and requests are made "Can you add xxxx package".
Rather than adding numerous package scripts and switches for each request it
was easier to add a tool for the user(s) to code their own package needs.
There are two areas that can be customized: how the base system is built
and what additional configurations and packages your hardware requires to be
able to boot and run. Each of those areas are handled in a different way.
There is two areas that can be customized: how the base system is build
and what additional configurations and packages requires your hardware to can
boot and work with. Each one of this areas is handled in a different way.
BASE SYSTEM CUSTOMIZATION
There are two ways to alter how the base system will be built:
There is two ways to alter how the base system will be built:
- Using a working copy of the book sources and editing the XML files.
This is the way used by book editors to test packages upgrades,
@ -24,22 +28,22 @@ able to boot and run. Each of those areas are handled in a different way.
This method requires you know very well the book sources and what
files need be edited. It will not be discussed here.
- Editing the generated build scripts to make any change you want.
- Editing the generated build scripts to make any change you would.
This is the method discussed below.
EDITING THE BASE SCRIPTS
To begin with, the build scripts should be generated with book defaults. To
do that, configure jhalfs activating any option you want included, but do not
select "Run the Makefile" option.
First step is to generate the build scripts with book defaults. To do that,
configure jhalfs activating any option you want included, but do not select
"Run the Makefile" option.
Under the ${BUILD_DIR}/${SCRIPT_ROOT}/$COMMANDS directory
Under the ${BUILD_DIR}/${SCRIPT_ROOT}/${PROGNAME}-commands directory
(using the defaults values to do an LFS build, that directory name is
/mnt/build_dir/jhalfs/lfs-commands) you will find the default build scripts.
If all you want is modify, add, or remove some command from a package
installation, for example to change its ./configure line, just edit the related
installation, for example to change it ./configure line, just edit the related
script. If changing or adding a patch, be sure to copy the new patch to the
${BUILD_DIR}/sources directory. When done, run 'make' from inside the
${BUILD_DIR}/${SCRIPT_ROOT} directory.
@ -49,38 +53,39 @@ ${BUILD_DIR}/${SCRIPT_ROOT} directory.
To remove a package from the system, just remove its script(s).
To change the version of some package, or to build a newer or older version
than that in the book, edit ${BUILD_DIR}/${SCRIPT_ROOT}/pkg_tarball_list to
change its tarball name and place the new tarball in the ${BUILD_DIR}/sources
directory.
To change the version of some package to build a newest or oldest one than the
one found in the book, edit ${BUILD_DIR}/${SCRIPT_ROOT}/pkg_tarball_list to
change it tarball name and place the new tarball in the ${BUILD_DIR}/sources
directory,
To replace a package by an equivalent one, rename the replaced package script
to reflect the new package name (for example, 102-man-db -> 102-man), edit the
script to make the required commands changes, place the new tarball in the
script to made the required commands changes, place the new tarball in the
${BUILD_DIR}/sources directory, and edit ${BUILD_DIR}/${SCRIPT_ROOT}/pkg_tarball_list
file to replace the removed package tarball name by the new package tarball
name.
file to replace the removed package tarball name by the new package tarball name.
To change the build order, rename the scripts changing the first 3-digits
string until they are sorted in the way you want.
string until have it ordered in the way you want.
To insert a new package, for example to build Cracklib in order to build
Shadow with Cracklib support, you should first decide before what package it
needs to be installed, in this example 107-shadow. Then create a new script
containing the needed commands, using an existing one as template, and name it
with the same 3-digits string used for that mentioned default package, but
adding another 1-digit string. In our example, the new script to build Cracklib
before Shadow will be named 107-1-cracklib. This naming scheme allows inserting
up to 10 scripts before each of the existing scripts. Place the tarball for
the new package and required patches, if any, in ${BUILD_DIR}/sources and edit
To insert a new package, for example to build Cracklib to can build Shadow
with Cracklib support, first you should decide before what default package it
need be installed, in this example before 107-shadow. Then create a new script
containing the needed commands, using an existing one as template, and name it with
the same 3-digits string used for that mentioned default package, but adding
another 1-digit string. In our example, the new script to build Cracklib just
before Shadow will be named 107-1-cracklib. This naming schema allow to insert
up to 10 scripts before each one of the default scripts. Place the tarball for
the new package and required patches, if any, if ${BUILD_DIR}/sources and edit
${BUILD_DIR}/${SCRIPT_ROOT}/pkg_tarball_list to add the tarball name for that
package.
When ready, launch again the jhalfs configuration interface. Make sure that
exactly the same options are selected as when generating the default build
scripts. Be sure that "Rebuild files" is unselected and select "Run the
Makefile" if you want. Then select "Rebuild the Makefile". This will create a
new Makefile based on the changes you made to the build scripts.
When ready, launch again the jhalfs configuration interface. Be sure that
are selected exactly the same options than when generating the default build
scripts. Be sure that "Rebuild files" is unselected and select "Run the Makefile"
if you want. Then select "Rebuild the Makefile". This will create a new Makefile
based on the changes you made to the build scripts.
ADDING POST-SYSTEM BUILD CONFIGURATION FILES AND EXTRA PACKAGES
@ -91,27 +96,35 @@ more info.
The feature described below was added so users could install remaining
configuration files, build the packages necessary to access the Internet
or to support specific hardware, or to install basic utilities that are
needed from the beginning, and was not intended to replace the BLFS
or to support specific hardware, or to install basic utilities that need
have available from the beginning, and was not intended to replace the BLFS
install system.
:::NOTICE:::
The following examples are for use with LFS and are not applicable to any
of the CLFS-sysroot or CLFS-Embedded books. The directory examples_CLFS-E
contains code extracted from Beyond CLFS-embedded. Any packages you chose to
add should honour the DESTDIR=${CLFS} switch or equivalent.
LAYOUT
A new directory has been added to JHALFS tree which contains the
A new directory has been added to JHALFS tree which will contain the
configuration scripts and a few examples. A switch has been added to the
configuration file which enables/disables the inclusion of custom scripts.
configuration file which enables/disables the inclusion of personal scripts.
custom
/config <-- where to put your scripts.
/examples <-- a few example scripts
/examples_CLFS-E <-- example scripts for CLFS-Embedded
template <-- ALL scripts MUST look like this
NOTE::: You are responsible for including all dependencies and ensuring they
are built in the right order.
are built in the proper order.
1. To add a package to the final JHALFS Makefile you must first create a file
in the custom/config directory. The directory custom/config may need
to be created first.
in the custom/config directory.
**All config files MUST follow the naming convention, xxx-PKG, where xxx
is the order number and PKG is the name of the package. The file naming
format is important as it defines the build order. The example shown
@ -121,36 +134,25 @@ configuration file which enables/disables the inclusion of custom scripts.
and rename it.
2. Populate the variables with the necessary values.
Variable function is self explanatory. PATCH variables must be
numbered, starting at PATCH1 (up to PATCH10). If the md5 checksum value
is known, it can be added after the URL as in (quotes needed):
PATCH1="http://patch-host/patch-path xxxxxxx..."
3. Build commands
If the package you want to include is found in the BLFS
book then you only need to copy/paste the commands between the xEOFx
text, otherwise you will need to define the commands yourself.
Variable function is self explanatory except for the inclusion of the
build cmds. If the package you want to include is found in the BLFS
book then you only need to copy/paste the cmd strings between the xEOFx
pairs, otherwise you will need to define the build cmds yourself.
NOTE::: This script you just created is not usable directly but contains
all the information necessary for jhalfs to create a build script
and an entry in the jhalfs Makefile.
4. As mentioned previously the build order is dictated by the 3 digit number
3. As mentioned previously the build order is dictated by the 3 digit number
in the file name. If a package has dependencies it must be numerically
larger than the dependency files.
e.g. The package mc has glib as a dependency, so the build order is:
i.e. The package mc has glib as a dependency and build order is
950-glib
951-mc
951-mc
5. A config file for BLFS-bootscripts is already created as 999-blfs_bootscripts.
4. A config file for BLFS-bootscripts is already created as 999-blfs_bootscripts.
If a package requires a bootscript to be installed add the cmd to this
file and NOT in the package script. The gpm script is included as an
example of patch file and the need for a blfs bootscript.
EXAMPLES
Other examples can be found in custom/examples. They are dated and
unmaintained, but can be useful for creating your own scripts.
example of multiple patch files and the need for a blfs bootscript.
#--------- GLIB example -----------
@ -173,6 +175,7 @@ for i in PATCH{1..10}; do
done
# Patches are named PATCH[1..10]
# This information is used to download the patch only
# If you do not have the MD5SUM the download will proceed with a warning.
PATCH1="http://www.linuxfromscratch.org/patches/blfs/svn/glib-1.2.10-gcc34-1.patch 0077a1cce5e8a2231ac5a9b08c6263ba"
@ -197,12 +200,14 @@ xEOFx
PKG="gpm"
PKG_VERSION="1.20.1"
PKG_FILE="gpm-1.20.1.tar.bz2"
PKG_FILE="gmp-1.20.1.tar.bz2"
URL="ftp://arcana.linux.it/pub/gpm/gpm-1.20.1.tar.bz2"
MD5="2c63e827d755527950d9d13fe3d87692"
for i in PATCH{1..10}; do
unset $i
done
# MD5SUM is not absolutely necessary but JHALFS whines and complains
# Add the MD5SUM if you can
PATCH1=" http://www.linuxfromscratch.org/patches/blfs/svn/gpm-1.20.1-segfault-1.patch"
PATCH2=" http://www.linuxfromscratch.org/patches/blfs/svn/gpm-1.20.1-silent-1.patch"
@ -260,3 +265,4 @@ echo "JUST A USELESS TRACE"
xEOFx
) > tmp

11
README.HLFS Normal file
View file

@ -0,0 +1,11 @@
$Id$
::::NOTICE::::
Hardened Linux From Scratch is a highly volatile project. Extreme design
changes can occur and the build could be broken for extended periods of
time.
As of July 26.2007, the Glibc-based systems builds should work.
uClibc-based system still fail due book issues.

View file

@ -1,87 +0,0 @@
TITLE : Package management in jhalfs
BY : Pierre Labastie (work in progress)
1. INTRODUCTION:
There are several hints discussing package management for LFS, but
nothing under jhalfs. There used to be a patch for PACO that I cannot
find now. So there was a need for such a tool, and an infrastructure,
which allows using a package manager inside jhalfs, has been developped.
I hope it is flexible enough to support several package managers, at least
among those who use DESTDIR install and/or LD_PRELOAD during install.
It has been tested with dpkg from Debian, pacman from Arch Linux,
and porg. Sample configuration files are given for those three packages.
I am sorry to say I have (almost) no experience with rpm, so I cannot
tell whether it would fit.
2. OVERVIEW OF THE SYSTEM:
For now, package management is only available for LFS. The `porg style'
(see below) package management has been ported to BLFS, but not the distro
style one (the book layout makes it rather difficult).
This tool comes in two flavours:
- for distros package managers (e.g dpkg or pacman), it basically performs
a "DESTDIR install" for all pages in chapter 8, 9 and 10 of the book. The
name of the DESTDIR directory is the same as the one of the executed
script. The path to this directory is available to the scriplets through
the PKG_DEST variable. The details of the DESTDIR part are given below.
After the package is installed in $PKG_DEST, a function "packInstall" is
called, which is supposed to create a binary package (e.g. make a .deb
file), store it to a repository and install it to the system.
- for porg style package manager, the install instructions are wrapped
between pairs of single quotes ('). This allows passing those instructions
to a function ("wrapInstall"), which may itself call porg or another
(e.g. fakeroot, not tested) instruction wrapper. Note that if the
instructions contain single quote charaters, they are changed to '\'',
which pass them literally. At the end of the installation, a function
"packInstall" is called, with a slighly different aim compared to the
DESTDIR one: it is used to make a tarball of the installed files (e.g.
using "porgball") and store them into some repository. But there is no
need to install them to the system, since this has already been done.
Note that with carefully crafted "packInstall" and "wrapInstall"
functions, a combination of the two methods could be used, for example for
DESTDIR installs using fakeroot. This is work in progress and not fully
implemented yet (well... Closer to a wish list actually).
3. DETAILS:
The XSL stylesheet used for generating the scriptlets, automatically
adds DESTDIR install instructions when "package management" is selected.
Also all the paths beginning with " /" or ">/" (absolute paths) are prepended
with $PKG_DEST. This has the default that you might want to move
files to non existent directories. There is no simple way to automatically
create those directories, because you have sometimes to use the full path
(instructions of the form `cp file dir') and sometimes only the dirname
(instructions of the form `cp file1 file2'). So the XSL stylesheet
creates a reasonable subset of the FHS hierarchy into the destination
directory. Empty directories are then removed before packing the
binary package.
In order to use the package manager, it has to be installed at the end of
chapter 7 (temporary installation) and chapter 8 (final install).
Furthermore, the administrative files and directories have to be created
during the `Creating Directories' and `Creating Essential Files' stages.
For all this, the user has to supply a file in docbook XML format, with
the necessary instructions and enough information to download the tarball.
This file should reside in the `pkgmngt' directory and be named
`packageManager.xml'. A template named `packageManager.xml.template' is
provided in the `pkgmngt' subdirectory. There are also three XML files for
dpkg, pacman, and porg, respectively `packageManager.xml.dpkg',
`packageManager.xml.pacman', and `packageManager.xml.porg', that you can
copy to `packageManager.xml' and modify to suit your needs.
They are not updated often, so the versions used can be rather old.
The last thing to do is to tell how to use the package manager. The user
has to provide two functions, "wrapInstall" and "packInstall", as described
above. Please note that nothing has been done to manage configuration files,
which are ususally treated specially by package managers: depending on
the book layout, it is sometimes possible to create those files afterwards,
and sometimes not, which means that you have to check them after each
upgrade. Both functions should be defined in a file named `packInstall.sh',
residing in the `pkgmngt' directory. A template is provided (actually a copy
of the file for dpkg), as well as three example scripts for dpkg, pacman,
and porg. Pacman Note: due to the way pacman checks the available space on
disk, the root directory in chroot must be a mount point, otherwise the
installation of packages fails.

18
TODO
View file

@ -1,6 +1,20 @@
jhalfs TODO
---------------
Remove RUN_ICA (it is redundant with COMPARE)
MASTER SCRIPT
-------------
- Nothing for now.
xLFS MODULES
------------
- To develop a new "restart" Makefile target code to can resume an stopped build
after a host reboot, if possible.
BLFS MODULE (See BLFS/TODO)
-----------
@ -8,4 +22,4 @@ BLFS MODULE (See BLFS/TODO)
OTHERS
------
- Bugs hunting and code clean-up.
- Bugs haunting and code clean-up.

406
XSL/blfs-tool.xsl Normal file
View file

@ -0,0 +1,406 @@
<?xml version="1.0"?>
<!-- $Id$ -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:exsl="http://exslt.org/common"
extension-element-prefixes="exsl"
version="1.0">
<!-- Create blfs-tool dependencies scripts -->
<xsl:template name="blfs-tool">
<!-- Fixed directory and ch_order values -->
<xsl:variable name="basedir">blfs-tool-deps/30_</xsl:variable>
<!-- libxml2 -->
<exsl:document href="{$basedir}01-libxml2" method="text">
<xsl:call-template name="header"/>
<xsl:text>
PKG_PHASE=libxml2
PACKAGE=libxml2
VERSION=2.6.29
TARBALL=libxml2-2.6.29.tar.gz
DOWNLOAD=ftp://xmlsoft.org/libxml2/libxml2-2.6.29.tar.gz
MD5SUM=8b99b6e8b08e838438d9e6b639d79ebd
</xsl:text>
<xsl:call-template name="disk_usage"/>
<xsl:call-template name="unpack"/>
<xsl:text>
cd $PKGDIR
./configure --prefix=/usr
make
make install
</xsl:text>
<xsl:call-template name="disk_usage"/>
<xsl:call-template name="clean_sources"/>
<xsl:call-template name="footer"/>
</exsl:document>
<!-- libxslt -->
<exsl:document href="{$basedir}02-libxslt" method="text">
<xsl:call-template name="header"/>
<xsl:text>
PKG_PHASE=libxslt
PACKAGE=libxslt
VERSION=1.1.21
TARBALL=libxslt-1.1.21.tar.gz
DOWNLOAD=ftp://xmlsoft.org/libxslt/libxslt-1.1.21.tar.gz
MD5SUM=59fe34e85692f71df2a38c2ee291b3ca
</xsl:text>
<xsl:call-template name="disk_usage"/>
<xsl:call-template name="unpack"/>
<xsl:text>
cd $PKGDIR
./configure --prefix=/usr
make
make install
</xsl:text>
<xsl:call-template name="disk_usage"/>
<xsl:call-template name="clean_sources"/>
<xsl:call-template name="footer"/>
</exsl:document>
<!-- tidy -->
<exsl:document href="{$basedir}03-tidy" method="text">
<xsl:call-template name="header"/>
<xsl:text>
PKG_PHASE=html-tidy
PACKAGE=tidy
VERSION=cvs_20070326
TARBALL=tidy-cvs_20070326.tar.bz2
DOWNLOAD=http://anduin.linuxfromscratch.org/files/BLFS/sources/tidy-cvs_20070326
MD5SUM=468bfaa5cf917a8ecbe7834c13a61376
</xsl:text>
<xsl:call-template name="disk_usage"/>
<xsl:call-template name="unpack"/>
<xsl:text>
cd $PKGDIR
./configure --prefix=/usr
make
make install
make -C htmldoc install_apidocs
</xsl:text>
<xsl:call-template name="disk_usage"/>
<xsl:call-template name="clean_sources"/>
<xsl:call-template name="footer"/>
</exsl:document>
<!-- unzip -->
<exsl:document href="{$basedir}04-unzip" method="text">
<xsl:call-template name="header"/>
<xsl:text>
PKG_PHASE=unzip
PACKAGE=unzip
VERSION=552
TARBALL=unzip552.tar.gz
DOWNLOAD=http://downloads.sourceforge.net/infozip/unzip552.tar.gz
MD5SUM=9d23919999d6eac9217d1f41472034a9
PATCH="http://www.linuxfromscratch.org/patches/blfs/svn/unzip-5.52-security_fix-1.patch 00ebf64fdda2ad54ddfc619f85f328bb"
</xsl:text>
<xsl:call-template name="disk_usage"/>
<xsl:call-template name="unpack"/>
<xsl:text>
cd $PKGDIR
patch -Np1 -i ../unzip-5.52-security_fix-1.patch
make -f unix/Makefile LOCAL_UNZIP=-D_FILE_OFFSET_BITS=64 linux
make prefix=/usr install
</xsl:text>
<xsl:call-template name="disk_usage"/>
<xsl:call-template name="clean_sources"/>
<xsl:call-template name="footer"/>
</exsl:document>
<!-- DocBook XML DTD -->
<exsl:document href="{$basedir}05-docbook-xml" method="text">
<xsl:call-template name="header"/>
<xsl:text>
PKG_PHASE=DocBook
PACKAGE=docbook-xml
VERSION=4.5
TARBALL=docbook-xml-4.5.zip
DOWNLOAD=http://www.docbook.org/xml/4.5/docbook-xml-4.5.zip
MD5SUM=03083e288e87a7e829e437358da7ef9e
</xsl:text>
<xsl:call-template name="disk_usage"/>
<xsl:text>
cd /sources
mkdir docbook-xml
cd docbook-xml
unzip ../docbook-xml-4.5.zip
SECONDS=0
install -v -d -m755 /usr/share/xml/docbook/xml-dtd-4.5
install -v -d -m755 /etc/xml
chown -R root:root .
cp -v -af docbook.cat *.dtd ent/ *.mod \
/usr/share/xml/docbook/xml-dtd-4.5
if [ ! -e /etc/xml/docbook ]; then
xmlcatalog --noout --create /etc/xml/docbook
fi
xmlcatalog --noout --add "public" \
"-//OASIS//DTD DocBook XML V4.5//EN" \
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" \
/etc/xml/docbook
xmlcatalog --noout --add "public" \
"-//OASIS//DTD DocBook XML CALS Table Model V4.5//EN" \
"file:///usr/share/xml/docbook/xml-dtd-4.5/calstblx.dtd" \
/etc/xml/docbook
xmlcatalog --noout --add "public" \
"-//OASIS//DTD XML Exchange Table Model 19990315//EN" \
"file:///usr/share/xml/docbook/xml-dtd-4.5/soextblx.dtd" \
/etc/xml/docbook
xmlcatalog --noout --add "public" \
"-//OASIS//ELEMENTS DocBook XML Information Pool V4.5//EN" \
"file:///usr/share/xml/docbook/xml-dtd-4.5/dbpoolx.mod" \
/etc/xml/docbook
xmlcatalog --noout --add "public" \
"-//OASIS//ELEMENTS DocBook XML Document Hierarchy V4.5//EN" \
"file:///usr/share/xml/docbook/xml-dtd-4.5/dbhierx.mod" \
/etc/xml/docbook
xmlcatalog --noout --add "public" \
"-//OASIS//ELEMENTS DocBook XML HTML Tables V4.5//EN" \
"file:///usr/share/xml/docbook/xml-dtd-4.5/htmltblx.mod" \
/etc/xml/docbook
xmlcatalog --noout --add "public" \
"-//OASIS//ENTITIES DocBook XML Notations V4.5//EN" \
"file:///usr/share/xml/docbook/xml-dtd-4.5/dbnotnx.mod" \
/etc/xml/docbook
xmlcatalog --noout --add "public" \
"-//OASIS//ENTITIES DocBook XML Character Entities V4.5//EN" \
"file:///usr/share/xml/docbook/xml-dtd-4.5/dbcentx.mod" \
/etc/xml/docbook
xmlcatalog --noout --add "public" \
"-//OASIS//ENTITIES DocBook XML Additional General Entities V4.5//EN" \
"file:///usr/share/xml/docbook/xml-dtd-4.5/dbgenent.mod" \
/etc/xml/docbook
xmlcatalog --noout --add "rewriteSystem" \
"http://www.oasis-open.org/docbook/xml/4.5" \
"file:///usr/share/xml/docbook/xml-dtd-4.5" \
/etc/xml/docbook
xmlcatalog --noout --add "rewriteURI" \
"http://www.oasis-open.org/docbook/xml/4.5" \
"file:///usr/share/xml/docbook/xml-dtd-4.5" \
/etc/xml/docbook
if [ ! -e /etc/xml/catalog ]; then
xmlcatalog --noout --create /etc/xml/catalog
fi
xmlcatalog --noout --add "delegatePublic" \
"-//OASIS//ENTITIES DocBook XML" \
"file:///etc/xml/docbook" \
/etc/xml/catalog
xmlcatalog --noout --add "delegatePublic" \
"-//OASIS//DTD DocBook XML" \
"file:///etc/xml/docbook" \
/etc/xml/catalog
xmlcatalog --noout --add "delegateSystem" \
"http://www.oasis-open.org/docbook/" \
"file:///etc/xml/docbook" \
/etc/xml/catalog
xmlcatalog --noout --add "delegateURI" \
"http://www.oasis-open.org/docbook/" \
"file:///etc/xml/docbook" \
/etc/xml/catalog
for DTDVERSION in 4.1.2 4.2 4.3 4.4
do
xmlcatalog --noout --add "public" \
"-//OASIS//DTD DocBook XML V$DTDVERSION//EN" \
"http://www.oasis-open.org/docbook/xml/$DTDVERSION/docbookx.dtd" \
/etc/xml/docbook
xmlcatalog --noout --add "rewriteSystem" \
"http://www.oasis-open.org/docbook/xml/$DTDVERSION" \
"file:///usr/share/xml/docbook/xml-dtd-4.5" \
/etc/xml/docbook
xmlcatalog --noout --add "rewriteURI" \
"http://www.oasis-open.org/docbook/xml/$DTDVERSION" \
"file:///usr/share/xml/docbook/xml-dtd-4.5" \
/etc/xml/docbook
xmlcatalog --noout --add "delegateSystem" \
"http://www.oasis-open.org/docbook/xml/$DTDVERSION/" \
"file:///etc/xml/docbook" \
/etc/xml/catalog
xmlcatalog --noout --add "delegateURI" \
"http://www.oasis-open.org/docbook/xml/$DTDVERSION/" \
"file:///etc/xml/docbook" \
/etc/xml/catalog
done
</xsl:text>
<xsl:call-template name="disk_usage"/>
<xsl:text>
SECS=$SECONDS
cd /sources
rm -rf docbook-xml
SECONDS=$SECS
</xsl:text>
<xsl:call-template name="footer"/>
</exsl:document>
<!-- DocBook XSL (empty and commented-out, it's not required for now) -->
<!--<exsl:document href="{$basedir}06-docbook-xsl" method="text">
<xsl:call-template name="header"/>
<xsl:text>
PKG_PHASE=docbook-xsl
PACKAGE=docbook-xsl
VERSION=
TARBALL=
DOWNLOAD=
MD5SUM=
</xsl:text>
<xsl:call-template name="disk_usage"/>
<xsl:call-template name="unpack"/>
<xsl:text>
cd $PKGDIR
</xsl:text>
<xsl:call-template name="disk_usage"/>
<xsl:call-template name="clean_sources"/>
<xsl:call-template name="footer"/>
</exsl:document>-->
<!-- gpm -->
<exsl:document href="{$basedir}07-gpm" method="text">
<xsl:call-template name="header"/>
<xsl:text>
PKG_PHASE=gpm
PACKAGE=gpm
VERSION=1.20.1
TARBALL=gpm-1.20.1.tar.bz2
DOWNLOAD=ftp://ftp.linux.ee/pub/gentoo/distfiles/distfiles/gpm-1.20.1.tar.bz2
MD5SUM=2c63e827d755527950d9d13fe3d87692
PATCH="http://www.linuxfromscratch.org/patches/blfs/svn/gpm-1.20.1-segfault-1.patch 8c88f92990ba7613014fcd1db14ca7ac"
PATCH="http://www.linuxfromscratch.org/patches/blfs/svn/gpm-1.20.1-silent-1.patch bf6cbefe20c6f15b587f19ebc1c8a37a"
</xsl:text>
<xsl:call-template name="disk_usage"/>
<xsl:call-template name="unpack"/>
<xsl:text>
cd $PKGDIR
patch -Np1 -i ../gpm-1.20.1-segfault-1.patch
patch -Np1 -i ../gpm-1.20.1-silent-1.patch
./configure --prefix=/usr --sysconfdir=/etc
LDFLAGS="$LDFLAGS -lm" make
make install
cp -v conf/gpm-root.conf /etc
ldconfig
</xsl:text>
<xsl:call-template name="disk_usage"/>
<xsl:call-template name="clean_sources"/>
<xsl:call-template name="footer"/>
</exsl:document>
<!-- lynx -->
<exsl:document href="{$basedir}08-lynx" method="text">
<xsl:call-template name="header"/>
<xsl:text>
PKG_PHASE=lynx
PACKAGE=lynx
VERSION=2.8.6
TARBALL=lynx2.8.6.tar.bz2
DOWNLOAD=http://lynx.isc.org/release/lynx2.8.6.tar.bz2
MD5SUM=dc80497b7dda6a28fd80404684d27548
</xsl:text>
<xsl:call-template name="disk_usage"/>
<xsl:call-template name="unpack"/>
<xsl:text>
cd $PKGDIR
./configure --prefix=/usr \
--sysconfdir=/etc/lynx \
--datadir=/usr/share/doc/lynx-2.8.6 \
--with-zlib \
--with-bzlib \
--with-screen=ncursesw \
--enable-locale-charset
make
make install-full
chgrp -v -R root /usr/share/doc/lynx-2.8.6/lynx_doc
</xsl:text>
<xsl:call-template name="disk_usage"/>
<xsl:call-template name="clean_sources"/>
<xsl:call-template name="footer"/>
</exsl:document>
<!-- sudo -->
<exsl:document href="{$basedir}09-sudo" method="text">
<xsl:call-template name="header"/>
<xsl:text>
PKG_PHASE=sudo
PACKAGE=sudo
VERSION=1.6.8p12
TARBALL=sudo-1.6.8p12.tar.gz
DOWNLOAD=http://anduin.linuxfromscratch.org/sources/BLFS/svn/s/sudo-1.6.8p12.tar.gz
MD5SUM=b29893c06192df6230dd5f340f3badf5
PATCH="http://www.linuxfromscratch.org/patches/blfs/svn/sudo-1.6.8p12-envvar_fix-1.patch 454925aedfe054dff8fe0d03b209f986"
</xsl:text>
<xsl:call-template name="disk_usage"/>
<xsl:call-template name="unpack"/>
<xsl:text>
cd $PKGDIR
patch -Np1 -i ../sudo-1.6.8p12-envvar_fix-1.patch
./configure --prefix=/usr --libexecdir=/usr/lib \
--enable-noargs-shell --with-ignore-dot --with-all-insults \
--enable-shell-sets-home
make
make install
</xsl:text>
<xsl:call-template name="disk_usage"/>
<xsl:call-template name="clean_sources"/>
<xsl:call-template name="footer"/>
</exsl:document>
<!-- wget -->
<exsl:document href="{$basedir}10-wget" method="text">
<xsl:call-template name="header"/>
<xsl:text>
PKG_PHASE=wget
PACKAGE=wget
VERSION=1.10.2
TARBALL=wget-1.10.2.tar.gz
DOWNLOAD=ftp://ftp.gnu.org/gnu/wget/wget-1.10.2.tar.gz
MD5SUM=795fefbb7099f93e2d346b026785c4b8
</xsl:text>
<xsl:call-template name="disk_usage"/>
<xsl:call-template name="unpack"/>
<xsl:text>
cd $PKGDIR
./configure --prefix=/usr --sysconfdir=/etc
make
make install
</xsl:text>
<xsl:call-template name="disk_usage"/>
<xsl:call-template name="clean_sources"/>
<xsl:call-template name="footer"/>
</exsl:document>
<!-- subversion -->
<exsl:document href="{$basedir}11-subversion" method="text">
<xsl:call-template name="header"/>
<xsl:text>
PKG_PHASE=subversion
PACKAGE=subversion
VERSION=1.3.1
TARBALL=subversion-1.3.1.tar.bz2
DOWNLOAD=http://subversion.tigris.org/tarballs/subversion-1.3.1.tar.bz2
MD5SUM=07b95963968ae345541ca99d0e7bf082
</xsl:text>
<xsl:call-template name="disk_usage"/>
<xsl:call-template name="unpack"/>
<xsl:text>
cd $PKGDIR
./configure --prefix=/usr \
--without-berkeley-db \
--with-installbuilddir=/usr/lib/apr-0
make
make install
rm doc/{Makefile,doxygen.conf}
find doc -type d -exec chmod 755 {} \;
find doc -type f -exec chmod 644 {} \;
install -v -m755 -d /usr/share/doc/subversion-1.3.1
cp -v -R doc/* /usr/share/doc/subversion-1.3.1
</xsl:text>
<xsl:call-template name="disk_usage"/>
<xsl:call-template name="clean_sources"/>
<xsl:call-template name="footer"/>
</exsl:document>
</xsl:template>
</xsl:stylesheet>

47
XSL/custom-tools.xsl Normal file
View file

@ -0,0 +1,47 @@
<?xml version="1.0"?>
<!-- $Id$ -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:exsl="http://exslt.org/common"
extension-element-prefixes="exsl"
version="1.0">
<!-- Create a custom tools directory containing scripts
to be run after the base system has been built -->
<!-- See blfs-tool.xsl for exsl:document examples -->
<xsl:template name="custom-tools">
<!-- Fixed directory and ch_order values -->
<xsl:variable name="basedir">custom-tools/20_</xsl:variable>
<!-- Add an exsl:document block for each script to be created.
This one is only a dummy example. You must replace "01" by
the proper build order and "dummy" by the script name -->
<exsl:document href="{$basedir}01-dummy" method="text">
<xsl:call-template name="header"/>
<xsl:text>
PKG_PHASE=dummy
PACKAGE=dummy
VERSION=0.0.0
TARBALL=dummy-0.0.0.tar.bz2
DOWNLOAD=http://www.example.com/sources/dummy-0.0.0.tar.bz2
MD5SUM=b0c2f10c23b1d529725c8f9c693858cf
PATCH="http://www.example.com/sources/dummy-0.0.0.fix1.patch 65c913efccffda4b9dc66e9002e8516e"
PATCH="http://www.example.com/sources/dummy-0.0.0.fix2.patch fb411aae8d1eb8a733bb1def9266f2ba"
</xsl:text>
<xsl:call-template name="disk_usage"/>
<xsl:call-template name="unpack"/>
<xsl:text>
cd $PKGDIR
./configure --prefix=/usr
make
make install
</xsl:text>
<xsl:call-template name="disk_usage"/>
<xsl:call-template name="clean_sources"/>
<xsl:call-template name="footer"/>
</exsl:document>
</xsl:template>
</xsl:stylesheet>

485
XSL/optimize.xsl Normal file
View file

@ -0,0 +1,485 @@
<?xml version="1.0"?>
<!-- $Id$ -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<!-- ####################### PARAMETERS ################################### -->
<!-- ###### MAKEFLAGS ###### -->
<!-- Should MAKEFLAGS be set? y = yes, n = no -->
<xsl:param name="set_makeflags">y</xsl:param>
<!-- Jobs control level. Left it empty for no jobs control -->
<xsl:param name="jobs">-j3</xsl:param>
<!-- Jobs control black-listed packages. One in each line.
NOTE: This and other similar parameters uses the PKG_PHASE value -->
<xsl:param name="no_jobs">
keep_this_line
autoconf
dejagnu
gettext
groff
man-db
keep_this_line
</xsl:param>
<!-- Additional make flags. -->
<xsl:param name="makeflags"></xsl:param>
<!-- Additional make flags black-listed packages. One in each line. -->
<xsl:param name="no_mkflags">
keep_this_line
keep_this_line
</xsl:param>
<!-- ############################ -->
<!-- ###### COMPILER FLAGS ###### -->
<!-- Should compiler envars be set? y = yes, n = no -->
<xsl:param name="set_buildflags">y</xsl:param>
<!-- Compiler optimizations black-listed packages. One in each line. -->
<xsl:param name="no_buildflags">
keep_this_line
binutils
binutils-pass1
binutils-pass2
gcc
gcc-pass1
gcc-pass2
glibc
grub
keep_this_line
</xsl:param>
<!-- Default envars setting. Left empty to not set a variable. -->
<!-- Default CFLAGS -->
<xsl:param name="cflags">-O3 -pipe</xsl:param>
<!-- Default CXXFLAGS -->
<xsl:param name="cxxflags">$CFLAGS</xsl:param>
<!-- Default OTHER_CFLAGS -->
<xsl:param name="other_cflags">$CFLAGS</xsl:param>
<!-- Default OTHER_CXXFLAGS -->
<xsl:param name="other_cxxflags">$CXXFLAGS</xsl:param>
<!-- Default LDFLAGS -->
<xsl:param name="ldflags"></xsl:param>
<!-- Default OTHER_LDFLAGS -->
<xsl:param name="other_ldflags"></xsl:param>
<!-- -->
<!-- By-package additional settings. A pair "package value" on each line.
The values set here will be added to the ones set above -->
<!-- Extra CFLAGS -->
<xsl:param name="extra_cflags">
zlib -fPIC
</xsl:param>
<!-- Extra CXXFLAGS -->
<xsl:param name="extra_cxxflags">
</xsl:param>
<!-- Extra OTHER_CFLAGS -->
<xsl:param name="extra_other_cflags">
</xsl:param>
<!-- Extra OTHER_CXXFLAGS -->
<xsl:param name="extra_other_cxxflags">
</xsl:param>
<!-- Extra LDFLAGS -->
<xsl:param name="extra_ldflags">
</xsl:param>
<!-- Extra OTHER_LDFLAGS -->
<xsl:param name="extra_other_ldflags">
</xsl:param>
<!-- -->
<!-- By-package settings. A pair "package value" on each line.
The values set here will override the ones set above -->
<!-- Extra CFLAGS -->
<xsl:param name="override_cflags">
</xsl:param>
<!-- Extra CXXFLAGS -->
<xsl:param name="override_cxxflags">
</xsl:param>
<!-- Extra OTHER_CFLAGS -->
<xsl:param name="override_other_cflags">
</xsl:param>
<!-- Extra OTHER_CXXFLAGS -->
<xsl:param name="override_other_cxxflags">
</xsl:param>
<!-- Extra LDFLAGS -->
<xsl:param name="override_ldflags">
</xsl:param>
<!-- Extra OTHER_LDFLAGS -->
<xsl:param name="override_other_ldflags">
</xsl:param>
<!-- ######################################################################## -->
<!-- ########################### NAMED TEMPLATES ########################### -->
<!-- Master optimizations template -->
<xsl:template name="optimize">
<xsl:param name="package" select="foo"/>
<xsl:text>&#xA;&#xA;</xsl:text>
<xsl:if test="$set_makeflags = 'y'">
<xsl:call-template name="makeflags">
<xsl:with-param name="package" select="$package"/>
</xsl:call-template>
</xsl:if>
<xsl:if test="$set_buildflags = 'y' and
not(contains(normalize-space($no_buildflags),concat(' ',$package,' ')))">
<xsl:call-template name="buildflags">
<xsl:with-param name="package" select="$package"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
<!-- MAKEFLAGS template -->
<xsl:template name="makeflags">
<xsl:param name="package" select="foo"/>
<!-- Test if jobs control must be set -->
<xsl:variable name="set_jobs">
<xsl:if test="$jobs != '' and
not(contains(normalize-space($no_jobs),concat(' ',$package,' ')))">1</xsl:if>
</xsl:variable>
<!-- Test if additional make flags must be set -->
<xsl:variable name="add_mkflags">
<xsl:if test="$makeflags != '' and
not(contains(normalize-space($no_mkflags),concat(' ',$package,' ')))">1</xsl:if>
</xsl:variable>
<!-- Write the envar -->
<xsl:if test="$set_jobs = '1' or $add_mkflags = '1'">
<xsl:text>MAKEFLAGS="</xsl:text>
<!-- Write jobs control value -->
<xsl:if test="$set_jobs = '1'">
<xsl:value-of select="$jobs"/>
</xsl:if>
<!-- If both values will be written, be sure that are space separated -->
<xsl:if test="$set_jobs = '1' and $add_mkflags = '1'">
<xsl:text> </xsl:text>
</xsl:if>
<!-- Write additional make flags value -->
<xsl:if test="$add_mkflags = '1'">
<xsl:value-of select="$makeflags"/>
</xsl:if>
<xsl:text>"&#xA;</xsl:text>
</xsl:if>
</xsl:template>
<!-- Master compiler flags template -->
<xsl:template name="buildflags">
<xsl:param name="package" select="foo"/>
<xsl:if test="$cflags != ''">
<xsl:call-template name="cflags">
<xsl:with-param name="package" select="$package"/>
</xsl:call-template>
</xsl:if>
<xsl:if test="$cxxflags != ''">
<xsl:call-template name="cxxflags">
<xsl:with-param name="package" select="$package"/>
</xsl:call-template>
</xsl:if>
<xsl:if test="$other_cflags != ''">
<xsl:call-template name="other_cflags">
<xsl:with-param name="package" select="$package"/>
</xsl:call-template>
</xsl:if>
<xsl:if test="$other_cxxflags != ''">
<xsl:call-template name="other_cxxflags">
<xsl:with-param name="package" select="$package"/>
</xsl:call-template>
</xsl:if>
<xsl:if test="$ldflags != ''">
<xsl:call-template name="ldflags">
<xsl:with-param name="package" select="$package"/>
</xsl:call-template>
</xsl:if>
<xsl:if test="$other_ldflags != ''">
<xsl:call-template name="other_ldflags">
<xsl:with-param name="package" select="$package"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
<!-- CFLAGS template -->
<xsl:template name="cflags">
<xsl:param name="package" select="foo"/>
<!-- Find the override value, if any -->
<xsl:variable name="override">
<xsl:call-template name="lookup.key">
<xsl:with-param name="key" select="$package"/>
<xsl:with-param name="table" select="normalize-space($override_cflags)"/>
</xsl:call-template>
</xsl:variable>
<!-- Find the extra settings, if any -->
<xsl:variable name="extra">
<xsl:call-template name="lookup.key">
<xsl:with-param name="key" select="$package"/>
<xsl:with-param name="table" select="normalize-space($extra_cflags)"/>
</xsl:call-template>
</xsl:variable>
<!-- Writte the envar -->
<xsl:text>CFLAGS="</xsl:text>
<xsl:choose>
<xsl:when test="$override != ''">
<xsl:value-of select="$override"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$cflags"/>
<xsl:if test="$extra != ''">
<xsl:value-of select="concat(' ',$extra)"/>
</xsl:if>
</xsl:otherwise>
</xsl:choose>
<xsl:text>"&#xA;</xsl:text>
</xsl:template>
<!-- CXXFLAGS template -->
<xsl:template name="cxxflags">
<xsl:param name="package" select="foo"/>
<!-- Find the override value, if any -->
<xsl:variable name="override">
<xsl:call-template name="lookup.key">
<xsl:with-param name="key" select="$package"/>
<xsl:with-param name="table" select="normalize-space($override_cxxflags)"/>
</xsl:call-template>
</xsl:variable>
<!-- Find the extra settings, if any -->
<xsl:variable name="extra">
<xsl:call-template name="lookup.key">
<xsl:with-param name="key" select="$package"/>
<xsl:with-param name="table" select="normalize-space($extra_cxxflags)"/>
</xsl:call-template>
</xsl:variable>
<!-- Writte the envar -->
<xsl:text>CXXFLAGS="</xsl:text>
<xsl:choose>
<xsl:when test="$override != ''">
<xsl:value-of select="$override"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$cxxflags"/>
<xsl:if test="$extra != ''">
<xsl:value-of select="concat(' ',$extra)"/>
</xsl:if>
</xsl:otherwise>
</xsl:choose>
<xsl:text>"&#xA;</xsl:text>
</xsl:template>
<!-- OTHER_CFLAGS template -->
<xsl:template name="other_cflags">
<xsl:param name="package" select="foo"/>
<!-- Find the override value, if any -->
<xsl:variable name="override">
<xsl:call-template name="lookup.key">
<xsl:with-param name="key" select="$package"/>
<xsl:with-param name="table" select="normalize-space($override_other_cflags)"/>
</xsl:call-template>
</xsl:variable>
<!-- Find the extra settings, if any -->
<xsl:variable name="extra">
<xsl:call-template name="lookup.key">
<xsl:with-param name="key" select="$package"/>
<xsl:with-param name="table" select="normalize-space($extra_other_cflags)"/>
</xsl:call-template>
</xsl:variable>
<!-- Writte the envar -->
<xsl:text>OTHER_CFLAGS="</xsl:text>
<xsl:choose>
<xsl:when test="$override != ''">
<xsl:value-of select="$override"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$other_cflags"/>
<xsl:if test="$extra != ''">
<xsl:value-of select="concat(' ',$extra)"/>
</xsl:if>
</xsl:otherwise>
</xsl:choose>
<xsl:text>"&#xA;</xsl:text>
</xsl:template>
<!-- OTHER_CXXFLAGS template -->
<xsl:template name="other_cxxflags">
<xsl:param name="package" select="foo"/>
<!-- Find the override value, if any -->
<xsl:variable name="override">
<xsl:call-template name="lookup.key">
<xsl:with-param name="key" select="$package"/>
<xsl:with-param name="table" select="normalize-space($override_other_cxxflags)"/>
</xsl:call-template>
</xsl:variable>
<!-- Find the extra settings, if any -->
<xsl:variable name="extra">
<xsl:call-template name="lookup.key">
<xsl:with-param name="key" select="$package"/>
<xsl:with-param name="table" select="normalize-space($extra_other_cxxflags)"/>
</xsl:call-template>
</xsl:variable>
<!-- Writte the envar -->
<xsl:text>OTHER_CXXFLAGS="</xsl:text>
<xsl:choose>
<xsl:when test="$override != ''">
<xsl:value-of select="$override"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$other_cxxflags"/>
<xsl:if test="$extra != ''">
<xsl:value-of select="concat(' ',$extra)"/>
</xsl:if>
</xsl:otherwise>
</xsl:choose>
<xsl:text>"&#xA;</xsl:text>
</xsl:template>
<!-- LDFLAGS template -->
<xsl:template name="ldflags">
<xsl:param name="package" select="foo"/>
<!-- Find the override value, if any -->
<xsl:variable name="override">
<xsl:call-template name="lookup.key">
<xsl:with-param name="key" select="$package"/>
<xsl:with-param name="table" select="normalize-space($override_ldflags)"/>
</xsl:call-template>
</xsl:variable>
<!-- Find the extra settings, if any -->
<xsl:variable name="extra">
<xsl:call-template name="lookup.key">
<xsl:with-param name="key" select="$package"/>
<xsl:with-param name="table" select="normalize-space($extra_ldflags)"/>
</xsl:call-template>
</xsl:variable>
<!-- Writte the envar -->
<xsl:text>LDFLAGS="</xsl:text>
<xsl:choose>
<xsl:when test="$override != ''">
<xsl:value-of select="$override"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$ldflags"/>
<xsl:if test="$extra != ''">
<xsl:value-of select="concat(' ',$extra)"/>
</xsl:if>
</xsl:otherwise>
</xsl:choose>
<xsl:text>"&#xA;</xsl:text>
</xsl:template>
<!-- OTHER_LDFLAGS template -->
<xsl:template name="other_ldflags">
<xsl:param name="package" select="foo"/>
<!-- Find the override value, if any -->
<xsl:variable name="override">
<xsl:call-template name="lookup.key">
<xsl:with-param name="key" select="$package"/>
<xsl:with-param name="table" select="normalize-space($override_other_ldflags)"/>
</xsl:call-template>
</xsl:variable>
<!-- Find the extra settings, if any -->
<xsl:variable name="extra">
<xsl:call-template name="lookup.key">
<xsl:with-param name="key" select="$package"/>
<xsl:with-param name="table" select="normalize-space($extra_other_ldflags)"/>
</xsl:call-template>
</xsl:variable>
<!-- Writte the envar -->
<xsl:text>OTHER_LDFLAGS="</xsl:text>
<xsl:choose>
<xsl:when test="$override != ''">
<xsl:value-of select="$override"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$other_ldflags"/>
<xsl:if test="$extra != ''">
<xsl:value-of select="concat(' ',$extra)"/>
</xsl:if>
</xsl:otherwise>
</xsl:choose>
<xsl:text>"&#xA;</xsl:text>
</xsl:template>
<!-- Parses a table-like param finding a pair key-value.
Copied from DocBook-XSL -->
<xsl:template name="lookup.key">
<xsl:param name="key" select="''"/>
<xsl:param name="table" select="''"/>
<xsl:if test="contains($table, ' ')">
<xsl:choose>
<xsl:when test="substring-before($table, ' ') = $key">
<xsl:variable name="rest" select="substring-after($table, ' ')"/>
<xsl:choose>
<xsl:when test="contains($rest, ' ')">
<xsl:value-of select="substring-before($rest, ' ')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$rest"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="lookup.key">
<xsl:with-param name="key" select="$key"/>
<xsl:with-param name="table" select="substring-after(substring-after($table,' '), ' ')"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:template>
</xsl:stylesheet>

130
XSL/urls.xsl Normal file
View file

@ -0,0 +1,130 @@
<?xml version='1.0' encoding='ISO-8859-1'?>
<!-- $Id$ -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="text"/>
<!-- The FTP server used as fallback -->
<xsl:param name="server">ftp://ftp.osuosl.org</xsl:param>
<!-- The book family (lfs or clfs). Needed to use the proper FTP path. -->
<xsl:param name="family">lfs</xsl:param>
<!-- The libc model used for HLFS -->
<xsl:param name="model" select="glibc"/>
<!-- The kernel series used for HLFS -->
<xsl:param name="kernel" select="2.6"/>
<xsl:template match="/">
<xsl:apply-templates select="//ulink"/>
</xsl:template>
<xsl:template match="ulink">
<!-- If some package don't have the predefined strings in their
name, the next test must be fixed to match it also. Skip possible
duplicated URLs due that may be splitted for PDF output -->
<xsl:if test="(ancestor::varlistentry[@condition=$model]
or not(ancestor::varlistentry[@condition])) and
(ancestor::varlistentry[@vendor=$kernel]
or not(ancestor::varlistentry[@vendor])) and
(contains(@url, '.bz2') or contains(@url, '.tar.gz') or
contains(@url, '.tgz') or contains(@url, '.patch')) and
not(ancestor-or-self::*/@condition = 'pdf')">
<!-- Extract the package name -->
<xsl:variable name="package">
<xsl:call-template name="package.name">
<xsl:with-param name="url" select="@url"/>
</xsl:call-template>
</xsl:variable>
<!-- Extract the directory for that package -->
<xsl:variable name="cut"
select="translate(substring-after($package, '-'),
'0123456789', '0000000000')"/>
<xsl:variable name="package2">
<xsl:value-of select="substring-before($package, '-')"/>
<xsl:text>-</xsl:text>
<xsl:value-of select="$cut"/>
</xsl:variable>
<xsl:variable name="dirname" select="substring-before($package2, '-0')"/>
<!-- Write the upstream URLs, fixing the redirected ones -->
<xsl:choose>
<xsl:when test="contains(@url,'?')">
<xsl:value-of select="substring-before(@url,'?')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@url"/>
</xsl:otherwise>
</xsl:choose>
<xsl:text> </xsl:text>
<!-- Write FTP mirror URLs -->
<xsl:value-of select="$server"/>
<xsl:text>/pub/</xsl:text>
<xsl:value-of select="$family"/>
<xsl:text>/conglomeration/</xsl:text>
<xsl:choose>
<!-- Fix some directories. Test against $dirname to be sure that we
are matching the start of a package name, not a string in a patch name
But some packages requires test against $package. -->
<xsl:when test="contains($dirname, 'bash')">
<xsl:text>bash/</xsl:text>
</xsl:when>
<xsl:when test="contains($package, 'dvhtool')">
<xsl:text>dvhtool/</xsl:text>
</xsl:when>
<xsl:when test="contains($dirname, 'gcc')">
<xsl:text>gcc/</xsl:text>
</xsl:when>
<xsl:when test="contains($dirname, 'glibc')">
<xsl:text>glibc/</xsl:text>
</xsl:when>
<xsl:when test="contains($package, 'powerpc-utils')">
<xsl:text>powerpc-utils/</xsl:text>
</xsl:when>
<xsl:when test="contains($package, 'tcl')">
<xsl:text>tcl/</xsl:text>
</xsl:when>
<xsl:when test="contains($package, 'uClibc')">
<xsl:text>uClibc/</xsl:text>
</xsl:when>
<xsl:when test="contains($dirname, 'udev')">
<xsl:text>udev/</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$dirname"/>
<xsl:text>/</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:value-of select="$package"/>
<!-- Write MD5SUM value -->
<xsl:text> </xsl:text>
<xsl:value-of select="../..//para/literal"/>
<xsl:text>&#x0a;</xsl:text>
</xsl:if>
</xsl:template>
<xsl:template name="package.name">
<xsl:param name="url"/>
<xsl:choose>
<xsl:when test="contains($url, '/')">
<xsl:call-template name="package.name">
<xsl:with-param name="url" select="substring-after($url, '/')"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="contains($url, '?')">
<xsl:value-of select="substring-before($url, '?')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$url"/>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>

247
XSL/user.xsl Normal file
View file

@ -0,0 +1,247 @@
<?xml version="1.0"?>
<!-- $Id$ -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:exsl="http://exslt.org/common"
extension-element-prefixes="exsl"
version="1.0">
<!-- Base system build customization templates.
This is a collection of free non-book dependant templates that can be
used to customize the build scripts content, how each of the base system
packages is build, or to insert scripts into the system build flow.
Don't edit the templates directly here, this file is only for reference
and your changes will be lost if updating the jhalfs code.
Select what of them you need and place it into you customization layout.-->
<!-- ########## TEMPLATES TO INSERT CODE AND TO ADD EXTRA SCRIPTS ########## -->
<!-- Hock to insert extra code after the logs date timestamp dump and
before the envars settings -->
<xsl:template name="user_header">
<xsl:text>&#xA;</xsl:text>
</xsl:template>
<!-- Hock to add envars or extra commands after unpacking the tarball
but before cd into the sources dir -->
<xsl:template name="user_pre_commands">
<xsl:text>&#xA;</xsl:text>
</xsl:template>
<!-- Hock for commands additions after the book commands but before
removing sources dir -->
<xsl:template name="user_footer">
<xsl:text>&#xA;</xsl:text>
</xsl:template>
<!-- Hock for inserting scripts before a selected one -->
<xsl:template name="insert_script_before">
<!-- Inherited values -->
<xsl:param name="reference" select="foo"/>
<xsl:param name="order" select="foo"/>
<!-- Added a string to be sure that this scripts are run
before the selected one -->
<xsl:variable name="insert_order" select="concat($order,'_0')"/>
<!-- Add an xsl:if block for each referenced sect1 you want
to insert scripts before -->
<xsl:if test="$reference = 'ID_of_selected_sect1'">
<!-- Add an exsl:document block for each script to be inserted
at this point of the build. This one is only a dummy example. -->
<!-- See blfs-tool.xsl for exsl:document examples -->
<exsl:document href="{$insert_order}01-dummy" method="text">
<xsl:call-template name="header"/>
<xsl:text>
PKG_PHASE=dummy
PACKAGE=dummy
VERSION=0.0.0
TARBALL=dummy-0.0.0.tar.bz2
DOWNLOAD=http://www.example.com/sources/dummy-0.0.0.tar.bz2
MD5SUM=b0c2f10c23b1d529725c8f9c693858cf
PATCH="http://www.example.com/sources/dummy-0.0.0.fix1.patch 65c913efccffda4b9dc66e9002e8516e"
PATCH="http://www.example.com/sources/dummy-0.0.0.fix2.patch fb411aae8d1eb8a733bb1def9266f2ba"
</xsl:text>
<xsl:call-template name="disk_usage"/>
<xsl:call-template name="unpack"/>
<xsl:text>
cd $PKGDIR
./configure --prefix=/usr
make
make check
make install
</xsl:text>
<xsl:call-template name="disk_usage"/>
<xsl:call-template name="clean_sources"/>
<xsl:call-template name="footer"/>
</exsl:document>
</xsl:if>
</xsl:template>
<!-- Hock for inserting scripts after a selected one -->
<xsl:template name="insert_script_after">
<!-- Inherited values -->
<xsl:param name="reference" select="foo"/>
<xsl:param name="order" select="foo"/>
<!-- Added a string to be sure that this scripts are run
after the selected one -->
<xsl:variable name="insert_order" select="concat($order,'_z')"/>
<!-- Add an xsl:if block for each referenced sect1 you want
to insert scripts after -->
<xsl:if test="$reference = 'ID_of_selected_sect1'">
<!-- Add an exsl:document block for each script to be inserted
at this point of the build. This one is only a dummy example. -->
<!-- See blfs-tool.xsl for exsl:document examples -->
<exsl:document href="{$insert_order}01-dummy" method="text">
<xsl:call-template name="header"/>
<xsl:text>
PKG_PHASE=dummy
PACKAGE=dummy
VERSION=0.0.0
TARBALL=dummy-0.0.0.tar.bz2
DOWNLOAD=http://www.example.com/sources/dummy-0.0.0.tar.bz2
MD5SUM=b0c2f10c23b1d529725c8f9c693858cf
PATCH="http://www.example.com/sources/dummy-0.0.0.fix1.patch 65c913efccffda4b9dc66e9002e8516e"
PATCH="http://www.example.com/sources/dummy-0.0.0.fix2.patch fb411aae8d1eb8a733bb1def9266f2ba"
</xsl:text>
<xsl:call-template name="disk_usage"/>
<xsl:call-template name="unpack"/>
<xsl:text>
cd $PKGDIR
./configure --prefix=/usr
make
make check
make install
</xsl:text>
<xsl:call-template name="disk_usage"/>
<xsl:call-template name="clean_sources"/>
<xsl:call-template name="footer"/>
</exsl:document>
</xsl:if>
</xsl:template>
<!-- ######################################################################## -->
<!-- ########## TEMPLATES TO SELECT THE MODE USED ON SCREEN BLOCKS ########## -->
<!-- NOTE: Testsuites commands are handled on the master stylesheets -->
<!-- userinput @remap='pre' -->
<xsl:template match="userinput[@remap='pre']">
<xsl:apply-templates select="." mode="pre"/>
</xsl:template>
<!-- userinput @remap='configure' -->
<xsl:template match="userinput[@remap='configure']">
<xsl:apply-templates select="." mode="configure"/>
</xsl:template>
<!-- userinput @remap='make' -->
<xsl:template match="userinput[@remap='make']">
<xsl:apply-templates select="." mode="make"/>
</xsl:template>
<!-- userinput @remap='install' -->
<xsl:template match="userinput[@remap='install']">
<xsl:apply-templates select="." mode="install"/>
</xsl:template>
<!-- userinput @remap='adjust' -->
<xsl:template match="userinput[@remap='adjust']">
<xsl:apply-templates select="." mode="adjust"/>
</xsl:template>
<!-- userinput @remap='locale-full' -->
<xsl:template match="userinput[@remap='locale-full']">
<xsl:apply-templates select="." mode="locale-full"/>
</xsl:template>
<!-- userinput without @remap -->
<xsl:template match="userinput">
<xsl:choose>
<xsl:when test="ancestor::sect2[@role='configuration']">
<xsl:apply-templates select="." mode="configuration_section"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="." mode="no_remap"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- ######################################################################## -->
<!-- ############## STOCK MODE TEMPLATES USED ON SCREEN BLOCKS ############## -->
<!-- NOTE: You can use this modes or create you own ones -->
<!-- mode pre -->
<xsl:template match="userinput" mode="pre">
<xsl:apply-templates select="." mode="default"/>
</xsl:template>
<!-- mode configure -->
<xsl:template match="userinput" mode="configure">
<xsl:apply-templates select="." mode="default"/>
</xsl:template>
<!-- mode make -->
<xsl:template match="userinput" mode="make">
<xsl:apply-templates select="." mode="default"/>
</xsl:template>
<!-- mode install -->
<xsl:template match="userinput" mode="install">
<xsl:apply-templates select="." mode="default"/>
</xsl:template>
<!-- mode adjust -->
<xsl:template match="userinput" mode="adjust">
<xsl:apply-templates select="." mode="default"/>
</xsl:template>
<!-- mode locale-full -->
<xsl:template match="userinput" mode="locale-full">
<xsl:apply-templates select="." mode="default"/>
</xsl:template>
<!-- mode configuration_section -->
<xsl:template match="userinput" mode="configuration_section">
<xsl:apply-templates select="." mode="default"/>
</xsl:template>
<!-- mode no_remap -->
<xsl:template match="userinput" mode="no_remap">
<xsl:apply-templates select="." mode="default"/>
</xsl:template>
<!-- mode default -->
<xsl:template match="userinput" mode="default">
<xsl:apply-templates/>
</xsl:template>
</xsl:stylesheet>

182
blfs-tool Executable file
View file

@ -0,0 +1,182 @@
#!/bin/bash
# $Id$
set -e
# From common/common-functions
# VT100 colors
declare -r BLACK=$'\e[1;30m'
declare -r DK_GRAY=$'\e[0;30m'
declare -r RED=$'\e[31m'
declare -r GREEN=$'\e[32m'
declare -r YELLOW=$'\e[33m'
declare -r BLUE=$'\e[34m'
declare -r MAGENTA=$'\e[35m'
declare -r CYAN=$'\e[36m'
declare -r WHITE=$'\e[37m'
declare -r OFF=$'\e[0m'
declare -r BOLD=$'\e[1m'
declare -r REVERSE=$'\e[7m'
declare -r HIDDEN=$'\e[8m'
declare -r tab_=$'\t'
declare -r nl_=$'\n'
declare -r DD_BORDER="${BOLD}==============================================================================${OFF}"
declare -r SD_BORDER="${BOLD}------------------------------------------------------------------------------${OFF}"
declare -r STAR_BORDER="${BOLD}******************************************************************************${OFF}"
# bold yellow > < pair
declare -r R_arrow=$'\e[1;33m>\e[0m'
declare -r L_arrow=$'\e[1;33m<\e[0m'
#>>>>>>>>>>>>>>>ERROR TRAPPING >>>>>>>>>>>>>>>>>>>>
#-----------------------#
simple_error() { # Basic error trap.... JUST DIE
#-----------------------#
# If +e then disable text output
if [[ "$-" =~ e ]]; then
echo -e "\n${RED}ERROR:${GREEN} basic error trapped!${OFF}\n" >&2
fi
}
see_ya() {
echo -e "\n${L_arrow}${BOLD}jhalfs-X${R_arrow} exit${OFF}\n"
}
##### Simple error TRAPS
# ctrl-c SIGINT
# ctrl-y
# ctrl-z SIGTSTP
# SIGHUP 1 HANGUP
# SIGINT 2 INTRERRUPT FROM KEYBOARD Ctrl-C
# SIGQUIT 3
# SIGKILL 9 KILL
# SIGTERM 15 TERMINATION
# SIGSTOP 17,18,23 STOP THE PROCESS
#####
set -e
trap see_ya 0
trap simple_error ERR
trap 'echo -e "\n\n${RED}INTERRUPT${OFF} trapped\n" && exit 2' 1 2 3 15 17 18 23
#>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
# envars not sourced from configuration file
COMMON_DIR="common"
VERBOSITY=1
[[ $VERBOSITY > 0 ]] && echo -n "Loading config params from <configuration>..."
source configuration
[[ $? > 0 ]] && echo "file:configuration did not load.." && exit 1
[[ $VERBOSITY > 0 ]] && echo "OK"
[[ $VERBOSITY > 0 ]] && echo -n "Loading function <func_check_version.sh>..."
source $COMMON_DIR/libs/func_check_version.sh
[[ $? > 0 ]] && echo " function module did not load.." && exit 2
[[ $VERBOSITY > 0 ]] && echo "OK"
[[ $VERBOSITY > 0 ]] && echo -n "Loading function <func_validate_configs.sh>..."
source $COMMON_DIR/libs/func_validate_configs.sh
[[ $? > 0 ]] && echo " function module did not load.." && exit 2
[[ $VERBOSITY > 0 ]] && echo "OK"
[[ $VERBOSITY > 0 ]] && echo "${SD_BORDER}${nl_}"
# Be sure that we have a configuration file
[[ -z $BOOK_BLFS ]] && echo -e "\nNo BLFS configuration found. Please configure it." && exit 1
# Set default book version
BRANCH_ID=${BRANCH_ID:=development}
# Set the SVN tree
case $BRANCH_ID in
development ) TREE=trunk/BOOK ;;
*EDIT* ) echo " You forgot to set the branch or stable book version."
echo " Please rerun make and fix the configuration."
exit 2 ;;
branch-* ) TREE=branches/${BRANCH_ID#branch-} ;;
* ) TREE=tags/${BRANCH_ID} ;;
esac
# Check for minimun dependencies versions
xsltprocVer=`xsltproc -V | head -n1 `
libxmlVer=$(echo $xsltprocVer | cut -d " " -f3)
libxsltVer=$(echo $xsltprocVer | cut -d " " -f5)
tidyVer=`tidy -V | cut -d " " -f9`
# Version numbers are packed strings not xx.yy.zz format.
check_version "2.06.20" "${libxmlVer:0:1}.${libxmlVer:1:2}.${libxmlVer:3:2}" "LIBXML2"
check_version "1.01.14" "${libxsltVer:0:1}.${libxsltVer:1:2}.${libxsltVer:3:2}" "LIBXSLT"
check_version "2004" "${tidyVer}" "TIDY"
XML_FILE="<?xml version='1.0' encoding='ISO-8859-1'?>
<?xml-stylesheet type='text/xsl' href='http://docbook.sourceforge.net/release/xsl/1.69.1/xhtml/docbook.xsl'?>
<!DOCTYPE article PUBLIC '-//OASIS//DTD DocBook XML V4.5//EN'
'http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd'>
<article>
<title>Test file</title>
<sect1>
<title>Some title</title>
<para>Some text</para>
</sect1>
</article>"
if `echo $XML_FILE | xmllint -noout -postvalid - 2>/dev/null` ; then
check_version "4.5" "4.5" "DocBook XML DTD"
else
echo "Warning: not found a working DocBook XML DTD 4.5 installation"
exit 2
fi
# if `echo $XML_FILE | xsltproc --noout - 2>/dev/null` ; then
# check_version "1.69.1" "1.69.1" "DocBook XSL"
# else
# echo "Warning: not found a working DocBook XSL 1.69.1 installation"
# exit 2
# fi
echo "${SD_BORDER}${nl_}"
# For consistency with other books
validate_config
echo "${SD_BORDER}${nl_}"
echo -n "Are you happy with these settings? yes/no (no): "
read ANSWER
if [ x$ANSWER != "xyes" ] ; then
echo "${nl_}Rerun make to fix the configuration options.${nl_}"
exit 1
fi
echo "${nl_}${SD_BORDER}${nl_}"
# Install the files
[[ ! -d $BLFS_ROOT ]] && mkdir -p $BLFS_ROOT
cp -r BLFS/* $BLFS_ROOT
cp -r menu $BLFS_ROOT
cp $COMMON_DIR/progress_bar.sh $BLFS_ROOT
cp README.BLFS $BLFS_ROOT
# Start the work
cd $BLFS_ROOT
# Clean-up
rm -rf libs/.svn
rm -rf menu/.svn
rm -rf menu/lxdialog/.svn
# Set some harcoded envars to their proper values
sed -i 's,blfs-xml,'$BLFS_XML',' update_book.sh libs/book.xsl
sed -i 's,tracking-dir,'$TRACKING_DIR',' update_book.sh gen-makefile.sh
# Fetch book sources and create packages and meta-packages dependencies files
if [[ -d $BLFS_XML ]] ; then
./update_book.sh
else
./update_book.sh get $BLFS_XML $TREE
fi
# Run the menuconfig interface
make -B

View file

@ -1,97 +0,0 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:exsl="http://exslt.org/common"
extension-element-prefixes="exsl"
version="1.0">
<xsl:param name="jobs_2" select="1"/>
<xsl:template match="/">
<xsl:apply-templates select="//sect1"/>
</xsl:template>
<xsl:template match="sect1">
<xsl:if
test="descendant::screen/userinput[contains(string(),'&#xA;chroot') or
starts-with(string(),'chroot')]">
<!-- The file names -->
<xsl:variable name="pi-file" select="processing-instruction('dbhtml')"/>
<xsl:variable name="pi-file-value" select="substring-after($pi-file,'filename=')"/>
<xsl:variable name="filename" select="substring-before(substring($pi-file-value,2),'.html')"/>
<!-- The build order -->
<xsl:variable name="position" select="position()"/>
<xsl:variable name="order">
<xsl:choose>
<xsl:when test="string-length($position) = 1">
<xsl:text>00</xsl:text>
<xsl:value-of select="$position"/>
</xsl:when>
<xsl:when test="string-length($position) = 2">
<xsl:text>0</xsl:text>
<xsl:value-of select="$position"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$position"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- Creating dirs and files -->
<exsl:document href="{$order}-{$filename}" method="text">
<xsl:text>#!/bin/bash&#xA;</xsl:text>
<xsl:apply-templates
select=".//userinput[contains(string(),'&#xA;chroot') or
starts-with(string(),'chroot')]"/>
<xsl:text>exit&#xA;</xsl:text>
</exsl:document>
</xsl:if>
</xsl:template>
<xsl:template match="userinput">
<xsl:call-template name="extract-chroot">
<xsl:with-param name="instructions" select="string()"/>
</xsl:call-template>
</xsl:template>
<xsl:template name="extract-chroot">
<xsl:param name="instructions" select="''"/>
<xsl:choose>
<xsl:when test="contains($instructions, '$(nproc || echo 1)')">
<xsl:call-template name="extract-chroot">
<xsl:with-param
name="instructions"
select="concat(substring-before($instructions, '$(nproc || echo 1)'), $jobs_2, substring-after($instructions, '$(nproc || echo 1)'))"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="not(starts-with($instructions,'&#xA;chroot')) and
contains($instructions, '&#xA;chroot')">
<xsl:call-template name="extract-chroot">
<xsl:with-param name="instructions"
select="substring(substring-after($instructions,
substring-before($instructions,
'&#xA;chroot')),2)"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="contains($instructions,'\&#xA;')">
<xsl:copy-of select="substring-before($instructions,'\&#xA;')"/>
<xsl:text>\
</xsl:text>
<xsl:call-template name="extract-chroot">
<xsl:with-param name="instructions"
select="substring-after($instructions,'\&#xA;')"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="contains($instructions,'&#xA;')">
<xsl:copy-of select="substring-before($instructions,'&#xA;')"/>
<xsl:text>
</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="$instructions"/>
<xsl:text>
</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>

View file

@ -1,5 +1,7 @@
#!/bin/bash
# $Id$
set -e
@ -32,12 +34,10 @@ run_make() { #
exit 1
fi
# Build the system
if [ -e "$MKFILE" ] ; then
if [ -e $MKFILE ] ; then
echo -ne "Building the system...\n"
# if { echo try tty; tty; }; then
cd "$JHALFSDIR" && make -j1
cd $JHALFSDIR && make
echo -ne "done\n"
# else echo there is no terminal!!; fi
fi
fi
}
@ -46,57 +46,64 @@ run_make() { #
#----------------------------#
clean_builddir() { #
#----------------------------#
# Test if the clean must be done.
if [ "${CLEAN}" = "y" ]; then
# If empty (i.e. could contain lost+found), do not do anything
if ls -d $BUILDDIR/* > /dev/null 2>&1 &&
[ "$(ls $BUILDDIR)" != "lost+found" ]; then
# Test if the clean must be done.
if [ "${CLEAN}" = "y" ]; then
# Test to make sure that the build directory was populated by jhalfs
if [ ! -d $JHALFSDIR ] || [ ! -d $BUILDDIR/sources ] ; then
echo "Looks like $BUILDDIR was not populated by a previous jhalfs run."
exit 1
# Test that dev filesystems are not mounted in $BUILDDIR
elif mount | grep $BUILDDIR/dev > /dev/null ; then
echo "Looks like kernel filesystems are still mounted on $BUILDDIR."
echo "Looks like kernel fylesystems are yet mounted on $BUILDDIR."
exit 1
else
if [ $JHALFSDIR/*gcc-pass1 != $JHALFSDIR/'*gcc-pass1' ]; then
echo -n "$BUILDDIR contains already built packages. Clean anyway? yes/no (yes): "
read ANSWER
if [ x${ANSWER:0:1} = "xn" -o x${ANSWER:0:1} = "xN" ] ; then
echo "${nl_}Rerun and change the option in the menu.${nl_}"
exit 1
fi
fi
# Clean the build directory
echo -n "Cleaning $BUILDDIR ..."
# First delete proc and sys directories, if they exist.
# Both should be empty. If not, we exit, and the rmdir command
# has generated an error message
# First delete proc and sys directories, if exist.
# Both should be empty, if not be sure to exit.
if [ -d $BUILDDIR/proc ] ; then
sudo rmdir $BUILDDIR/proc || exit 1
fi
if [ -d $BUILDDIR/sys ] ; then
sudo rmdir $BUILDDIR/sys || exit 1
fi
sudo rm -rf $BUILDDIR/{bin,boot,dev,etc,home,lib{,64,32,x32},media,mnt,run}
sudo rm -rf $BUILDDIR/{opt,root,sbin,srv,tmp,tools,cross-tools,usr,var}
sudo rm -rf $BUILDDIR/{bin,boot,dev,etc,home,lib,media,mnt,opt,root,sbin,srv,tmp,tools,cross-tools,usr,var}
echo "done"
if [[ "${BLFS_TOOL}" = "y" ]] ; then
echo -n "Cleaning $BUILDDIR/$BLFS_ROOT ..."
sudo rm -rf $BUILDDIR/$BLFS_ROOT
echo "done"
fi
echo -n "Cleaning $JHALFSDIR ..."
sudo rm -rf $JHALFSDIR
echo "done"
echo -n "Cleaning remaining extracted sources in $BUILDDIR/sources ..."
sudo rm -rf `find $BUILDDIR/sources -maxdepth 1 -mindepth 1 -type d`
echo "done"
echo -n "Removing dangling symlinks in / ..."
sudo rm -f /tools /cross-tools
echo -n "Cleaning remainig extracted sources in $BUILDDIR/sources ..."
sudo rm -rf `find $BUILDDIR/sources/* -maxdepth 0 -type d`
echo "done"
fi
fi
fi
}
VERBOSITY2=$VERBOSITY
[[ $VERBOSITY2 > 0 ]] && echo ""
[[ $VERBOSITY2 > 0 ]] && echo -n "Loading <func_book_parser>..."
source $COMMON_DIR/libs/func_book_parser
[[ $? > 0 ]] && echo "file libs/func_book_parser did not load.." && exit 1
[[ $VERBOSITY2 > 0 ]] && echo "OK"
[[ $VERBOSITY2 > 0 ]] && echo -n "Loading <func_download_pkgs>..."
source $COMMON_DIR/libs/func_download_pkgs
[[ $? > 0 ]] && echo "file libs/func_download_pkgs did not load.." && exit 1
[[ $VERBOSITY2 > 0 ]] && echo "OK"
[[ $VERBOSITY2 > 0 ]] && echo -n "Loading <func_wrt_Makefile>..."
source $COMMON_DIR/libs/func_wrt_Makefile
[[ $? > 0 ]] && echo "file libs/func_wrt_Makefile did not load.." && exit 1
[[ $VERBOSITY2 > 0 ]] && echo "OK"
[[ $VERBOSITY2 > 0 ]] && echo -n "Loading <func_blfs_deps>..."
source $COMMON_DIR/libs/func_blfs_deps
[[ $? > 0 ]] && echo "file libs/func_blfs_deps did not load.." && exit 1
[[ $VERBOSITY2 > 0 ]] && echo "OK"
[[ $VERBOSITY2 > 0 ]] && echo -n " ..."

View file

@ -1,38 +1,33 @@
#!/bin/bash
#$Id$
set -e
LOGSDIR=$1
VERSION=$2
DATE=$3
LINE="================================================================================"
# Make sure that we have a directory as first argument
[ ! -d "$LOGSDIR" ] && \
echo -e "\nUSAGE: create-sbu_du-report.sh logs_directory [book_version] [date]\n" && exit
[[ ! -d "$LOGSDIR" ]] && \
echo -e "\nUSAGE: create-sbu_du-report.sh logs_directory [book_version]\n" && exit
# Make sure that the first argument is a jhalfs logs directory
[ ! -f "$LOGSDIR"/000-masterscript.log ] && \
[[ ! -f "$LOGSDIR"/000-masterscript.log ]] && \
echo -e "\nLooks like $LOGSDIR isn't a jhalfs logs directory.\n" && exit
# Make sure something has been built otherwise no need for report :)
[ ! -f "$LOGSDIR"/???-binutils-pass1* ] && \
echo -e "\nLooks like nothing has been built yet. Aborting report.\n" && exit
# If this script is run manually, the book version may be unknown
[ -z "$VERSION" ] && VERSION=unknown
[ -z "$DATE" ] && DATE=$(date --iso-8601)
[[ -z "$VERSION" ]] && VERSION=unknown
# If there is iteration logs directories, copy the logs inside iteration-1
# to the top level dir
[ -d "$LOGSDIR"/build_1 ] && \
[[ -d "$LOGSDIR"/build_1 ]] && \
cp $LOGSDIR/build_1/* $LOGSDIR
# Set the report file
REPORT="$VERSION"-SBU_DU-"$DATE".report
REPORT="$VERSION"-SBU_DU-$(date --iso-8601).report
[ -f "$REPORT" ] && : >$REPORT
[ -f $REPORT ] && : >$REPORT
# Dump generation time stamp and book version
echo -e "\n`date`\n" > "$REPORT"
@ -48,30 +43,19 @@ fi
# Dump CPU and memory info
echo -e "\n\n\t\tCPU type:\n" >> "$REPORT"
lscpu >> "$REPORT"
cat /proc/cpuinfo >> "$REPORT"
echo -e "\n\t\tMemory info:\n" >> "$REPORT"
free >> "$REPORT"
# Parse only that logs that have time data
pushd ${LOGSDIR}
BUILDLOGS="`grep -l "^Totalseconds:" * | sort -n`"
BUILDLOGS="`grep -l "^Totalseconds:" ${LOGSDIR}/*`"
# Match the first timed log to extract the SBU unit value from it
FIRSTLOG=`grep -l "^Totalseconds:" * | sort -n | head -n1`
BASELOG=`grep -l "^Totalseconds:" ???-binutils* | head -n1`
BASELOG=`grep -l "^Totalseconds:" $LOGSDIR/* | head -n1`
echo -e "\nUsing ${BASELOG#*[[:digit:]]-} to obtain the SBU unit value."
SBU_UNIT=`sed -n 's/^Totalseconds:\s\([[:digit:]]*\)$/\1/p' $BASELOG`
popd
# Get the -j value of the SBU
if [ "$(sed -n '/REALSBU/s/.*\([yn]\).*/\1/p' "$REPORT")" = y ]; then
J_VALUE="1"
else
J_VALUE=$(sed -n '/N_PARALLEL/s/.*<\([^>]*\).*/\1/p' "$REPORT")
fi
# if jhalfs.config does not exist, or OPTIMIZE is 0, then J_VALUE is
# still empty. Assume 1 in that case
echo -e "\nThe SBU unit value is equal to $SBU_UNIT seconds at -j${J_VALUE:=1}.\n"
echo -e "\n\n$LINE\n\nThe SBU unit value is equal to $SBU_UNIT seconds at -j$J_VALUE.\n" >> "$REPORT"
echo -e "\nThe SBU unit value is equal to $SBU_UNIT seconds.\n"
echo -e "\n\n$LINE\n\nThe SBU unit value is equal to $SBU_UNIT seconds.\n" >> "$REPORT"
# Set the first value to 0 for grand totals calculation
SBU2=0
@ -86,7 +70,7 @@ for log in $BUILDLOGS ; do
# Start SBU calculation
# Build time
TIME=`sed -n 's/^Totalseconds:\s\([[:digit:]]*\)$/\1/p' ${LOGSDIR}/$log`
TIME=`sed -n 's/^Totalseconds:\s\([[:digit:]]*\)$/\1/p' $log`
SECS=`perl -e 'print ('$TIME' % '60')';`
MINUTES=`perl -e 'printf "%.0f" , (('$TIME' - '$SECS') / '60')';`
SBU=`perl -e 'printf "%.1f" , ('$TIME' / '$SBU_UNIT')';`
@ -96,10 +80,10 @@ for log in $BUILDLOGS ; do
# Start disk usage calculation
# Disk usage before unpacking the package
DU1=`grep "^KB: " ${LOGSDIR}/$log | head -n1 | cut -f1 | sed -e 's/KB: //'`
DU1=`grep "^KB: " $log | head -n1 | cut -f1 | sed -e 's/KB: //'`
DU1MB=`perl -e 'printf "%.3f" , ('$DU1' / '1024')';`
# Disk usage before deleting the source and build dirs
DU2=`grep "^KB: " ${LOGSDIR}/$log | tail -n1 | cut -f1 | sed -e 's/KB: //'`
DU2=`grep "^KB: " $log | tail -n1 | cut -f1 | sed -e 's/KB: //'`
DU2MB=`perl -e 'printf "%.3f" , ('$DU2' / '1024')';`
# Calculate disk space required to do the build
REQUIRED1=`perl -e 'print ('$DU2' - '$DU1')';`
@ -107,7 +91,7 @@ for log in $BUILDLOGS ; do
# Append installed files disk usage to the previous entry,
# except for the first parsed log
if [ "$log" != "$FIRSTLOG" ] ; then
if [ "$log" != "$BASELOG" ] ; then
INSTALL=`perl -e 'print ('$DU1' - '$DU1PREV')';`
INSTALLMB=`perl -e 'printf "%.3f" , ('$DU1MB' - '$DU1MBPREV')';`
echo -e "Installed files disk usage:\t\t\t\t$INSTALL KB or $INSTALLMB MB\n" >> $REPORT
@ -131,19 +115,7 @@ for log in $BUILDLOGS ; do
done
# For printing the last 'Installed files disk usage', we need to 'du' the
# root dir, excluding the jhalfs directory (and lost+found). We assume
# that the rootdir is $LOGSDIR/../..
DU1=`du -skx --exclude=jhalfs --exclude=lost+found --exclude var/lib $LOGSDIR/../.. | cut -f1`
DU1MB=`perl -e 'printf "%.3f" , ('$DU1' / '1024')';`
INSTALL=`perl -e 'print ('$DU1' - '$DU1PREV')';`
INSTALLMB=`perl -e 'printf "%.3f" , ('$DU1MB' - '$DU1MBPREV')';`
echo -e "Installed files disk usage:\t\t\t\t$INSTALL KB or $INSTALLMB MB\n" >> $REPORT
# Append install values for grand total
INSTALL2=`perl -e 'printf "%.3f" , ('$INSTALL2' + '$INSTALL')';`
INSTALLMB2=`perl -e 'printf "%.3f" , ('$INSTALLMB2' + '$INSTALLMB')';`
# Dump grand totals
echo -e "\n$LINE\n\nTotal time required to build the system:\t\t$SBU2 SBU" >> $REPORT
echo -e "\n$LINE\n\nTotal time required to build the systen:\t\t$SBU2 SBU" >> $REPORT
# Total disk usage: including /tools but not /sources.
echo -e "Total Installed files disk usage:\t\t\t$INSTALL2 KB or $INSTALLMB2 MB" >> $REPORT

View file

@ -1,78 +0,0 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- Extracts minimal versions from LFS book host requirements,
and generates a script containing statements of the
form MIN_prog_VERSION=xx.yy.zz.
-->
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="text"/>
<xsl:template match="/sect1">
<xsl:apply-templates select=".//listitem//emphasis"/>
</xsl:template>
<xsl:template match="emphasis">
<!-- We assume that what is emphasized is in the form:
aa...aa-dccsaaa (a anything except @, - "dash", d digit,
c anything except space, s space)
or
aa...aasdccsaaa
This means we have to replace digits with @, and look for '-@'
or ' @' -->
<xsl:variable name="normalized-string"
select="translate(normalize-space(string()),
'0123456789',
'@@@@@@@@@@')"/>
<xsl:variable name="begin-ver">
<xsl:choose>
<xsl:when test="contains($normalized-string,' @')">
<xsl:value-of select="string-length(substring-before($normalized-string,' @'))+1"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="string-length(substring-before($normalized-string,'-@'))+1"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="remaining-part"
select="substring($normalized-string,number($begin-ver)+1)"/>
<xsl:variable name="end-ver">
<xsl:choose>
<xsl:when test="contains($remaining-part,' ')">
<xsl:value-of
select="string-length(substring-before($remaining-part,' '))"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of
select="string-length($remaining-part)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:text>local MIN_</xsl:text>
<xsl:choose>
<xsl:when test="contains(string(),'Kernel')">
<xsl:text>Linux</xsl:text>
</xsl:when>
<xsl:when test="contains(string(),'GLIBC')">
<xsl:text>Glibc</xsl:text>
</xsl:when>
<xsl:when test="contains(string(),'XZ')">
<xsl:text>Xz</xsl:text>
</xsl:when>
<xsl:otherwise>
<!-- We assume that there are no dash nor space in other names -->
<xsl:value-of select="substring(string(),1,number($begin-ver)-1)"/>
</xsl:otherwise>
</xsl:choose>
<xsl:text>_VER=</xsl:text>
<xsl:value-of select="substring(string(),number($begin-ver)+1,$end-ver)"/>
<xsl:text>
</xsl:text>
</xsl:template>
</xsl:stylesheet>

View file

@ -1,84 +0,0 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="text"/>
<xsl:template match="/">
<xsl:text>#!/bin/bash
</xsl:text>
<xsl:apply-templates select="//userinput[contains(string(),'--bind') or
contains(string(),'/proc') or
contains(string(),'readlink') or
contains(string(),'-Rv')]"/>
</xsl:template>
<xsl:template match="userinput">
<xsl:call-template name="check-mount">
<xsl:with-param name="mytext" select="string()"/>
</xsl:call-template>
<xsl:text>
</xsl:text>
</xsl:template>
<xsl:template name="check-mount">
<xsl:param name="mytext" select="''"/>
<xsl:choose>
<xsl:when test="contains($mytext,'&#xA;')">
<xsl:call-template name="check-mount">
<xsl:with-param name="mytext"
select="substring-before($mytext,'&#xA;')"/>
</xsl:call-template>
<xsl:text>&#xA;</xsl:text>
<xsl:call-template name="check-mount">
<xsl:with-param name="mytext"
select="substring-after($mytext,'&#xA;')"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="starts-with(normalize-space($mytext),'mountpoint')">
<xsl:copy-of select="$mytext"/>
</xsl:when>
<xsl:when test="starts-with(normalize-space($mytext),'mount')">
<xsl:variable name="mountpoint">
<xsl:call-template name="last-arg">
<xsl:with-param name="myline" select="$mytext"/>
</xsl:call-template>
</xsl:variable>
<xsl:text>mountpoint -q </xsl:text>
<xsl:copy-of select="$mountpoint"/>
<xsl:text> || </xsl:text>
<xsl:copy-of select="$mytext"/>
</xsl:when>
<xsl:when test="starts-with(normalize-space($mytext),'umount')">
<xsl:variable name="mountpoint">
<xsl:call-template name="last-arg">
<xsl:with-param name="myline" select="$mytext"/>
</xsl:call-template>
</xsl:variable>
<xsl:text>mountpoint -q </xsl:text>
<xsl:copy-of select="$mountpoint"/>
<xsl:text> &amp;&amp; </xsl:text>
<xsl:copy-of select="$mytext"/>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="$mytext"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="last-arg">
<xsl:param name="myline" select="''"/>
<xsl:choose>
<xsl:when test="contains($myline,' ')">
<xsl:call-template name="last-arg">
<xsl:with-param name="myline" select="substring-after($myline,' ')"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="$myline"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>

View file

@ -0,0 +1,90 @@
#!/bin/bash
# $Id$
#----------------------------------#
blfs_tool_clean_scripts() { # Remove unselected dependencies scripts
#----------------------------------#
for file in ${PROGNAME}-commands/blfs-tool-deps/* ; do
# Keep the script file name
this_script=`basename $file`
case "${this_script}" in
*libxml2 ) [[ "${DEP_LIBXML}" = "n" ]] && rm ${file} ;;
*libxslt ) [[ "${DEP_LIBXSLT}" = "n" ]] && rm ${file} ;;
*tidy ) [[ "${DEP_TIDY}" = "n" ]] && rm ${file} ;;
*unzip ) [[ "${DEP_UNZIP}" = "n" ]] && rm ${file} ;;
*docbook-xml ) [[ "${DEP_DBXML}" = "n" ]] && rm ${file} ;;
*docbook-xsl ) [[ "${DEP_DBXSL}" = "n" ]] && rm ${file} ;;
*gpm ) [[ "${DEP_GPM}" = "n" ]] && rm ${file} ;;
*lynx ) [[ "${DEP_LYNX}" = "n" ]] && rm ${file} ;;
*sudo ) [[ "${DEP_SUDO}" = "n" ]] && rm ${file} ;;
*wget ) [[ "${DEP_WGET}" = "n" ]] && rm ${file} ;;
*subversion ) [[ "${DEP_SVN}" = "n" ]] && rm ${file} ;;
esac
done
}
#----------------------------------#
wrt_blfs_tool_targets() { #
#----------------------------------#
PREV=""
echo "${tab_}${GREEN}Processing... ${L_arrow}BLFS_TOOL ${R_arrow}"
for file in blfs-tool-deps/* ; do
# Keep the script file name
this_script=`basename $file`
# Grab the phase name to be used with INSTALL_LOG and tracking dir touch
name=`grep "^PKG_PHASE=" ${file} | sed -e 's@PKG_PHASE=@@'`
# Grab also the package version
pkg_ver=`grep "^VERSION=" ${file} | sed -e 's@VERSION=@@'`
# Append each name of the script files to a list (this will become
# the names of the targets in the Makefile)
blfs_tool="$blfs_tool ${this_script}"
#--------------------------------------------------------------------#
# >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
#--------------------------------------------------------------------#
#
# Drop in the name of the target on a new line, and the previous target
# as a dependency. Also call the echo_message function.
wrt_target "${this_script}" "$PREV"
# Touch timestamp file if installed files logs will be created.
if [ "$name" != "" ] && [ "${INSTALL_LOG}" = "y" ] ; then
wrt_TouchTimestamp
fi
# Run the script.
wrt_RunScript "$file"
# Write installed files log
if [ "$name" != "" ] && [ "${INSTALL_LOG}" = "y" ] ; then
wrt_LogNewFiles "$name"
fi
# Touch the tracking file.
if [ "$PROGNAME" = "clfs2" ]; then
echo -e "\t@touch \$(MOUNT_PT)$TRACKING_DIR/${name}-${pkg_ver}" >> $MKFILE.tmp
else
echo -e "\t@touch $TRACKING_DIR/${name}-${pkg_ver}" >> $MKFILE.tmp
fi
# Include a touch of the target name so make can check
# if it's already been made.
wrt_touch
#
#--------------------------------------------------------------------#
# >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
#--------------------------------------------------------------------#
# Keep the script file name for Makefile dependencies.
PREV=${this_script}
done
}

View file

@ -1,180 +1,166 @@
#!/bin/bash
# $Id$
#----------------------------#
get_book() { #
#----------------------------#
cd $JHALFSDIR
if [ -z "$WORKING_COPY" ] ; then
# Check for Subversion or git instead of just letting the script fail.
test `type -p git` || eval "echo \"This feature requires Git.\"
if [ -z $WORKING_COPY ] ; then
# Check for Subversion instead of just letting the script hit 'svn' and fail.
test `type -p svn` || eval "echo \"This feature requires Subversion.\"
exit 1"
echo -n "Downloading the $PROGNAME document, $LFSVRS version... "
echo -n "Downloading the lfs document, branch/tag/commit: $COMMIT... "
case $PROGNAME in
lfs) svn_root="LFS" ;;
hlfs) svn_root="HLFS" ;;
clfs) svn_root="cross-lfs" ;;
clfs2) svn_root="cross-lfs" ;;
clfs3) svn_root="cross-lfs" ;;
*) echo "BOOK not defined in function <get_book>"
exit 1 ;;
esac
# Grab a fresh book if it's missing, otherwise, update it from the
# repo. If we've already extracted the commands, move on to getting the
# sources.
if [ ! -d "$BOOK"/.git ]; then
git clone "$REPO" "$BOOK" >>"$LOGDIR/$LOG" 2>&1
if [ "$COMMIT" != trunk ]; then
pushd "$BOOK" >/dev/null
echo "Checking out $COMMIT at $PWD"
git checkout "$COMMIT" >>"$LOGDIR/$LOG" 2>&1
popd >/dev/null
fi
else
cd "$BOOK"
# If the repo is in "detached head" state, git pull fails, so get
# back first to trunk:
git checkout trunk >>"$LOGDIR/$LOG" 2>&1
git pull >>"$LOGDIR/$LOG" 2>&1
if [ "$COMMIT" != "trunk" ]; then
git checkout "$COMMIT" >>"$LOGDIR/$LOG" 2>&1
if [ -d ${PROGNAME}-$LFSVRS ] ; then
cd ${PROGNAME}-$LFSVRS
if LC_ALL=C svn up | grep -q At && \
test -d $JHALFSDIR/${PROGNAME}-commands && \
test -f $JHALFSDIR/pkg_tarball_list ; then
# Set the canonical book version
echo -ne "done\n"
cd $JHALFSDIR
case $PROGNAME in
clfs | clfs2 | clfs3 )
VERSION=$(xmllint --noent $BOOK/prologue/$ARCH/bookinfo.xml 2>/dev/null | grep subtitle | sed -e 's/^.*ion //' -e 's/<\/.*//') ;;
*)
VERSION=$(xmllint --noent $BOOK/prologue/bookinfo.xml 2>/dev/null | grep subtitle | sed -e 's/^.*ion //' -e 's/<\/.*//') ;;
esac
get_sources
else
echo -ne "done\n"
extract_commands
fi
else
svn co $SVN/${svn_root}/${TREE} ${PROGNAME}-$LFSVRS >>$LOGDIR/$LOG 2>&1
echo -ne "done\n"
extract_commands
fi
echo -ne "done\n"
else # Working copy
else
echo -ne "Using $BOOK as book's sources ...\n"
extract_commands
fi
echo -ne " Document version ${L_arrow}${BOLD}${VERSION}${R_arrow}\n"
}
#----------------------------#
extract_commands() { #
#----------------------------#
# Check for libxslt instead of just letting the script hit 'xsltproc' and fail.
test `type -p xsltproc` || eval "echo \"This feature requires libxslt.\"
exit 1"
cd $JHALFSDIR
# Clean
rm -rf "$COMMANDS"
case $PROGNAME in
clfs | clfs2 | clfs3 )
VERSION=$(xmllint --noent $BOOK/prologue/$ARCH/bookinfo.xml 2>/dev/null | grep subtitle | sed -e 's/^.*ion //' -e 's/<\/.*//') ;;
*)
VERSION=$(xmllint --noent $BOOK/prologue/bookinfo.xml 2>/dev/null | grep subtitle | sed -e 's/^.*ion //' -e 's/<\/.*//') ;;
esac
# Extract the commands
# Start clean
if [ -d ${PROGNAME}-commands ]; then
rm -rf ${PROGNAME}-commands
mkdir -v ${PROGNAME}-commands
fi
echo -n "Extracting commands for"
echo -n " ${L_arrow}${BOLD}LFS${R_arrow} build... "
# The scripts pages are xincluded by the book, so must
# be generated for running xsltproc
pushd $BOOK > /dev/null
if [ -f process-scripts.sh ]; then
bash process-scripts.sh >> $LOGDIR/$LOG 2>&1
fi
# Recent git versions need version.ent to be generated
if [ -f git-version.sh ]; then
bash git-version.sh "$INITSYS" >> $LOGDIR/$LOG 2>&1
fi
popd > /dev/null
if [ "$ALL_CORES" = "y" ]; then
JOBS="\$(nproc)"
else
JOBS="$N_PARALLEL"
fi
if [ "$REALSBU" = y ]; then JOBSBP1=1; else JOBSBP1="$JOBS"; fi
# Dump the commands in shell script form from the book.
case ${PROGNAME} in
clfs)
echo -n " ${L_arrow}${BOLD}$ARCH${R_arrow} target architecture... "
xsltproc --nonet \
--xinclude \
--stringparam method $METHOD \
--stringparam testsuite $TEST \
--stringparam bomb-testsuite $BOMB_TEST \
--stringparam vim-lang $VIMLANG \
--stringparam timezone $TIMEZONE \
--stringparam page $PAGE \
--stringparam lang $LANG \
--stringparam sparc $SPARC64_PROC \
-o ./${PROGNAME}-commands/ $XSL $BOOK/$ARCH-index.xml >>$LOGDIR/$LOG 2>&1
;;
# First profile the book, for revision and arch. Note that
# MULTIBLIB is set to "default" if pure 64 bit book. In this case,
# profiling on arch is useless, but does not hurt either.
xsltproc --nonet \
--xinclude \
--stringparam profile.revision "$INITSYS" \
--stringparam profile.arch "$MULTILIB" \
--output prbook.xml \
$BOOK/stylesheets/lfs-xsl/profile.xsl \
$BOOK/index.xml >> $LOGDIR/$LOG 2>&1
clfs2)
echo -n " ${L_arrow}${BOLD}$ARCH${R_arrow} target architecture... "
xsltproc --nonet \
--xinclude \
--stringparam vim-lang $VIMLANG \
--stringparam timezone $TIMEZONE \
--stringparam page $PAGE \
--stringparam lang $LANG \
-o ./${PROGNAME}-commands/ $XSL $BOOK/$ARCH-index.xml >>$LOGDIR/$LOG 2>&1
;;
clfs3)
echo -n " ${L_arrow}${BOLD}$ARCH${R_arrow} target architecture... "
xsltproc --nonet \
--xinclude \
--stringparam endian x$ENDIAN \
--stringparam timezone $TIMEZONE \
--stringparam page $PAGE \
--stringparam lang $LANG \
-o ./${PROGNAME}-commands/ $XSL $BOOK/$ARCH-index.xml >>$LOGDIR/$LOG 2>&1
;;
hlfs)
echo -n " ${L_arrow}${BOLD}$MODEL + $KERNEL${R_arrow} HLFS flavour... "
xsltproc --nonet \
--xinclude \
--stringparam model $MODEL \
--stringparam kernel $KERNEL \
--stringparam testsuite $TEST \
--stringparam bomb-testsuite $BOMB_TEST \
--stringparam features x$SSP$ASLR$PAX$HARDENED_TMP$WARNINGS$MISC$BLOWFISH \
--stringparam timezone $TIMEZONE \
--stringparam page $PAGE \
--stringparam lang $LANG \
--stringparam grsecurity_host $GRSECURITY_HOST \
-o ./${PROGNAME}-commands/ $XSL $BOOK/index.xml >>$LOGDIR/$LOG 2>&1
;;
lfs)
echo -n " ${L_arrow}${BOLD}LFS${R_arrow} build... "
xsltproc --nonet \
--xinclude \
--stringparam testsuite $TEST \
--stringparam bomb-testsuite $BOMB_TEST \
--stringparam vim-lang $VIMLANG \
--stringparam timezone $TIMEZONE \
--stringparam page $PAGE \
--stringparam lang $LANG \
--stringparam custom-tools $CUSTOM_TOOLS \
--stringparam blfs-tool $BLFS_TOOL \
--stringparam optimize $OPTIMIZE \
-o ./${PROGNAME}-commands/ $XSL $BOOK/index.xml >>$LOGDIR/$LOG 2>&1
;;
*) echo -n " ${L_arrow}${BOLD}${PROGNAME}${R_arrow} book invalid, terminate build... "
exit 1 ;;
esac
[[ "${BLFS_TOOL}" = "y" ]] && blfs_tool_clean_scripts
# Use the profiled book for generating the scriptlets
xsltproc --nonet \
--stringparam testsuite "$TEST" \
--stringparam ncurses5 "$NCURSES5" \
--stringparam strip "$STRIP" \
--stringparam del-la-files "$DEL_LA_FILES" \
--stringparam full-locale "$FULL_LOCALE" \
--stringparam timezone "$TIMEZONE" \
--stringparam page "$PAGE" \
--stringparam lang "$LANG" \
--stringparam pkgmngt "$PKGMNGT" \
--stringparam wrap-install "$WRAP_INSTALL" \
--stringparam hostname "$HOSTNAME" \
--stringparam interface "$INTERFACE" \
--stringparam ip "$IP_ADDR" \
--stringparam gateway "$GATEWAY" \
--stringparam prefix "$PREFIX" \
--stringparam broadcast "$BROADCAST" \
--stringparam domain "$DOMAIN" \
--stringparam nameserver1 "$DNS1" \
--stringparam nameserver2 "$DNS2" \
--stringparam font "$FONT" \
--stringparam fontmap "$FONTMAP" \
--stringparam unicode "$UNICODE" \
--stringparam keymap "$KEYMAP" \
--stringparam local "$LOCAL" \
--stringparam log-level "$LOG_LEVEL" \
--stringparam script-root "$SCRIPT_ROOT" \
--stringparam jobs "$JOBS" \
--stringparam jobs-bp1 "$JOBSBP1" \
--output "./${COMMANDS}/" \
$XSL \
prbook.xml >> $LOGDIR/$LOG 2>&1
# Remove flags requesting user action in some cases. Much easier here than
# in the stylesheet...
sed -i 's/-iv /-v /' "./${COMMANDS}/"chapter??/*kernel*
# If doing a destdir install (PM without wrap), the gcc instructions
# fail for two reasons: a missing dir, and gcc -dumpmachine returns a
# wrong string.
if [ "$PKGMNGT" = y ] && [ "$WRAP_INSTALL" = n ]; then
sed -e 's|(gcc|&/xgcc|' \
-e '/lto_plug/imkdir -pv $PKG_DEST/usr/lib/bfd-plugins' \
-i ./${COMMANDS}/chapter08/*gcc
fi
echo "done"
# Make the scripts executable.
chmod -R +x "$JHALFSDIR/${COMMANDS}"
create_chroot_scripts
create_kernfs_scripts
# we create the VERSION variable here. Should maybe go into its own
# function. But at this point we can use the profiled xml to get
# version from lfs-release in the lfs case.
VERSION=$(grep 'echo.*lfs-release' prbook.xml | sed 's/.*echo[ ]*\([^ ]*\).*/\1/')
chmod -R +x $JHALFSDIR/${PROGNAME}-commands
# Done. Moving on...
get_sources
}
#----------------------------#
create_chroot_scripts() { #
#----------------------------#
rm -rf chroot-scripts
echo -n "Creating chroot commands scripts from $BOOK"
if [ ! -z $ARCH ] ; then echo -n " $ARCH" ; fi
echo -n "... "
xsltproc --nonet --xinclude \
--stringparam jobs_2 "$JOBS_2" \
-o chroot-scripts/ chroot.xsl \
$BOOK/chapter0?/*chroot*.xml >> $LOGDIR/$LOG 2>&1
echo "done"
}
#----------------------------#
create_kernfs_scripts() { #
#----------------------------#
rm -rf kernfs-scripts
mkdir kernfs-scripts
echo -n "Creating virtual kernel FS commands scripts from $BOOK"
if [ ! -z $ARCH ] ; then echo -n " $ARCH" ; fi
echo -n "... "
xsltproc --nonet \
-o kernfs-scripts/devices.sh kernfs.xsl \
$BOOK/*/kernfs.xml >> $LOGDIR/$LOG 2>&1
chmod +x kernfs-scripts/devices.sh
xsltproc --nonet \
-o kernfs-scripts/teardown.sh kernfs.xsl \
$BOOK/chapter??/reboot.xml >> $LOGDIR/$LOG 2>&1
chmod +x kernfs-scripts/teardown.sh
echo "done"
}

View file

@ -1,3 +1,5 @@
# $Id$
check_version() {
: <<inline_doc
Tests for a minimum version level. Compares to version numbers and forces an
@ -20,10 +22,7 @@ inline_doc
declare -i major minor revision change
declare -i ref_major ref_minor ref_revision ref_change
declare -r spaceSTR=" "
declare -r spaceSTR1=" "
shopt -s extglob #needed for ${x##*(0)} below
declare -r spaceSTR=" "
ref_version=$1
tst_version=$2
@ -33,11 +32,11 @@ inline_doc
local IFS
write_error_and_die() {
echo -e "\n\t\t$TXT is missing or version -->${tst_version}<-- is too old.
echo -e "\n\t\t$TXT version -->${tst_version}<-- is too old.
This script requires ${ref_version} or greater\n"
# Ask the user instead of bomb, to make happy that packages which version
# ouput don't follow our expectations
echo "If you are sure that you have installed a proper version of ${BOLD}$TXT${OFF}"
echo "If you are sure that you have instaled a proper version of ${BOLD}$TXT${OFF}"
echo "but jhalfs has failed to detect it, press 'c' and 'ENTER' keys to continue,"
echo -n "otherwise press 'ENTER' key to stop jhalfs. "
read ANSWER
@ -50,192 +49,87 @@ inline_doc
fi
}
echo -ne "${TXT}${spaceSTR:${#TXT}} ${L_arrow}${BOLD}${tst_version}${OFF}${R_arrow}"
echo -ne "${TXT}${dotSTR:${#TXT}} ${L_arrow}${BOLD}${tst_version}${OFF}${R_arrow}"
# Split up w.x.y.z as well as w.x.y-rc (catch release candidates).
# Also strip trailing "+" which appears for kernel built from a Git
# repository where HEAD is not a tag.
IFS=".-(pab+"
set -- $ref_version # set positional parameters to minimum ver values
# echo -ne "$TXT:\t${L_arrow}${BOLD}${tst_version}${OFF}${R_arrow}"
IFS=".-(pa" # Split up w.x.y.z as well as w.x.y-rc (catch release candidates)
set -- $ref_version # set postional parameters to minimum ver values
ref_major=$1; ref_minor=$2; ref_revision=$3
#
set -- $tst_version # Set positional parameters to test version values
# Values beginning with zero are taken as octal, so that for example
# 2.07.08 gives an error because 08 cannot be octal. The ## stuff supresses
# leading zero's
major=${1##*(0)}; minor=${2##*(0)}; revision=${3##*(0)}
set -- $tst_version # Set postional parameters to test version values
major=$1; minor=$2; revision=$3
#
# Compare against minimum acceptable version..
(( major > ref_major )) &&
echo " ${spaceSTR1:${#tst_version}}${GREEN}OK${OFF} (Min version: ${ref_version})" &&
return
(( major > ref_major )) && echo " ${spaceSTR:${#tst_version}}${GREEN}OK${OFF}" && return
(( major < ref_major )) && write_error_and_die
# major=ref_major
(( minor < ref_minor )) && write_error_and_die
(( minor > ref_minor )) &&
echo " ${spaceSTR1:${#tst_version}}${GREEN}OK${OFF} (Min version: ${ref_version})" &&
return
(( minor > ref_minor )) && echo " ${spaceSTR:${#tst_version}}${GREEN}OK${OFF}" && return
# minor=ref_minor
(( revision >= ref_revision )) &&
echo " ${spaceSTR1:${#tst_version}}${GREEN}OK${OFF} (Min version: ${ref_version})" &&
return
(( revision >= ref_revision )) && echo " ${spaceSTR:${#tst_version}}${GREEN}OK${OFF}" && return
# oops.. write error msg and die
write_error_and_die
}
# local -r PARAM_VALS='${config_param}${dotSTR:${#config_param}} ${L_arrow}${BOLD}${!config_param}${OFF}${R_arrow}'
#----------------------------#
check_prerequisites() { #
#----------------------------#
HOSTREQS=$(find $BOOK -name hostreqs.xml)
eval $(xsltproc $COMMON_DIR/hostreqs.xsl $HOSTREQS)
# Avoid translation of version strings
local LC_ALL=C
export LC_ALL
# LFS prerequisites
if [ -n "$MIN_Linux_VER" ]; then
check_version "$MIN_Linux_VER" "`uname -r`" "KERNEL"
fi
if [ -n "$MIN_Bash_VER" ]; then
check_version "$MIN_Bash_VER" "$BASH_VERSION" "BASH"
fi
if [ ! -z $MIN_GCC_VER ]; then
check_version "$MIN_GCC_VER" "`gcc -dumpfullversion -dumpversion`" "GCC"
check_version "$MIN_GCC_VER" "`g++ -dumpfullversion -dumpversion`" "G++"
elif [ ! -z $MIN_Gcc_VER ]; then
check_version "$MIN_Gcc_VER" "`gcc -dumpfullversion -dumpversion`" "GCC"
fi
if [ -n "$MIN_Glibc_VER" ]; then
check_version "$MIN_Glibc_VER" "$(ldd --version | head -n1 | awk '{print $NF}')" "GLIBC"
fi
if [ -n "$MIN_Binutils_VER" ]; then
check_version "$MIN_Binutils_VER" "$(ld --version | head -n1 | awk '{print $NF}')" "BINUTILS"
fi
if [ -n "$MIN_Tar_VER" ]; then
check_version "$MIN_Tar_VER" "$(tar --version | head -n1 | cut -d" " -f4)" "TAR"
fi
if [ -n "$MIN_Bzip2_VER" ]; then
# LFS/HLFS/CLFS prerequisites
check_version "2.6.2" "`uname -r`" "KERNEL"
check_version "3.0" "$BASH_VERSION" "BASH"
check_version "3.0.1" "`gcc -dumpversion`" "GCC"
libcVer="`/lib/libc.so.6 | head -n1`"
libcVer="${libcVer##*version }"
check_version "2.2.5" ${libcVer%%,*} "GLIBC"
check_version "2.12" "$(ld --version | head -n1 | cut -d" " -f4)" "BINUTILS"
check_version "1.15" "$(tar --version | head -n1 | cut -d" " -f4)" "TAR"
bzip2Ver="$(bzip2 --version 2>&1 < /dev/null | head -n1 | cut -d" " -f8)"
check_version "$MIN_Bzip2_VER" "${bzip2Ver%%,*}" "BZIP2"
fi
if [ -n "$MIN_Bison_VER" ]; then
check_version "$MIN_Bison_VER" "$(bison --version | head -n1 | cut -d" " -f4)" "BISON"
fi
if [ -n "$MIN_Coreutils_VER" ]; then
check_version "$MIN_Coreutils_VER" "$(chown --version | head -n1 | cut -d" " -f4)" "COREUTILS"
fi
if [ -n "$MIN_Diffutils_VER" ]; then
check_version "$MIN_Diffutils_VER" "$(diff --version | head -n1 | cut -d" " -f4)" "DIFF"
fi
if [ -n "$MIN_Findutils_VER" ]; then
check_version "$MIN_Findutils_VER" "$(find --version | head -n1 | cut -d" " -f4)" "FIND"
fi
if [ -n "$MIN_Gawk_VER" ]; then
check_version "$MIN_Gawk_VER" "$(gawk --version | head -n1 | awk -F'[ ,]+' '{print $3}')" "GAWK"
fi
if [ -n "$MIN_Grep_VER" ]; then
check_version "$MIN_Grep_VER" "$(grep --version | head -n1 | awk '{print $NF}')" "GREP"
fi
if [ -n "$MIN_Gzip_VER" ]; then
check_version "$MIN_Gzip_VER" "$(gzip --version 2>&1 | head -n1 | cut -d" " -f2)" "GZIP"
fi
if [ -n "$MIN_M4_VER" ]; then
check_version "$MIN_M4_VER" "$(m4 --version 2>&1 | head -n1 | awk '{print $NF}')" "M4"
fi
if [ -n "$MIN_Make_VER" ]; then
check_version "$MIN_Make_VER" "$(make --version | head -n1 | cut -d " " -f3 | cut -c1-4)" "MAKE"
fi
if [ -n "$MIN_Patch_VER" ]; then
check_version "$MIN_Patch_VER" "$(patch --version | head -n1 | sed 's/.*patch //')" "PATCH"
fi
if [ -n "$MIN_Perl_VER" ]; then
check_version "$MIN_Perl_VER" "$(perl -V:version | cut -f2 -d\')" "PERL"
fi
if [ -n "$MIN_Sed_VER" ]; then
check_version "$MIN_Sed_VER" "$(sed --version | head -n1 | cut -d" " -f4)" "SED"
fi
if [ -n "$MIN_Texinfo_VER" ]; then
check_version "$MIN_Texinfo_VER" "$(makeinfo --version | head -n1 | awk '{ print$NF }')" "TEXINFO"
fi
if [ -n "$MIN_Xz_VER" ]; then
check_version "$MIN_Xz_VER" "$(xz --version | head -n1 | cut -d" " -f4)" "XZ"
fi
if [ -n "$MIN_Python_VER" ]; then
check_version "$MIN_Python_VER" "3.$(python3 -c"import sys; print(sys.version_info.minor,'.',sys.version_info.micro,sep='')")" "PYTHON"
fi
}
#----------------------------#
check_alfs_tools() { #
#----------------------------#
: << inline_doc
Those tools are needed for the proper operation of jhalfs
inline_doc
# Avoid translation of version strings
local LC_ALL=C
export LC_ALL
check_version "1.0.2" "${bzip2Ver%%,*}" "BZIP2"
check_version "1.875" "$(bison --version | head -n1 | cut -d" " -f4)" "BISON"
check_version "5.2.1" "$(chown --version | head -n1 | cut -d")" -f2)" "COREUTILS"
check_version "2.8" "$(diff --version | head -n1 | cut -d" " -f4)" "DIFF"
check_version "4.1.20" "$(find --version | head -n1 | cut -d" " -f4)" "FIND"
check_version "3.0" "$(gawk --version | head -n1 | cut -d" " -f3)" "GAWK"
check_version "2.5" "$(grep --version | head -n1 | awk '{print $NF}')" "GREP"
check_version "1.2.4" "$(gzip --version 2>&1 | head -n1 | cut -d" " -f2)" "GZIP"
check_version "3.79.1" "$(make --version | head -n1 | cut -d " " -f3 | cut -c1-4)" "MAKE"
check_version "2.5.4" "$(patch --version | head -n1 | cut -d" " -f2)" "PATCH"
check_version "3.0.2" "$(sed --version | head -n1 | cut -d" " -f4)" "SED"
# Check for minimum sudo version
SUDO_LOC="$(whereis -b sudo | cut -d" " -f2)"
if [ -x $SUDO_LOC ]; then
sudoVer="$(sudo -V | head -n1 | cut -d" " -f3)"
check_version "1.7.0" "${sudoVer}" "SUDO"
check_version "1.6.8" "${sudoVer}" "SUDO"
else
echo "${nl_}\"${RED}sudo${OFF}\" ${BOLD}must be installed on your system for jhalfs to run"
exit 1
fi
# Check for wget presence (using a dummy version)
WGET_LOC="$(whereis -b wget | cut -d" " -f2)"
if [ -x $WGET_LOC ]; then
wgetVer="$(wget --version | head -n1 | cut -d" " -f3)"
if echo "$wgetVer" | grep -q '^[[:digit:]]'; then
check_version "1.0.0" "${wgetVer}" "WGET"
else echo Wget detected, but no version found. Continuing anyway.
# Check for minimum libxml2 and libxslt versions
xsltprocVer=$(xsltproc -V | head -n1 )
libxmlVer=$(echo $xsltprocVer | cut -d " " -f3)
libxsltVer=$(echo $xsltprocVer | cut -d " " -f5)
# Version numbers are packed strings not xx.yy.zz format.
check_version "2.06.20" "${libxmlVer:0:1}.${libxmlVer:1:2}.${libxmlVer:3:2}" "LIBXML2"
check_version "1.01.14" "${libxsltVer:0:1}.${libxsltVer:1:2}.${libxsltVer:3:2}" "LIBXSLT"
# The next versions checks are required only when BLFS_TOOL is set and
# this dependencies has not be selected for installation
if [[ "$BLFS_TOOL" = "y" ]] ; then
if [[ -z "$DEP_TIDY" ]] ; then
tidyVer=$(tidy -V | cut -d " " -f9)
check_version "2004" "${tidyVer}" "TIDY"
fi
else
echo "${nl_}\"${RED}wget${OFF}\" ${BOLD}must be installed on your system for jhalfs to run"
exit 1
fi
# Before checking libxml2 and libxslt version information, ensure tools
# needed from those packages are actually available. Avoids a small
# cosmetic bug of book version information not being retrieved if
# xmllint is unavailable, especially when on recent non-LFS hosts.
XMLLINT_LOC="$(whereis -b xmllint | cut -d" " -f2)"
XSLTPROC_LOC="$(whereis -b xsltproc | cut -d" " -f2)"
if [ ! -x $XMLLINT_LOC ]; then
echo "${nl_}\"${RED}xmllint${OFF}\" ${BOLD}must be installed on your system for jhalfs to run"
exit 1
fi
if [ -x $XSLTPROC_LOC ]; then
# Check for minimum libxml2 and libxslt versions
xsltprocVer=$(xsltproc -V | head -n1 )
libxmlVer=$(echo $xsltprocVer | cut -d " " -f3)
libxsltVer=$(echo $xsltprocVer | cut -d " " -f5)
# Version numbers are packed strings not xx.yy.zz format.
check_version "2.06.20" "${libxmlVer:0:1}.${libxmlVer:1:2}.${libxmlVer:3:2}" "LIBXML2"
check_version "1.01.14" "${libxsltVer:0:1}.${libxsltVer:1:2}.${libxsltVer:3:2}" "LIBXSLT"
else
echo "${nl_}\"${RED}xsltproc${OFF}\" ${BOLD}must be installed on your system for jhalfs to run"
exit 1
fi
# Now that we do profiling, we need the docbook DTD, and the docbook XSL
# stylesheets.
# Minimal docbook-xml code for testing
XML_FILE="<?xml version='1.0' encoding='ISO-8859-1'?>
<?xml-stylesheet type='text/xsl' href='http://docbook.sourceforge.net/release/xsl/current/xhtml/docbook.xsl'?>
# Check if the proper DocBook-XML-DTD and DocBook-XSL are correctly installed
XML_FILE="<?xml version='1.0' encoding='ISO-8859-1'?>
<?xml-stylesheet type='text/xsl' href='http://docbook.sourceforge.net/release/xsl/1.69.1/xhtml/docbook.xsl'?>
<!DOCTYPE article PUBLIC '-//OASIS//DTD DocBook XML V4.5//EN'
'http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd'>
<article>
@ -246,17 +140,24 @@ inline_doc
</sect1>
</article>"
if echo $XML_FILE | xmllint -nonet -noout -postvalid - 2>/dev/null ; then
check_version "4.5" "4.5" "DocBook XML DTD"
else
echo "Error: you need the Docbook XML DTD for running jhalfs"
exit 1
fi
if [[ -z "$DEP_DBXML" ]] ; then
if `echo $XML_FILE | xmllint -noout -postvalid - 2>/dev/null` ; then
check_version "4.5" "4.5" "DocBook XML DTD"
else
echo "Warning: not found a working DocBook XML DTD 4.5 installation"
exit 2
fi
fi
if echo $XML_FILE | xsltproc -nonet -noout - 2>/dev/null ; then
check_version "current" "current" "DocBook XSL stylesheets"
else
echo "Error: you need the Docbook XSL stylesheets for running jhalfs"
exit 1
fi
}
# if [[ -z "$DEP_DBXSL" ]] ; then
# if `echo $XML_FILE | xsltproc --noout - 2>/dev/null` ; then
# check_version "1.69.1" "1.69.1" "DocBook XSL"
# else
# echo "Warning: not found a working DocBook XSL 1.69.1 installation"
# exit 2
# fi
# fi
fi # end BLFS_TOOL=Y
}

View file

@ -1,3 +1,5 @@
# $Id$
#----------------------------------#
wrt_compare_targets() { #
#----------------------------------#
@ -6,9 +8,8 @@ wrt_compare_targets() { #
# and "ITERATIONS" with no "$".
ITERATION=iteration-$N
if [ "$N" != "1" ] ; then
wrt_system_build "$1" "$N" "$PREV_IT"
wrt_system_build "$N" "$PREV_IT"
fi
# add needed Makefile target
this_script=$ITERATION
CHROOT_wrt_target "$ITERATION" "$PREV"
wrt_compare_work "$ITERATION" "$PREV_IT"
@ -17,33 +18,32 @@ wrt_compare_targets() { #
PREV_IT=$ITERATION
PREV=$ITERATION
done
# We need to prevent "userdel" in all iterations but the last
# We need to access the scriptlets in "dir"
local dir
printf -v dir chapter%02d "$1"
REVISED=cleanup
if ls $dir/*revised* 2>/dev/null; then REVISED=revised; fi
sed -i '/userdel/d' $dir/*$REVISED*
for (( N = 2; N < ITERATIONS; N++ )); do
sed -i '/userdel/d' $dir-build_$N/*$REVISED*
done
}
#----------------------------------#
wrt_system_build() { #
#----------------------------------#
local CHAP=$1
local RUN=$2
local PREV_IT=$3
local RUN=$1
local PREV_IT=$2
chapter_targets $CHAP $RUN
if [[ "$PROGNAME" = "clfs" ]] ; then
final_system_Makefiles $RUN
else
chapter6_Makefiles $RUN
fi
CHROOT_TGT="$CHROOT_TGT $PREV_IT $system_build"
if [[ "$PROGNAME" = "clfs" ]] ; then
basicsystem="$basicsystem $PREV_IT $system_build"
else
chapter6="$chapter6 $PREV_IT $system_build"
fi
if [[ "$RUN" = "$ITERATIONS" ]] ; then
CHROOT_TGT="$CHROOT_TGT iteration-$RUN"
if [[ "$PROGNAME" = "clfs" ]] ; then
basicsystem="$basicsystem iteration-$RUN"
else
chapter6="$chapter6 iteration-$RUN"
fi
fi
}
@ -53,32 +53,55 @@ wrt_compare_work() { #
local ITERATION=$1
local PREV_IT=$2
local PRUNEPATH="/dev /home /${SCRIPT_ROOT} /lost+found /media /mnt /opt /proc \
/sources /root /run /srv /sys /tmp /tools /usr/local /usr/src /var"
/sources /root /srv /sys /tmp /tools /usr/local /usr/src"
local ROOT_DIR=/
local DEST_TOPDIR=/${SCRIPT_ROOT}
local ICALOGDIR=/${SCRIPT_ROOT}/logs/ICA
local ICALOGDIR=/${SCRIPT_ROOT}/${LOGDIRBASE}/ICA
local FARCELOGDIR=/${SCRIPT_ROOT}/${LOGDIRBASE}/farce
if [[ "$RUN_ICA" = "y" ]] ; then
local DEST_ICA=$DEST_TOPDIR/ICA && \
# the PRUNEPATH additional setting is to avoid .pyc files to show up in diff
(
cat << EOF
@PRUNEPATH="$PRUNEPATH \$\$(find /usr/lib -name __pycache__)"; \\
extras/do_copy_files "\$\$PRUNEPATH" $ROOT_DIR $DEST_ICA/$ITERATION >>logs/\$@ 2>&1 && \\
extras/do_ica_prep $DEST_ICA/$ITERATION >>logs/\$@ 2>&1
@extras/do_copy_files "$PRUNEPATH" $ROOT_DIR $DEST_ICA/$ITERATION >> ${LOGDIRBASE}/\$@ 2>&1 && \\
extras/do_ica_prep $DEST_ICA/$ITERATION >> ${LOGDIRBASE}/\$@ 2>&1
EOF
) >> $MKFILE.tmp
if [[ "$ITERATION" != "iteration-1" ]] ; then
wrt_do_ica_work "$PREV_IT" "$ITERATION" "$DEST_ICA"
fi
fi
if [[ "$RUN_FARCE" = "y" ]] ; then
local DEST_FARCE=$DEST_TOPDIR/farce && \
(
cat << EOF
@extras/do_copy_files "$PRUNEPATH" $ROOT_DIR $DEST_FARCE/$ITERATION >> ${LOGDIRBASE}/\$@ 2>&1 && \\
extras/filelist $DEST_FARCE/$ITERATION $DEST_FARCE/filelist-$ITERATION >> ${LOGDIRBASE}/\$@ 2>&1
EOF
) >> $MKFILE.tmp
if [[ "$ITERATION" != "iteration-1" ]] ; then
wrt_do_farce_work "$PREV_IT" "$ITERATION" "$DEST_FARCE"
fi
fi
}
#----------------------------------#
wrt_do_ica_work() { #
#----------------------------------#
echo -e "\t@extras/do_ica_work $1 $2 $ICALOGDIR $3 >>logs/\$@ 2>&1" >> $MKFILE.tmp
echo -e "\t@extras/do_ica_work $1 $2 $ICALOGDIR $3 >> ${LOGDIRBASE}/\$@ 2>&1" >> $MKFILE.tmp
}
#----------------------------------#
wrt_do_farce_work() { #
#----------------------------------#
local OUTPUT=$FARCELOGDIR/${1}_V_${2}
local PREDIR=$3/$1
local PREFILE=$3/filelist-$1
local ITEDIR=$3/$2
local ITEFILE=$3/filelist-$2
echo -e "\t@extras/farce --directory $OUTPUT $PREDIR $PREFILE $ITEDIR $ITEFILE >> ${LOGDIRBASE}/\$@ 2>&1" >> $MKFILE.tmp
}
#----------------------------------#
@ -86,31 +109,24 @@ wrt_logs() { #
#----------------------------------#
local build=build_$1
local file
local ch_order=${PREV%%_*}
echo -e "\t@cd /\$(SCRIPT_ROOT)/${LOGDIRBASE} && mkdir $build && mv -f ${ch_order}_* $build" >> $MKFILE.tmp
if [ ! "${1}" = "1" ] ; then
(
cat << EOF
@cd logs && \\
mkdir $build && \\
mv -f `echo ${system_build} | sed 's/ /* /g'`* $build && \\
if [ ! $build = build_1 ] ; then \\
cd $build && \\
for file in \`ls .\` ; do \\
mv -f \$\$file \`echo \$\$file | sed -e 's,-$build,,'\` ; \\
done ; \\
fi
@cd /\$(SCRIPT_ROOT)
@if [ -d test-logs ] ; then \\
cd test-logs && \\
mkdir $build && \\
mv -f `echo ${system_build} | sed 's/ /* /g'`* $build && \\
if [ ! $build = build_1 ] ; then \\
cd $build && \\
for file in \`ls .\` ; do \\
mv -f \$\$file \`echo \$\$file | sed -e 's,-$build,,'\` ; \\
done ; \\
fi ; \\
cd /\$(SCRIPT_ROOT) ; \\
fi ;
@cd $build && \\
for file in \`ls .\` ; do \\
mv -f \$\$file \`echo \$\$file | sed -e 's,-$build,,'\` ; \\
done ;
EOF
) >> $MKFILE.tmp
fi
if [ ${CONFIG_TESTS} = "y" ] ; then
echo -e "\t@cd /\$(SCRIPT_ROOT)/${TESTLOGDIRBASE} && mkdir $build && mv -f ${ch_order}_* $build" >> $MKFILE.tmp
fi
echo -e "\t@cd /\$(SCRIPT_ROOT)" >> $MKFILE.tmp
}

View file

@ -1,96 +1,64 @@
#!/bin/bash
# $Id$
#----------------------------------#
wrt_CustomTools_target() { # Add any users supplied scripts
#----------------------------------#
PREV=""
echo " Adding custom packages... ${BOLD}START${OFF}"
echo "${tab_}${GREEN}Processing... ${L_arrow}CUSTOM_TOOLS ${R_arrow}"
# Create the custom_tools scripts directory
mkdir -p custom-tools
for file in custom-tools/* ; do
# Keep the script file name
this_script=`basename $file`
for file in $JHALFSDIR/custom-commands/*; do
if [[ `basename ${file}` = "*" ]]; then
break
# Grab the phase name to be used with INSTALL_LOG and tracking dir touch
name=`grep "^PKG_PHASE=" ${file} | sed -e 's@PKG_PHASE=@@'`
# Grab also the package version
pkg_ver=`grep "^VERSION=" ${file} | sed -e 's@VERSION=@@'`
# Append each name of the script files to a list (this will become
# the names of the targets in the Makefile)
custom_list="$custom_list ${this_script}"
#--------------------------------------------------------------------#
# >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
#--------------------------------------------------------------------#
#
# Drop in the name of the target on a new line, and the previous target
# as a dependency. Also call the echo_message function.
wrt_target "${this_script}" "$PREV"
# Touch timestamp file if installed files logs will be created.
if [ "$name" != "" ] && [ "${INSTALL_LOG}" = "y" ] ; then
wrt_TouchTimestamp
fi
source $file
this_script=$(basename ${file})
echo "$tab_${GREEN}Adding${OFF} ${this_script}"
# Create a Makefile entry
if [[ "x${PKG}" = "x" ]]; then
# Create an entry for a self contained cmd script that does not
# reference a package tarball
CHROOT_wrt_target "${this_script}" "$PREV"
CHROOT_wrt_RunAsRoot "custom-tools/${this_script}"
wrt_touch
# Run the script.
wrt_RunScript "$file"
# Create the build script file
( cat <<- xEOFx
#!/bin/bash
set -e
`cat tmp`
exit
xEOFx
) > custom-tools/${this_script}
# Write installed files log
if [ "$name" != "" ] && [ "${INSTALL_LOG}" = "y" ] ; then
wrt_LogNewFiles "$name"
fi
# Touch the tracking file.
if [ "$PROGNAME" = "clfs2" ]; then
echo -e "\t@touch \$(MOUNT_PT)$TRACKING_DIR/${name}-${pkg_ver}" >> $MKFILE.tmp
else
# Create an entry for package
CHROOT_wrt_target "${this_script}" "$PREV"
CHROOT_Unpack "${PKG_FILE}"
CHROOT_wrt_RunAsRoot "custom-tools/${this_script}"
CHROOT_wrt_RemoveBuildDirs "${PKG}"
echo -e "\t@touch $TRACKING_DIR/${PKG}-${PKG_VERSION}" >> $MKFILE.tmp
wrt_touch
# Create the build script file
( cat <<- xEOFx
#!/bin/bash
set -e
cd \$PKGDIR
`cat tmp`
exit
xEOFx
) > custom-tools/$this_script
echo -e "\t@touch $TRACKING_DIR/${name}-${pkg_ver}" >> $MKFILE.tmp
fi
rm -f tmp
PREV=$this_script
custom_list="${custom_list} ${this_script}"
# Include a touch of the target name so make can check
# if it's already been made.
wrt_touch
#
#--------------------------------------------------------------------#
# >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
#--------------------------------------------------------------------#
# Keep the script file name for Makefile dependencies.
PREV=${this_script}
done
# Make the scripts executable.
chmod +x custom-tools/*
echo " Adding custom packages... ${BOLD}DONE${OFF}"
}
#----------------------------------#
add_CustomToolsURLS() { # Add any users supplied scripts URL information
#----------------------------------#
local this_script
local URL PKG PKG_VERSION PKG_FILE MD5
> urls.lst.tmp
for this_script in $JHALFSDIR/custom-commands/*; do
if [[ `basename ${this_script}` = "*" ]]; then
CUSTOM_TOOLS="n"
break
fi
source $this_script
# A cmd only script had no PKG defined
[[ "x${PKG}" = "x" ]] && continue
echo "${URL} ${MD5}" >> urls.lst.tmp
# Add any patches..
for PATCH in PATCH{1..10}; do
[[ -n ${!PATCH} ]] && echo "${!PATCH} CUSTOM-PATCH-MD5SUM" >> urls.lst.tmp
done
done
cat urls.lst.tmp >> $BUILDDIR/sources/urls.lst
rm urls.lst.tmp
}

View file

@ -1,20 +1,16 @@
#!/bin/bash
# $Id$
#----------------------------#
get_sources() { # Download file, write name to MISSING_FILES.DMP if an error
#----------------------------#
local saveIFS=$IFS
local IFS line URL1 URL2 FILE BOOKMD5 MD5 HAVEMD5 fromARCHIVE
# Test if the packages must be downloaded
[ "$GETPKG" = y ] || return 0
local URL FILE BOOKMD5 MD5 HAVEMD5 fromARCHIVE WGETPARAM MAYBEMORE
WGETPARAM=""
if [[ "${RETRYSRCDOWNLOAD}" = "y" ]] ; then
WGETPARAM+="--retry-connrefused"
fi
WGETPARAM+=" --tries ${RETRYDOWNLOADCNT}"
WGETPARAM+=" --timeout ${DOWNLOADTIMEOUT}"
[ ! "$GETPKG" = "y" ] && return
gs_wrt_message(){
echo "${RED}$1${OFF}"
@ -23,67 +19,73 @@ get_sources() { # Download file, write name to MISSING_FILES.DMP if
# Housekeeping
[[ ! -d $BUILDDIR/sources ]] && mkdir $BUILDDIR/sources
cd $BUILDDIR/sources
[[ -f MD5SUMS ]] && rm MD5SUMS
[[ -f MISSING_FILES.DMP ]] && rm MISSING_FILES.DMP
[[ -f urls.lst ]] && rm urls.lst
# Generate URLs file
create_urls
# Clean up leftovers from preceding attempts
>MISSING_FILES.DMP
IFS=$'\x0A' # Modify the 'internal field separator' to break on 'LF' only
for line in `cat urls.lst`; do
IFS=$saveIFS # Restore the system defaults
# Normally, urls.lst contains lines with two fields:
# <package url> <book md5>, but
# if a custom patch has an md5, there is a third field
# on the line, due to the way add_CustomToolsURLS works.
cat urls.lst | while read URL BOOKMD5 MAYBEMORE; do
FILE=$(basename "$URL") # File name
# Skip some packages if they aren't needed
case $line in
*/tcl* | */expect* | */dejagnu* | */tree* | */gcc-testsuite* )
[[ "$TEST" = "0" ]] && continue
;;
*/vim-*-lang* )
[[ "$VIMLANG" = "0" ]] && continue
;;
*linux/linux-* )
[[ -z "$CONFIG" ]] && [[ -z "$BOOT_CONFIG" ]] && \
[[ "$GETKERNEL" = "n" ]] && continue
;;
esac
# Locations
URL1=`echo $line | cut -d" " -f2` # Preferred URL
URL2=`echo $line | cut -d" " -f1` # Fallback Upstream URL
FILE=`basename $URL1` # File name
BOOKMD5=`echo $line | cut -d" " -f3` # MD5 book value
# Validation pair
MD5="$BOOKMD5 $FILE"
HAVEMD5=1
set -e
# If the file exists in the archive, copy it to the
# If the file exists in the archive copy it to the
# $BUILDDIR/sources dir. MD5SUM will be validated later.
if [ -n "${SRC_ARCHIVE}" ] &&
[ -d "${SRC_ARCHIVE}" ] &&
[ -f "${SRC_ARCHIVE}/$FILE" ]; then
cp "${SRC_ARCHIVE}/$FILE" .
if [ ! -z ${SRC_ARCHIVE} ] &&
[ -d ${SRC_ARCHIVE} ] &&
[ -f ${SRC_ARCHIVE}/$FILE ]; then
cp ${SRC_ARCHIVE}/$FILE .
echo "$FILE: -- copied from $SRC_ARCHIVE"
fromARCHIVE=1
else
echo "${BOLD}${YELLOW}$FILE: not found in ${SRC_ARCHIVE}${OFF}"
fromARCHIVE=0
# If the file does not exist yet in /sources, download a fresh one
if [ ! -f "$FILE" ] ; then
if [ -n "$SRC_ARCHIVE" ] ; then
echo "${BOLD}${YELLOW}$FILE: not found in ${SRC_ARCHIVE} nor in ${BUILDDIR}/sources${OFF}"
else
echo "${BOLD}${YELLOW}$FILE: not found in ${BUILDDIR}/sources${OFF}"
fi
if ! wget "$URL" $WGETPARAM; then
gs_wrt_message "$FILE not found on any server..SKIPPING"
# If the file does not exist yet in /sources download a fresh one
if [ ! -f $FILE ] ; then
if ! wget $URL1 && ! wget $URL2 ; then
gs_wrt_message "$FILE not found in the SRC_ARCHIVE or on any server..SKIPPING"
continue
fi
else
echo "${BOLD}${YELLOW}$FILE: using cached file in ${BUILDDIR}/sources${OFF}"
fi
fi
# Deal with bootscripts md5sum issue,
# or skip if it is a custom patch without md5
[ $BOOKMD5 = "BOOTSCRIPTS-MD5SUM" ] && continue
[ $BOOKMD5 = "CUSTOM-PATCH-MD5SUM" ] && continue
# IF the md5sum does not match
# IF the md5sum does not match the existing files
if ! echo "$MD5" | md5sum -c - >/dev/null ; then
[ "$fromARCHIVE" = 1 ] && echo "${BOLD}${YELLOW}MD5SUM did not match $SRC_ARCHIVE copy${OFF}"
[ "$fromARCHIVE" = 0 ] && echo "${BOLD}${YELLOW}MD5SUM did not match REMOTE copy${OFF}"
[[ $fromARCHIVE = "1" ]] && echo "${BOLD}${YELLOW}MD5SUM did not match SRC_ARCHIVE copy${OFF}"
[[ $fromARCHIVE = "0" ]] && echo "${BOLD}${YELLOW}MD5SUM did not match REMOTE copy${OFF}"
# Remove the old file and download a new one
rm -fv "$FILE"
rm -fv $FILE
# Force storage in SRC_ARCHIVE
fromARCHIVE=0;
# Try to retrieve again the file.
if ! wget "$URL" $WGETPARAM; then
gs_wrt_message "$FILE not found on the server... SKIPPING"
# Try to retrieve again the file. Servers in reverse order.
if ! wget $URL2 && ! wget $URL1 ; then
gs_wrt_message "$FILE not found on the servers.. SKIPPING"
continue
fi
fi
@ -96,7 +98,7 @@ get_sources() { # Download file, write name to MISSING_FILES.DMP if
fi
# Generate a fresh MD5SUM for this file
if [ "$HAVEMD5" = "0" ] ; then
if [[ "$HAVEMD5" = "0" ]] ; then
echo "${BOLD}${YELLOW}Generating a new MD5SUM for ${OFF}$FILE"
echo "NEW MD5SUM: $(md5sum $FILE)" >> MISSING_FILES.DMP
fi
@ -106,13 +108,12 @@ get_sources() { # Download file, write name to MISSING_FILES.DMP if
# Copy the freshly downloaded file
# to the source archive.
if [ -n "${SRC_ARCHIVE}" ] &&
[ -d "${SRC_ARCHIVE}" ] &&
[ -w "${SRC_ARCHIVE}" ] &&
[ ! -f "${SRC_ARCHIVE}/$FILE" ] &&
[ "$fromARCHIVE" = 0 ] ; then
if [ ! -z ${SRC_ARCHIVE} ] &&
[ -d ${SRC_ARCHIVE} ] &&
[ -w ${SRC_ARCHIVE} ] &&
[ "$fromARCHIVE" = "0" ] ; then
echo "Storing file:<$FILE> in the package archive"
cp -f "$FILE" "${SRC_ARCHIVE}"
cp -f $FILE ${SRC_ARCHIVE}
fi
done
@ -130,20 +131,90 @@ create_urls() { #
#----------------------------#
cd $JHALFSDIR
echo -n "Creating URLs file... "
xsltproc --nonet --xinclude \
--stringparam pkgmngt "$PKGMNGT" \
--stringparam revision "$INITSYS" \
--output ../sources/urls.lst \
urls.xsl \
$BOOK/chapter03/chapter03.xml >>$LOGDIR/$LOG 2>&1
echo "OK"
case ${PROGNAME} in
clfs)
echo -n "Creating CLFS <${ARCH}> specific URLs file"
xsltproc --nonet --xinclude \
--stringparam server $SERVER \
--stringparam family clfs \
-o $BUILDDIR/sources/urls.lst $CODE_DIR/XSL/urls.xsl \
$BOOK/materials/$ARCH-chapter.xml >>$LOGDIR/$LOG 2>&1
;;
clfs2)
echo -n "Creating CLFS2 <${ARCH}> specific URLs file"
xsltproc --nonet --xinclude \
--stringparam server $SERVER \
--stringparam family clfs \
-o $BUILDDIR/sources/urls.lst $CODE_DIR/XSL/urls.xsl \
$BOOK/materials/$ARCH-chapter.xml >>$LOGDIR/$LOG 2>&1
;;
clfs3)
echo -n "Creating CLFS3 <${ARCH}> specific URLs file"
xsltproc --nonet --xinclude \
--stringparam server $SERVER \
--stringparam family clfs \
-o $BUILDDIR/sources/urls.lst $CODE_DIR/XSL/urls.xsl \
$BOOK/materials/$ARCH-chapter.xml >>$LOGDIR/$LOG 2>&1
;;
hlfs)
echo -n "Creating HLFS <${MODEL}> + <${KERNEL}> specific URLs file"
xsltproc --nonet --xinclude \
--stringparam server $SERVER \
--stringparam family lfs \
--stringparam model $MODEL \
--stringparam kernel $KERNEL \
-o $BUILDDIR/sources/urls.lst $CODE_DIR/XSL/urls.xsl \
$BOOK/chapter04/chapter04.xml >>$LOGDIR/$LOG 2>&1
;;
lfs)
echo -n "Creating LFS specific URLs file"
xsltproc --nonet --xinclude \
--stringparam server $SERVER \
--stringparam family lfs \
-o ../sources/urls.lst $CODE_DIR/XSL/urls.xsl \
$BOOK/chapter03/chapter03.xml >>$LOGDIR/$LOG 2>&1
;;
esac
add_extra_urls
echo " ...OK"
cd $BUILDDIR/sources
if [[ "${CUSTOM_TOOLS}" = "y" ]]; then
add_CustomToolsURLS
fi
}
#----------------------------# Add download URLs found in user added scripts,
add_extra_urls() { # blfs-tool-deps scripts, and custom-tools scripts
#----------------------------#
local saveIFS=$IFS
local IFS file line package tarball download md5sum patchurl patchname patchmd5
local BLFS_SERVER="${SERVER}/pub/blfs/conglomeration/"
for file in ${PROGNAME}-commands/*/* ; do
# Grab the package name, tarball, download URL and MD5SUM
package=`grep "^PACKAGE=" ${file} | sed -e 's@PACKAGE=@@'`
tarball=`grep "^TARBALL=" ${file} | sed -e 's@TARBALL=@@'`
download=`grep "^DOWNLOAD=" ${file} | sed -e 's@DOWNLOAD=@@'`
md5sum=`grep "^MD5SUM=" ${file} | sed -e 's@MD5SUM=@@'`
# Be sure that we have a download URL and MD5SUM value
if [ -n "${download}" ] && [ -n "${md5sum}" ] ; then
# Write the package entry
echo "${download} ${BLFS_SERVER}${package}/${tarball} ${md5sum}" >> ../sources/urls.lst
fi
# Handle the patches, if any
IFS=$'\x0A'
for line in `grep "^PATCH=" ${file}` ; do
IFS=$saveIFS
patchurl=`echo ${line} | sed -e 's@PATCH="@@' -e 's@ .*@@'`
patchname=${patchurl##*/}
patchmd5=`echo ${line} | sed -e 's@.* @@' -e 's@"@@'`
# Write the patch entry
echo "${patchurl} ${BLFS_SERVER}${package}/${patchname} ${patchmd5}" >> ../sources/urls.lst
done
done
}

View file

@ -1,271 +0,0 @@
#!/bin/bash
#----------------------------# Prepare BLFS_ROOT and extract
install_blfs_tools() { # the scriptlets to build
#----------------------------# the dependency tools
set -e
# Install the files
[[ ! -d "${BUILDDIR}${BLFS_ROOT}" ]] && {
sudo mkdir -pv "${BUILDDIR}${BLFS_ROOT}"
sudo chown "$USER" "${BUILDDIR}${BLFS_ROOT}"
}
cp -r BLFS/* ${BUILDDIR}${BLFS_ROOT}
cp -r menu ${BUILDDIR}${BLFS_ROOT}
cp $COMMON_DIR/progress_bar.sh ${BUILDDIR}${BLFS_ROOT}
cp README.BLFS ${BUILDDIR}${BLFS_ROOT}
if [ "$WRAP_INSTALL" = y ]; then
sed -e 's/PKGDIR/JH_UNPACKDIR/' \
-e 's/PKG_DEST/JH_PKG_DIR/' \
$PKGMNGTDIR/packInstall.sh > ${BUILDDIR}${BLFS_ROOT}/packInstall.sh
fi
# Set some harcoded envars to their proper values
sed -i s@tracking-dir@$TRACKING_DIR@ \
${BUILDDIR}${BLFS_ROOT}/{Makefile,gen-makefile.sh,gen_pkg_book.sh}
# If we have a working copy, copy it:
if [[ "$BLFS_WORKING_COPY" = "y" ]]; then
echo "copying the local BLFS working copy (may take some time)"
# -r: recursive; -u: only if newer; -T: otherwise, would copy to a subdirectory
# of blfs-xml, if blfs-xml already exists; --preserve=timestamps: if the local
# book has already been validated, tmp is posterior to the others, and
# validation will not be done again.
# sudo is needed because make (below) may already have been run and
# may have put some files owned by root
sudo cp -ruT --preserve=timestamps $BLFS_WC_LOCATION \
${BUILDDIR}${BLFS_ROOT}/$BLFS_XML
fi
# Copy the LFS book. Note that now, the book is downloaded before running
# the BLFS tools.
sudo cp -ruT --preserve=timestamps $BOOK \
${BUILDDIR}${BLFS_ROOT}/$LFS_XML
# Downloads the book if necessary, initialize the tracking file and the
# package database.
# updating first is needed if the xml sources have already been cloned
# and we want to set the branches.
# Note that if LFS-BRANCH or BLFS-BRANCH is empty, which may happen
# if using a working copy, then the corresponding update is not
# performed by make (see BLFS/Makefile).
# sudo is needed if $BUILDDIR/var/lib is owned by root and /var/lib/jhalfs
# has to be created
sudo make -j1 -C $BUILDDIR$BLFS_ROOT \
REV=$INITSYS \
LFS-BRANCH=${COMMIT} \
BLFS-BRANCH=${BLFS_COMMIT} \
update
sudo make -j1 -C $BUILDDIR$BLFS_ROOT \
REV=$INITSYS \
TRACKING_DIR=$BUILDDIR$TRACKING_DIR \
LFS_XML=$BUILDDIR$BLFS_ROOT/$LFS_XML \
LFS-BRANCH="${COMMIT}" \
BLFS_XML=$BUILDDIR$BLFS_ROOT/$BLFS_XML \
BLFS-BRANCH=${BLFS_COMMIT} \
$BUILDDIR$BLFS_ROOT/packages.xml
# But then $BUILDDIR/var/lib/ is owned by root if just created, which
# prevents $LUSER to create "nss_db". The problem is that $LUSER
# May not have been created yet. So do not change ownership here
# and do it in master.sh for chapter 4.
#sudo chown $LUSER:$LGROUP $BUILDDIR/var/lib
# Because the BLFS Makefile is supposed to be used in chroot (or booted)
# mode, the tracking file has wrong path for DTD. Change it:
sudo sed -i s@$BUILDDIR@@ $BUILDDIR$TRACKING_DIR/instpkg.xml
# Manually build a 'configuration' file
if [ "$DEP_LIBXML" = y ]; then
LINE_LIBXML='CONFIG_libxml2=y'
else
LINE_LIBXML='#CONFIG_libxml2 is not set'
fi
if [ "$DEP_LIBXSLT" = y ]; then
LINE_LIBXSLT='CONFIG_libxslt=y'
else
LINE_LIBXSLT='#CONFIG_libxslt is not set'
fi
# DocBook is a rec dep of libxslt
# if [ "$DEP_DBXML" = y ]; then
# LINE_DBXML='CONFIG_DocBook=y'
# else
# LINE_DBXML='#CONFIG_DocBook is not set'
# fi
if [ "$DEP_LYNX" = y ]; then
LINE_LYNX='CONFIG_lynx=y'
else
LINE_LYNX='#CONFIG_lynx is not set'
fi
if [ "$DEP_SUDO" = y ]; then
LINE_SUDO='CONFIG_sudo=y'
else
LINE_SUDO='#CONFIG_sudo is not set'
fi
if [ "$DEP_WGET" = y ]; then
LINE_WGET='CONFIG_wget=y'
else
LINE_WGET='#CONFIG_wget is not set'
fi
if [ "$DEP_GPM" = y ]; then
LINE_GPM='CONFIG_gpm=y'
else
LINE_GPM='#CONFIG_gpm is not set'
fi
if [ "$DEP_GIT" = y ]; then
LINE_GIT='CONFIG_git=y'
else
LINE_GIT='#CONFIG_git is not set'
fi
cat >$BUILDDIR$BLFS_ROOT/configuration <<EOF
$LINE_LIBXML
$LINE_LIBXSLT
$LINE_WGET
$LINE_GIT
$LINE_GPM
$LINE_LYNX
$LINE_SUDO
MAIL_SERVER=sendmail
optDependency=2
SUDO=n
LANGUAGE=$LANG
WRAP_INSTALL=$WRAP_INSTALL
PACK_INSTALL=/blfs_root/packInstall.sh
DEL_LA_FILES=$DEL_LA_FILES
STATS=n
SRC_ARCHIVE=/sources
BUILD_ROOT=/sources
BUILD_SUBDIRS=y
JOBS=$(if [ "$ALL_CORES" = y ]; then echo 0; else echo $N_PARALLEL; fi)
EOF
# The 0 value above is for using all cores
for OPT_VAR in CFLAGS CXXFLAGS LDFLAGS; do
eval optVal=\$${OPT_VAR}_$DEF_OPT_MODE
if [ -n "$optVal" ] && [ "$optVal" != unset ]; then
echo "CFG_$OPT_VAR"=\"$optVal\" >> $BUILDDIR$BLFS_ROOT/configuration
else
echo "CFG_$OPT_VAR"=EMPTY >> $BUILDDIR$BLFS_ROOT/configuration
fi
done
# Generates the scripts for the blfs tools dependencies (in ./scripts)
yes "yes" | $BUILDDIR$BLFS_ROOT/gen_pkg_book.sh \
$BUILDDIR$TRACKING_DIR/instpkg.xml \
$BUILDDIR$BLFS_ROOT
# Move the scriptlets where they should be
sudo rm -rf $BUILDDIR$BLFS_ROOT/scripts
mv scripts $BUILDDIR$BLFS_ROOT
# Generates a list containing download and copying instructions for tarballs
echo -e '#!/bin/bash\nset -e\n' > $BUILDDIR$BLFS_ROOT/download_script
sed -n -e '/PACKAGE=/,/^fi/{/^fi/a\
[ ! -f "$JH_SRC_ARCHIVE/$PACKAGE" ] && cp $PACKAGE $JH_SRC_ARCHIVE
p}' \
-e '/|[ ]*md5sum/p' \
-e '/PACKAGE1=/,/^fi/{/^fi/a\
[ ! -f "$JH_SRC_ARCHIVE/$PACKAGE1" ] && cp $PACKAGE1 $JH_SRC_ARCHIVE
p}' \
-e '/PATCH=/,/^fi/{/^fi/a\
[ ! -f "$JH_SRC_ARCHIVE/$PATCH" ] && cp $PATCH $JH_SRC_ARCHIVE
p}' \
-e '/URL=/,/^fi/{/^fi/a\
[ ! -f "$JH_SRC_ARCHIVE/$BOOTPACKG" ] && cp $BOOTPACKG $JH_SRC_ARCHIVE
p}' \
$BUILDDIR$BLFS_ROOT/scripts/* >> $BUILDDIR$BLFS_ROOT/download_script
chmod u+x $BUILDDIR$BLFS_ROOT/download_script
# Downloads (or copy) to build_dir/sources
pushd $BUILDDIR/sources
# Remove `unpacked' files if some have been left
sudo find . -name unpacked -exec rm \{\} \;
if [ "$GETPKG" = "y" ]; then
JH_SRC_ARCHIVE=${SRC_ARCHIVE:-/dev/null} \
$BUILDDIR$BLFS_ROOT/download_script
else # Save the download script in case the user wants to run it later
cp $BUILDDIR$BLFS_ROOT/download_script .
fi
popd
rm -v $BUILDDIR$BLFS_ROOT/download_script
# Suppresses unneeded parts of the scriptlets
if [ "$DEP_LIBXSLT" = y ]; then
# libxslt pulls docbook-xsl in, which populates the catalog with annoying
# **EDITME** references. Fortunately, those lines are regognizable because
# they occur between lines containing '/etc/xml/catalog' at the end of the
# line (without '&&'). I have not found a simple way to delete lines
# between 2 addresses, excluding either the first or the last one. So use
# a loop for accumulating lines and deleting at the end.
# Sorry for sed syntax.
sed -i '\@^[[:space:]]*/etc/xml/catalog$@{
n
:a
\@/etc/xml/catalog$@bb
N
ba
:b
d}' \
$BUILDDIR$BLFS_ROOT/scripts/*docbook-xsl
fi
if [ "$DEP_SUDO" = y ]; then
sed -i '/cat.*pam.d/i mkdir -p /etc/pam.d' $BUILDDIR$BLFS_ROOT/scripts/*sudo
fi
# At last generates the build Makefile
mkdir -p $BUILDDIR$BLFS_ROOT/work
pushd $BUILDDIR$BLFS_ROOT/work
../gen-makefile.sh
# The generated Makefile updates the tracking file after each package
# installation, using libxslt, which is not installed yet. So move
# updating to the end of the process, adding an 'update' target
sed -i -e '/xsltproc/,+6d' \
-e '/^all/i update:' \
-e 's/touch/@touch/' Makefile
cat >> Makefile << EOF
update: all
@echo Updating the tracking file
@for pack in \$\$(grep '<productname' ../$LFS_XML/tmp/lfs-full.xml | \\
sed 's/.*>\([^<]*\)<.*/\1/' | \\
sort | uniq); do \\
case "x\$\$pack" in \\
xgcc* | *pass[12] | xvim | \\
xshadow | xPython | xlinux-headers | xdbus | xsystemd )\\
continue ;; \\
esac; \\
VERSION=\$\$(grep -A1 ">\$\$pack</product" \\
../$LFS_XML/tmp/lfs-full.xml | \\
head -n2| \\
sed -n '2s/.*>\([^<]*\)<.*/\1/p'); \\
xsltproc --stringparam packages ../packages.xml \\
--stringparam package \$\$pack \\
--stringparam version \$\$VERSION \\
-o track.tmp \\
../xsl/bump.xsl \$(TRACKING_FILE); \\
sed -i 's@PACKDESC@$BLFS_ROOT/packdesc.dtd@' track.tmp; \\
xmllint --format --postvalid track.tmp > \$(TRACKING_FILE); \\
rm track.tmp; \\
done; \\
VERSION=\$\$(grep 'echo.*lfs-release' ../$LFS_XML/tmp/lfs-full.xml | \\
sed 's/.*echo[ ]*\([^ ]*\).*/\1/'); \\
xsltproc --stringparam packages ../packages.xml \\
--stringparam package LFS-Release \\
--stringparam version \$\$VERSION \\
-o track.tmp \\
../xsl/bump.xsl \$(TRACKING_FILE); \\
sed -i 's@PACKDESC@$BLFS_ROOT/packdesc.dtd@' track.tmp; \\
xmllint --format --postvalid track.tmp > \$(TRACKING_FILE); \\
rm track.tmp; \\
for file in *-*; do \\
xsltproc --stringparam packages ../packages.xml \\
--stringparam package \$\${file##*z-} \\
-o track.tmp \\
../xsl/bump.xsl \$(TRACKING_FILE); \\
sed -i 's@PACKDESC@$BLFS_ROOT/packdesc.dtd@' track.tmp; \\
xmllint --format --postvalid track.tmp > \$(TRACKING_FILE); \\
rm track.tmp; \\
done
@touch \$@
@echo -e "\n\n "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK
@echo --------------------------------------------------------------------------------\$(WHITE)
EOF
popd
}

View file

@ -1,83 +0,0 @@
#----------------------------------#
wrt_save_target() { #
#----------------------------------#
local target
case $1 in
SUDO_TGT ) target=SUDO ;;
CHROOT_TGT ) target=CHROOT ;;
esac
CHROOT_wrt_target save-ch5 "$PREV";
wrt_save_work $target
wrt_touch
PREV=save-ch5
eval $1=\"\$$1 save-ch5\"
}
#----------------------------------#
wrt_save_work() { #
#----------------------------------#
local ROOT_DIR
case x"$1" in
xSUDO ) ROOT_DIR="$BUILDDIR/" ;;
xCHROOT) ROOT_DIR=/ ;;
esac
local PRUNEPATH="./dev ./home ./lost+found ./media ./mnt ./opt ./proc ./root ./run ./srv ./sys ./tmp ./var"
local DEST_TOPDIR="${ROOT_DIR}${SCRIPT_ROOT}"
(
cat << EOF
@mkdir -p /tmp >>logs/\$@ 2>&1 && \\
TARNAME=chapter5-\$\$(date +%Y-%m-%d-T-%Hh%M).tar && \\
TMPFILE=\$\$(mktemp -p /tmp) && \\
TMPLOG=\$\$(mktemp -p /tmp) && \\
for F in $PRUNEPATH; do echo \$\$F >> \$\$TMPFILE; done && \\
tar -X \$\$TMPFILE -cvf /tmp/\$\$TARNAME -C ${ROOT_DIR} . >>\$\$TMPLOG 2>>logs/\$@ && \\
cat \$\$TMPLOG >>logs/\$@ 2>&1 && \\
mv /tmp/\$\$TARNAME $DEST_TOPDIR >>logs/\$@ 2>&1 && \\
rm \$\$TMPFILE \$\$TMPLOG
EOF
) >> $MKFILE.tmp
}
#----------------------------------#
wrt_do_ica_work() { #
#----------------------------------#
echo -e "\t@extras/do_ica_work $1 $2 $ICALOGDIR $3 >>logs/\$@ 2>&1" >> $MKFILE.tmp
}
#----------------------------------#
wrt_logs() { #
#----------------------------------#
local build=build_$1
local file
(
cat << EOF
@cd logs && \\
mkdir $build && \\
mv -f `echo ${system_build} | sed 's/ /* /g'`* $build && \\
if [ ! $build = build_1 ] ; then \\
cd $build && \\
for file in \`ls .\` ; do \\
mv -f \$\$file \`echo \$\$file | sed -e 's,-$build,,'\` ; \\
done ; \\
fi
@cd /\$(SCRIPT_ROOT)
@if [ -d test-logs ] ; then \\
cd test-logs && \\
mkdir $build && \\
mv -f `echo ${system_build} | sed 's/ /* /g'`* $build && \\
if [ ! $build = build_1 ] ; then \\
cd $build && \\
for file in \`ls .\` ; do \\
mv -f \$\$file \`echo \$\$file | sed -e 's,-$build,,'\` ; \\
done ; \\
fi ; \\
cd /\$(SCRIPT_ROOT) ; \\
fi ;
EOF
) >> $MKFILE.tmp
}

View file

@ -1,3 +1,5 @@
# $Id$
declare -r dotSTR=".................."
@ -5,10 +7,12 @@ declare -r dotSTR=".................."
validate_config() { # Are the config values sane (within reason)
#----------------------------#
: <<inline_doc
Validates the configuration parameters.
Validates the configuration parameters. The global var PROGNAME selects the
parameter list.
input vars: none
externals: color constants
PROGNAME (lfs,hlfs,clfs,clfs2,clfs3,blfs)
modifies: none
returns: nothing
on error: write text to console and dies
@ -16,33 +20,45 @@ validate_config() { # Are the config values sane (within reason)
inline_doc
# Common settings by Config.in sections and books family
local -r BOOK_common="COMMIT BOOK CUSTOM_TOOLS"
local -r BOOK_common="BOOK CUSTOM_TOOLS"
local -r BOOK_clfsX="ARCH TARGET"
local -r GENERAL_common="LUSER LGROUP LHOME BUILDDIR CLEAN GETPKG SRC_ARCHIVE \
RETRYSRCDOWNLOAD RETRYDOWNLOADCNT DOWNLOADTIMEOUT \
RUNMAKE"
local -r BUILD_chroot="TEST STRIP"
SERVER GETKERNEL RUNMAKE"
local -r BUILD_chroot="TEST BOMB_TEST STRIP"
local -r BUILD_common="FSTAB CONFIG TIMEZONE PAGE LANG INSTALL_LOG"
local -r ADVANCED_chroot="COMPARE RUN_ICA ITERATIONS OPTIMIZE"
local -r ADVANCED_chroot="COMPARE RUN_ICA RUN_FARCE ITERATIONS OPTIMIZE"
local -r ADVANCED_common="REPORT REBUILD_MAKEFILE"
# BOOK Settings by book
local -r LFS_book="$BOOK_common INITSYS BLFS_TOOL"
local -r LFS_book="$BOOK_common BLFS_TOOL"
#local -r HLFS_added="SET_SSP SET_ASLR SET_PAX SET_HARDENED_TMP SET_WARNINGS \
# SET_MISC SET_BLOWFISH"
local -r HLFS_added=""
local -r HLFS_book="$BOOK_common BLFS_TOOL MODEL KERNEL GRSECURITY_HOST $HLFS_added"
local -r CLFS_book="$BOOK_common BLFS_TOOL METHOD $BOOK_clfsX TARGET32 BOOT_CONFIG"
local -r CLFS2_book="$BOOK_common BLFS_TOOL $BOOK_clfsX"
local -r CLFS3_book="$BOOK_common $BOOK_clfsX PLATFORM MIPS_LEVEL"
# Build Settings by book
local -r LFS_build="$BUILD_chroot NCURSES5 $BUILD_common PKGMNGT FULL_LOCALE WRAP_INSTALL"
# System Settings by book
local -r LFS_system="HOSTNAME INTERFACE IP_ADDR GATEWAY PREFIX BROADCAST DOMAIN DNS1 DNS2 FONT KEYMAP LOCAL LOG_LEVEL"
local -r LFS_build="$BUILD_chroot VIMLANG $BUILD_common"
local -r HLFS_build="$BUILD_chroot $BUILD_common"
local -r CLFS_build="$BUILD_chroot VIMLANG $BUILD_common"
local -r CLFS2_build="STRIP VIMLANG $BUILD_common"
local -r CLFS3_build=" $BUILD_common"
# Full list of books settings
local -r lfs_PARAM_LIST="$LFS_book $GENERAL_common $LFS_build $LFS_system $ADVANCED_chroot ALL_CORES CPUSET N_PARALLEL REALSBU SAVE_CH5 $ADVANCED_common"
# local -r blfs_PARAM_LIST="BRANCH_ID BLFS_ROOT BLFS_XML TRACKING_DIR"
local -r lfs_PARAM_LIST="$LFS_book $GENERAL_common $LFS_build $ADVANCED_chroot $ADVANCED_common"
local -r hlfs_PARAM_LIST="$HLFS_book $GENERAL_common $HLFS_build $ADVANCED_chroot $ADVANCED_common"
local -r clfs_PARAM_LIST="$CLFS_book $GENERAL_common $CLFS_build $ADVANCED_chroot $ADVANCED_common"
local -r clfs2_PARAM_LIST="$CLFS2_book $GENERAL_common $CLFS2_build $ADVANCED_common"
local -r clfs3_PARAM_LIST="$CLFS3_book $GENERAL_common $CLFS3_build $ADVANCED_common"
local -r blfs_PARAM_LIST="BRANCH_ID BLFS_ROOT BLFS_XML TRACKING_DIR"
# Additional variables
local -r blfs_tool_PARAM_LIST="\
BLFS_COMMIT BLFS_ROOT BLFS_XML TRACKING_DIR \
DEP_LIBXML DEP_LIBXSLT DEP_DBXML DEP_LYNX DEP_SUDO DEP_WGET \
DEP_GIT DEP_GPM"
# Additional variables (add DEP_DBXSL when required again)
local -r blfs_tool_PARAM_LIST="BLFS_BRANCH_ID BLFS_ROOT BLFS_XML TRACKING_DIR \
DEP_LIBXML DEP_LIBXSLT DEP_TIDY DEP_UNZIP \
DEP_DBXML DEP_LYNX DEP_SUDO DEP_WGET \
DEP_SVN DEP_GPM"
local -r custom_tool_PARAM_LIST="TRACKING_DIR"
# Internal variables
@ -63,15 +79,6 @@ inline_doc
exit 1
}
# This function is only used when testing package management files.
write_pkg_and_die() {
echo -e "\n${DD_BORDER}"
echo "Package management is requested but" >&2
echo -e $* >&2
echo -e "${DD_BORDER}\n"
exit 1
}
validate_file() {
# For parameters ending with a '+' failure causes a warning message only
echo -n "`eval echo $PARAM_VALS`"
@ -121,19 +128,21 @@ inline_doc
}
set +e
for config_param in $lfs_PARAM_LIST; do
PARAM_GROUP=${PROGNAME}_PARAM_LIST
for config_param in ${!PARAM_GROUP}; do
case $config_param in
# Envvars that depend on other settings to be displayed
COMPARE) [[ ! "$COMPARE" = "y" ]] && echo -e "`eval echo $PARAM_VALS`" ;;
RUN_ICA) [[ "$COMPARE" = "y" ]] && echo -e "`eval echo $PARAM_VALS`" ;;
ITERATIONS) [[ "$COMPARE" = "y" ]] && echo -e "`eval echo $PARAM_VALS`" ;;
TARGET32) [[ -n "${TARGET32}" ]] && echo -e "`eval echo $PARAM_VALS`" ;;
MIPS_LEVEL) [[ "${ARCH}" = "mips" ]] && echo -e "`eval echo $PARAM_VALS`" ;;
RETRYSRCDOWNLOAD) [[ "$GETPKG" = "y" ]] && echo -e "`eval echo $PARAM_VALS`" ;;
RETRYDOWNLOADCNT) [[ "$GETPKG" = "y" ]] && echo -e "`eval echo $PARAM_VALS`" ;;
DOWNLOADTIMEOUT) [[ "$GETPKG" = "y" ]] && echo -e "`eval echo $PARAM_VALS`" ;;
CPUSET) [[ "$HAVE_CGROUP" = "y" ]] && [[ "$ALL_CORES" = "y" ]] && echo -e "`eval echo $PARAM_VALS`" ;;
N_PARALLEL) [[ "$ALL_CORES" = "n" ]] && echo -e "`eval echo $PARAM_VALS`" ;;
GETKERNEL ) if [[ -z "$CONFIG" ]] && [[ -z "$BOOT_CONFIG" ]] ; then
[[ "$GETPKG" = "y" ]] && echo -e "`eval echo $PARAM_VALS`"
fi ;;
COMPARE) [[ ! "$COMPARE" = "y" ]] && echo -e "`eval echo $PARAM_VALS`" ;;
RUN_ICA) [[ "$COMPARE" = "y" ]] && echo -e "`eval echo $PARAM_VALS`" ;;
RUN_FARCE) [[ "$COMPARE" = "y" ]] && echo -e "`eval echo $PARAM_VALS`" ;;
ITERATIONS) [[ "$COMPARE" = "y" ]] && echo -e "`eval echo $PARAM_VALS`" ;;
BOMB_TEST) [[ ! "$TEST" = "0" ]] && echo -e "`eval echo $PARAM_VALS`" ;;
TARGET32) [[ -n "${TARGET32}" ]] && echo -e "`eval echo $PARAM_VALS`" ;;
MIPS_LEVEL) [[ "${ARCH}" = "mips" ]] && echo -e "`eval echo $PARAM_VALS`" ;;
SERVER) [[ "$GETPKG" = "y" ]] && echo -e "`eval echo $PARAM_VALS`" ;;
# Envars that requires some validation
LUSER) echo -e "`eval echo $PARAM_VALS`"
@ -154,7 +163,7 @@ inline_doc
# warning -z+ -w+
SRC_ARCHIVE) [[ "$GETPKG" = "y" ]] && validate_dir -z+ -d -w+ ;;
# The build directory/partition MUST exist and be writable by the user
BUILDDIR) validate_dir -z -d
BUILDDIR) validate_dir -z -d -w
[[ "xx x/x" =~ x${!config_param}x ]] && write_error_and_die ;;
LHOME) validate_dir -z -d ;;
@ -166,7 +175,7 @@ inline_doc
BOOT_CONFIG) [[ "${METHOD}" = "boot" ]] && validate_file -z -e -s ;;
# Treatment of LANG parameter
LANG ) # See if the locale value has been set
LANG ) # See it the locale value has been set
echo -n "`eval echo $PARAM_VALS`"
[[ -z "${!config_param}" ]] &&
echo " -- Variable $config_param cannot be empty!" &&
@ -174,36 +183,11 @@ inline_doc
echo
;;
# Treatment of HOSTNAME
HOSTNAME) echo -e "`eval echo $PARAM_VALS`"
[[ "${!config_param}" = "**EDIT ME**" ]] && write_error_and_die
;;
# BLFS params.
BRANCH_ID | BLFS_ROOT | BLFS_XML ) echo "`eval echo $PARAM_VALS`" ;;
TRACKING_DIR ) validate_dir -z -d -w ;;
# Case of PKGMNGT: two files, packageManager.xml and packInstall.sh
# must exist in $PKGMNGTDIR if PKGMNGT='y':
PKGMNGT) echo -e "`eval echo $PARAM_VALS`"
if [ "$PKGMNGT" = y ]; then
if [ ! -e "$PKGMNGTDIR/packageManager.xml" ]; then
write_pkg_and_die $PKGMNGTDIR/packageManager.xml does not exist
fi
if [ ! -e "$PKGMNGTDIR/packInstall.sh" ]; then
write_pkg_and_die $PKGMNGTDIR/packInstall.sh does not exist
fi
if [ ! -s "$PKGMNGTDIR/packageManager.xml" ]; then
write_pkg_and_die $PKGMNGTDIR/packageManager.xml has zero size
fi
if [ ! -s "$PKGMNGTDIR/packInstall.sh" ]; then
write_pkg_and_die $PKGMNGTDIR/packInstall.sh has zero size
fi
if [ ! -r "$PKGMNGTDIR/packageManager.xml" ]; then
write_pkg_and_die $PKGMNGTDIR/packageManager.xml is not readable
fi
if [ ! -r "$PKGMNGTDIR/packInstall.sh" ]; then
write_pkg_and_die $PKGMNGTDIR/packInstall.sh is not readable
fi
fi
;;
# Display non-validated envars found in lfs_PARAM_LIST
# Display non-validated envars found in ${PROGNAME}_PARAM_LIST
* ) echo -e "`eval echo $PARAM_VALS`" ;;
esac

View file

@ -1,5 +1,7 @@
#!/bin/bash
# $Id$
#=== MAKEFILE HEADER ===
#----------------------------------#
@ -15,36 +17,22 @@ wrt_Makefile_header() { #
SHELL = /bin/bash
SRC = /sources
MOUNT_PT = $BUILDDIR
PKG_LST = $PKG_LST
SCRIPT_ROOT = $SCRIPT_ROOT
CMDSDIR = $PROGNAME-commands
SRC = /sources
SRCSDIR = \$(MOUNT_PT)\$(SRC)
FILELOGDIR = /\$(SCRIPT_ROOT)/$FILELOGDIRBASE
LUSER = $LUSER
LGROUP = $LGROUP
LHOME = $LHOME
SCRIPT_ROOT = $SCRIPT_ROOT
BASEDIR = \$(MOUNT_PT)
SRCSDIR = \$(BASEDIR)/sources
CMDSDIR = \$(BASEDIR)/\$(SCRIPT_ROOT)/$COMMANDS
LOGDIR = \$(BASEDIR)/\$(SCRIPT_ROOT)/$LOGDIRBASE
TESTLOGDIR = \$(BASEDIR)/\$(SCRIPT_ROOT)/$TESTLOGDIRBASE
crCMDSDIR = /\$(SCRIPT_ROOT)/$COMMANDS
crLOGDIR = /\$(SCRIPT_ROOT)/$LOGDIRBASE
crTESTLOGDIR = /\$(SCRIPT_ROOT)/$TESTLOGDIRBASE
crFILELOGDIR = /\$(SCRIPT_ROOT)/$FILELOGDIRBASE
SU_LUSER = sudo -H -u \$(LUSER) sh -c
LUSER_HOME = \$(LHOME)/\$(LUSER)
PRT_DU = echo -e "\nKB: \`du -skx --exclude=\$(SCRIPT_ROOT) --exclude=lost+found \$(MOUNT_PT) \`\n"
PRT_DU_CR = echo -e "\nKB: \`du -skx --exclude=\$(SCRIPT_ROOT) --exclude=lost+found --exclude /var/lib / \`\n"
SU_LUSER = su - \$(LUSER) -c
ADD_REPORT = $REPORT
ADD_CUSTOM_TOOLS = $CUSTOM_TOOLS
ADD_BLFS_TOOLS = $BLFS_TOOL
PKGMNGT = $PKGMNGT
WRAP_INSTALL = $WRAP_INSTALL
CPUSET = $CPUSET
export PATH := \${PATH}:/usr/sbin
@ -61,43 +49,16 @@ EOF
#==== TARGET HEADER ====
#----------------------------------#
LUSER_wrt_target() { # Create target and initialize log file
wrt_target() { # Create target
#----------------------------------#
local i=$1
local PREV=$2
local version
if [ "$3" != "" ]; then
version=-$3
fi
(
cat << EOF
$i: $PREV
@\$(call echo_message, Building)
${NO_PROGRESS} @export BASHBIN=\$(SHELL) && \$(SHELL) progress_bar.sh \$@ \$\$PPID &
@echo "\$(nl_)\`date\`\$(nl_)" >logs/\$@$version
@ : > envars
EOF
) >> $MKFILE.tmp
}
#----------------------------------#
CHROOT_wrt_target() { # Create target and initialize log file
#----------------------------------#
local i=$1
local PREV=$2
local version
if [ "$3" != "" ]; then
version=-$3
fi
(
cat << EOF
$i: $PREV
@\$(call echo_message, Building)
${NO_PROGRESS} @export BASHBIN=\$(SHELL) && \$(SHELL) progress_bar.sh \$@ \$\$PPID &
@echo "\$(nl_)\`date\`\$(nl_)" >logs/\$@$version
@ : > envars
@export BASHBIN=\$(SHELL) && \$(SHELL) progress_bar.sh \$@ \$\$PPID &
EOF
) >> $MKFILE.tmp
}
@ -105,179 +66,63 @@ EOF
#=======================
#======== UNPACK =======
#======== RUN THE SCRIPT =======
#----------------------------------#
LUSER_wrt_unpack() { # Unpack and set 'ROOT' var
#----------------------------------#
local FILE="$1"
local optSAVE_PREVIOUS="$2"
local version
if [ "$3" != "" ]; then
version=-"$3"
fi
if [[ "${optSAVE_PREVIOUS}" != "1" ]]; then
(
cat << EOF
@\$(call remove_existing_dirs,$FILE)
EOF
) >> $MKFILE.tmp
fi
(
cat << EOF
@\$(PRT_DU) >>logs/\$@$version
@\$(call unpack,$FILE)
@\$(call get_pkg_root_LUSER)
EOF
) >> $MKFILE.tmp
}
#----------------------------------#
CHROOT_Unpack() { #
#----------------------------------#
local FILE=$1
local optSAVE_PREVIOUS=$2
local version
if [ "$3" != "" ]; then
version=-"$3"
fi
if [ "${optSAVE_PREVIOUS}" != "1" ]; then
(
cat << EOF
@\$(call remove_existing_dirs2,$FILE)
EOF
) >> $MKFILE.tmp
fi
(
cat << EOF
@\$(PRT_DU_CR) >>logs/\$@$version
@\$(call unpack2,$FILE)
@\$(call get_pkg_root2)
EOF
) >> $MKFILE.tmp
}
#=======================
#===== TESTS LOGS ======
#----------------------------------#
LUSER_wrt_test_log() { # Initialize testsuite log file
#----------------------------------#
local version
if [ "$2" != "" ]; then
version=-$2
fi
local TESTLOGFILE=$1$version
(
cat << EOF
@echo "export TEST_LOG=\$(TESTLOGDIR)/$TESTLOGFILE" >> envars && \\
echo "\$(nl_)\`date\`\$(nl_)" >\$(TESTLOGDIR)/$TESTLOGFILE
EOF
) >> $MKFILE.tmp
}
#----------------------------------#
CHROOT_wrt_test_log() { #
#----------------------------------#
local version
if [ "$2" != "" ]; then
version=-$2
fi
local TESTLOGFILE=$1$version
(
cat << EOF
@echo "export TEST_LOG=\$(crTESTLOGDIR)/$TESTLOGFILE" >> envars && \\
echo "\$(nl_)\`date\`\$(nl_)" >\$(crTESTLOGDIR)/$TESTLOGFILE
EOF
) >> $MKFILE.tmp
}
#=======================
#======== RUN AS =======
#----------------------------------#
wrt_RunAsRoot() { # Some scripts must be run as root..
wrt_RunAsRoot() { # Some not-chroot scripts must be run as root..
#----------------------------------#
local MOUNT_ENV
local version
if [ "$2" != "" ]; then
version=-$2
fi
local file=$1
case ${PROGNAME} in
lfs ) MOUNT_ENV="LFS" ;;
clfs ) MOUNT_ENV="CLFS" ;;
clfs2 ) MOUNT_ENV="CLFS" ;;
clfs3 ) MOUNT_ENV="CLFS" ;;
hlfs ) MOUNT_ENV="HLFS" ;;
*) echo "undefined progname $PROGNAME"; exit 1 ;;
esac
(
cat << EOF
@export LFS=\$(MOUNT_PT) && \\
$COMMANDS/`dirname $file`/\$@ >>logs/\$@$version 2>&1
@export ${MOUNT_ENV}=\$(MOUNT_PT) && \$(CMDSDIR)/`dirname $file`/\$@ > $LOGDIRBASE/\$@ 2>&1
EOF
) >> $MKFILE.tmp
}
#----------------------------------#
LUSER_wrt_RunAsUser() { # Calculate time with perl, footer to log file
wrt_RunScript() { #
#----------------------------------#
local file=$1
local version
if [ "$2" != "" ]; then
version=-$2
fi
(
cat << EOF
@source ~/.bashrc && \\
\$(CMDSDIR)/`dirname $file`/\$@ >> \$(LOGDIR)/\$@$version 2>&1
@\$(CMDSDIR)/`dirname $file`/\$@ > $LOGDIRBASE/\$@ 2>&1
EOF
) >> $MKFILE.tmp
}
#----------------------------------#
CHROOT_wrt_RunAsRoot() { #
#----------------------------------#
local file=$1
local version
if [ "$2" != "" ]; then
version=-$2
fi
(
cat << EOF
@source envars && \\
\$(crCMDSDIR)/`dirname $file`/\$@ >>\$(crLOGDIR)/\$@$version 2>&1
EOF
) >> $MKFILE.tmp
}
#=======================
#====== COPY FSTAB =====
#----------------------------------#
LUSER_wrt_CopyFstab() { #
LUSER_wrt_CopyFstab() { # Needed for CLFS Sysroot and Embedded
#----------------------------------#
(
cat << EOF
@cp -v \$(MOUNT_PT)/sources/fstab \$(MOUNT_PT)/etc/fstab >>logs/\$@ 2>&1 && \\
\$(PRT_DU) >>logs/\$@
@cp -v \$(MOUNT_PT)/sources/fstab \$(MOUNT_PT)/etc/fstab > $LOGDIRBASE/\$@ 2>&1
EOF
) >> $MKFILE.tmp
}
#----------------------------------#
CHROOT_wrt_CopyFstab() { #
wrt_CopyFstab() { #
#----------------------------------#
(
cat << EOF
@cp -v /sources/fstab /etc/fstab >>logs/\$@ 2>&1 && \\
\$(PRT_DU_CR) >>logs/\$@
@cp -v /sources/fstab /etc/fstab > $LOGDIRBASE/\$@ 2>&1
EOF
) >> $MKFILE.tmp
}
@ -288,7 +133,7 @@ EOF
#==== INSTALLED FILES LOGS ====
#----------------------------------#
LUSER_wrt_TouchTimestamp() { #
LUSER_wrt_TouchTimestamp() { # Needed for CLFS Sysroot and Embedded
#----------------------------------#
(
cat << EOF
@ -298,7 +143,7 @@ EOF
}
#----------------------------------#
CHROOT_wrt_TouchTimestamp() { #
wrt_TouchTimestamp() { #
#----------------------------------#
(
cat << EOF
@ -308,48 +153,23 @@ EOF
}
#----------------------------------#
LUSER_wrt_LogNewFiles() { #
LUSER_wrt_LogNewFiles() { # Needed for CLFS Sysroot and Embedded
#----------------------------------#
local name=$1
(
cat << EOF
@\$(call log_new_files_LUSER,$1)
@\$(call log_new_files_LUSER,$name)
EOF
) >> $MKFILE.tmp
}
#----------------------------------#
CHROOT_wrt_LogNewFiles() { #
wrt_LogNewFiles() { #
#----------------------------------#
local name=$1
(
cat << EOF
@\$(call log_new_files,$1)
EOF
) >> $MKFILE.tmp
}
#=======================
#==== RM BUILD DIRS ====
#----------------------------------#
LUSER_RemoveBuildDirs() { #
#----------------------------------#
local name=`echo ${1} | sed 's/[0-9]-//'`
(
cat << EOF
@\$(call remove_build_dirs,$name)
EOF
) >> $MKFILE.tmp
}
#----------------------------------#
CHROOT_wrt_RemoveBuildDirs() { #
#----------------------------------#
local name=`echo ${1} | sed 's/[0-9]-//'`
(
cat << EOF
@\$(call remove_build_dirs2,$name)
@\$(call log_new_files,$name)
EOF
) >> $MKFILE.tmp
}

View file

@ -1,3 +1,6 @@
# $Id$
BOLD = ""
RED = ""
GREEN = ""
@ -24,28 +27,28 @@ endef
define sh_echo_PHASE
echo $(BOLD)--------------------------------------------------------------------------------;\
echo $(tab_)$(tab_)Executing $(BLUE)$(1)$(WHITE) scripts; \
echo $(BOLD)--------------------------------------------------------------------------------$(WHITE)
echo $(BOLD)--------------------------------------------------------------------------------echo $(WHITE)
endef
define echo_SU_request
@echo $(BOLD)--------------------------------------------------------------------------------
@echo $(BLUE)$@
@echo $(WHITE)ROOT privilege is required to perform a number of commands
@echo sudo may request a password in order to execute all high privilege commands
@echo $(WHITE)ROOT privilege is required to perform a number commands
@echo sudo will request a password to all high privilege cmds to execute correctly
endef
define echo_SULUSER_request
@echo $(BOLD)--------------------------------------------------------------------------------
@echo $(BOLD)$(BLUE)$@
@echo $(WHITE)You are going to log into the user account $(BOLD)$(YELLOW)$(LUSER)$(OFF)
@echo sudo may require a password
@echo sudo requires a password
endef
define echo_CHROOT_request
@echo $(BOLD)--------------------------------------------------------------------------------
@echo $(BOLD)$(BLUE)$@
@echo $(WHITE)You are going to CHROOT into $(MOUNT_PT)
@echo a password may be required
@echo $(WHITE)You are going to CHROOT into $(MOUNT_PT) $(BOLD)$(YELLOW)$(LUSER)$(OFF)
@echo a password is required
endef
define echo_message
@ -53,114 +56,6 @@ define echo_message
@echo $(BOLD)$(1) target $(BLUE)$@$(BOLD)$(WHITE)
endef
#=======================
#=== BUILD FUNCTIONS ===
define remove_existing_dirs
@PKG_PATH=`ls -t $(SRCSDIR)/$(1) | head -n1` && \
ROOT=`tar -tf $$PKG_PATH | head -n1 | sed -e 's@^./@@;s@/.*@@'` && \
[ -n "$$ROOT" ] && \
if [ -d $(SRCSDIR)/$$ROOT ]; then \
rm -rf $(SRCSDIR)/$$ROOT && \
rm -rf $(SRCSDIR)/$${ROOT%-*}-build; \
fi;
endef
define remove_existing_dirs2
@PKG_PATH=`ls -t $(SRC)/$(1) | head -n1` && \
ROOT=`tar -tf $$PKG_PATH | head -n1 | sed -e 's@^./@@;s@/.*@@'` && \
[ -n "$$ROOT" ] && \
if [ -d $(SRC)/$$ROOT ]; then \
rm -rf $(SRC)/$$ROOT && \
rm -rf $(SRC)/$${ROOT%-*}-build; \
fi;
@if [ "$(PKGMNGT)" = "y" ] && [ -d $(SRC)/$@ ]; then \
rm -rf $(SRC)/$@ && rm -f $(SRC)/*.deb; \
fi;
endef
#==#
define unpack
@cd $(SRCSDIR) && \
tar -xvf `ls -t $(1) | head -n1` > $(PKG_LST)
endef
define unpack2
@cd $(SRC) && \
tar -xvf `ls -t $(1) | head -n1` > $(PKG_LST)
endef
#==#
define get_pkg_root
@ROOT=`head -n1 $(SRCSDIR)/$(PKG_LST) | sed 's@^./@@;s@/.*@@'` && \
if [ "$(1)" != "nouser" ]; then \
echo "export PKGDIR=$(SRCSDIR)/$$ROOT" > envars; \
chown -R $(LUSER) $(SRCSDIR)/$$ROOT; \
else \
echo "export PKGDIR=$(crSRCSDIR)/$$ROOT" > envars; \
fi;
endef
define get_pkg_root2
@ROOT=`head -n1 $(SRC)/$(PKG_LST) | sed 's@^./@@;s@/.*@@'` && \
echo "export PKGDIR=$(SRC)/$$ROOT" > envars; \
if [ "$(PKGMNGT)" = "y" ]; then \
echo "export PKG_DEST=$(SRC)/$@" >> envars; \
echo "source packInstall.sh" >> envars; \
echo "export -f packInstall" >> envars; \
if [ "$(WRAP_INSTALL)" = "y" ]; then \
echo "export -f wrapInstall" >> envars; \
fi; \
fi;
endef
define get_pkg_root_LUSER
@ROOT=`head -n1 $(SRCSDIR)/$(PKG_LST) | sed 's@^./@@;s@/.*@@'` && \
echo "export PKGDIR=$(SRCSDIR)/$$ROOT" > envars
endef
#==#
define touch_timestamp
@touch $(SRC)/timestamp-marker && sleep 1
endef
define touch_timestamp_LUSER
@touch $(SRCSDIR)/timestamp-marker && sleep 1
endef
define log_new_files
@find / -xdev ! -path "/$(SCRIPT_ROOT)/*" ! -path "/tmp/*" ! -path "$(SRC)/*" \
-newer $(SRC)/timestamp-marker -not -type d \
-printf "%p\t%s\t%u:%g\t%m\t%l\n" | sort > $(crFILELOGDIR)/$(1)
endef
define log_new_files_LUSER
@find $(BASEDIR) -xdev ! -path "$(BASEDIR)/$(SCRIPT_ROOT)/*" ! -path "$(BASEDIR)/tmp/*" ! -path "$(SRCSDIR)/*" \
-newer $(SRCSDIR)/timestamp-marker -not -type d \
-printf "%p\t%s\t%u:%g\t%m\t%l\n" | sort > $(BASEDIR)$(crFILELOGDIR)/$(1)
endef
#==@
define remove_build_dirs
@ROOT=`head -n1 $(SRCSDIR)/$(PKG_LST) | sed 's@^./@@;s@/.*@@'` && \
rm -rf $(SRCSDIR)/$$ROOT && \
rm -rf $(SRCSDIR)/$(1)-build
endef
define remove_build_dirs2
@ROOT=`head -n1 $(SRC)/$(PKG_LST) | sed 's@^./@@;s@/.*@@'` && \
rm -rf $(SRC)/$$ROOT && \
rm -rf $(SRC)/$(1)-build
endef
#==#
define housekeeping
@touch $@ && \
sleep .25 && \
@ -175,14 +70,40 @@ endef
#=======================
#=== INSTALL_LOG FUNCTIONS ===
define touch_timestamp
@touch $(SRC)/timestamp-marker && sleep 1
endef
define touch_timestamp_LUSER
@touch $(SRCSDIR)/timestamp-marker && sleep 1
endef
define log_new_files
@find / -xdev ! -path "/$(SCRIPT_ROOT)/*" ! -path "/tmp/*" ! -path "$(SRC)/*" \
-newer $(SRC)/timestamp-marker -not -type d \
-printf "%p\t%s\t%u:%g\t%m\t%l\n" | sort > $(FILELOGDIR)/$(1)
endef
define log_new_files_LUSER
@find $(MOUNT_PT) -xdev ! -path "$(MOUNT_PT)/$(SCRIPT_ROOT)/*" ! -path "$(MOUNT_PT)/tmp/*" ! -path "$(SRCSDIR)/*" \
-newer $(SRCSDIR)/timestamp-marker -not -type d \
-printf "%p\t%s\t%u:%g\t%m\t%l\n" | sort > $(MOUNT_PT)$(FILELOGDIR)/$(1)
endef
#=======================
#==== FINAL MESSAGES ===
define echo_report
echo ; \
echo $(BOLD) The report file $(BLUE)$(1)$(BOLD) has been created ; \
echo ; \
echo $(WHITE)Please send the $(BOLD)$(MOUNT_PT)/jhalfs/$(1)$(WHITE) ; \
echo file to $(BOLD)alfs-discuss@lists.linuxfromscratch.org$(WHITE) ; \
echo $(WHITE)If this is a development book build, please send the ; \
echo $(BOLD)$(MOUNT_PT)/$(SCRIPT_ROOT)/$(1)$(WHITE) file to ; \
echo $(BOLD)manuel@linuxfromscratch.org$(WHITE) ; \
echo ; \
echo That will help us to keep more accurate SBU and ; \
echo disk usage values into the book. Thanks. ; \
@ -200,25 +121,26 @@ define echo_finished
@echo To be able to boot your new system you need to follow
@echo the next steps:$(WHITE)
@echo
@echo $(tab_)- Mount the virtual kernel file systems.
@echo
@echo $(tab_)- Enter to the chroot using the command found
@echo $(tab_)" in the section -Entering the Chroot Environment-"
@echo $(tab_)" except if building with METHOD=boot."
@echo $(tab_)in the section -Entering the Chroot Environment-
@echo $(tab_)except if building CLFS with METHOD=boot.
@echo
@echo $(tab_)- Set a password for the root user.
@echo
@echo $(tab_)- Edit or create /etc/fstab and any other configuration file
@echo $(tab_)" required to suit your needs."
@echo $(tab_)- Edit or create /etc/fstab, /etc/hosts, /etc/sysconfig/clock,
@echo $(tab_)/etc/sysconfig/console, /etc/sysconfig/network,
@echo $(tab_)/etc/sysconfig//network-devices/ifconfig.eth0/ipv4 and
@echo $(tab_)any other configuration file required to suit your needs.
@echo
@echo $(tab_)- Set-up the boot loader.
@echo $(tab_)- Exit from the chroot.
@echo
@echo $(tab_)You can set-up the new boot-loader installed on the new system
@echo $(tab_)or the host bootloader.
@echo
@echo $(tab_)If the last, it is better to exit first from the chroot.
@echo
@echo $(tab_)- Exit from the chroot and umount the filesystems.
@echo $(tab_)- Set-up the boot loader, except if building CLFS with METHOD=boot.
@echo $(tab_)You can set-up the host bootloader or the new boot-loader
@echo $(tab_)installed on the new system.
@echo $(tab_)If the last, you must to mount the virtual filesystems, re-enter
@echo $(tab_)the chroot and be sure that /dev is populated with the
@echo $(tab_)required devices before configure the boot-loader. When ready,
@echo $(tab_)exit from the chroot and umount the filesystems
@echo
@echo If you are an experienced LFS user, several of those steps can be
@echo skipped or done in a different way. But then, that is something
@ -246,7 +168,7 @@ define echo_boot_finished
@echo 1.If it is necessary, transfer the newly created partition to the target machine
@echo 2.Boot the new partition.
@echo 3.Once you are logged in issue the following commands
@echo $(tab_) $(BOLD)cd /jhalfs
@echo $(tab_) $(BOLD)cd /$(SCRIPT_ROOT)
@echo $(tab_) $(BOLD)make makesys
@echo The build process should resume. Follow any instructions that appear.
@echo --------------------------------------------------------------------------------

View file

@ -1,60 +0,0 @@
<?xml version='1.0' encoding='ISO-8859-1'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="text"/>
<!-- Should we include a package manager? -->
<xsl:param name="pkgmngt" select="'n'"/>
<!-- The system for LFS: sysv of systemd -->
<xsl:param name="revision" select="'sysv'"/>
<xsl:template match="/">
<xsl:apply-templates
select="//varlistentry[(@revision=$revision or not(@revision)) and
//para[contains(string(),'Download:')]"/>
<xsl:if test="$pkgmngt='y'">
<xsl:apply-templates
select="document('packageManager.xml')//sect1[@id='package']//para"/>
</xsl:if>
</xsl:template>
<xsl:template match="para">
<xsl:call-template name="package_name">
<xsl:with-param name="url" select="ulink/@url"/>
</xsl:call-template>
</xsl:template>
<xsl:template name="package_name">
<xsl:param name="url" select="'foo'"/>
<xsl:variable name="sub-url" select="substring-after($url,'/')"/>
<xsl:choose>
<xsl:when test="contains($sub-url,'/') and
not(substring-after($sub-url,'/')='')">
<xsl:call-template name="package_name">
<xsl:with-param name="url" select="$sub-url"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="contains($sub-url,'.patch')"/>
<xsl:when test="contains($sub-url,'?')">
<xsl:value-of select="substring-before($sub-url,'?')"/>
<xsl:text>&#xA;</xsl:text>
</xsl:when>
<xsl:when test="contains($sub-url,'/')">
<xsl:value-of select="substring-before($sub-url,'/')"/>
<xsl:text>&#xA;</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$sub-url"/>
<xsl:text>&#xA;</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>

View file

@ -1,8 +1,9 @@
# shellcheck shell=bash
# $Id$
set -e
# Be sure that we know the target name
# Be sure that we know the taget name
[[ -z $1 ]] && exit
TARGET=$1 # Remember the target build we are looking for
MAKE_PPID=$2
@ -14,19 +15,19 @@ declare -r ERASE_LINE=${CSI}$'2K'
declare -r FRAME_OPEN=${CSI}$'2G['
declare -r FRAME_CLOSE=${CSI}$'63G]'
declare -r TS_POSITION=${CSI}$'65G'
declare -r RESET_LINE=${CURSOR_OFF}${ERASE_LINE}${FRAME_OPEN}${FRAME_CLOSE}
declare -r LINE_WRAP_OFF=${CSI}$'?7l'
declare -r LINE_WRAP_ON=${CSI}$'?7h'
declare -a RESET_LINE=${CURSOR_OFF}${ERASE_LINE}${FRAME_OPEN}${FRAME_CLOSE}
declare -r GRAPHIC_STR="| / - \\ + "
declare -a GRAPHIC_STR="| / - \\ + "
declare -i SEC=0 # Seconds accumulator
declare -i PREV_SEC=0
# Prevent segfault on stripping phases
if [[ "$BASHBIN" = "/tools/bin/bash" ]] ; then
SLEEP=/tools/bin/sleep
elif [ -x /bin/sleep ] ; then
SLEEP=/bin/sleep
else
SLEEP=/usr/bin/sleep
SLEEP=/bin/sleep
fi
write_or_exit() {
@ -46,22 +47,22 @@ write_or_exit "${RESET_LINE}${TS_POSITION}0 min. 0 sec"
# loop forever..
while true ; do
# Loop through the animation string
for GRAPHIC_CHAR in ${GRAPHIC_STR} ; do
write_or_exit "${CSI}$((SEC + 3))G${GRAPHIC_CHAR}"
$SLEEP .12 # This value MUST be less than .2 seconds.
done
# Loop through the animation string
for GRAPHIC_CHAR in ${GRAPHIC_STR} ; do
write_or_exit "${CSI}$((SEC + 3))G${GRAPHIC_CHAR}"
$SLEEP .12 # This value MUST be less than .2 seconds.
done
# A BASH internal variable, the number of seconds the script
# has been running. modulo convert to 0-59
SEC=$((SECONDS % 60))
# A BASH internal variable, the number of seconds the script
# has been running. modulo convert to 0-59
SEC=$(($SECONDS % 60))
# Detect rollover of the seconds.
(( PREV_SEC > SEC )) && write_or_exit "${RESET_LINE}"
PREV_SEC=$SEC
# Detect rollover of the seconds.
(( PREV_SEC > SEC )) && write_or_exit "${RESET_LINE}"
(( PREV_SEC = SEC ))
# Display the accumulated time. div minutes.. modulo seconds.
write_or_exit "${TS_POSITION}$((SECONDS / 60)) min. $SEC sec"
# Display the accumulated time. div minutes.. modulo seconds.
write_or_exit "${TS_POSITION}$(($SECONDS / 60)) min. $SEC sec"
done
exit

View file

@ -1,36 +0,0 @@
#!/bin/bash
if [ -z "$CPUSPEC" ] || [ "$#" -lt 1 ]; then
echo "usage: CPUSPEC=... $0 command"
exit 1
fi
ARGS="$@"
set +e
if type systemd-run >/dev/null 2>&1 ; then # systemd
sudo systemd-run -G --pty -d --uid=$(whoami) \
-p AllowedCPUs="$CPUSPEC" \
--slice "user-$(whoami).slice" \
"$@"
elif type loginctl >/dev/null 2>&1 ; then #elogind
sudo mkdir /sys/fs/cgroup/jhalfs
sudo sh -c "echo +cpuset > /sys/fs/cgroup/cgroup.subtree_control"
(
sudo sh -c "echo $BASHPID > /sys/fs/cgroup/jhalfs/cgroup.procs"
sudo sh -c "
SESS_CGROUP=/sys/fs/cgroup/\$XDG_SESSION_ID
echo $CPUSPEC > \$SESS_CGROUP/cpuset.cpus
( echo \$BASHPID > \$SESS_CGROUP/cgroup.procs &&
exec sudo -u $(whoami) $ARGS )"
)
sudo rmdir /sys/fs/cgroup/jhalfs
else # no session manager
sudo mkdir /sys/fs/cgroup/jhalfs
sudo sh -c "echo +cpuset > /sys/fs/cgroup/cgroup.subtree_control"
sudo sh -c "echo \"$CPUSPEC\" > /sys/fs/cgroup/jhalfs/cpuset.cpus"
(sudo sh -c "echo $BASHPID > /sys/fs/cgroup/jhalfs/cgroup.procs" &&
exec "$@")
sudo rmdir /sys/fs/cgroup/jhalfs
fi

View file

@ -1,74 +0,0 @@
<?xml version='1.0' encoding='ISO-8859-1'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="text"/>
<!-- Do we use a package manager? -->
<xsl:param name="pkgmngt" select="'n'"/>
<!-- The system for LFS: sysv of systemd -->
<xsl:param name="revision" select="'sysv'"/>
<xsl:template match="/">
<xsl:apply-templates select="//varlistentry[@revision=$revision
or not(@revision)]//ulink"/>
<xsl:if test="$pkgmngt='y'">
<xsl:apply-templates
select="document('packageManager.xml')//ulink"/>
</xsl:if>
</xsl:template>
<xsl:template match="ulink">
<!-- If some package doesn't have the predefined strings in their
name, the next test must be fixed to match it also. Skip possible
duplicated URLs due that may be splitted for PDF output -->
<xsl:if test="(contains(@url, '.bz2') or contains(@url, '.tar.gz') or
contains(@url, '.tgz') or contains(@url, '.patch') or
contains(@url, '.xz') or contains(@url, '.lzma')) and
not(ancestor-or-self::*/@condition = 'pdf')">
<!-- Extract the package name -->
<xsl:variable name="package">
<xsl:call-template name="package.name">
<xsl:with-param name="url" select="@url"/>
</xsl:call-template>
</xsl:variable>
<!-- Write the upstream URLs, fixing the redirected ones -->
<xsl:choose>
<xsl:when test="contains(@url,'?')">
<xsl:value-of select="substring-before(@url,'?')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@url"/>
</xsl:otherwise>
</xsl:choose>
<!-- Write MD5SUM value -->
<xsl:text> </xsl:text>
<xsl:value-of select="../following-sibling::para/literal"/>
<xsl:text>&#x0a;</xsl:text>
</xsl:if>
</xsl:template>
<xsl:template name="package.name">
<xsl:param name="url"/>
<xsl:choose>
<xsl:when test="contains($url, '/') and not (substring-after($url,'/')='')">
<xsl:call-template name="package.name">
<xsl:with-param name="url" select="substring-after($url, '/')"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="contains($url, '?')">
<xsl:value-of select="substring-before($url, '?')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$url"/>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>

View file

@ -1,159 +0,0 @@
# Generated by Kconfiglib (https://github.com/ulfalizer/Kconfiglib)
#
# BOOK Settings
#
# BOOK_LFS is not set
BOOK_LFS_SYSD=y
# BOOK_BLFS is not set
INITSYS="systemd"
RUN_ME="./jhalfs run"
BRANCH=y
# WORKING_COPY is not set
COMMIT="trunk"
LFS_MULTILIB_NO=y
# LFS_MULTILIB_I686 is not set
# LFS_MULTILIB_X32 is not set
# LFS_MULTILIB_ALL is not set
MULTILIB="default"
BUILD_CHROOT=y
# BUILD_BOOT is not set
METHOD="chroot"
BLFS_TOOL=y
#
# blfs-tool dependencies
#
DEP_LIBXML=y
DEP_LIBXSLT=y
DEP_DBXML=y
DEP_LYNX=y
DEP_SUDO=y
DEP_WGET=y
# DEP_GPM is not set
DEP_GIT=y
# end of blfs-tool dependencies
BLFS_BRANCH=y
# BLFS_WORKING_COPY is not set
BLFS_COMMIT="trunk"
BLFS_ROOT="/blfs_root"
BLFS_XML="blfs-xml"
LFS_XML="lfs-xml"
# CUSTOM_TOOLS is not set
TRACKING_DIR="/var/lib/jhalfs/BLFS"
# end of BOOK Settings
#
# General Settings
#
LUSER="lfs"
LGROUP="lfs"
LHOME="/home"
BUILDDIR="/mnt/build_dir"
GETPKG=y
SRC_ARCHIVE="$SRC_ARCHIVE"
RETRYSRCDOWNLOAD=y
RETRYDOWNLOADCNT=20
DOWNLOADTIMEOUT=30
SERVER="http://ftp.osuosl.org"
RUNMAKE=y
CLEAN=y
# end of General Settings
#
# Build Settings
#
CONFIG_TESTS=y
#
# Test settings
#
# TST_1 is not set
TST_2=y
# end of Test settings
TEST=2
PKGMNGT=y
PKG_PACK=y
# LIB_LOAD is not set
INSTALL_LOG=y
STRIP=y
DEL_LA_FILES=y
# NO_PROGRESS_BAR is not set
# end of Build Settings
#
# System configuration
#
# HAVE_FSTAB is not set
CONFIG_BUILD_KERNEL=y
CONFIG="$(pwd)/mihari-dev-kernel-config"
NCURSES5=y
TIMEZONE="KST"
LANG="ko_KR.UTF-8"
FULL_LOCALE=y
PAGE_LETTER=y
# PAGE_A4 is not set
PAGE="letter"
HOSTNAME="mahiroOS-dev.local"
#
# Network configuration
#
INTERFACE="eth0"
IP_ADDR="10.0.2.9"
GATEWAY="10.0.2.2"
PREFIX="24"
BROADCAST="10.0.2.255"
DOMAIN="local"
DNS1="10.0.2.3"
DNS2="8.8.8.8"
# end of Network configuration
#
# Console configuration
#
FONT="lat0-16"
KEYMAP="us"
# LOCAL is not set
# end of Console configuration
# end of System configuration
#
# Advanced Features
#
REPORT=y
# SAVE_CH5 is not set
# COMPARE is not set
CONFIG_OPTIMIZE=y
#
# Parallelization and Optimization settings
#
N_PARALLEL=12
OPT_1=y
# OPT_2 is not set
# end of Parallelization and Optimization settings
OPTIMIZE=1
#
# Internal Settings (WARNING: for jhalfs developers only)
#
SCRIPT_ROOT="jhalfs"
JHALFSDIR="$BUILDDIR/$SCRIPT_ROOT"
LOGDIRBASE="logs"
LOGDIR="$JHALFSDIR/$LOGDIRBASE"
TESTLOGDIRBASE="test-logs"
TESTLOGDIR="$JHALFSDIR/$TESTLOGDIRBASE"
FILELOGDIRBASE="installed-files"
FILELOGDIR="$JHALFSDIR/$FILELOGDIRBASE"
ICALOGDIR="$LOGDIR/ICA"
MKFILE="$JHALFSDIR/Makefile"
XSL="lfs.xsl"
PKG_LST="unpacked"
# end of Internal Settings (WARNING: for jhalfs developers only)
# end of Advanced Features
# REBUILD_MAKEFILE is not set

View file

@ -1,159 +0,0 @@
# Generated by Kconfiglib (https://github.com/ulfalizer/Kconfiglib)
#
# BOOK Settings
#
# BOOK_LFS is not set
BOOK_LFS_SYSD=y
# BOOK_BLFS is not set
INITSYS="systemd"
RUN_ME="./jhalfs run"
BRANCH=y
# WORKING_COPY is not set
COMMIT="trunk"
LFS_MULTILIB_NO=y
# LFS_MULTILIB_I686 is not set
# LFS_MULTILIB_X32 is not set
# LFS_MULTILIB_ALL is not set
MULTILIB="default"
BUILD_CHROOT=y
# BUILD_BOOT is not set
METHOD="chroot"
BLFS_TOOL=y
#
# blfs-tool dependencies
#
DEP_LIBXML=y
DEP_LIBXSLT=y
DEP_DBXML=y
DEP_LYNX=y
DEP_SUDO=y
DEP_WGET=y
# DEP_GPM is not set
DEP_GIT=y
# end of blfs-tool dependencies
BLFS_BRANCH=y
# BLFS_WORKING_COPY is not set
BLFS_COMMIT="trunk"
BLFS_ROOT="/blfs_root"
BLFS_XML="blfs-xml"
LFS_XML="lfs-xml"
# CUSTOM_TOOLS is not set
TRACKING_DIR="/var/lib/jhalfs/BLFS"
# end of BOOK Settings
#
# General Settings
#
LUSER="lfs"
LGROUP="lfs"
LHOME="/home"
BUILDDIR="/mnt/build_dir"
GETPKG=y
SRC_ARCHIVE="$SRC_ARCHIVE"
RETRYSRCDOWNLOAD=y
RETRYDOWNLOADCNT=20
DOWNLOADTIMEOUT=30
SERVER="http://ftp.osuosl.org"
RUNMAKE=y
CLEAN=y
# end of General Settings
#
# Build Settings
#
CONFIG_TESTS=y
#
# Test settings
#
# TST_1 is not set
TST_2=y
# end of Test settings
TEST=2
PKGMNGT=y
PKG_PACK=y
# LIB_LOAD is not set
INSTALL_LOG=y
STRIP=y
DEL_LA_FILES=y
# NO_PROGRESS_BAR is not set
# end of Build Settings
#
# System configuration
#
# HAVE_FSTAB is not set
CONFIG_BUILD_KERNEL=y
CONFIG="$(pwd)/mihari-dev-kernel-config"
NCURSES5=y
TIMEZONE="KST"
LANG="ko_KR.UTF-8"
FULL_LOCALE=y
PAGE_LETTER=y
# PAGE_A4 is not set
PAGE="letter"
HOSTNAME="mahiroOS-dev.local"
#
# Network configuration
#
INTERFACE="eth0"
IP_ADDR="10.0.2.9"
GATEWAY="10.0.2.2"
PREFIX="24"
BROADCAST="10.0.2.255"
DOMAIN="local"
DNS1="10.0.2.3"
DNS2="8.8.8.8"
# end of Network configuration
#
# Console configuration
#
FONT="lat0-16"
KEYMAP="us"
# LOCAL is not set
# end of Console configuration
# end of System configuration
#
# Advanced Features
#
REPORT=y
# SAVE_CH5 is not set
# COMPARE is not set
CONFIG_OPTIMIZE=y
#
# Parallelization and Optimization settings
#
N_PARALLEL=12
OPT_1=y
# OPT_2 is not set
# end of Parallelization and Optimization settings
OPTIMIZE=1
#
# Internal Settings (WARNING: for jhalfs developers only)
#
SCRIPT_ROOT="jhalfs"
JHALFSDIR="$BUILDDIR/$SCRIPT_ROOT"
LOGDIRBASE="logs"
LOGDIR="$JHALFSDIR/$LOGDIRBASE"
TESTLOGDIRBASE="test-logs"
TESTLOGDIR="$JHALFSDIR/$TESTLOGDIRBASE"
FILELOGDIRBASE="installed-files"
FILELOGDIR="$JHALFSDIR/$FILELOGDIRBASE"
ICALOGDIR="$LOGDIR/ICA"
MKFILE="$JHALFSDIR/Makefile"
XSL="lfs.xsl"
PKG_LST="unpacked"
# end of Internal Settings (WARNING: for jhalfs developers only)
# end of Advanced Features
# REBUILD_MAKEFILE is not set

View file

@ -1,22 +0,0 @@
PKG="libffi"
PKG_VERSION="3.2.1"
PKG_FILE="libffi-3.2.1.tar.gz"
URL="http://sourceware.org/pub/libffi/${PKG_FILE}"
MD5="83b89587607e3eb65c70d361f13bab43"
for i in PATCH{1..10}; do
unset $i
done
( cat << "xEOFx"
sed -e '/^includesdir/ s/$(libdir).*$/$(includedir)/' \
-i include/Makefile.in &&
sed -e '/^includedir/ s/=.*$/=@includedir@/' \
-e 's/^Cflags: -I${includedir}/Cflags:/' \
-i libffi.pc.in &&
./configure --prefix=/usr --disable-static &&
make
make install
xEOFx
) > tmp

View file

@ -1,28 +0,0 @@
PKG="pcre"
PKG_VERSION="8.37"
PKG_FILE="pcre-8.37.tar.bz2"
URL="ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/${PKG_FILE}"
MD5="ed91be292cb01d21bc7e526816c26981"
for i in PATCH{1..10}; do
unset $i
done
PATCH1="https://www.linuxfromscratch.org/patches/downloads/pcre/pcre-8.37-upstream_fixes-1.patch 718c4314fba52ed559c75ff7660cc391"
( cat << "xEOFx"
patch -Np1 -i ../pcre-8.37-upstream_fixes-1.patch &&
./configure --prefix=/usr \
--docdir=/usr/share/doc/pcre-8.37 \
--enable-unicode-properties \
--enable-pcre16 \
--enable-pcre32 \
--enable-pcregrep-libz \
--enable-pcregrep-libbz2 \
--enable-pcretest-libreadline \
--disable-static &&
make
make install &&
mv -v /usr/lib/libpcre.so.* /lib &&
ln -sfv ../../lib/$(readlink /usr/lib/libpcre.so) /usr/lib/libpcre.so
xEOFx
) > tmp

View file

@ -1,22 +0,0 @@
PKG="python3"
PKG_VERSION="3.4.3"
PKG_FILE="Python-3.4.3.tar.xz"
URL="https://www.python.org/ftp/python/3.4.3/${PKG_FILE}"
MD5="7d092d1bba6e17f0d9bd21b49e441dd5"
for i in PATCH{1..10}; do
unset $i
done
( cat << "xEOFx"
CXX="/usr/bin/g++" \
./configure --prefix=/usr \
--enable-shared \
--with-system-expat \
--with-system-ffi \
--without-ensurepip &&
make
make install &&
chmod -v 755 /usr/lib/libpython3.4m.so &&
chmod -v 755 /usr/lib/libpython3.so
xEOFx
) > tmp

View file

@ -1,15 +0,0 @@
PKG="glib"
PKG_VERSION="2.44.1"
PKG_FILE="glib-2.44.1.tar.xz"
URL="http://ftp.gnome.org/pub/gnome/sources/glib/2.44/${PKG_FILE}"
MD5="83efba4722a9674b97437d1d99af79db"
for i in PATCH{1..10}; do
unset $i
done
( cat << "xEOFx"
./configure --prefix=/usr --with-pcre=system &&
make
make install
xEOFx
) > tmp

View file

@ -1,19 +0,0 @@
PKG="mc"
PKG_VERSION="4.8.14"
PKG_FILE="mc-4.8.14.tar.xz"
URL="http://ftp.midnight-commander.org/${PKG_FILE}"
MD5="fbdaddb9edcf8925dcf3231331a8720b"
for i in PATCH{1..10}; do
unset $i
done
( cat << "xEOFx"
./configure --prefix=/usr \
--sysconfdir=/etc \
--with-screen=ncurses \
--enable-charset &&
make
make install
cp -v doc/keybind-migration.txt /usr/share/mc
xEOFx
) > tmp

View file

@ -1,23 +0,0 @@
# The PPP package contains the pppd daemon and the chat program.
# This is used for connecting to other machines; often for connecting
# to the Internet via a dial-up or PPPoE connection to an ISP.
#
PKG="ppp"
PKG_VERSION="2.4.7"
PKG_FILE="ppp-${PKG_VERSION}.tar.gz"
URL="http://samba.org/ftp/ppp/${PKG_FILE}"
MD5="78818f40e6d33a1d1de68a1551f6595a"
for i in PATCH{1..10}; do
unset $i
done
( cat << "xEOFx"
./configure --prefix=/usr &&
make
make install &&
make install-etcppp
xEOFx
) > tmp

View file

@ -1,34 +0,0 @@
# The OpenSSL package contains management tools and libraries
# relating to cryptography. These are useful for providing
# cryptography functions to other packages, notably OpenSSH,
# email applications and web browsers (for accessing HTTPS sites).
#
PKG="openssl"
PKG_VERSION="1.0.2d"
PKG_FILE="openssl-${PKG_VERSION}.tar.gz"
URL="ftp://ftp.openssl.org/source/${PKG_FILE}"
MD5="38dd619b2e77cbac69b99f52a053d25a"
for i in PATCH{1..10}; do
unset $i
done
( cat << "xEOFx"
./config --prefix=/usr \
--openssldir=/etc/ssl \
--libdir=lib \
shared \
zlib-dynamic &&
make
#sed -i 's# libcrypto.a##;s# libssl.a##' Makefile
make MANDIR=/usr/share/man MANSUFFIX=ssl install &&
install -dv -m755 /usr/share/doc/openssl-1.0.2d &&
cp -vfr doc/* /usr/share/doc/openssl-1.0.2d
#
# Note: certificates not installed by this.
#
xEOFx
) > tmp

View file

@ -1,49 +0,0 @@
PKG="gpm"
PKG_VERSION="1.20.7"
PKG_FILE="gpm-${PKG_VERSION}.tar.bz2"
URL="https://anduin.linuxfromscratch.org/BLFS/gpm/${PKG_FILE}"
MD5="bf84143905a6a903dbd4d4b911a2a2b8"
for i in PATCH{1..10}; do
unset $i
done
PATCH1="https://www.linuxfromscratch.org/patches/blfs/svn/gpm-1.20.7-consolidated-1.patch"
( cat << "xEOFx"
patch -Np1 -i ../gpm-1.20.7-consolidated-1.patch &&
./autogen.sh &&
./configure --prefix=/usr --sysconfdir=/etc &&
make
make install &&
install-info --dir-file=/usr/share/info/dir \
/usr/share/info/gpm.info &&
rm -fv /usr/lib/libgpm.a &&
ln -sfv libgpm.so.2.1.0 /usr/lib/libgpm.so &&
install -v -m644 conf/gpm-root.conf /etc &&
install -v -m755 -d /usr/share/doc/gpm-1.20.7/support &&
install -v -m644 doc/support/* \
/usr/share/doc/gpm-1.20.7/support &&
install -v -m644 doc/{FAQ,HACK_GPM,README*} \
/usr/share/doc/gpm-1.20.7
# The normal cmd to install the boot script for gpm
# --- PUT THIS CMD INSIDE 999-blfs_bootscripts
#make install-gpm
cat > /etc/sysconfig/mouse << "EOF"
# Begin /etc/sysconfig/mouse
MDEVICE="/dev/input/mice"
PROTOCOL="imps2"
GPMOPTS=""
# End /etc/sysconfig/mouse
EOF
xEOFx
) > tmp

View file

@ -1,32 +0,0 @@
# Lynx is a text based web browser.
#
PKG="lynx"
PKG_VERSION="2.8.8rel.2"
PKG_FILE="lynx${PKG_VERSION}.tar.bz2"
URL="ftp://lynx.isc.org/${PKG_FILE}"
MD5="b231c2aa34dfe7ca25681ef4e55ee7e8"
for i in PATCH{1..10}; do
unset $i
done
( cat << "xEOFx"
./configure --prefix=/usr \
--sysconfdir=/etc/lynx \
--datadir=/usr/share/doc/lynx-2.8.8rel.2 \
--with-zlib \
--with-bzlib \
--with-screen=ncursesw \
--enable-locale-charset &&
make
make install-full &&
chgrp -v -R root /usr/share/doc/lynx-2.8.8rel.2/lynx_doc
sed -i 's/#\(LOCALE_CHARSET\):FALSE/\1:TRUE/' /etc/lynx/lynx.cfg
sed -i 's/#\(DEFAULT_EDITOR\):/\1:vi/' /etc/lynx/lynx.cfg
sed -i 's/#\(PERSISTENT_COOKIES\):FALSE/\1:TRUE/' /etc/lynx/lynx.cfg
xEOFx
) > tmp

View file

@ -1,28 +0,0 @@
# dhcpcd is an implementation of the DHCP client specified in RFC2131.
# This is useful for connecting your computer to a network which uses
# DHCP to assign network addresses.
#
PKG="dhcpcd"
PKG_VERSION="6.9.3"
PKG_FILE="dhcpcd-${PKG_VERSION}.tar.xz"
URL="http://roy.marples.name/downloads/dhcpcd/${PKG_FILE}"
MD5="8357d023c4687d27bc6ea7964236b2a6"
for i in PATCH{1..10}; do
unset $i
done
( cat << "xEOFx"
./configure --libexecdir=/lib/dhcpcd \
--dbdir=/var/lib/dhcpcd &&
make
make install
# Add the following to boot scripts.
#make install-service-dhcpcd
# more configuration?
xEOFx
) > tmp

View file

@ -1,22 +0,0 @@
# NASM (Netwide Assembler) is an 80x86 assembler designed
# for portability and modularity. It includes a
# disassembler as well.
PKG="nasm"
PKG_VERSION="2.11.08"
PKG_FILE="nasm-${PKG_VERSION}.tar.xz"
URL="http://www.nasm.us/pub/nasm/releasebuilds/2.11.08/${PKG_FILE}"
MD5="0d461a085b088a14dd6628c53be1ce28"
for i in PATCH{1..10}; do
unset $i
done
( cat << "xEOFx"
./configure --prefix=/usr &&
make
make install
xEOFx
) > tmp

View file

@ -1,32 +0,0 @@
# SYSLINUX is a collection of boot loaders for the Linux
# operating system which operates off Linux ext2/3
# filesystems, MS-DOS FAT filesystems, network servers
# using PXE firmware, or from CD-ROMs. The FAT
# filesystem version can be installed from DOS, NT, or
# Linux.
#
# It includes a sophisticated API for add-on "COM32"
# modules, including a significant subset of the
# standard C library.
#
# It also includes MEMDISK, a tool to boot legacy
# operating systems from nontraditional media like PXE
# or CD-ROM.
#
PKG="syslinux"
PKG_VERSION="3.36"
PKG_FILE="syslinux-$PKG_VERSION}.tar.bz2"
URL="http://www.kernel.org/pub/linux/utils/boot/syslinux/${PKG_FILE}"
MD5="d1bfdaa53d31f572f540be55d1480027"
for i in PATCH{1..10}; do
unset $i
done
( cat << "xEOFx"
make
make install
xEOFx
) > tmp

View file

@ -1,19 +0,0 @@
PKG="blfs-bootscripts"
PKG_VERSION="20150924"
PKG_FILE="blfs-bootscripts-${PKG_VERSION}.tar.bz2"
URL="http://anduin.linuxfromscratch.org/sources/BLFS/conglomeration/blfs-bootscripts/${PKG_FILE}"
MD5="97a371743223ac3815bf491863a39c7d"
for i in PATCH{1..10}; do
unset $i
done
( cat << "xEOFx"
#
# Insert ALL the blfs bootscripts you want to install
# EXAMPLE
#
make install-gpm
make install-service-dhcpcd
xEOFx
) > tmp

View file

@ -1,25 +0,0 @@
# Any comments you wish to add
#
PKG=""
PKG_VERSION=""
PKG_FILE=""
URL=""
MD5=""
for i in PATCH{1..10}; do
unset $i
done
PATCH1=""
# Up to 10 patches can be added. The PATCH variable must be numbered
# even if there is only one. If the patch md5 checksum is known, add
# it after the name as in (quotes are required):
# PATCHx="patch-url md5"
( cat << "xEOFx"
# Your script here. Be aware that it is passed
# verbatim, and that none of the above variables
# will be defined when running the script. For example,
# If you want to use ${PKG_VERSION}, you have to
# redefine it here.
xEOFx
) > tmp

View file

@ -1,5 +1,5 @@
#!/bin/bash
# $Id$
set -e
: <<inline_doc

View file

@ -1,4 +1,5 @@
#!/bin/bash
# $Id$
# Acknowledgment:
# The following code is a modified version of an original work written by
@ -42,9 +43,9 @@ if [ ! -f "$CMP_DIR/icaprep" ]; then
# hackery to allow easy diffing. Essentially, replace each
# archive with a dir of the same name and extract the object
# files from the archive into this dir. Despite their names,
# libm.a & libmcheck.a are not actual ar archives.
# libieee.a & libmcheck.a are not actual ar archives.
echo -n "Extracting object files from \".a\" files in ${CMP_DIR}... "
L=$(find $CMP_DIR -name '*.a' ! -name 'libm.a' ! -name 'libmcheck.a')
L=$(find $CMP_DIR -name '*.a' ! -name 'libieee.a' ! -name 'libmcheck.a')
for F in $L; do
mv $F ${F}.XX
mkdir $F

View file

@ -1,4 +1,5 @@
#!/bin/bash
# $Id$
# Acknowledgment:
# The following code is a modified version of an original work written by

896
extras/farce Executable file
View file

@ -0,0 +1,896 @@
#!/bin/bash
# Acknowledgment:
# The following code is a no-modified version (except for this comment
# and the inline_doc fragment) of an original work written by
# Ken Moffat and is included here with his permission.
#
# FARCE: Farce Assists Rebuild Comparison Evaluation ;)
#
# to answer the question "can it rebuild itself?"
#
# We expect four arguments - first directory path, filelist
# containing the files in this directory which we wish to compare,
# second directory path, filelist for second directory.
#
# Yes, we could just compare everything in each tree, but the
# filelist script knows about files it can reasonably ignore,
# and this also allows us to build a sytem, boot it and get a
# list of files, build a full desktop environment, and only then
# build and boot the "can it build itself" test system and get
# _its_ filelist.
#
# What this script aims to do:
# ____________________________
#
# First, report files not in both builds.
#
# Then, confirm symlinks point to same targets.
#
# After that, compare individual files -
# if different, run the file name through 'expected'
# to pick out files that are unlikely to match (logs,
# pids, fstab [assumes '/' is a different device each time],
# count these as 'expected'.
#
# For whatever is left, check the file type - ar archives
# have their members extraced and compared (every member has
# a timestamp), gzipped files are compared beyond their
# timestamp, binaries, at least those using shared libs or
# which are shared objects, are copied and subjected to
# --strip-debug. If files match at this stage, count them as
# 'accepted'.
#
# As a last step for any file that doesn't match, copy it
# through some perl regexps to "process" it (convert any
# date, time, kernel-version information from standard formats
# into tokens, then see if the tokensi match.
#
# For details of the regexps, see the tokenize function.
# Those files that match after this are also counted as
# 'accepted'. Note that I don't always start from the kernel
# version that I'm going to build, so this copes with e.g. perl
# files that hardcode the kernel version.
#
# We now have files that don't match. A few of these seem to be
# common to all builds - some (members of) c++ libraries or ar
# archives, a few programs which perhaps use some sort of c++ code).
# The file name # is passed to the 'failure' function - these
# recognized filenames are labelled as 'predictable FAIL:',
# anything else is labelled as 'unexpected FAIL:'.
#
# output:
# stderr - files only in one of the builds, failure messages,
# and totals.
#
# farce-results - more details, including which files were treated
# as expected differences, files where neither copy could be read,
# files treated as accepted, with the reason (and member for ar
# archives). This data is typically up to 100 characters wide -
# sometimes it's a bit more, but it doesn't wrap too badly in a
# 100 character xterm.
#
# farce-extras - diffs for the files, or members, that didn't
# match. This file is to establish new regexps for picking up
# date/time/kernel-version formats.
#
# farce-identical - the names of the files which are identical
#
# farce-substitutions - whenever using tokenizeanddiff results in a
# difference being accepted, for both versions diff the before and
# after versions to show what got changed. If the file is a binary,
# the output may still be hard to read. Note that I _know_ glibc
# version strings pass one of the regexps looking for a kernel version
# - since I expect you to use the same version of glibc for each
# build, this is not a problem.
#
# farce-differ - the names of the files which could not be treated
# as matching (whether or not I regard the failure as predictable)
# for possible input to ICA processing.
#
# Copyright (C) 2005, 2006 Ken Moffat <ken@linuxfromscratch.org>
#
# All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or (at
# your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
# NON INFRINGEMENT. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
: <<inline_doc
desc: do farce analisys and report
usage: farce -directory $FARCELOGDIR/dir path1 list1 path2 list2
input vars: $1 farce log dir for this comparation
$2 full path to previous iteration
$3 full path to filelist for previos iteration
$4 full path to current iteration
$5 full path to filelist for current iteration
externals: --
modifies: --
returns: --
on error:
on success:
inline_doc
VERSION="002"
# variables for output files
RESULT=farce-results
EXTRAS=farce-extras
IDENTICAL=farce-identical
SUBS=farce-substitutions
DIFFER=farce-differ
# documenting the variables
# C1, C2 temp files to hold disassembled code
# D1, D2 temp directories for extracting member of ar archive
# DIFF temp file for diffing the filelists
# F1, F2 temp files for tokenizeanddiff
# FTYPE obsolete, commented out
# M1, M2 temp files to hold members of an ar archive
# MEMBERS temp file to list members of ar archive
# OP1, OP2 the original $PWD, needed when extracting members of ar
# archives
# P1, P2 paths to first and second build
# S1, S2 temp files for shared objects
# functions
function dohelp() {
echo "`basename $0`: compare trees of files from a build"
echo "and lists of the files they contained"
echo ""
echo "`basename $0` [ -help | -version ] || path1 list1 path2 list2"
}
function emessage() {
# write a string to both stderr and $RESULT
echo "$@" >&2
echo "$@" >&5
}
function expected() {
# if we expect it to differ because of its name,
# allow it and report, return true ; else return false
case $1 in
/boot/grub/menu.lst)
# just in case somebody puts this into the main filesystem
true;;
/etc/aliases.db)
# some sort of database for postfix, not parsable
true;;
/etc/blkid.tab)
# includes dev name for rootfs
true;;
/etc/fstab)
# fstab, e.g. ' / ' will differ
true;;
/etc/group*)
true;;
/etc/hosts)
# with dhcp client, I add current ip address to this in a hook
true;;
/etc/ld.so.*)
# .conf and .cache can vary,
# particularly if one system has a full build when I run this
true;;
/etc/lilo.conf|/etc/yaboot.conf)
# bootloader control, I assume grub will all be on a separate
true;;
/etc/mtab)
# at a minimum, different '/'
true;;
/etc/ntp.drift)
true;;
/etc/passwd*)
true;;
/etc/shadow*)
true;;
/etc/ssh/*key|/etc/ssh/*pub)
# openssh keys
true;;
/misc/*)
# where I put buildscripts (which mostly won't change)
# and stamps containing name/time/space which will differ in the times
true;;
/root/*)
# expect .bash_history etc to differ - if we can read them
true;;
/usr/bin/lynx)
# part of my inital builds, I guess this uses anonymous namespaces
true;;
/usr/include/c++/*/*/bits/stdc++.h.gch/*)
# precompiled headers
true;;
/usr/lib*/libstdc++.a|/usr/lib*/libstdc++.so*|/usr/lib*/libsupc++.a)
# probably, anonymous namespaces
# libstdc++.a, libstdc++.so.n.n.n, libsupc++.a
true;;
/usr/share/info/dir)
# if one system has had extra stuff built, this will likely be bigger
true;;
/usr/share/man/whatis)
# if one system has had extra stuff built, this will likely be bigger
true;;
/var/lib/locate/locatedb)
# if one system has had extra stuff built, this will likely be bigger
true;;
/var/lib/nfs/*)
# allow nfs bookkeeping
true;;
/var/log/*)
true;;
/var/run/utmp)
true;;
/var/spool/fcron*)
true;;
/var/state/*)
# allow dhcp leases
true;;
/var/tmp/random-seed)
true;;
# following start with wildcards
*Image*|*.PPCBoot*|*vmlinuz*|*lfskernel*)
# compressed kernels, sometimes just building at a different
# date/time is enough to change the length of them, because the
# long format date and time is part of the compressed data
true;;
*pid*)
# pids, including e.g. /var/spool/postfix/pid/*
true;;
*)
# nothing else is expected to be different
false;;
esac
if [ $? -eq 0 ]; then
message "expected difference in $1"
let expected=$expected+1
case $TYPE in
AR)
let EXPAR=$EXPAR+1
;;
ELF)
let EXPELF=$EXPELF+1
;;
UNK)
let EXPUNK=$EXPUNK+1
;;
# so far, no other valid types, so don't accumulate them
*)
emessage "internal error, expected difference for $1 of type $TYPE not allowed"
exit 2
;;
esac
true
else
false
fi
}
function failure() {
# first parm is filename or token
# second parm is the error message
# update the appropriate total
# and write to both stderr and the results
# by using emessage
let different=$different+1
case $TYPE in
AR)
let DIFAR=$DIFAR+1
;;
ELF)
let DIFELF=$DIFELF+1
;;
GZ)
let DIFGZ=$DIFGZ+1
;;
SYM)
let DIFSYM=$DIFSYM+1
;;
UNK)
let DIFUNK=$DIFUNK+1
;;
*)
emessage "internal error in failure() for TYPE $TYPE"
exit 2
;;
esac
test -f ${P1}$1 && echo $1 >&9
emessage "FAIL: $2"
}
function fatal() {
# unrecoverable error
echo $*
exit 1
}
function filetype() {
TYPE=`file ${P1}${FILE}`
case $TYPE in
*'current ar archive'*)
let TOTAR=$TOTAR+1
TYPE=AR
;;
*' ELF '*)
let TOTELF=$TOTELF+1
TYPE=ELF
;;
*'gzip compressed data'*)
let TOTGZ=$TOTGZ+1
TYPE=GZ
;;
*)
let TOTUNK=$TOTUNK+1
TYPE=UNK
;;
esac
}
function message() {
# write a string to $RESULT
echo $* >&5
}
function onlyone() {
#report files only in one build
# text should go to both stderr and the results,
# but blank lines only go to the results
if [ $1 == '<' ]; then
emessage "File(s) only in the first build"
else
emessage "File(s) only in the second build"
fi
message ""
FILES=`cat $DIFF | grep "^$1" | cut -d ' ' -f 2`
for F in $FILES; do
emessage $F
let only=$only+1
done
message ""
}
# 'test' functions are called with three arguments:
# the two pathes and the filename
# - we know the file is of this type, so see if we
# can get it to match by reasonalbe means.
# if not, treat it as different.
#
# NB if pathes are absolute, we need to prefix them
# with the original $PWD to access the .a files
#
function testar() {
# ar archives include timestamps for the members,
# but diff doesn't show file timestamps unless the data differs
# put out a message to help locate which archive any messages
# about the members refer to.
# try just stripping them U1,2 undebuggable
U1=`mktemp` || fatal "cannot create a temporary file"
U2=`mktemp` || fatal "cannot create a temporary file"
cp ${1}${3} $U1
cp ${2}${3} $U2
strip --strip-debug $U1
strip --strip-debug $U2
cmp -s $U1 $U2
rm $U1 $U2
if [ $? -eq 0 ]; then
let accepted=$accepted+1
let ACCAR=$ACCAR+1
message "archive $3 matches after strip --strip-debug"
return
fi
# rest of this function retained primarily for pathologically bad builds
# put out a message in the log to help identify which archive has issues.
message "examining ar archive $3"
D1=`mktemp -d` || fatal "cannot create a temporary directory"
D2=`mktemp -d` || fatal "cannot create a temporary directory"
cd $D1
ar -x ${OP1}${1}${3}
cd $D2
ar -x ${OP2}${2}${3}
cd
# diff the members - true means they match
diff -Na $D1 $D2 >/dev/null
if [ $? -eq 0 ]; then
message "accept: $3 after diffing the members"
let accepted=$accepted+1
let ACCAR=$ACCAR+1
else
# process individual members to eliminate date/time/kernel-version
# first, check the members are the same
M1=`mktemp` || fatal "cannot create a temporary file"
M2=`mktemp` || fatal "cannot create a temporary file"
cd $D1
MEMBERS=
for F in *; do
MEMBERS="$MEMBERS $F"
done
cd
echo $MEMBERS | sort >$M1
cd $D2
MEMBERS=
for F in *; do
MEMBERS="$MEMBERS $F"
done
cd
echo $MEMBERS | sort >$M2
cmp -s $M1 $M2
if [ $? -ne 0 ]; then
# oh dear, different members
echo "list of members differs for archive $3" >&6
diff $M1 $M2 >&6
failure $3 "$3 list of members differs"
else
# members (names) are same,
# process each one
STATUS=0
for M in $MEMBERS; do
#avoid firing up perl on matching members
cmp -s $D1/$M $D2/$M
if [ $? -ne 0 ]; then
tokenizeanddiff $D1/$M $D2/$M $FILE:$M
if [ $? -eq 0 ]; then
message "member $M matches after processing"
else
message "member $M DIFFERS after processing"
STATUS=1
fi
fi
done
if [ $STATUS -eq 0 ]; then
let accepted=$accepted+1
let ACCAR=$ACCAR+1
else
let different=$different+1
let DIFAR=$DIFAR+1
echo $3 >&9
emessage "FAIL: in $3"
fi
fi
rm $M1 $M2
fi
rm -rf $D1 $D2
}
function testgzip() {
# bytes 4,5,6,7 are the timestamp, so ignore these
cmp -s -i 8 ${1}${3} ${2}${3}
if [ $? -eq 0 ]; then
message "accept: $3 after ignoring gzip timestamp"
let accepted=$accepted+1
let ACCGZ=$ACCGZ+1
else
failure $3 " $3 even after ignoring gzip timestamp"
fi
}
function testso() {
# shared object - first try stripping it
# in fact, this now handles ALL ELF files
S1=`mktemp` || fatal "cannot create a temporary file"
S2=`mktemp` || fatal "cannot create a temporary file"
cp ${1}${3} $S1
strip --strip-debug $S1
cp ${2}${3} $S2
strip --strip-debug $S2
cmp -s $S1 $S2
if [ $? -eq 0 ]; then
message "accept: $3 after --strip-debug"
let accepted=$accepted+1
let ACCELF=$ACCELF+1
else
tokenizeanddiff $S1 $S2 $3
if [ $? -ne 0 ]; then
failure $3 " $3 differs after stripping and processing"
else
message "accept: $3 after --strip-debug and processing"
let accepted=$accepted+1
let ACCELF=$ACCELF+1
fi
fi
rm $S1 $S2
}
function tokenize() {
# use regexes to replace date/time/kernel-version text
# with tokens which may allow files to match even though
# they have hardcoded date/time/kernel-version.
# arguments are file to process, and where to put it.
# these regexes are somewhat long, and the order they
# are applied in is important (to stop short ones being
# used when a longer version would match).
# KV00 linux version date (e.g. as in the kernel itself)
# allow 2 or 3 groups of three alphas here - optional smp, with day, mon
# KV01 kernel version, including possible cpu details (that is for cdda2wav)
# KV02 just the version, in quotes e.g. "2.6.12.6" or '2.6.13', for perl stuff
# except that "|' gives me grif, so try a boundary
# also, it might need local version on the end, I really want
# quote2.\d+.\d+.{0,32}quote - it is the quotes that don't work.
# DT00 Day Mon .d+ hh:mm:ss TZN CCYY variations include non-caps and 'mon d'
# DT01 Mon .d+ CCYY hh:mm:ss
# DT02 hh:mm:ss Mon .d CCYY
# DT03 Mon .d CCYY
# DT04 Day Mon { ,d}d hh:mm:ss CCYY - for groff example postscript files
# (somewhat similar to DT00, but ' d' or ' dd' for day of month and no TZN )
# DT05 hh:mm:ss
# DT06 ISO date using space as separator
# DT07 ISO date using dash as separator
# DT08 ISO date using slash as separator
# DT09 fullmonth (capitalised), day number, comma, 4-digit year (groff 1.18.1 ps)
# DT10 dd, fullmonth (capitalised), 4-digit year (groff 1.18.1 manpages)
# DT11 '(xample comma space digit(s) backslash ) in groff memef.ps which is
# quite clearly the day of the month when it was compiled, preceded by 'example'
# with something weird between the e and the x.
if [ $# -ne 2 ]; then
fatal "tokenizing called with $# arguments : $*"
fi
cat $1 | perl -p \
-e 's/(L|l)inux.*\d\.\d\.\d+.* \#\d+( [A-Za-z][a-z]{2}){2,3} \d+ \d\d:\d\d:\d\d [A-Za-z]{3} \d{4}\b/%KV00%/g;' \
-e 's/(L|l)inux( (\w|_)+)?(-| |_)\d\.\d(\.\d+){1,2}((-|_)?(\w|_)+)?( |\000)*/%KV01%/g;' \
-e 's/\W2(\.\d+){2,3}(-|_)?((\w|_)+)?\s*\W/%KV02%/g;' \
-e 's/\b([A-Za-z][a-z]{2} ){2}( |\d)?\d \d\d:\d\d:\d\d [A-Za-z]{3} \d{4}\b/%DT00%/g;' \
-e 's/\b[A-Z][a-z]{2} ( |\d)\d \d{4} \d\d:\d\d:\d\d\b/%DT01%/g;' \
-e 's/\b\d\d:\d\d:\d\d [A-Z][a-z]{2} ( |\d)\d \d{4}\b/%DT02%/g;' \
-e 's/\b[A-Z][a-z]{2} ( |\d)\d \d{4}\b/%DT03%/g;' \
-e 's/\b([A-Z][a-z]{2} ){2}( |\d)\d \d\d:\d\d:\d\d \d{4}/%DT04%/g;' \
-e 's/\b\d\d:\d\d:\d\d\b/%DT05%/g;' \
-e 's/\b\d{4} \d\d \d\d\b/%DT06%/g;' \
-e 's/\b\d{4}-\d\d-\d\d\b/%DT07%/g;' \
-e 's/\b\d{4}\/\d\d\/\d\d\b/%DT08%/g;' \
-e 's/\b[A-Z][a-z]{2,} \d{1,2}, \d{4}/%DT09%/g;' \
-e 's/\b\d\d [A-Z][a-z]{2,} \d{4}/%DT10%/g;' \
-e 's/\(xample, \d{1,2}\\\)/%DT11%/g;' \
>$2
}
function tokenizeanddiff() {
# Call tokenize for the inputs, then compare the results
# Input arguments are path/filename for old and new versions
# third parm is readable name (filename, or archivename:member)
# to help understand what is in the extras output.
# - sometimes called for files, but other times called for
# members of ar archives extracted into temporary directories
#message tokenizeanddiff called for $1 $2 $3
F1=`mktemp` || fatal "cannot create a temporary file"
F2=`mktemp` || fatal "cannot create a temporary file"
tokenize $1 $F1
tokenize $2 $F2
# actually, cmp is probably more efficient
# but for picking up the pieces it will be better to
# use diff to see what got through.
cmp -s $F1 $F2
TOKENRESULT=$?
if [ $TOKENRESULT -ne 0 ]; then
echo "failure in $3..." >&6
diff -a $F1 $F2 >&6
rm $F1 $F2
false
else
# show what we did
echo "substitutions for $3" >&8
echo "build one" >&8
diff -a $1 $F1 >&8
echo "build two" >&8
diff -a $2 $F2 >&8
rm $F1 $F2
true
fi
}
function validateargs() {
# validate the arguments
BAD=0
if ! [ -d $1 ]; then
echo "Error: first argument is not a directory" >&2
let BAD=$BAD+1
fi
NAME=`basename ${2%%-*}`
if [ $NAME != filelist ]; then
echo "Error: second argument is not a recognized filelist" >&2
let BAD=$BAD+1
fi
if ! [ -d $3 ]; then
echo "Error: third argument is not a directory" >&2
let BAD=$BAD+1
fi
NAME=`basename ${4%%-*}`
if [ $NAME != filelist ]; then
echo "Error: fourth argument is not a recognized filelist" >&2
let BAD=$BAD+1
fi
for I in $1 $2 $3 $4; do
if ! [ -r $I ]; then
echo "Error: cannot read $I" >&2
let BAD=$BAD+1
fi
done
if [ $1 == $3 ]; then
echo "Error: directory pathes are identical" >&2
let BAD=$BAD+1
fi
if [ $2 == $4 ]; then
echo "Error: filelist names are identical" >&2
let BAD=$BAD+1
fi
if [ $BAD -eq 0 ]; then
ARGS=valid
fi
}
# Mainline
ARGS=unproven
OUTDIR=
if [ $# -eq 1 ]; then
case $1 in
-version|--version)
echo "`basename $0` version $VERSION"
exit 0
;;
-help|--help)
dohelp
exit 0
;;
esac
fi
if [ $1 = "--directory" ]; then
OUTDIR=$2
shift 2
grep '/$' $OUTDIR >/dev/null 2>&1 || OUTDIR=`echo $OUTDIR | sed 's%$%/%'`
echo "creating directory $OUTDIR"
mkdir -p $OUTDIR
if [ $? -ne 0 ]; then
echo "cannot mkdir $OUTDIR"
exit 1
fi
fi
if [ $# -eq 4 ]; then
validateargs $*
fi
if ! [ $ARGS == valid ]; then
dohelp
fatal "`basename $0`: error in arguments"
fi
# ok, we're happy, lets hit these files
exec 5>${OUTDIR}$RESULT
exec 6>${OUTDIR}$EXTRAS
exec 7>${OUTDIR}$IDENTICAL
exec 8>${OUTDIR}$SUBS
exec 9>${OUTDIR}$DIFFER
>${OUTDIR}$RESULT
if [ $? -ne 0 ]; then
fatal "cannot write to ${OUTDIR}$RESULT"
fi
emessage "will compare:"
emessage " first build at $1 with files listed in $2"
emessage "second build at $3 with files listed in $4"
let accepted=0
let different=0
let expected=0
let matched=0
let only=0
let predictable=0
let unreadable=0
let total=0
# break down the accepted
let ACCAR=0
let ACCELF=0
let ACCGZ=0
let ACCUNK=0
# break down definitely different
let DIFAR=0
let DIFELF=0
let DIFGZ=0
let DIFSYM=0
let DIFUNK=0
# break down the expected differences
let EXPAR=0
let EXPELF=0
let EXPGZ=0
let EXPUNK=0
# break down the identical files
let MATAR=0
let MATELF=0
let MATGZ=0
let MATSYM=0
let MATUNK=0
# break down how many of each type
let TOTAR=0
let TOTELF=0
let TOTGZ=0
let TOTSYM=0
let TOTUNK=0
# now identify differences between the two trees
DIFF=`mktemp` || fatal "cannot create a temporary file"
diff $2 $4 >$DIFF
for RUN in '<' '>' ; do
grep -q "$RUN" $DIFF && onlyone "$RUN"
done
rm $DIFF
# and compare them
message "Results of file comparison:"
message ""
# Strip any trailing slash from the path for tidyness,
# because the filenames all start with a slash. Unfortunately,
# unfortunately, '/' becomes empty, which breaks subroutines,
# so special case it.
# also, to process ar archives we need to extract them in temp
# directories - that means that after cd'ing we've broken any
# relative path, so save original pwd as necessary.
P1=`echo $1 | sed 's%/$%%'`
echo $1 | grep '^/' >/dev/null
if [ $? -ne 0 ]; then
# relative path
OP1=${PWD}/
#echo "setting OP1 to $OP1"
else
OP1=
#echo "$1 is an absolute path"
fi
test -z "$P1" && P1='/'
P2=`echo $3 | sed 's%/$%%'`
echo $3 | grep '^/' >/dev/null
if [ $? -ne 0 ]; then
# relative path
OP2=${PWD}/
#echo "setting OP2 to $OP2"
else
OP2=
#echo "$3 is an absolute path"
fi
test -z "$P2" && P2='/'
echo "about to read $2"
while read FILE ; do
#echo "process $FILE"
#echo "test existence of ${P2}${FILE}"
# confirm it exists in second build
# we have already reported files only in one build
if [ -f ${P2}"${FILE}" ]; then
let total=$total+1
# check we can read both of them
# or count as unreadable - I used to separate only-one-unreadable,
# but if you compre '/' and a _copy_ of /mnt/lfs that assumption
# breaks, so be less picky.
if ! [ -r "${P1}${FILE}" ] || ! [ -r "${P2}${FILE}" ]; then
message "cannot read one or both versions of $FILE"
let unreadable=$unreadable+1
continue
fi
if [ -h "${P1}${FILE}" ]; then
# for symlink, look at what it points to
# exceptionally, do not call filetype
TYPE=SYM
let TOTSYM=$TOTSYM+1
SL1=`ls -l "${P1}${FILE}" | awk '{ print $11 }'`
SL2=`ls -l "${P2}${FILE}" | awk '{ print $11 }'`
if [ "$SL1" = "$SL2" ]; then
echo "symlink $FILE matches for $SL1" >&5
let matched=$matched+1
let MATSYM=$MATSYM+1
else
failure TARGET " symlink $FILE points to $SL1 and $SL2"
echo $FILE >&9
fi
else
# regular file, start by typing it for accounting,
# then compare it
filetype ${P1}${FILE}
cmp -s "${P1}${FILE}" "${P2}${FILE}"
if [ $? -eq 0 ]; then
let matched=$matched+1
case $TYPE in
AR)
let MATAR=$MATAR+1
;;
ELF)
let MATELF=$MATELF+1
;;
GZ)
let MATGZ=$MATGZ+1
;;
UNK)
let MATUNK=$MATUNK+1
;;
*)
echo "unexpected TYPE of $TYPE for $FILE" >&2
exit 2
;;
esac
echo ${FILE} >&7
else
# seems different, can we do better ?
# test if we expect it to differ
expected $FILE
if [ $? -ne 0 ]; then
case $TYPE in
GZ)
testgzip $P1 $P2 $FILE ;;
AR)
testar $P1 $P2 $FILE ;;
ELF)
testso $P1 $P2 $FILE ;;
*)
# long-stop - strip dates from text files
tokenizeanddiff "${P1}${FILE}" "${P2}${FILE}" "$FILE"
if [ $? -eq 0 ]; then
message "accepted $FILE after processing"
let accepted=$accepted+1
let ACCUNK=$ACCUNK+1
else
failure "$FILE" " $FILE is different"
fi
;;
esac
fi
fi
fi
fi
done < $2
message ""
# write totals to stderr as well as the results file
emessage "$only files in only one of the builds"
emessage "$total files compared, of which"
emessage "$unreadable files could not be read, skipped"
emessage "$matched files are identical"
emessage "$expected files differed as expected"
emessage "$accepted files had allowable differences"
#emessage "$predictable files differed as they normally do"
emessage "$different files differed"
# totals of different file types
emessage ""
emessage "$TOTAR ar archives"
emessage " of which $MATAR are identical"
emessage " of which $ACCAR are accepted after strip-debug or extracting, diffing, tokenizing"
emessage " of which $EXPAR differed as expected"
emessage " of which $DIFAR differed"
emessage "$TOTELF ELF executables or shared libraries"
emessage " of which $MATELF are identical"
emessage " of which $ACCELF are accepted after stripping and tokenizing"
emessage " of which $EXPELF differed as expected"
emessage " of which $DIFELF differed"
emessage "$TOTGZ gzipped files"
emessage " of which $MATGZ are identical"
emessage " of which $ACCGZ are accepted after comparing beyond timestamp"
emessage " of which $DIFGZ are different"
emessage "$TOTSYM symbolic links"
emessage " of which $MATSYM are identical"
emessage " of which $DIFSYM have different targets"
emessage "$TOTUNK other files"
emessage " of which $MATUNK are identical"
emessage " of which $ACCUNK are accepted after tokenizing"
emessage " of which $EXPUNK differed as expected"
emessage " of which $DIFUNK differed"

60
extras/filelist Executable file
View file

@ -0,0 +1,60 @@
#!/bin/bash
#$Id$
# Acknowledgment:
# The following code is a modified version of an original work written by
# Ken Moffat for their "farce" project and is included here with his
# permission.
#
set -e
: <<inline_doc
desc: creates farce file lists
usage: filelist $DEST_FARCE/$ITERATION $DEST_FARCE/$ITERATION.filelist
input vars: $1 directory where files from current iteration are stored
$2 name of the file list to be created
externals: --
modifies: --
returns: --
on error:
on success:
inline_doc
if [ $# -eq 2 ]; then
OUTFILE=$2
if [ -e $2 ]; then
echo -e "\nOutput $2 already exists\n"
exit
fi
else
echo -e "\nMissing argument\n"
exit 2
fi
if [ "$1" == "/" ]; then
LOC=$1
else
# ensure the path or mountpoint ends with a slash
# because of the seds after the 'find'
LOC=`echo $1 | sed 's%[^/]$%&/%'`
fi
echo -en "\nCreating file list for farce amalysis in $OUTFILE ..."
if [ -f $OUTFILE ]; then
echo "refusing to overwrite $OUTFILE"
exit 1
fi
# check we can indeed do this
>$OUTFILE
if [ $? -ne 0 ]; then
echo "error, cannot write to $OUTFILE"
exit 1
fi
find $LOC -xdev -xtype f | sed "s%^${LOC}%/%" | sort >$OUTFILE
echo -e "done.\n"
exit

View file

@ -1,184 +0,0 @@
#!/bin/bash
set -e
: << inline_doc
Installs a set-up to build BLFS packages.
You can set these variables:
TRACKING_DIR : where the installed package file is kept.
(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.
Must start with a '/' (default /blfs_root)
BLFS_COMMIT : any commit (branch/tag/sha)
(default trunk)
LFS_COMMIT : any commit (branch/tag/sha)
(default trunk)
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) 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
This script can also be called automatically after running make in this
directory. The parameters will then be taken from the configuration file.
inline_doc
# VT100 colors
declare -r BLACK=$'\e[1;30m'
declare -r DK_GRAY=$'\e[0;30m'
declare -r RED=$'\e[31m'
declare -r GREEN=$'\e[32m'
declare -r YELLOW=$'\e[33m'
declare -r BLUE=$'\e[34m'
declare -r MAGENTA=$'\e[35m'
declare -r CYAN=$'\e[36m'
declare -r WHITE=$'\e[37m'
declare -r OFF=$'\e[0m'
declare -r BOLD=$'\e[1m'
declare -r REVERSE=$'\e[7m'
declare -r HIDDEN=$'\e[8m'
declare -r tab_=$'\t'
declare -r nl_=$'\n'
declare -r DD_BORDER="${BOLD}==============================================================================${OFF}"
declare -r SD_BORDER="${BOLD}------------------------------------------------------------------------------${OFF}"
declare -r STAR_BORDER="${BOLD}******************************************************************************${OFF}"
declare -r dotSTR=".................." # Format display of parameters and versions
# bold yellow > < pair
declare -r R_arrow=$'\e[1;33m>\e[0m'
declare -r L_arrow=$'\e[1;33m<\e[0m'
VERBOSITY=1
# Take parameters from "configuration" if $1="auto"
if [ "$1" = auto ]; then
[[ $VERBOSITY > 0 ]] && echo -n "Loading configuration ... "
source configuration
[[ $? > 0 ]] && echo -e "\nconfiguration could not be loaded" && exit 2
[[ $VERBOSITY > 0 ]] && echo "OK"
fi
if [ "$BOOK_BLFS" = y ]; then
## Read variables and sanity checks
[[ "$BRANCH" = y ]] && BLFS_COMMIT=$COMMIT
[[ "$WORKING_COPY" = y ]] && BLFS_BOOK=$BOOK
[[ "$BOOK" = "**EDIT ME**" ]] &&
echo You have not set the BLFS working copy location && exit 1
[[ "$LFS_BRANCH" = y ]] && LFS_COMMIT=$BLFS_LFS_COMMIT
[[ "$LFS_WORKING_COPY" = y ]] && LFS_BOOK=$BLFS_LFS_BOOK
[[ "$LFS_BOOK" = "**EDIT ME**" ]] &&
echo You have not set the LFS working copy location && exit 1
fi
COMMON_DIR="common"
# blfs-tool envars
BLFS_TOOL='y'
BUILDDIR=$(cd ~;pwd)
BLFS_ROOT="${BLFS_ROOT:=/blfs_root}"
TRACKING_DIR="${TRACKING_DIR:=/var/lib/jhalfs/BLFS}"
INITSYS="${INITSYS:=sysv}"
BLFS_COMMIT=${BLFS_COMMIT:=trunk}
LFS_COMMIT=${LFS_COMMIT:=trunk}
BLFS_XML=${BLFS_XML:=blfs-xml}
LFS_XML=${LFS_XML:=lfs-xml}
# Validate the configuration:
PARAMS="BLFS_ROOT TRACKING_DIR INITSYS BLFS_XML LFS_XML"
if [ "$WORKING_COPY" = y ]; then
PARAMS="$PARAMS WORKING_COPY BLFS_BOOK"
else
PARAMS="$PARAMS BLFS_COMMIT"
fi
if [ "$LFS_WORKING_COPY" = y ]; then
PARAMS="$PARAMS LFS_WORKING_COPY LFS_BOOK"
else
PARAMS="$PARAMS LFS_COMMIT"
fi
# Format for displaying parameters:
declare -r PARAM_VALS='${config_param}${dotSTR:${#config_param}} ${L_arrow}${BOLD}${!config_param}${OFF}${R_arrow}'
for config_param in $PARAMS; do
echo -e "`eval echo $PARAM_VALS`"
done
echo "${SD_BORDER}${nl_}"
echo -n "Are you happy with these settings? yes/no (no): "
read ANSWER
if [ x$ANSWER != "xyes" ] ; then
echo "${nl_}Rerun make and fix your settings.${nl_}"
exit
fi
[[ $VERBOSITY > 0 ]] && echo "${SD_BORDER}${nl_}"
#*******************************************************************#
[[ $VERBOSITY > 0 ]] && echo -n "Loading function <func_check_version.sh> ..."
source $COMMON_DIR/libs/func_check_version.sh
[[ $? > 0 ]] && echo " function module did not load.." && exit 2
[[ $VERBOSITY > 0 ]] && echo " OK"
[[ $VERBOSITY > 0 ]] && echo "${SD_BORDER}${nl_}"
# Check for build prerequisites.
echo
check_alfs_tools
echo "${SD_BORDER}${nl_}"
# Install the files
[[ $VERBOSITY > 0 ]] && echo -n "Populating the ${BUILDDIR}${BLFS_ROOT} directory "
[[ ! -d ${BUILDDIR}${BLFS_ROOT} ]] && mkdir -pv ${BUILDDIR}${BLFS_ROOT}
rm -rf ${BUILDDIR}${BLFS_ROOT}/*
cp -r BLFS/* ${BUILDDIR}${BLFS_ROOT}
cp -r menu ${BUILDDIR}${BLFS_ROOT}
cp $COMMON_DIR/progress_bar.sh ${BUILDDIR}${BLFS_ROOT}
cp README.BLFS ${BUILDDIR}${BLFS_ROOT}
[[ $VERBOSITY > 0 ]] && echo "... OK"
# Clean-up
[[ $VERBOSITY > 0 ]] && echo -n "Cleaning the ${BUILDDIR}${BLFS_ROOT} directory "
# We do not want to keep an old version of the book:
rm -rf ${BUILDDIR}${BLFS_ROOT}/$BLFS_XML
rm -rf ${BUILDDIR}${BLFS_ROOT}/$LFS_XML
# Set some harcoded envars to their proper values
sed -i s@tracking-dir@$TRACKING_DIR@ \
${BUILDDIR}${BLFS_ROOT}/{Makefile,gen-makefile.sh,gen_pkg_book.sh}
# Ensures the tracking directory exists.
# Throws an error if it does not exist and the user does not
# have write permission to create it.
# If it exists, does nothing.
mkdir -p $TRACKING_DIR
[[ $VERBOSITY > 0 ]] && echo "... OK"
[[ -z "$BLFS_BOOK" ]] ||
[[ $BLFS_BOOK = $BUILDDIR$BLFS_ROOT/$BLFS_XML ]] || {
[[ $VERBOSITY > 0 ]] && echo -n "Retrieving BLFS working copy (may take some time) "
cp -a $BLFS_BOOK $BUILDDIR$BLFS_ROOT/$BLFS_XML
[[ $VERBOSITY > 0 ]] && echo "... OK"
}
[[ -z "$LFS_BOOK" ]] ||
[[ $LFS_BOOK = $BUILDDIR$BLFS_ROOT/$LFS_XML ]] || {
[[ $VERBOSITY > 0 ]] && echo -n "Retrieving the LFS working copy (may take some time) "
cp -a $LFS_BOOK $BUILDDIR$BLFS_ROOT/$LFS_XML
[[ $VERBOSITY > 0 ]] && echo "... OK"
}
[[ $VERBOSITY > 0 ]] && echo "Initializing the BLFS tool directory "
make -j1 -C $BUILDDIR$BLFS_ROOT \
TRACKING_DIR=$TRACKING_DIR \
REV=$INITSYS \
LFS_XML=$BUILDDIR$BLFS_ROOT/$LFS_XML \
LFS-BRANCH=${LFS_COMMIT} \
BLFS_XML=$BUILDDIR$BLFS_ROOT/$BLFS_XML \
BLFS-BRANCH=${BLFS_COMMIT} \
$BUILDDIR$BLFS_ROOT/packages.xml
[[ $VERBOSITY > 0 ]] && echo "... OK"

514
jhalfs
View file

@ -1,25 +1,29 @@
#!/bin/bash
# $Id$
set -e
# Pass trap handlers to functions
set -E
# VT100 colors
declare -r BLACK=$'\e[1;30m'
declare -r DK_GRAY=$'\e[0;30m'
declare -r RED=$'\e[31m'
declare -r GREEN=$'\e[32m'
declare -r YELLOW=$'\e[33m'
# shellcheck disable=SC2034
declare -r BLUE=$'\e[34m'
declare -r MAGENTA=$'\e[35m'
declare -r CYAN=$'\e[36m'
declare -r WHITE=$'\e[37m'
declare -r OFF=$'\e[0m'
declare -r BOLD=$'\e[1m'
declare -r REVERSE=$'\e[7m'
declare -r HIDDEN=$'\e[8m'
declare -r tab_=$'\t'
declare -r nl_=$'\n'
# shellcheck disable=SC2034
declare -r DD_BORDER="${BOLD}==============================================================================${OFF}"
# shellcheck disable=SC2034
declare -r SD_BORDER="${BOLD}------------------------------------------------------------------------------${OFF}"
# shellcheck disable=SC2034
declare -r STAR_BORDER="${BOLD}******************************************************************************${OFF}"
# bold yellow > < pair
@ -31,14 +35,14 @@ declare -r L_arrow=$'\e[1;33m<\e[0m'
#-----------------------#
simple_error() { # Basic error trap.... JUST DIE
#-----------------------#
LASTLINE="$1"
LASTERR="$2"
LASTSOURCE="$4"
error_message "${GREEN} Error $LASTERR at $LASTSOURCE line ${LASTLINE}!"
# If +e then disable text output
if [[ "$-" =~ e ]]; then
echo -e "\n${RED}ERROR:${GREEN} basic error trapped!${OFF}\n" >&2
fi
}
see_ya() {
printf '\n%b%bjhalfs%b exit%b\n' "$L_arrow" "$BOLD" "$R_arrow" "$OFF"
echo -e "\n${L_arrow}${BOLD}jhalfs-X${R_arrow} exit${OFF}\n"
}
##### Simple error TRAPS
# ctrl-c SIGINT
@ -53,114 +57,55 @@ see_ya() {
#####
set -e
trap see_ya 0
trap 'simple_error "${LINENO}" "$?" "${FUNCNAME}" "${BASH_SOURCE}"' ERR
trap 'echo -e "\n\n${RED}INTERRUPT${OFF} trapped\n" && exit 2' \
HUP INT QUIT TERM # STOP stops tterminal output and does not seem to
# execute the handler
trap simple_error ERR
trap 'echo -e "\n\n${RED}INTERRUPT${OFF} trapped\n" && exit 2' 1 2 3 15 17 18 23
#>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
simple_message() {
# Prevents having to check $VERBOSITY everywhere
if [ "$VERBOSITY" -ne 0 ] ; then
# shellcheck disable=SC2059
printf "$*"
fi
}
warning_message() {
simple_message "${YELLOW}\\nWARNING:${OFF} $*\\n\\n"
}
error_message() {
# Prints an error message and exits with LASTERR or 1
if [ -n "$LASTERR" ] ; then
LASTERR=$(printf '%d' "$LASTERR")
else
LASTERR=1
fi
# If +e then disable text output
if [[ "$-" =~ e ]]; then
printf '\n\n%bERROR:%b %s\n' "$RED" "$OFF" "$*" >&2
fi
exit "$LASTERR"
}
load_file() {
# source files in a consistent way with an optional message
file="$1"
shift
msg="Loading file ${file}..."
[ -z "$*" ] || msg="$*..."
simple_message "$msg"
# shellcheck disable=SC1090
source "$file" 2>/dev/null || error_message "$file did not load"
simple_message "OK\\n"
}
git_commit=$(git log -1 --format=format:"%h %ad")
version="
${BOLD} \"jhalfs\"${OFF} builder tool (development) $git_commit
${BOLD} \"jhalfs-X\"${OFF} builder tool (experimental) \$Rev$
\$Date$
Copyright (C) 2005-2023, the jhalfs team:
Jeremy Huntwork
George Boudreau
Manuel Canales Esparcia
Thomas Pegg
Matthew Burgess
Pierre Labastie
Written by George Boudreau and Manuel Canales Esparcia,
plus several contributions.
Unless specified, all the files in this directory and its sub-directories
are subjected to the ${BOLD}MIT license${OFF}. See the ${BOLD}LICENSE${OFF} file.
Based on an idea from Jeremy Huntwork
The files in the ${BOLD}menu${OFF} directory are subjected to the ${BOLD}ISC License${OFF}.
See ${BOLD}LICENSE.txt${OFF} and ${BOLD}README${OFF} in that directory.
This set of files are published under the
${BOLD}Gnu General Public License, Version 2.${OFF}
"
usage="${nl_}${tab_}${BOLD}${RED}This script cannot be called directly${OFF}
${tab_}Type ${BOLD}make${OFF} to run the tool, or
${tab_}Type ${BOLD}./jhalfs -v${OFF} to display version information."
case $1 in
-v ) echo "$version" && exit ;;
-v ) echo "$version" && exit 1 ;;
run ) : ;;
* ) echo "$usage" && exit 1 ;;
* )
echo "${nl_}${tab_}${BOLD}${RED}This script cannot be called directly: EXITING ${OFF}${nl_}"
exit 1
;;
esac
# If the user has not saved his configuration file, let's ask
# if he or she really wants to run this stuff
time_current=$(stat -c '%Y' configuration 2>/dev/null || date +%s)
time_old=$(stat -c '%Y' configuration.old 2>/dev/null || printf '%s' "$time_current")
if [ "$(printf '%d' "$time_old")" -ge "$(printf '%d' "$time_current")" ] ; then
printf 'Do you want to run jhalfs? yes/no (yes): '
read -r ANSWER
case ${ANSWER:0:1} in
n|N) printf "\nExiting gracefully.\n"; exit ;;
esac
fi
# Change this to 0 to suppress almost all messages
VERBOSITY=1
load_file configuration "Loading config params from <configuration>"
[[ $VERBOSITY > 0 ]] && echo -n "Loading config params from <configuration>..."
source configuration
[[ $? > 0 ]] && echo "file:configuration did not load.." && exit 1
[[ $VERBOSITY > 0 ]] && echo "OK"
# These are boolean vars generated from Config.in.
# ISSUE: If a boolean parameter is not set to y(es) there
# is no variable defined by the menu app. This can
# cause a headache if you are not aware.
# The following variables MUST exist. If they don't, the
# default value is n(o).
# ISSUE: If a boolean parameter is not set <true> that
# variable is not defined by the menu app. This can
# cause a headache if you are not careful.
# The following parameters MUST be created and have a
# default value.
RUNMAKE=${RUNMAKE:-n}
GETPKG=${GETPKG:-n}
GETKERNEL=${GETKERNEL:-n}
COMPARE=${COMPARE:-n}
RUN_FARCE=${RUN_FARCE:-n}
RUN_ICA=${RUN_ICA:-n}
PKGMNGT=${PKGMNGT:-n}
WRAP_INSTALL=${WRAP_INSTALL:-n}
BOMB_TEST=${BOMB_TEST:-n}
STRIP=${STRIP:=n}
REPORT=${REPORT:=n}
NCURSES5=${NCURSES5:-n}
DEL_LA_FILES=${DEL_LA_FILES:-n}
FULL_LOCALE=${FULL_LOCALE:-n}
VIMLANG=${VIMLANG:-n}
GRSECURITY_HOST=${GRSECURITY_HOST:-n}
CUSTOM_TOOLS=${CUSTOM_TOOLS:-n}
REBUILD_MAKEFILE=${REBUILD_MAKEFILE:-n}
@ -173,243 +118,256 @@ SET_HARDENED_TMP=${SET_HARDENED_TMP:=n}
SET_WARNINGS=${SET_WARNINGS:=n}
SET_MISC=${SET_MISC:=n}
SET_BLOWFISH=${SET_BLOWFISH:=n}
UNICODE=${UNICODE:=n}
LOCAL=${LOCAL:=n}
ALL_CORES=${ALL_CORES:=n}
REALSBU=${REALSBU:=n}
SAVE_CH5=${SAVE_CH5:=n}
if [[ "${NO_PROGRESS_BAR}" = "y" ]] ; then
# shellcheck disable=SC2034
NO_PROGRESS="#"
fi
# Sanity check on the location of $BUILDDIR / $JHALFSDIR
CWD="$(cd "$(dirname "$0")" && pwd)"
if [[ $JHALFSDIR == "$CWD" ]]; then
echo " The jhalfs source directory conflicts with the jhalfs build directory."
echo " Please move the source directory or change the build directory."
exit 2
CWD=$(cd `dirname $0` && pwd)
if [[ $JHALFSDIR == $CWD ]]; then
echo " The jhalfs source directory conflicts with the jhalfs build directory."
echo " Please move the source directory or change the build directory."
exit 2
fi
# Book surces envars
BRANCH_ID=${BRANCH_ID:=development}
case $BRANCH_ID in
development )
case $PROGNAME in
clfs2 ) TREE=branches/clfs-sysroot/BOOK ;;
clfs3 ) TREE=branches/clfs-embedded/BOOK ;;
*) TREE=trunk/BOOK ;;
esac
LFSVRS=development
;;
*EDIT* ) echo " You forgot to set the branch or stable book version."
echo " Please rerun make and fix the configuration."
exit 2 ;;
branch-* )
LFSVRS=${BRANCH_ID}
TREE=branches/${BRANCH_ID#branch-}/BOOK
;;
* )
case $PROGNAME in
lfs | hlfs )
LFSVRS=${BRANCH_ID}
TREE=tags/${BRANCH_ID}/BOOK
;;
clfs | clfs2 | clfs3)
LFSVRS=${BRANCH_ID}
TREE=tags/${BRANCH_ID}
;;
esac
;;
esac
# Set the document location...
BOOK=${BOOK:=$JHALFSDIR/book-source}
#--- Envars not sourced from configuration
# shellcheck disable=SC2034
declare -r REPO=https://git.linuxfromscratch.org/lfs.git
declare -r LOG=000-masterscript.log
declare -r COMMANDS=lfs-commands
# Set true internal variables
COMMON_DIR="common"
PACKAGE_DIR=LFS
MODULE=$PACKAGE_DIR/master.sh
PKGMNGTDIR="pkgmngt"
# The name packageManager.xml is hardcoded in *.xsl, so no variable.
for file in \
"$COMMON_DIR/common-functions" \
"$COMMON_DIR/libs/func_book_parser" \
"$COMMON_DIR/libs/func_download_pkgs" \
"$COMMON_DIR/libs/func_wrt_Makefile" \
"$MODULE" ; do
load_file "$file"
done
simple_message "${SD_BORDER}${nl_}"
#*******************************************************************#
LASTERR=2
for file in \
"$COMMON_DIR/libs/func_check_version.sh" \
"$COMMON_DIR/libs/func_validate_configs.sh" \
"$COMMON_DIR/libs/func_custom_pkgs" ; do
load_file "$file"
done
unset LASTERR
simple_message "${SD_BORDER}${nl_}"
simple_message "Checking tools required for jhalfs${nl_}"
check_alfs_tools
simple_message "${SD_BORDER}${nl_}"
BOOK=${BOOK:=$PROGNAME-$LFSVRS}
# blfs-tool envars
BLFS_TOOL=${BLFS_TOOL:-n}
DEP_LIBXML=${DEP_LIBXML:-n}
DEP_LIBXSLT=${DEP_LIBXSLT:-n}
DEP_TIDY=${DEP_TIDY:-n}
DEP_UNZIP=${DEP_UNZIP:-n}
DEP_DBXML=${DEP_DBXML:-n}
DEP_DBXSL=${DEP_DBXSL:-n}
DEP_GPM=${DEP_GPM:-n}
DEP_LYNX=${DEP_LYNX:-n}
DEP_SUDO=${DEP_SUDO:-n}
DEP_WGET=${DEP_WGET:-n}
DEP_SVN=${DEP_SVN:-n}
if [[ "${BLFS_TOOL}" = "y" ]] ; then
#not needed now that the check is in alfs_tools
# simple_message 'Checking supplementary tools for installing BLFS'
# check_blfs_tools
simple_message "${SD_BORDER}${nl_}"
BLFS_BRANCH=${BLFS_BRANCH:-n}
BLFS_WORKING_COPY=${BLFS_WORKING_COPY:-n}
if [[ "${BLFS_WORKING_COPY}" = "y" ]] &&
[[ ! -d "$BLFS_WC_LOCATION/postlfs" ]] ; then
echo " BLFS tools: This is not a working copy: $BLFS_WC_LOCATION."
echo " Please rerun make and fix the configuration."
exit 2
fi
load_file "${COMMON_DIR}/libs/func_install_blfs"
BLFS_BRANCH_ID=${BLFS_BRANCH_ID:=development}
case $BLFS_BRANCH_ID in
development ) BLFS_TREE=trunk/BOOK ;;
*EDIT* ) echo " You forgot to set the BLFS branch or stable book version."
echo " Please rerun make and fix the configuration."
exit 2 ;;
branch-* ) BLFS_TREE=branches/${BLFS_BRANCH_ID#branch-} ;;
* ) BLFS_TREE=tags/${BLFS_BRANCH_ID} ;;
esac
fi
#--- Envars not sourced from configuration
case $PROGNAME in
clfs* ) declare -r SVN="http://svn.cross-lfs.org/svn/repos" ;;
* ) declare -r SVN="svn://svn.linuxfromscratch.org" ;;
esac
declare -r LOG=000-masterscript.log
# Needed to can fetch BLFS book sources when building CLFS
declare -r SVN_2="svn://svn.linuxfromscratch.org"
# Set true internal variables
CODE_DIR=`pwd`
COMMON_DIR="common"
PACKAGE_DIR=$(echo $PROGNAME | tr '[a-z]' '[A-Z]')
MODULE=$PACKAGE_DIR/master.sh
# Qick fix until have the new code ready
XSL=$CODE_DIR/$PACKAGE_DIR/$XSL
[[ $VERBOSITY > 0 ]] && echo -n "Loading common-functions module..."
source $COMMON_DIR/common-functions
[[ $? > 0 ]] && echo " $COMMON_DIR/common-functions did not load.." && exit
[[ $VERBOSITY > 0 ]] && echo "OK"
[[ $VERBOSITY > 0 ]] && echo -n "Loading code module <$MODULE>..."
source $MODULE
[[ $? > 0 ]] && echo "$MODULE did not load.." && exit 2
[[ $VERBOSITY > 0 ]] && echo "OK"
#
[[ $VERBOSITY > 0 ]] && echo "${SD_BORDER}${nl_}"
#*******************************************************************#
[[ $VERBOSITY > 0 ]] && echo -n "Loading function <func_check_version.sh>..."
source $COMMON_DIR/libs/func_check_version.sh
[[ $? > 0 ]] && echo " function module did not load.." && exit 2
[[ $VERBOSITY > 0 ]] && echo "OK"
[[ $VERBOSITY > 0 ]] && echo -n "Loading function <func_validate_configs.sh>..."
source $COMMON_DIR/libs/func_validate_configs.sh
[[ $? > 0 ]] && echo " function module did not load.." && exit 2
[[ $VERBOSITY > 0 ]] && echo "OK"
[[ $VERBOSITY > 0 ]] && echo -n "Loading function <func_custom_pkgs>..."
source $COMMON_DIR/libs/func_custom_pkgs
[[ $? > 0 ]] && echo " function module did not load.." && exit 2
[[ $VERBOSITY > 0 ]] && echo "OK"
[[ $VERBOSITY > 0 ]] && echo "${SD_BORDER}${nl_}"
###################################
### MAIN ###
###################################
# Check for build prereequisites.
echo
check_prerequisites
echo "${SD_BORDER}${nl_}"
validate_config
echo "${SD_BORDER}${nl_}"
echo -n "Are you happy with these settings? yes/no (no): "
read -r ANSWER
if [ "x$ANSWER" != "xyes" ] ; then
read ANSWER
if [ x$ANSWER != "xyes" ] ; then
echo "${nl_}Rerun make to fix the configuration options.${nl_}"
exit
exit 1
fi
echo "${nl_}${SD_BORDER}${nl_}"
# Load additional modules or configuration files based on global settings
# compare module
if [[ "$COMPARE" = "y" ]]; then
load_file "${COMMON_DIR}/libs/func_compare.sh" 'Loading compare module'
fi
#
# save module
if [[ "$SAVE_CH5" = "y" ]]; then
load_file "${COMMON_DIR}/libs/func_save.sh" 'Loading save module'
fi
#
# optimize module
# the optimize_functions file is needed for wrt_makeflags even
# if optimize=0, because we need to pass NINJAJOBS=1
load_file optimize/optimize_functions 'Loading optimization module'
if [[ "$OPTIMIZE" != "0" ]]; then
#
# optimize configurations
load_file optimize/opt_config 'Loading optimization config'
# Validate optimize settings, if required
validate_opt_settings
fi
# Parallelization is outside optimization, because it is now in the book
if [[ "$ALL_CORES" = "n" ]]; then
# shellcheck disable=SC2034
JH_MAKEFLAGS="-j${N_PARALLEL}"
[[ $VERBOSITY > 0 ]] && echo -n "Loading compare module..."
source $COMMON_DIR/libs/func_compare.sh
[[ $? > 0 ]] && echo "$COMMON_DIR/libs/func_compare.sh did not load.." && exit
[[ $VERBOSITY > 0 ]] && echo "OK"
fi
#
if [[ "$REBUILD_MAKEFILE" = "n" ]] ; then
# If requested, clean the build directory
# If $BUILDDIR has subdirectories like tools/ or bin/, stop the run
# and notify the user about that.
if [ -d $BUILDDIR/tools -o -d $BUILDDIR/bin ] && [ -z $CLEAN ] ; then
eval "$no_empty_builddir"
fi
# If requested, clean the build directory
clean_builddir
if [[ ! -d $JHALFSDIR ]]; then
sudo mkdir -p "$JHALFSDIR"
# Do not assume there is a group named as $USER, do not use
# $USER:$USER...
sudo chown "$USER" "$JHALFSDIR"
mkdir -p $JHALFSDIR
fi
# Create $BUILDDIR/sources even though it could be created by get_sources()
# Create $BUILDDIR/sources even though it could be created by get_sources()
if [[ ! -d $BUILDDIR/sources ]]; then
sudo mkdir -p "$BUILDDIR/sources"
sudo chmod a+wt "$BUILDDIR/sources"
mkdir -p $BUILDDIR/sources
fi
# Create the log directory
#
# Create the log directory
if [[ ! -d $LOGDIR ]]; then
mkdir "$LOGDIR"
mkdir $LOGDIR
fi
true >"$LOGDIR/$LOG"
>$LOGDIR/$LOG
#
# Copy common helper files
cp $COMMON_DIR/{makefile-functions,progress_bar.sh} $JHALFSDIR/
#
# Copy common helper files
cp "$COMMON_DIR"/{makefile-functions,progress_bar.sh,run-in-cgroup.sh} "$JHALFSDIR/"
# Copy needed stylesheets
cp "$COMMON_DIR"/{packages.xsl,chroot.xsl,kernfs.xsl} "$JHALFSDIR/"
cp "$PACKAGE_DIR/$XSL" "$JHALFSDIR/"
export XSL=$JHALFSDIR/${XSL}
# Copy packageManager.xml, if needed
[[ "$PKGMNGT" = "y" ]] && {
sed s@BOOK@"$BOOK"@ "$PKGMNGTDIR/packageManager.xml" > \
"$JHALFSDIR/"packageManager.xml
cp "$PKGMNGTDIR/packInstall.sh" "$JHALFSDIR/"
}
# Copy urls.xsl, if needed
[[ "$GETPKG" = "y" ]] && cp "$COMMON_DIR/urls.xsl" "$JHALFSDIR/"
# Always create the test-log directory to allow user to "uncomment" test
# instructions
install -d -m 1777 "$TESTLOGDIR"
# Create the installed-files directory, if needed
[[ "$INSTALL_LOG" = "y" ]] && [[ ! -d $FILELOGDIR ]] && install -d -m 1777 "$FILELOGDIR"
# Prepare report creation, if needed
# Create the test-log directory, if needed
[[ "$TEST" != "0" ]] && [[ ! -d $TESTLOGDIR ]] && install -d -m 1777 $TESTLOGDIR
#
# Create the installed-files directory, if needed
[[ "$INSTALL_LOG" = "y" ]] && [[ ! -d $FILELOGDIR ]] && install -d -m 1777 $FILELOGDIR
#
# Prepare report creation, if needed
if [[ "$REPORT" = "y" ]]; then
cp $COMMON_DIR/create-sbu_du-report.sh "$JHALFSDIR/"
# After making sure that all looks sane, dump the settings to a file
cp $COMMON_DIR/create-sbu_du-report.sh $JHALFSDIR/
# After being sure that all looks sane, dump the settings to a file
# This file will be used to create the REPORT header
validate_config >"$JHALFSDIR/jhalfs.config"
validate_config > $JHALFSDIR/jhalfs.config
fi
# Copy optimize files, if needed
[[ "$OPTIMIZE" != "0" ]] && cp optimize/opt_override "$JHALFSDIR/"
# Copy compare files, if needed
#
# Copy compare files, if needed
if [[ "$COMPARE" = "y" ]]; then
mkdir -p "$JHALFSDIR/extras"
cp extras/* "$JHALFSDIR/extras"
mkdir -p $JHALFSDIR/extras
cp extras/* $JHALFSDIR/extras
fi
#
# Copy custom tools config files, if requested
if [[ "${CUSTOM_TOOLS}" = "y" ]]; then
echo "Copying custom tool scripts to $JHALFSDIR"
mkdir -p "$JHALFSDIR/custom-commands"
cp -f custom/config/* "$JHALFSDIR/custom-commands"
fi
# Download or updates the book source
# Note that all customization to $JHALFSDIR have to be done before this.
# But the LFS book is needed for BLFS tools.
get_book
extract_commands
echo "${SD_BORDER}${nl_}"
cd "$CWD" # the functions above change directory
# Install blfs-tool, if requested.
# Install blfs-tool, if requested.
if [[ "${BLFS_TOOL}" = "y" ]] ; then
echo Installing BLFS book and tools
install_blfs_tools 2>&1 | tee -a "$LOGDIR/$LOG"
[[ ${PIPESTATUS[0]} != 0 ]] && exit 1
# Install the files
[[ ! -d ${BUILDDIR}${BLFS_ROOT} ]] && mkdir -p ${BUILDDIR}${BLFS_ROOT}
cp -r BLFS/* ${BUILDDIR}${BLFS_ROOT}
cp -r menu ${BUILDDIR}${BLFS_ROOT}
cp $COMMON_DIR/progress_bar.sh ${BUILDDIR}${BLFS_ROOT}
cp README.BLFS ${BUILDDIR}${BLFS_ROOT}
# Clean-up
rm -rf ${BUILDDIR}${BLFS_ROOT}/libs/.svn
rm -rf ${BUILDDIR}${BLFS_ROOT}/menu/.svn
rm -rf ${BUILDDIR}${BLFS_ROOT}/menu/lxdialog/.svn
# Set some harcoded envars to their proper values
sed -i 's,blfs-xml,'$BLFS_XML',' ${BUILDDIR}${BLFS_ROOT}/{update_book.sh,libs/book.xsl}
sed -i 's,tracking-dir,'$TRACKING_DIR',' ${BUILDDIR}${BLFS_ROOT}/{update_book.sh,gen-makefile.sh}
fi
#
get_book
echo "${SD_BORDER}${nl_}"
# Get the BLFS book, if requested.
if [[ "${BLFS_TOOL}" = "y" ]] ; then
echo -n "Downloading the BLFS document, $BLFS_BRANCH_ID version... "
if [[ ! -d ${BUILDDIR}${BLFS_ROOT}/${BLFS_XML} ]] ; then
mkdir -p ${BUILDDIR}${BLFS_ROOT}/${BLFS_XML}
svn co $SVN_2/BLFS/$BLFS_TREE ${BUILDDIR}${BLFS_ROOT}/${BLFS_XML} >>$LOGDIR/$LOG 2>&1
else
pushd ${BUILDDIR}${BLFS_ROOT}/${BLFS_XML} 1> /dev/null
svn up >>$LOGDIR/$LOG 2>&1
popd 1> /dev/null
fi
echo -ne "done\n"
echo "${SD_BORDER}${nl_}"
fi
fi
# shellcheck disable=SC2034
# When regenerating the Makefile we need to know also the canonical book version
if [[ "$REBUILD_MAKEFILE" = "y" ]] ; then
# Sanity check: users tend to tick "rebuild Makefile"
# without generating one first. Check we have one:
if [ ! -f $MKFILE ]; then
set -e
error_message "You cannot \"rebuild Makefile\" without first building one"
fi
# When regenerating the Makefile, we need to know also the
# canonical book version
VERSION=$(grep 'echo.*lfs-release' "$JHALFSDIR/prbook.xml" | sed 's/.*echo[ ]*\([^ ]*\).*/\1/')
case $PROGNAME in
clfs | clfs2 | clfs3 )
VERSION=$(xmllint --noent $JHALFSDIR/$BOOK/prologue/$ARCH/bookinfo.xml 2>/dev/null | grep subtitle | sed -e 's/^.*ion //' -e 's/<\/.*//') ;;
*)
VERSION=$(xmllint --noent $JHALFSDIR/$BOOK/prologue/bookinfo.xml 2>/dev/null | grep subtitle | sed -e 's/^.*ion //' -e 's/<\/.*//') ;;
esac
fi
build_Makefile
echo "${SD_BORDER}${nl_}"
# Check for build prerequisites.
echo
cd "$CWD"
check_prerequisites
echo "${SD_BORDER}${nl_}"
# All is well, run the build (if requested)
run_make

Some files were not shown because too many files have changed in this diff Show more