Compare commits

..

54 commits

Author SHA1 Message Date
Pierre Labastie
e7f93a02ce typo 2017-04-03 12:36:01 +00:00
Pierre Labastie
95c46b9df5 Merge trunk "When asked its version, jhalfs should not return an error code"
r3953
2017-04-02 09:04:15 +00:00
Pierre Labastie
de10f6c5a5 Merge trunk r3949 "Fix issues in clfs" 2017-04-02 08:46:55 +00:00
Pierre Labastie
10bc5b9130 merge trunk r3950 "fix version wording" 2017-04-02 08:42:47 +00:00
Pierre Labastie
479cb9b70e Add a CHEATSHEET file 2017-03-28 20:13:06 +00:00
Pierre Labastie
654a56a4d9 Merge trunk r3945 (refactor two README files) 2017-03-27 19:51:06 +00:00
Pierre Labastie
b9cd0ee5f1 Merge trunk r3943 2017-03-27 19:12:06 +00:00
Pierre Labastie
580d773239 Merge trunk r3940,41 2017-03-27 16:26:14 +00:00
Pierre Labastie
90f822ab03 Merge trunk r3938:
Existence of package management files is tested even if PKGMNGT=n. Fix that.
Thanks to Michael D.L. for reporting
2017-03-25 21:02:19 +00:00
Pierre Labastie
3d48216613 typo 2017-03-20 15:37:16 +00:00
Pierre Labastie
085739c3eb Fix BLFS/TODO Id keyword and update it 2017-03-20 15:23:37 +00:00
Pierre Labastie
2706ad528f - Update README.PACKAGE_MANAGEMENT for porg
- Improve (?) README test
- Make VERSION lowercase in packInstall.sh.porg, since porg will do that
  anyway
2017-03-20 15:14:54 +00:00
Pierre Labastie
89b7cce9ca Merge trunk r3928, update README's 2017-03-20 14:15:28 +00:00
Pierre Labastie
14bcaee318 Merge trunk r3926-27 2017-03-20 14:12:25 +00:00
Pierre Labastie
76cf25fb34 Merge trunk r3924:
Make SBU and size computations incompatible with package management, since
the figures are wrong when package management is on (see #1694)
2017-03-18 18:25:21 +00:00
Pierre Labastie
fc0802bf5f Add instructions to copy to SRC_ARCHIVE in func_install_blfs, so that files
are kept in host repo, and not downloaded again, should a new build be
    started.
2017-03-16 13:36:47 +00:00
Pierre Labastie
54380e5020 Allows to retrieve package from SRC_ARCHIVE, in case it is not already there
and is in archive. This should not happen in normal operation, but may happen
    in func_install_blfs
2017-03-16 12:45:11 +00:00
Pierre Labastie
50618eeb88 Add the possibility to choose build and source dirs, and whether subdirs are
used in blfs tools, + various fixes
2017-03-15 21:00:31 +00:00
Pierre Labastie
8010030910 Merge trunk rev 3916:
Add the possibility to install BLFS tools to a running LFS from the jhalfs
menu:
- Add the possibility to choose BOOK_BLFS from menu. That hides all the
  irrelevant parameters
- Adapt install-blfs-tools.sh
- Change slightly mconf.c so that there is a better alignement in menus
2017-03-15 09:50:15 +00:00
Pierre Labastie
e43d0d0edb Test for FQDN in <replaceable> tags, instead of HOSTNAME, for the full
name of the host. Adapted only to LFS-20170310 and up.
2017-03-11 19:37:26 +00:00
Pierre Labastie
7e5ff87dd2 Merge trunk revs 3906-8 2017-03-11 16:53:29 +00:00
Pierre Labastie
e06a0d35bc Default to not stripping binaries 2017-03-05 18:28:03 +00:00
Pierre Labastie
d8ddcfb96a Fix the generation of scripts of
the networkd page (systemd book).
2017-03-05 08:49:45 +00:00
Pierre Labastie
deb6b6c8fd Fixes:
- when the user fstab and/or kernel config are the same as the ones in
$BUILDDIR/sources: avoid to cp on itself
- set SRC_ARCHIVE=/dev/null in BLFS tools download script if SRC_ARCHIVE is
empty
2017-03-05 08:35:09 +00:00
Pierre Labastie
5253014591 Add soundtouchs case to packInstall.sh.porg 2017-03-04 11:58:31 +00:00
Pierre Labastie
a9dadcf142 Output /etc/os-release when the init system is systemd 2017-03-03 21:13:38 +00:00
Pierre Labastie
796cd28b08 Merge trunk rev 3896:
Unless explicitely set on the command line, the REV parameter
in BLFS tools make is the same as the preceding used one. Formerly, it
was set to sysv unless defined on the command line
2017-03-02 16:40:34 +00:00
Pierre Labastie
eb8667a45d Install units rather than bootscripts when REV=systemd 2017-03-01 16:07:26 +00:00
Pierre Labastie
50a8ed0de7 Update and fix README files 2017-03-01 10:59:02 +00:00
Pierre Labastie
45f0437fcf Merge rev 3890 from trunk:
Fix Ed tarball download
2017-02-28 12:49:28 +00:00
Pierre Labastie
f769d1fca3 Fix installation of BLFS tools for recent book instructions 2017-02-27 17:32:14 +00:00
Pierre Labastie
6c9002b012 Fix the BLFS tools for the "Xorg Legacy" page 2017-02-27 14:02:16 +00:00
Pierre Labastie
ed4f11f2a7 Invert the logic for downloading tarballs:
- First upstream url
- Second upstrem ftp
- Last mirror server.
This allows to test whether upstream links are alive
2017-02-27 14:00:04 +00:00
Pierre Labastie
1cf1ad6fa6 Adapt BLFS/envars.conf to modern BLFS books 2017-02-27 13:57:52 +00:00
Pierre Labastie
0c5dfcc581 Add several cases to the special cases in packInstall.sh.porg:
- put the version extraction in a function
- use packages.xml if needed
2017-02-27 13:55:30 +00:00
Pierre Labastie
dc315ea7c8 Merge trunk r3881 into new_features branch 2016-12-03 18:31:32 +00:00
Pierre Labastie
e042e91776 Remove completely all references to tidy as a BLfs tool. 2016-11-24 16:45:41 +00:00
Pierre Labastie
c785566356 propagate trunk 3877 2016-10-16 14:16:26 +00:00
Pierre Labastie
c650f9bf2a When testing preceding/following-sibling for wrapping,
only use the first in the series
2016-08-26 14:42:07 +00:00
Pierre Labastie
24e2a6f2f8 Fixes for BLFS porg:
- add a special case for cacerts in packInstall.sh, so that a dummy version
  is generated, otherwise porgball does not work as intended
- do not quote out apostrophes in scripts, when generating configuration
  instructions
2016-08-26 07:13:09 +00:00
Pierre Labastie
7bbcce3ce7 Fix "blfs_root" location in envars.conf, to match initial location
when installing BLFS tools.
Convert package names to lowercase in wrap and pack functions for porg, since
porg does that anyway
2016-08-25 10:04:30 +00:00
Pierre Labastie
316db22956 Install the wrap and pack functions whan installing BLFS tools 2016-08-24 15:56:50 +00:00
Pierre Labastie
013a0bcac8 Merge trunk 3871 2016-08-24 15:25:33 +00:00
Pierre Labastie
e234d23768 BLFS porg style package management:
- update envarc.conf so that the system is made aware of the wrapInstall
and packInstall functions
- update scripts.xsl for wrapping install commands
- update gen_config.xsl to add the variable WRAP_INSTALL
- use the variable WRAP_INSTALL in gen_pkg_book
TODO: install the correct pack - wrap functions when installing BLFS tools
2016-08-24 15:15:14 +00:00
Pierre Labastie
df42c7cff7 Porg style package management:
- Add new variable WRAP_INSTALL in COnfig.in and jhalfs
- Generates the install commands inside a wrapper function
- Add files packInstall.sh.porg and packageManager.xml.porg
- TODO: update README.PACKAGE...
- TODO: make new templates in pkgmngt and document them
2016-07-21 16:43:35 +00:00
Pierre Labastie
33ff403b33 Adapt IP GATEWAY to book instructions 2016-06-25 14:39:47 +00:00
Pierre Labastie
04952c6322 Merge trunk up to revision 3866 2016-06-25 10:30:15 +00:00
Pierre Labastie
7bd0866514 Merge trunk up to revision 3864 2016-06-19 14:41:18 +00:00
Pierre Labastie
99ba6d8548 Merge trunk up to r3857 2016-03-08 20:29:02 +00:00
Pierre Labastie
af20a037df Merge trunk r3853 2016-01-30 08:36:23 +00:00
Pierre Labastie
bc5aee2c5f Merge trunk r3851 2016-01-01 18:24:07 +00:00
Pierre Labastie
6b6d54d952 Merge trunk r3849 2015-12-21 08:02:53 +00:00
Pierre Labastie
77fa8baa59 Add IP, hostname, domain, etc to the list of configuration parameters.
Font and encoding are in configuration too, but are not passed to the build
commands
Works only for LFS
2015-12-13 15:28:33 +00:00
Pierre Labastie
2453b766d0 Create a new branch for experimenting with new featutes described in
http://lists.linuxfromscratch.org/pipermail/alfs-discuss/2015-November/010357.html
+ long overdue: allowing to set hostname, address, etc, during the
configuration process.
2015-12-13 13:50:54 +00:00
139 changed files with 24706 additions and 29625 deletions

5
.gitignore vendored
View file

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

View file

@ -1,14 +1,20 @@
# 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>
# $Id$
ifdef V
Q =
else
Q = @
endif
# Known behavior
LANG=C
LC_ALL=C
# Makefile should reside in a directory where there are two subdirectories
# initially:
TOPDIR = $(shell pwd)
@ -19,7 +25,6 @@ MENU = $(TOPDIR)/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
@ -32,9 +37,7 @@ CONFIG_OUT = $(TOPDIR)/configuration
# the linear book:
BOOK_XML = $(TOPDIR)/book.xml
LFSTMP = $(LFS_XML)/tmp
RENDERTMP = $(BLFS_XML)/tmp
LFS_FULL = $(LFSTMP)/lfs-full.xml
BLFS_FULL = $(RENDERTMP)/blfs-full.xml
# The right-hand side is updated by jhalfs:
@ -54,28 +57,16 @@ define INITIAL_TRACK
</sublist>
endef
# 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
SVN = svn://svn.linuxfromscratch.org/BLFS/trunk/BOOK
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:
@ -95,18 +86,19 @@ ifneq ($(REV),sysv)
endif
$(BOOK_XML): $(CONFIG_OUT)
$(Q)$(TOPDIR)/gen_pkg_book.sh $(TRACKFILE) $(TOPDIR) $(BLFS_FULL) $(LFS_FULL)
$(Q)$(TOPDIR)/gen_pkg_book.sh $(TOPDIR) $(BLFS_FULL)
$(CONFIG_OUT): $(CONFIG_CONFIG_IN)
$(Q)CONFIG_="" KCONFIG_CONFIG=configuration \
python3 $(MENU)/menuconfig.py $(CONFIG_CONFIG_IN)
$(CONFIG_OUT): $(CONFIG_CONFIG_IN) $(MENU)/mconf
$(Q)$(MENU)/mconf $(CONFIG_CONFIG_IN)
$(MENU)/mconf:
$(Q)$(MAKE) -C $(MENU) ncurses conf mconf
$(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)
$(PACK_LIST): $(XSLDIR)/gen_pkg_list.xsl $(XSLDIR)/specialCases.xsl $(TRACKFILE)
$(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
@ -119,10 +111,11 @@ $(PACK_LIST): $(XSLDIR)/gen_pkg_list.xsl $(XSLDIR)/specialCases.xsl $(TRACKFILE)
$(TRACKFILE): $(TRACKING_DIR)
$(Q)if ! [ -f $@ ]; then \
echo Initializing $(TRACKFILE) && \
/bin/echo -e '$(INITIAL_TRACK)' > $@; \
/bin/echo -e '$(INITIAL_TRACK)' > $@ && \
$(MAKE) $(PACK_LIST); \
fi
$(Q)for track in $(TRACKING_DIR)/*-*; do \
if [ -f $$track ]; then \
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) \
@ -131,8 +124,7 @@ $(TRACKFILE): $(TRACKING_DIR)
-o track.tmp $(XSLDIR)/bump.xsl $@ && \
sed -i 's@PACKDESC@$(TOPDIR)/packdesc.dtd@' track.tmp && \
xmllint --format --postvalid track.tmp > $@; \
fi; \
rm -f $$track; \
fi; \
done; \
rm -f track.tmp
@ -145,89 +137,36 @@ $(XSLDIR)/specialCases.xsl: $(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)..."
@echo "Adjusting 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..."
@echo "Validating the 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)
update: $(BLFS_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
$(Q)cd $(BLFS_XML) && svn up
$(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
@echo Getting the book sources...
$(Q)svn co $(SVN) $@
# 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
- $(MAKE) -C $(MENU) clean
FORCE:
.PHONY: clean all update $(CONFIG_OUT) version FORCE
.PHONY: clean all update $(CONFIG_OUT) FORCE

View file

@ -2,6 +2,7 @@
#
# Project TODO list
#
# $Id$
#####
@ -15,26 +16,3 @@
the BLFS book should be revised and validated, but our time is limited.
-- 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)

99
BLFS/envars.conf Normal file
View file

@ -0,0 +1,99 @@
#####
#
# Configuration file for the BLFS module
#
# $Id$
#
# Set default envars used in the build scripts
#
#####
#======== Common envars ==========
#--- The build directory:
# - If BUILD_SUBDIRS is set, this directory contains sub directories
# (one for each package), where packages are unpacked, and compiled.
# - If BUILD_SUBDIRS is unset, packages are unpacked, and compiled directly
# in $BUILD_ROOT.
export BUILD_ROOT=/sources
export BUILD_SUBDIRS=1
#--- The local repository for packages/file:
# Any missing file will be downloaded and archived either:
# - into a subdirectory (one for each page of the book) fo this directory,
# if SRC_SUBDIRS is set.
# - directly into this directory if SRC_SUBDIRS is unset.
# This directory can be the same as $BUILD_ROOT, provided BUILD_SUBDIRS
# and SRC_SUBDIRS are different.
export SRC_ARCHIVE=/sources
unset SRC_SUBDIRS
#--- Set a well-known working locale when building software
# Note that an UTF-8 locale may be needed for some packages,
# but normally it is set in the package instructions.
# Furthermore, LANG may be set in /etc/profile, which is
# sourced at the end of this file.
export LC_ALL=C
#--- Server used if the file isn't found in SRC_DIR,
# and cannot be downloaded from upstream.
#
# The server path MUST be set as listed in
# http://www.linuxfromscratch.org/blfs/download.html.
# Note that despite the name of the variable, it can be an http url.
export FTP_SERVER=http://ftp.osuosl.org/pub/blfs/
#--- Keep the buid directory to examine it:
# If KEEP_FILES is unset, the extracted tarball is removed after build.
# Otherwise, the build tree is kept for later study.
#export KEEP_FILES=1
unset KEEP_FILES
### Currently not used in scripts ###
# Use a server close to you for Xorg (see http://wiki.x.org/wiki/Mirrors)
# export FTP_X_SERVER=ftp://mirror.cict.fr/x.org/
#======== Optimizations =============
# Global optimization settings can be placed here. This settings can be
# overriden 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="-j5"
#export CFLAGS="-O3 -pipe"
#export CXXFLAGS=$CFLAGS
#export LDFLAGS="-s"
#export OTHER_CFLAGS=$CFLAGS
#export OTHER_CXXFLAGS=$CXXFLAGS
#export OTHER_LDFLAGS=$LDFLAGS
#======== Environment settings ========
# The prefered way to setup environment variables nowadays
# is to set them in /etc/profile{,.d/*.sh}.
# It is recommended to source /etc/profile in this file
# since a package may add some new variables in there,
# which may be needed later in dependant packages.
if [ -r /etc/profile ]; then source /etc/profile; fi
#======== Package management ========
# We need the functions in "packInstall.sh" when installing a package,
# if package management is requested. Note that we have no way to know
# whether package management is requested for a given build.
# Furthermore, "sudo -E" exports variables, but not functions from
# the environment, and sudo needs to be called before porg, due
# to porg limitations. So we just export the location of the file
# where the functions are defined, and we'll source it just before
# installing.
export PACK_INSTALL=/blfs_root/packInstall.sh # change as needed

View file

@ -1,5 +1,7 @@
#!/bin/bash
#
# $Id$
#
set -e
declare TOPDIR='..'
@ -40,7 +42,7 @@ __write_build_cmd() { #
#----------------------------------#
(
cat << EOF
@${BUILD_SCRIPTS}/\$@ >logs/\$@ 2>&1
@source ${TOPDIR}/envars.conf && ${BUILD_SCRIPTS}/\$@ >logs/\$@ 2>&1
EOF
) >> $MKFILE.tmp
}
@ -48,15 +50,12 @@ 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
(
cat << EOF
@xsltproc --stringparam packages ${PACK_FILE} \\
--stringparam package "${pkg_name}" \\
--stringparam package ${pkg_name#*-?-} \\
-o track.tmp \\
${BUMP} \$(TRACKING_FILE) && \\
sed -i 's@PACKDESC@${ATOPDIR}/packdesc.dtd@' track.tmp && \\

View file

@ -1,5 +1,7 @@
#!/bin/bash
# $Id: gen-special.sh 21 2012-02-16 15:06:19Z labastie $
#-------------------------------------------------------------------------
# generates an xsl stylesheet containing a template for special
# cases in the book:
@ -36,9 +38,13 @@ EXCEPTIONS=$(grep 'ENTITY.*version[ ]*"[^0-9"&.].*[0-9]' ${BLFS_DIR}/packages.en
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"
NV_LIST="cacerts xorg-env kde-pre-install-config kf5-intro lxqt-pre-install \
lxqt-post-install ojdk-conf tex-path"
# Set PATH to be sure to find udevadm
SAVPATH=$PATH
PATH=/bin:/sbin:/usr/bin:/usr/sbin
UDEVVERSION=$(udevadm --version)
cat >$SPECIAL_FILE << EOF
<?xml version="1.0" encoding="ISO-8859-1"?>
@ -48,6 +54,30 @@ cat >$SPECIAL_FILE << EOF
<xsl:template match='*' mode="special">
<xsl:choose>
<xsl:when test="contains(@id,'udev')">
<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">$UDEVVERSION</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>
<!-- 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
@ -95,7 +125,6 @@ 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
@ -116,7 +145,7 @@ EOF
# 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\|#' |
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
@ -131,11 +160,7 @@ EOF
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>
@ -153,7 +178,6 @@ EOF
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>
@ -170,35 +194,21 @@ 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
cat >> tmpfile << EOF
<xsl:element name="dependency">
<xsl:attribute name="status">
<xsl:value-of select="\$status"/>
</xsl:attribute>
<xsl:attribute name="name">$packname</xsl:attribute>
<xsl:attribute name="type">ref</xsl:attribute>
</xsl:element>
EOF
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
@ -208,57 +218,28 @@ for ver_ent in $EXCEPTIONS; do
[[ -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>
<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"/>
<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:text>&#xA; </xsl:text>
</package><xsl:text>&#xA;</xsl:text>
</xsl:when>
EOF
done

View file

@ -1,54 +1,32 @@
#!/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
TOPDIR=$1
if test -z "$TOPDIR"; then
TOPDIR=$(pwd)
fi
BLFS_FULL=$3
BLFS_FULL=$2
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 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
#--------------------------#
parse_configuration() { #
@ -68,21 +46,7 @@ parse_configuration() { #
optDependency=* | \
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..
SUDO=* ) eval ${REPLY} # Define/set a global variable..
continue ;;
esac
@ -101,17 +65,13 @@ parse_configuration() { #
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="DEP_LEVEL SUDO MAIL_SERVER WRAP_INSTALL"
local -r PARAM_VALS='${config_param}${dotSTR:${#config_param}} ${L_arrow}${BOLD}${!config_param}${OFF}${R_arrow}'
local config_param
local -i index
@ -128,15 +88,18 @@ validate_configuration() { #
# Generates the root of the dependency tree
#
#--------------------------#
generate_deps() { #
generate_deps() { #
#--------------------------#
local -i index
local DepDir=$1
rm -f $DepDir/*.{tree,dep}
rm -f $DepDir/*.{o,}dep
for (( index=0 ; index < ${#TARGET[*]} ; index ++ )); do
echo 1 b ${TARGET[${index}]} >> $DepDir/root.dep
echo 1 ${TARGET[${index}]} >> $DepDir/root.odep
done
echo 1 > $DepDir/root.dep
echo 1 >> $DepDir/root.dep
cat $DepDir/root.odep >> $DepDir/root.dep
}
#
@ -187,65 +150,14 @@ 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)"
generate_dependency_tree root.dep 1
echo
LIST="$(tree_browse root.dep)"
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" \
xsltproc --stringparam list "$LIST" \
-o ${BookXml} \
${MakeBook} \
$BLFS_FULL
@ -268,79 +180,13 @@ for ht in ${BookHtml}/*.html
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} \
xsltproc --xinclude --nonet \
--stringparam sudo $SUDO \
--stringparam wrap-install $WRAP_INSTALL \
-o ./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

View file

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

View file

@ -1,145 +1,38 @@
#!/bin/bash
#
# $Id$
#
#-----------------------------------------------------------------------------#
# This is a set of (recursive) functions for manipulating a dependency graph. #
# We use algorithms and definitions from chapter 4 (mainly section 4.2) of #
# https://algs4.cs.princeton.edu/. The graph we manipulate is the directed #
# graph of the dependencies: nodes are packages in the BLFS book. A node A is #
# connected to a node B if package A depends on B. A topological order (rev- #
# erted) is exactly what we want for a build order. But a topological order #
# only exists if the graph is acyclic. We'll therefore have to remove cycles. #
# There are a number of other features we want to consider: #
# - edges are weighted according to the dependency requirement: #
# 1 for required #
# 2 for recommended #
# 3 for optional #
# 4 for external #
# We should consider only edges with weight lower or equal to that #
# specified by the user, but see below. #
# - we do not want to build the whole book. The user requests a set of #
# packages, and we'd like to consider only nodes reachable from this set #
# using edges of weight not exceeding the specified weight. #
# - we do not want to rebuild packages already built. But we still have to #
# generate the full dependency graph, because if A depends on B, which is #
# already built, and B depends on C, which is not built, or needs to be #
# updated, then A may depends on C. We therefore have to remove already #
# built (and up to date) packages from the graph, but need to keep the #
# dependency chain. #
# - when doing the topological sort, we want to consider all the edges and #
# not only those not exceeding the specified weight: If a package A in the #
# reachable subgraph depends optionally on another package B in the same #
# subgraph, we want to build B before A if possible. But this means we'll #
# have to remove cycles for all weights. #
# - dependencies have another qualifier: before, after, or first. We use #
# it as follows: for "after", we can build the dependency after the #
# package, but if a package A depends on B with an "after" qualifier, and #
# a package C depends on A with a "before" qualifier, C may need B to be #
# able to use A. So the only safe way to consider "after" qualifiers is to #
# consider that they are "before" deps for any parent of the packages #
# considered. There is an exception to that rule: if B depends on C #
# (possibly through a chain of several dependencies), then C should still #
# be built before B. For "after", the dependency has to be built both #
# before and after the package. So we duplicate the dependency as a #
# "-pass1" package, and change the graph accordingly. #
# We'll therefore have a 3 pass procedure. First build the set of nodes #
# reachable from the root set. Second, remove dangling edges (those pointing #
# to packages outside the node set), and move "after" edges to "before" edges #
# originating from the parents as well as creating the "-pass1" nodes. Third #
# remove cycles and generate a topological sort. #
# #
# Pass 1: graph generation #
# ======================== #
# Data layout for pass 1 #
# ---------------------- #
# A node of the graph is represented by a text file <nodeName>.dep. Each edge #
# starting from this node is represented by a line in this file. We keep #
# those files in the same directory. We introduce a special node named root, #
# whose edges point to the list of nodes requested by the user. Each line #
# contains three fields: #
# - the weight of the edge #
# - the qualifier: "before" (b), "after" (a), or "first" (f) #
# - the name of the destination of the edge (without the ".dep" extension) #
# #
# Recursive function "generate_subgraph" #
# -------------------------------------- #
# This function treats a node of the graph that is not a leaf and that is #
# seen for the first time in the DFS. The dependencies of this node are #
# known, and stored in a .dep file. For each dependency in that file, there #
# are three cases: #
# - the weight of the edge leading to that dependency is higher than #
# requested. This dependency is discarded (some information printed) #
# - the weight of the edge is lower or equal to requested, but the node #
# has already been visited (the .dep file exists). Discard too (some #
# information printed) #
# - the weight of the edge is lower or equal to requested, and the node #
# has not been seen: then the dependencies of that node are generated, #
# and there are two cases: #
# - the node has no dependencies: just create an empty .dep file, so #
# that we know the node has been visited #
# - the node has dependencies: call generate_subgraph for that node #
# #
# This function takes four parameters: #
# - The node filename: this is the only one useful for the algorithm #
# - The depth: number of steps starting from root (for pretty print only) #
# - The weight of the edge leading to that node (for printing) #
# - The qualifier (for printing) #
# #
# Pass 2: graph transformation #
# ============================ #
# We now have three loops over nodes of the graph #
# Loop 1: Remove dead edges #
# ------------------------- #
# Since some nodes have not been created because the edges leading to them #
# had too high a weight, those edges have to be suppressed. #
# For each existing node file, we make a list of lines to remove by #
# testing whether the destination exists. We then remove the lines. #
# Another approach would be to make a temporary file and output only #
# lines that should stay, then rename the file. This would save a loop. #
# All in all it is an N*e process, where N is the number of nodes and e #
# the average number of edges originating from a node. #
# Loop 2: Treat "after" edges #
# --------------------------- #
# If a node is the origin of edges qualified as "after", we want the #
# nodes which are the destination of those edges to be built after #
# the origin node, but before any node that depend on the origin #
# node. For that, the general rule is to change: #
# P---b--->A---a--->D #
# to: #
# P---b--->Agroupxx---b--->A #
# | #
# ---b--->D #
# But there is a problem if D depends on P, possibly through a chain, #
# because we create a cycle which shouldn't exist. If this is the case, #
# we leave A as a dependency of P: #
# P---b--->A #
# #
# Agroupxx---b--->A #
# | #
# ---b--->D #
# Doing so, it may happen that Agroupxx has no parent. We then add #
# Agroupxx as a dependency of root. The problem with this algorithm is #
# the search for paths from D to A, which may be exponential in the #
# number of nodes in the graph. #
# #
# Loop 3: Add -pass1 nodes #
# ------------------------ #
# Sometimes there is no way to escape a cycle. A package A needs B, and B #
# needs A. In that case, it is often possible to build a degraded version #
# of package A, then B, then rebuild A. The book indicates this with the #
# following dependency chain, using a qualifier of "first": #
# B---f--->A---b--->X...Y---b--->B #
# where the X...Y notation represents a chain of dependencies from A to B. #
# So the third loop is over nodes containing "f" qualifiers, and does the #
# following: it creates a new node A-pass1, which is a copy of A, and #
# remove from A-pass1 all the dependencies leading to B through a chain, #
# to obtain: #
# A---b--->X...Y---b--->B---b--->A-pass1 #
# It may then happen that nothing depends on A. So this is tested, and A #
# is added to the root node if it is orphaned. #
# TODO: document the third pass #
# TODO: needs also to document the .tree files #
# TODO: The following is obsolete #
#---------------------------------------------------------------------------#
# This is a set of (recursive) functions for manipulating a dependency #
# tree. Everything would be "simple" without circular dependencies. We #
# would just have to build the tree using the packages.xml file, and to #
# provide a function for browsing it. But we need to be able to detect #
# circular dependencies and to possibly change the tree depending on #
# priorities. This is why we keep with each node a record of the path #
# from the root to the node, which we call *link* and a record of the #
# successive priorities which we call *priolink*. #
# #
# Layout of the tree: #
# #
# A node of the tree is represented by a file <nodeName>.dep. We keep all #
# those files in the same directory. The root node file is "root.dep". #
# Files <nodeName>.dep have the following layout: #
# - the first line is the link: the link is an array of numbers #
# (n1 n2 ... nN), describing the path from the root to <nodeName>: n1 #
# is the position of the first node of the path in root.dep, n2 is the #
# position of the second node of the path in <node1>.dep and so on. The #
# link is not needed for normal tree operations (building a subtree or #
# browsing the tree), but it allows to check whether a dependency is #
# circular, and to find its parent. #
# - the second line is an array of priorities (p1 p2 ... pN), giving the #
# priority (1=required, 2=recommended, 3=optional) of each dependency #
# in the link. #
# - each subsequent line is of the form "p <depname>", where p is the #
# priority as above, and <depname> is the name of the dependency. The #
# position which is recorded in the link is the number of the line #
# minus 2. #
# #
# Circular dependencies: #
# #
# In case we find a cirdular dependency, it has the form : #
@ -158,283 +51,9 @@
# Global variables:
# A string of spaces for indenting:
declare -a spaceSTR=" "
# When we are backing up from a circular dependency, `parentNode'
# contains the node which has an edge entering the cycle
declare parentNode
#---------------------#
generate_subgraph() { #
#---------------------#
: <<inline_doc
function: Create a subgraph of all the nodes reachable from the node
represented by the file whose name is $1. The edges considered
are those with maximal weight DEP_LEVEL (recursive function).
input vars: $1 : file name corresponding to the node whose edges will be
followed for the DFS
$2 : weight of the edge leading to this node
$3 : depth (root is 1)
$4 : qualifier (a for after, b for before, f for first)
externals: vars: DEP_LEVEL contains 1 if we want to build the
tree only for required dependencies,
2 if we want also recommended ones,
3 if we want also optional ones, but only
for the requested packages,
4 if we want all the dependencies
(excluding external of course)
MAIL_SERVER contains the name of the MTA we want to use.
files: ../xsl/dependencies.xsl: stylesheet for creating the
.dep files
../packages.xml: File containing packages id
and dependencies
returns: 0 if the tree has been successfully created
output: files: for each node reachable from $1, a file <node>.dep.
on error: nothing
on success: nothing
inline_doc
local depFile=$1
local -i weight=$2
local -i depth=$3
local qualifier=$4
local -i spacing=0
local priostring
local buildstring
local id_of_dep
local prio_of_dep
local build_of_dep
local dep_level
if (( depth < 10 )); then spacing=1; fi
case $weight in
1) priostring=required ;;
2) priostring=recommended ;;
3) priostring=optional ;;
esac
case $qualifier in
a) buildstring=runtime ;;
b|f) buildstring= ;;
esac
dep_level=$DEP_LEVEL
if [ "$dep_level" = 3 ] && [ "$depth" -gt 2 ]; then dep_level=2; fi
if [ "$dep_level" -gt 3 ]; then dep_level=3; fi
echo -en "\nNode: $depth${spaceSTR:0:$(( depth + spacing ))}${RED}${depFile%.dep}${OFF} $priostring $buildstring"
depth=$(( depth + 1 ))
if (( depth < 10 )); then spacing=1; else spacing=0; fi
# Start of loop
{
while read prio_of_dep build_of_dep id_of_dep; do
case $prio_of_dep in
1) priostring=required ;;
2) priostring=recommended ;;
3) priostring=optional ;;
4) priostring=external ;;
esac
case $build_of_dep in
a ) buildstring=runtime ;;
b|f) buildstring= ;;
esac
# Has this entry already been seen?
# TODO: no there is no special case!
# We have a special case here: if the entry has been seen at depth > 2
# and now depth=2 and DEP_LEVEL=3, optional deps have not been processed.
# If this is the case, just consider it has not been seen.
if [ -f ${id_of_dep}.dep ] ; then
case $depth$DEP_LEVEL in
23) ;;
*)
# Just display it and proceed.
echo -en "\nEdge: $depth${spaceSTR:0:$((depth + spacing))}${MAGENTA}${id_of_dep}${OFF} $priostring $buildstring"
continue
;;
esac
fi
# Is the weight higher than requested?
if [ "$prio_of_dep" -gt $dep_level ]; then
# Just display it and proceed.
echo -en "\n Out: $depth${spaceSTR:0:$((depth + spacing))}${YELLOW}${id_of_dep}${OFF} $priostring $buildstring"
continue
fi
# Otherwise, let's build the corresponding subgraph.
xsltproc --stringparam idofdep "$id_of_dep" \
--stringparam MTA "$MAIL_SERVER" \
-o ${id_of_dep}.dep \
../xsl/dependencies.xsl ../packages.xml
if [[ -s ${id_of_dep}.dep ]]; then # this dependency has dependencies
generate_subgraph ${id_of_dep}.dep $prio_of_dep $depth $build_of_dep
else # id_of_dep has no dependencies, just touch the file and display
touch ${id_of_dep}.dep
echo -en "\nLeaf: $depth${spaceSTR:0:$((depth + spacing))}${CYAN}${id_of_dep}${OFF} $priostring $buildstring"
fi
done
} <$depFile
depth=$(( depth - 1 ))
if (( depth < 10 )); then spacing=1; else spacing=0; fi
echo -en "\n End: $depth${spaceSTR:0:$((depth + spacing))}${GREEN}${depFile%.dep}${OFF}"
return 0
}
#-----------#
path_to() { #
#-----------#
: <<inline_doc
function: check whether there is a path from $1 to $2 on the graph
input vars: $1 contains the filename of the starting node.
$2 contains the name of the node to reach
$3 contains the weight above which we do not want to
follow an edge
$seen (global) contains the list of already seen nodes.
It must ve set to " " prior to calling the function
returns: 0 if the node has been found
1 if not
on error: nothing
on success: nothing
inline_doc
local start=$1
local seek=$2
local prio=$3
local prio_of_dep
local build_of_dep
local id_of_dep
local r
if test "${start%.dep}" = "$seek"; then return 0; fi
seen="$seen${start%.dep} "
if test -s $start; then
{
while read prio_of_dep build_of_dep id_of_dep; do
if test "$prio" -lt "$prio_of_dep"; then continue; fi
if ! test "${seen% $id_of_dep *}" = "$seen"; then continue; fi
if path_to ${id_of_dep}.dep $seek $prio; then return 0; fi
done
} < $start
fi
return 1
}
#------------------#
clean_subgraph() { #
#------------------#
: <<inline_doc
function: Remove dangling edges and create groups of deps for "after"
deps: A-before->B-after->C becomes:
A -before-> Bgroupxx -before-> B
\
-before-> C
the name of the group is chosen so that it is unlikely as
a package name (so that it is removed when building the
xml book).
Also change the "first" qualifier so that a cycle:
A -first-> B ---chain---> A becomes:
B ---chain---> A -before-> B-pass1
and we remove all the dependencies which have a chain to
A in B-pass1.
Since we do not change anything else, it may happen that
nothing depends on B. In that case, B is appended to root.
input vars: None
files: <node>.dep files containing dangling edges and
"after" qualifiers
returns: 0
output: files: <node>.dep files containing no dangling edges and
no "after" qualifiers
on error: nothing
on success: nothing
inline_doc
local node
local id_of_dep
local prio_of_dep
local build_of_dep
local lines_to_remove
local lines_to_change
local parent
local p
local b
local start
local seen
for node in $(ls *.dep); do
if test $node = root.dep; then continue; fi
echo Cleaning $node
lines_to_remove=
{
while read prio_of_dep build_of_dep id_of_dep; do
if ! test -f ${id_of_dep}.dep; then
lines_to_remove="$lines_to_remove $id_of_dep"
continue
fi
done
} <$node
for id_of_dep in $lines_to_remove; do
sed "/\ $id_of_dep\$/d" -i $node
done
done
for node in $(grep -l ' a ' *.dep); do
lines_to_remove=
echo Process "runtime" deps in $node
if ! [ -e ${node%.dep}groupxx.dep ]; then
b=0 # Nothing depends on <node>groupxx
for parent in $(grep -l ${node%.dep}\$ *); do
p=0 # No "after" dependency depends on this parent
for start in $(grep ' a ' $node | cut -d' ' -f3); do
seen=" " # global variable used in "path_to"
if path_to ${start}.dep ${parent%.dep} 3; then p=1; break; fi
done
if test $p = 0; then
b=1
sed -i "s/\ ${node%.dep}\$/&groupxx/" $parent
fi
done
echo "1 b ${node%.dep}" > ${node%.dep}groupxx.dep
if test $b = 0; then echo "1 b ${node%.dep}groupxx" >> root.dep; fi
fi
{
while read prio_of_dep build_of_dep id_of_dep; do
if test $build_of_dep = a; then
if ! grep -q ${id_of_dep} ${node%.dep}groupxx.dep; then
echo "$prio_of_dep b ${id_of_dep}" >> ${node%.dep}groupxx.dep
fi
lines_to_remove="$lines_to_remove $id_of_dep"
fi
done
} <$node
for id_of_dep in $lines_to_remove; do
sed "/a\ $id_of_dep\$/d" -i $node
done
done
for node in $(grep -l ' f ' *); do
echo Process "first" deps in $node
lines_to_change=
{
while read prio_of_dep build_of_dep id_of_dep; do
if test $build_of_dep = f; then
if ! test -f ${id_of_dep}-pass1.dep; then
cp ${id_of_dep}{,-pass1}.dep;
fi
lines_to_change="$lines_to_change $id_of_dep"
unset lr # lines to remove in -pass1
{
while read p b start; do
seen=" " # global variable used in "path_to"
if path_to ${start}.dep ${node%.dep} $p; then
lr="$lr $start"
fi
done
} < ${id_of_dep}-pass1.dep
for p in $lr; do
sed "/\ $p\$/d" -i ${id_of_dep}-pass1.dep
done
fi
done
} <$node
for id_of_dep in $lines_to_change; do
sed "/\ $id_of_dep\$/"'{s/[[:digit:]] f /1 b /;s/$/-pass1/}' -i $node
if ! grep -q " $id_of_dep\$" *.dep; then
echo 1 b $id_of_dep >>root.dep
fi
done
done
} # End clean_subgraph
# When we are backing up from a circular dependency, `exchange_triplet'
# shall contain (parent dependency_0 dependency_n):
declare -a exchange_triplet
#----------------------------#
generate_dependency_tree() { #
@ -443,24 +62,27 @@ generate_dependency_tree() { #
function: Create a subtree of the dependency tree
(recursive function)
input vars: $1 : file with a list of targets (child nodes)
the first line of the file is the link
the first line of the file is the link
$2 : priority (1=req, 2=rec, 3=opt)
externals: vars: DEP_LEVEL contains 1 if we want to build the
tree only for required dependencies,
2 if we want also recommended ones,
and 3 if we want optional ones too.
MAIL_SERVER contains the name of the MTA we want to use.
files: ../xsl/dependencies.xsl: stylesheet for creating the
.dep files
../packages.xml: File containing packages id
and dependencies
returns: 0 if the tree has been successfully created
1 if we are backing up to the parent of a circular dep
and there are only required deps in the cycle
2 if we are backing up to the parent of a circular dep
and there are recommended deps and no optional deps in the
cycle
3 if we are backing up to the parent of a circular dep
and there are optiional deps in the cycle
modifies: vars: parentNode is set when return is not 0
modifies: vars: exchange_triplet contains the triplet when return is 1
output: files: for each <pkg> with dependencies in $1,
a file <pkg>.tree and its dependencies
a file <pkg>.dep and its dependencies
on error: nothing
on success: nothing
inline_doc
local depFile=$1
local DepFile=$1
local priority=$2
local -a rootlink
local -a priolink
@ -468,113 +90,156 @@ local -a otherlink
local -i depth
local -i count=0
local id_of_dep
local build_of_dep
local prio_of_dep
local parent
local lines_to_remove=
local srootlink
local dep_level
local priostring
local dpriostring
local i
{
read -a rootlink
# We use fd number 6 for input from DepFile, because we need 0 for user input
read -u6 -a rootlink
depth=${#rootlink[*]}
read -a priolink
read -u6 -a priolink
dep_level=$DEP_LEVEL
# For now, process optional deps only for the root packages.
if (( $DEP_LEVEL > 2 )) && (( $depth > 1 )); then dep_level=2; fi
srootlink="${rootlink[*]} "
case $priority in
1) priostring=required ;;
2) priostring=recommended ;;
3) priostring=optional ;;
4) priostring=external ;;
esac
# start of depFile
echo -en "\nNode: $depth${spaceSTR:0:$depth}${RED}${depFile%.tree}${OFF} $priostring"
# start of DepFile
echo -en "\nNode: $depth${spaceSTR:0:$depth}${RED}$DepFile${OFF} $priostring"
while read prio_of_dep build_of_dep id_of_dep; do
case $prio_of_dep in
while read -u6 prio_of_dep id_of_dep; do
case $prio_of_dep in
1) dpriostring=required ;;
2) dpriostring=recommended ;;
3) dpriostring=optional ;;
esac
4) dpriostring=external ;;
esac
# count entries in file
(( count++ ))
# Has this entry already been seen?
if [ -f ${id_of_dep}.tree ]; then # found ${id_of_dep}.tree already in tree
otherlink=($(head -n 1 ${id_of_dep}.tree))
if [ -f ${id_of_dep}.dep ]; then # found ${id_of_dep}.dep already in tree
otherlink=($(head -n 1 ${id_of_dep}.dep))
if [ -z "${otherlink[*]}" ]
then echo otherlink empty for $id_of_dep.tree
then echo otherlink empty for $id_of_dep.dep
echo This should not happen, but happens to happen...
exit 1
fi
#Do not use "${rootlink[*]}" =~ "${otherlink[*]}": case rootlink=(1 11)
# Do not use "${rootlink[*]}" =~ "${otherlink[*]}": case rootlink=(1 11)
# and otherlink=(1 1)
if [[ ${srootlink#"${otherlink[*]} "} != ${srootlink} ]]; then # cir. dep
echo -en "\nCirc: $((depth+1))${spaceSTR:0:$((depth+1))}${YELLOW}${id_of_dep}${OFF} $dpriostring"
# Find lowest priority in branch from parent to depFile:
# First look for the other parent of this dependency.
# The parent has the same link without the last entry.
# We do not need otherlink anymore so just destroy the last element
unset otherlink[-1]
parent=$(grep ^"${otherlink[*]}"\$ -l *)
parent=${parent%.dep}
# Find lowest priority in branch from parent to DepFile:
p2=0
for (( i=${#otherlink[*]}; i < $depth ; i++ )) ; do
if (( ${priolink[i]} > $p2 )); then p2=${priolink[i]}; fi
done
if (( $prio_of_dep >= $p2 )); then # prune
lines_to_remove="$lines_to_remove $id_of_dep"
sed -i "/$id_of_dep/d" ${depFile/.tree/.dep}
else # find and set parent, then return lowest priority
# The parent has the same link without the last entry.
# We do not need otherlink anymore so just destroy the last element
unset otherlink[-1]
# We cannot use grep -l, because we need to restrict to the first line,
# since the prio line may match
for f in *.tree; do
if head -n1 $f | grep -q ^"${otherlink[*]}"\$; then
parentNode=$f; break
fi
done
return $p2
sed -i "/$id_of_dep/d" ${DepFile/.dep/.odep}
else #backup with prio priority
exchange_triplet=($parent $id_of_dep ${DepFile%.dep})
return $priority
fi
else # not circular: prune tree (but not .dep, since it may happen that
else # not circular: prune tree (but not .odep, since it may happen that
# the tree is destroyed and rebuilt in another order)
lines_to_remove="$lines_to_remove $id_of_dep"
fi # circular or not
continue # this dependency has already been seen, and the associated
# subtree computed. We are done
fi # Has this entry already been seen?
# So, this entry has not already been seen. Let's build the corresponding
# subtree. First check there is a subtree...
# Use -s, because it may happen that after removing lines, .dep exists
# but is empty.
if [[ -s ${id_of_dep}.dep ]]; then # this dependency has dependencies
sed "1i${rootlink[*]} $count\\
${priolink[*]} $prio_of_dep" < ${id_of_dep}.dep \
> ${id_of_dep}.tree # add link and priolink
generate_dependency_tree ${id_of_dep}.tree $prio_of_dep
# Test return value, in case we exchange dependencies
p2=$?
case $p2 in
0) # Normal return
;;
$prio_of_dep) # we remove this dep, but since it may become unreachable,
# move it to be built later (as a dep of parent).
tree_erase ${id_of_dep}.tree
lines_to_remove="$lines_to_remove $id_of_dep"
sed -i "/${id_of_dep}/d" ${depFile/.tree/.dep}
echo "$prio_of_dep b $id_of_dep" >> $parentNode
# must be added to .dep in case parentNode is destroyed when erasing
# the tree
echo "$prio_of_dep b $id_of_dep" >> ${parentNode/.tree/.dep}
continue
;;
*) # We are backing up
return $p2
;;
esac
else # id_of_dep has no dependencies, just record the link in a file
# and print
echo "${rootlink[*]} $count" > ${id_of_dep}.tree
# So, this entry has not already been seen.
# If this is an external dep, just display it and go to next dep:
if [ "$prio_of_dep" -eq 4 ]; then
echo "${rootlink[*]} $count" > ${id_of_dep}.dep
echo -en "\nLeaf: $(($depth+1))${spaceSTR:0:$(($depth+1))}${CYAN}${id_of_dep}${OFF} $dpriostring"
continue
fi
# Otherwise, let's build the corresponding
# subtree. Since decisions about circular deps can lead us to start again
# dependencies, we restart until the flag is false.
flag=true
while [ $flag = true ]; do
flag=false
if [ ! -f "${id_of_dep}.odep" ]; then
xsltproc --stringparam dependencies ${dep_level} \
--stringparam idofdep $id_of_dep \
--stringparam MTA $MAIL_SERVER \
-o ${id_of_dep}.odep \
../xsl/dependencies.xsl ../packages.xml
fi
# Use -s, because it may happen that after removing lines, .odep exists
# but is empty.
if [[ -s ${id_of_dep}.odep ]]; then # this dependency has dependencies
sed "1i${rootlink[*]} $count\\
${priolink[*]} $prio_of_dep" < ${id_of_dep}.odep \
> ${id_of_dep}.dep # add link and priolink
generate_dependency_tree ${id_of_dep}.dep $prio_of_dep
# Test return value, in case we exchange dependencies
p2=$?
case $p2 in
0) # Normal return
;;
[123]) # We are backing up to parent
if [[ ${exchange_triplet} == ${DepFile%.dep} ]] ; then
# We are the parent!
# First, we have to find the parent of our new direct dep, and remove
# the new direct dep from the parent.odep:
otherlink=($(head -n1 ${exchange_triplet[2]}.dep))
unset otherlink[-1]
parent=$(grep -l ^"${otherlink[*]}"\$ *.dep)
sed -i /[[:digit:]]\ ${exchange_triplet[2]}\$/d ${parent/.dep/.odep}
tree_erase ${id_of_dep}.dep
# We want that our direct dep be ${exchange_triplet[2]} and that id_of_dep
# be pulled in as an indirect dep, so exchange.
# Just doing a sed -i "s@${id_of_dep}@${exchange_triplet[2]}@" $DepFile
# is not good if $DepFile contains several times the same line
# so first find the first line and then sed
lineno=$(sed -n /${id_of_dep}/= $DepFile | head -n1)
sed -i "${lineno}s@${id_of_dep}@${exchange_triplet[2]}@" $DepFile
# Do the same for the odep file:
local OdepFile=${DepFile/.dep/.odep}
lineno=$(sed -n /${id_of_dep}/= $OdepFile | head -n1)
sed -i "${lineno}s@${id_of_dep}@${exchange_triplet[2]}@" $OdepFile
id_of_dep=${exchange_triplet[2]}
flag=true # we have to regenerate the tree for the new dependency
else
# We are not the parent. If our priority is greater than p2
# we have to change the triplet and return priority, else return current p2.
# echo (DEBUG) backing up to ${exchange_triplet} at ${DepFile%.dep}
if (( $priority > $p2 )); then
exchange_triplet[2]=${DepFile%.dep}
return $priority
else
return $p2
fi
fi
;;
esac
else # id_of_dep has no dependencies, just record the link in a file
# and print
echo "${rootlink[*]} $count" > ${id_of_dep}.dep
echo -en "\nLeaf: $(($depth+1))${spaceSTR:0:$(($depth+1))}${CYAN}${id_of_dep}${OFF} $dpriostring"
fi
done
done
echo -en "\n End: $depth${spaceSTR:0:$depth}${GREEN}${depFile%.tree}${OFF}"
} <$depFile
echo -en "\n End: $depth${spaceSTR:0:$depth}${GREEN}$DepFile${OFF}"
} 6<$DepFile
# It may happen that a file is created with several times
# the same line. Normally, all those lines but one
# would be flagged to be removed (or all of them if
@ -584,13 +249,12 @@ echo -en "\n End: $depth${spaceSTR:0:$depth}${GREEN}${depFile%.tree}${OFF}"
# so first get the position of last line and then delete
# that line
for line in $lines_to_remove
do lineno=$(sed -n /^[[:digit:]]\ b\ $line\$/= $depFile | tail -n1)
sed -i ${lineno}d $depFile
do lineno=$(sed -n /^[[:digit:]]\ $line\$/= $DepFile | tail -n1)
sed -i ${lineno}d $DepFile
done
return 0
}
#---------------#
tree_browse() { #
#---------------#
@ -600,8 +264,8 @@ local f
#echo file=$file
for f in $(grep '[^0-9 ]' $file | sed 's/.* //'); do
# echo f=$f
if grep -q '[^0-9 ]' ${f}.tree ; then
tree_browse ${f}.tree
if grep -q '[^0-9 ]' ${f}.dep ; then
tree_browse ${f}.dep
fi
echo $f
done
@ -612,24 +276,18 @@ tree_erase() { #
#--------------#
local file=$1
local f
local rootlink
local -a rootlink
local rootlink2
#echo file=$file
rootlink="$(head -n1 $file) "
rootlink=($(head -n1 $file))
for f in $(grep '[^0-9 ]' $file | sed 's/.* //'); do
if [ -f ${f}.tree ]; then
rootlink2="$(head -n1 ${f}.tree) "
# We want two things:
# i) do not erase the file if it is in another branch
# ii) do not erase the file if there is a circular dependency
# for case i), we test that rootlink is contained in rootlink2
# for case ii), we test that rootlink2 is not contained in
# rootlink.
# echo " f"=$f
if [ -f ${f}.dep ]; then
rootlink2="$(head -n1 ${f}.dep) "
# See comment above about srootlink
if [[ ${rootlink2#${rootlink}} != ${rootlink2} &&
${rootlink#${rootlink2}} == ${rootlink} ]] ; then
tree_erase ${f}.tree
if [[ ${rootlink2#"${rootlink[*]} "} != ${rootlink2} ]] ; then
tree_erase ${f}.dep
fi
fi
done

View file

@ -18,6 +18,5 @@
<!-- 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

View file

@ -1,5 +1,7 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- $Id: bump.xsl 21 2012-02-16 15:06:19Z labastie $ -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
@ -7,26 +9,15 @@
<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"/>
[string(name)=$package]/version"/>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="$version"/>
<xsl:value-of select="$version"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
@ -42,8 +33,8 @@
<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>
<name><xsl:value-of select="$package"/></name>
<version><xsl:value-of select="$vers"/></version>
</package>
</xsl:if>
</sublist>
@ -53,8 +44,8 @@
<xsl:choose>
<xsl:when test="string(name)=$package">
<package>
<name><xsl:copy-of select="$package"/></name>
<version><xsl:copy-of select="$vers"/></version>
<name><xsl:value-of select="name"/></name>
<version><xsl:value-of select="$vers"/></version>
</package>
</xsl:when>
<xsl:otherwise>

View file

@ -1,11 +1,14 @@
<?xml version="1.0"?>
<!-- $Id: dependencies.xsl 24 2012-02-16 15:26:15Z labastie $ -->
<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="dependencies" select="2"/>
<xsl:param name="idofdep" select="'dbus'"/>
<xsl:key name="depnode"
@ -17,14 +20,39 @@
</xsl:template>
<xsl:template match="package">
<xsl:apply-templates select="./dependency"/>
<xsl:apply-templates select="./dependency[@status='required']">
<xsl:with-param name="priority" select="1"/>
</xsl:apply-templates>
<xsl:if test="$dependencies &gt; '1'">
<xsl:apply-templates select="./dependency[@status='recommended']">
<xsl:with-param name="priority" select="2"/>
</xsl:apply-templates>
<xsl:if test="$dependencies = '3'">
<xsl:apply-templates select="./dependency[@status='optional']">
<xsl:with-param name="priority" select="3"/>
</xsl:apply-templates>
</xsl:if>
</xsl:if>
</xsl:template>
<xsl:template match="module">
<xsl:apply-templates select="./dependency"/>
<xsl:apply-templates select="./dependency[@status='required']">
<xsl:with-param name="priority" select="1"/>
</xsl:apply-templates>
<xsl:if test="$dependencies &gt; '1'">
<xsl:apply-templates select="./dependency[@status='recommended']">
<xsl:with-param name="priority" select="2"/>
</xsl:apply-templates>
<xsl:if test="$dependencies = '3'">
<xsl:apply-templates select="./dependency[@status='optional']">
<xsl:with-param name="priority" select="3"/>
</xsl:apply-templates>
</xsl:if>
</xsl:if>
</xsl:template>
<xsl:template match="dependency">
<xsl:param name="priority"/>
<xsl:variable name="depname">
<xsl:choose>
<xsl:when test="@name='x-window-system'">xinit</xsl:when>
@ -37,11 +65,10 @@
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!--
<xsl:variable name="install_it">
<xsl:choose>
<xsl:when test="@type='link'">
<!- - No way to track versions: install ! - ->
<!-- No way to track versions: install ! -->
1
</xsl:when>
<xsl:otherwise>
@ -52,43 +79,22 @@
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
-->
<xsl:apply-templates select="dependency"/>
<!--
<xsl:apply-templates select="dependency">
<xsl:with-param name="priority" select="1"/>
</xsl:apply-templates>
<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:value-of select="$priority"/>
</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

View file

@ -1,5 +1,7 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- $Id: gen_config.xsl 21 2012-02-16 15:06:19Z labastie $ -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
@ -10,189 +12,62 @@
<xsl:apply-templates select="//list"/>
<xsl:text>comment ""
menu "Build settings"
menu "Default package for resolving MTA dependency"
choice
prompt "Mail server for resolving the MTA dependency"
choice
prompt "Mail server"
config MS_sendmail
bool "sendmail"
config MS_postfix
bool "postfix"
config MS_exim
bool "exim"
endchoice
config MAIL_SERVER
endchoice
config MAIL_SERVER
string
default "sendmail" if MS_sendmail
default "postfix" if MS_postfix
default "exim" if MS_exim
default sendmail if MS_sendmail
default postfix if MS_postfix
default exim if MS_exim
choice
endmenu
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"
bool "Required and recommended dependencies"
config DEPLVL_3
bool "Req/rec plus optional dependencies of requested package(s)"
bool "Required, recommended and optional dependencies"
config DEPLVL_4
bool "All non external dependencies"
endchoice
config optDependency
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
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)
Select if sudo will be used (you build as a normal user)
otherwise sudo is not needed (you build as root)
config WRAP_INSTALL
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
Select if you want the installation commands to be wrapped
between "wrapInstall '" and "' ; packInstall" functions,
where wrapInstall is used to set up a LD_PRELOAD library (for
example using porg), and packInstall makes the package tarball
</xsl:text>
</xsl:template>
@ -201,7 +76,7 @@ endmenu
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:text>config&#9;MENU_</xsl:text>
<xsl:value-of select="@id"/>
<xsl:text>
bool&#9;"</xsl:text>
@ -209,13 +84,16 @@ bool&#9;"</xsl:text>
<xsl:text>"
default&#9;n
if&#9;MENU_</xsl:text>
menu "</xsl:text>
<xsl:value-of select="name"/>
<xsl:text>"
depends MENU_</xsl:text>
<xsl:value-of select="@id"/>
<xsl:text>
</xsl:text>
<xsl:apply-templates select="sublist"/>
<xsl:text>endif
<xsl:text>endmenu
</xsl:text>
</xsl:if>
@ -226,7 +104,7 @@ if&#9;MENU_</xsl:text>
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:text>&#9;config&#9;MENU_</xsl:text>
<xsl:value-of select="@id"/>
<xsl:text>
&#9;bool&#9;"</xsl:text>
@ -234,13 +112,16 @@ if&#9;MENU_</xsl:text>
<xsl:text>"
&#9;default&#9;n
&#9;if&#9;MENU_</xsl:text>
&#9;menu "</xsl:text>
<xsl:value-of select="name"/>
<xsl:text>"
&#9;depends MENU_</xsl:text>
<xsl:value-of select="@id"/>
<xsl:text>
</xsl:text>
<xsl:apply-templates select="package"/>
<xsl:text>&#9;endif
<xsl:text>&#9;endmenu
</xsl:text>
</xsl:if>
@ -270,21 +151,24 @@ if&#9;MENU_</xsl:text>
<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;config&#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,' ()','___')"/>
&#9;&#9;menu "</xsl:text>
<xsl:value-of select="name"/>
<xsl:text>"
&#9;&#9;depends 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>&#9;&#9;endmenu
</xsl:text>
</xsl:if>

View file

@ -1,15 +1,14 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- $Id: gen_pkg_list.xsl 21 2012-02-16 15:06:19Z labastie $ -->
<!-- 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"
@ -23,116 +22,13 @@
<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>
<xsl:text>&#xA;&#xA;</xsl:text>
<!-- 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',
@ -159,9 +55,7 @@
'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 -->
]) &gt; 0">
<xsl:text> </xsl:text>
<sublist>
<xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
@ -196,14 +90,16 @@
<package><xsl:text>&#xA; </xsl:text>
<xsl:element name="name">
<xsl:value-of select="normalize-space(title)"/>
</xsl:element>
</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">
<!-- Do not use .//*, which would include self. -->
<xsl:apply-templates
select="descendant::node()[contains(translate(@xreflabel,
'123456789',
'000000000'),
'-0')
]"
mode="normal">
<xsl:sort select="@id"/>
</xsl:apply-templates>
<xsl:text> </xsl:text>
@ -312,7 +208,6 @@
</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>
@ -356,8 +251,6 @@
<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">
@ -367,13 +260,6 @@
<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>
@ -383,13 +269,6 @@
<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>
@ -400,30 +279,17 @@
</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: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:element name="dependency">
<xsl:attribute name="status">
<xsl:value-of select="$status"/>
</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:for-each>
</xsl:template>
@ -435,7 +301,6 @@
<!-- 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>
@ -447,7 +312,7 @@
<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:when test="para/xref|para[@id]/ulink">
<xsl:value-of select="$glue"/>
<xsl:element name="dependency">
<xsl:attribute name="status">
@ -460,13 +325,6 @@
<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"/>

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,11 +1,12 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- $Id: make_book.xsl 31 2012-02-19 08:25:04Z labastie $ -->
<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">
@ -24,8 +25,6 @@
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"/>
@ -80,37 +79,8 @@
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')
@ -135,158 +105,6 @@
<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>
@ -413,7 +231,6 @@
<!-- 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>
@ -451,7 +268,6 @@
</xsl:otherwise>
</xsl:choose>
</xsl:element>
</xsl:if>
</xsl:template>
<!-- The case of depdendencies of perl modules. Same treatment
@ -580,7 +396,7 @@
</para>
<screen><userinput>packagedir=<xsl:value-of
select="substring-before($tarball,'.tar.')"/>
select="substring-before($tarball,'.tar.bz2')"/>
<xsl:text>&#xA;</xsl:text>
<xsl:value-of select="substring-before($install-instructions,
'as_root')"/>

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,11 +1,12 @@
$Id$
This file contains examples of menu settings for various tasks.
------------------------------
LFS book, System V, stable (8.2) version.
LFS book, System V, stable (8.0) 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)
Build in /mnt/lfs (verify you have write access too)
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
Build a kernel, whose configuration is in /home/user/config-4.9.9-lfs-1
An fstab for the future system si located in /home/user/fstablfs
Run only the critical testsuites
Settings for a French user
Run four make jobs in parallel
@ -13,11 +14,12 @@ 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)
Branch (preceded by "branch-"), stable Version, or tag (8.0)
[ ] Add blfs-tool support (NEW)
[ ] Add custom tools support (NEW)
General Settings --->
[ ] Change the default user/group and homedir for this build (NEW)
Build Directory (/mnt/lfs)
[*] Retrieve source files
Package Archive Directory (/usr/src)
@ -37,9 +39,9 @@ Build Settings --->
[*] Use a custom fstab file
Fstab file (optional) ($HOME/fstablfs)
[*] Build the kernel
Kernel config file ($HOME/config-4.15-lfs-1)
Kernel config file ($HOME/config-4.9.9-lfs-1)
[ ] Strip Installed Binaries/Libraries
[ ] Install non-wide-character ncurses
[ ] Install vim-lang package
[ ] DO NOT use/display progress_bar
TimeZone (Europe/Paris)
Language (fr_FR.UTF-8)
@ -61,9 +63,9 @@ Advanced Features --->
------------------------------
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)
Build in /mnt/lfs (verify you have write access too)
Clean the build directory before beginning
Build a kernel, whose configuration is in /home/user/config-4.15-lfs-systemd
Build a kernel, whose configuration is in /home/user/config-4.10.3-lfs-systemd
An fstab for the future system si located in /home/user/fstablfs
Run all the testsuites
Settings for an user in California
@ -77,6 +79,7 @@ BOOK Settings --->
[ ] Add custom tools support (NEW)
General Settings --->
[ ] Change the default user/group and homedir for this build (NEW)
Build Directory (/mnt/lfs)
[*] Retrieve source files
Package Archive Directory (/usr/src)
@ -96,9 +99,9 @@ Build Settings --->
[*] Use a custom fstab file
Fstab file (optional) ($HOME/fstablfs)
[*] Build the kernel
Kernel config file ($HOME/config-4.15-lfs-systemd
Kernel config file ($HOME/config-4.10.3-lfs-systemd
[ ] Strip Installed Binaries/Libraries
[ ] Install non-wide-character ncurses
[ ] Install vim-lang package
[ ] DO NOT use/display progress_bar
TimeZone (America/Los_Angeles)
Language (en_US.UTF-8)
@ -117,3 +120,68 @@ Advanced Features --->
[ ] Rebuild the Makefile (see help)
------------------------------
------------------------------
CLFS book, systemd, stable version (as of April 2017)
X86 multilib
Download the files to /usr/src (verify you have write access)
Build in /mnt/clfs (verify you have write access too)
Clean the build directory before beginning
Use "boot" method, with a temporary kernel in /home/user/config-boot
Build a kernel, whose configuration is in /home/user/config-4.10.3-clfs-systemd
An fstab for the future system si located in /home/user/fstablfs
Run all the testsuites for final system
Settings for an user in Sidney (Australia)
Run four make jobs in parallel
-----------------------------
BOOK Settings --->
Use BOOK (Cross-Compiled Linux From Scratch) --->
Release (Branch or stable book) --->
Branch (preceded by "branch-"), stable Version, or tag (3.0.0-systemd)
Target architecture (x86) --->
Library (multilib) --->
Build method (boot) --->
BOOT kernel config file (mandatory) ($HOME/config-boot)
[ ] Add blfs-tool support (NEW)
[ ] Add custom tools support (NEW)
General Settings --->
[ ] Change the default user/group and homedir for this build (NEW)
Build Directory (/mnt/clfs)
[*] 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 (All final system testsuites) --->
Flavour (Don't stop on testsuite failures) --->
[ ] 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.10.3-clfs-systemd
[ ] Strip Installed Binaries/Libraries
[ ] Install vim-lang package
[ ] DO NOT use/display progress_bar
TimeZone (Australia/Sydney)
Language (en_AU.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 (Cross tools (only MAKEFLAGS), temp tools and final system) --->
Internal Settings (WARNING: for jhalfs developers only) --->
[ ] Rebuild the Makefile (see help)
--------------------------------

449
CLFS/clfs.xsl Normal file
View file

@ -0,0 +1,449 @@
<?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? OBSOLETE should always be 'n'-->
<xsl:param name="vim-lang" select="n"/>
<!-- 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"/>
<!-- x86 32 bit target triplet -->
<xsl:param name="x86" select="i686-pc-linux-gnu"/>
<!-- mips target triplet -->
<xsl:param name="mips" select="mips-unknown-linux-gnu"/>
<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'"/>
<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')"/>
<!-- test instructions -->
<xsl:when test="@remap = 'test'">
<xsl:choose>
<!-- Avoid executing the note before perl tests while in 'chroot' -->
<xsl:when test="ancestor::note[@os='a00'] and $method='chroot'"/>
<xsl:when test="$testsuite = '0'"/>
<xsl:when test=
"$testsuite = '1' and
not(ancestor::sect1[@id='ch-system-gcc']) and
not(ancestor::sect1[contains(@id,'ch-system-eglibc')]) and
not(ancestor::sect1[contains(@id,'ch-system-glibc')]) and
not(ancestor::sect1[contains(@id,'ch-system-gmp')]) and
not(ancestor::sect1[contains(@id,'ch-system-mpfr')]) and
not(ancestor::sect1[contains(@id,'ch-system-mpc')]) and
not(ancestor::sect1[contains(@id,'ch-system-ppl')]) and
not(ancestor::sect1[contains(@id,'ch-system-isl')]) and
not(ancestor::sect1[contains(@id,'ch-system-cloog')]) and
not(ancestor::sect1[contains(@id,'ch-system-cloog-ppl')]) and
not(ancestor::sect1[@id='ch-system-binutils'])"/>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="$bomb-testsuite = 'n'">
<xsl:choose>
<!-- special case for (e)glibc -->
<xsl:when test="contains(string(), 'glibc-check-log')">
<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>
<!-- special case for procps-ng -->
<xsl:when test="contains(string(), 'pushd')">
<xsl:text>{ </xsl:text>
<xsl:apply-templates/>
<xsl:text>; } &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
</xsl:when>
<xsl:when test="contains(string(), 'make -k')">
<xsl:apply-templates/>
<xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
</xsl:when>
<xsl:when test="contains(string(), 'make')">
<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:if test="not(contains(string(), '&gt;&gt;'))">
<xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
</xsl:if>
<xsl:text>&#xA;</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<!-- bomb-testsuite != 'n'-->
<xsl:choose>
<!-- special case for (e)glibc -->
<xsl:when test="contains(string(), 'glibc-check-log')">
<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>
<!-- special case for gmp -->
<xsl:when test="contains(string(), 'tee gmp-check-log')">
<xsl:text>(</xsl:text>
<xsl:apply-templates/>
<xsl:text>&gt;&gt; $TEST_LOG 2&gt;&amp;1 &amp;&amp; exit $PIPESTATUS)&#xA;</xsl:text>
</xsl:when>
<!-- special case for procps-ng -->
<xsl:when test="contains(string(), 'pushd')">
<xsl:text>{ </xsl:text>
<xsl:apply-templates/>
<xsl:text>; } &gt;&gt; $TEST_LOG 2&gt;&amp;1&#xA;</xsl:text>
</xsl:when>
<xsl:when test="contains(string(), 'make -k')">
<xsl:apply-templates/>
<xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1 || true&#xA;</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates/>
<xsl:if test="not(contains(string(), '&gt;&gt;'))">
<xsl:text> &gt;&gt; $TEST_LOG 2&gt;&amp;1</xsl:text>
</xsl:if>
<xsl:text>&#xA;</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<!-- End of test instructions -->
<!-- Fixing toolchain test suites run XXX more to fix -->
<xsl:when test="contains(string(),'glibc-check-log')">
<xsl:choose>
<xsl:when test="$testsuite != '0'">
<xsl:value-of select="substring-before(string(),'2&gt;')"/>
<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="string() = 'make check' or
contains(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(),'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>
<!-- Add -j1 to make install commands -->
<xsl:when test="contains(string(),'make ') and
contains(string(),'install')">
<xsl:value-of select="substring-before(string(),'make ')"/>
<xsl:text>make -j1 </xsl:text>
<xsl:value-of select="substring-after(string(),'make ')"/>
<xsl:text>&#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-eglibc']">
<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:when test="ancestor::sect1[@id='ch-final-preps-variables']">
<xsl:choose>
<xsl:when test="contains(string(),'target triplet')">
<xsl:value-of select="$x86"/>
</xsl:when>
<xsl:when test="contains(string(),'mips')">
<xsl:value-of select="$mips"/>
</xsl:when>
<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>

1265
CLFS/master.sh Normal file

File diff suppressed because it is too large Load diff

157
CLFS2/clfs2.xsl Normal file
View file

@ -0,0 +1,157 @@
<?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'] and
not(@id='ch-cross-tools-sysroot-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: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-eglibc']">
<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>

537
CLFS2/master.sh Normal file
View file

@ -0,0 +1,537 @@
#!/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 "unset PKG_CONFIG_PATH" >> \$(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}"
}

156
CLFS3/clfs3.xsl Normal file
View file

@ -0,0 +1,156 @@
<?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>

587
CLFS3/master.sh Normal file
View file

@ -0,0 +1,587 @@
#!/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 "unset PKG_CONFIG_PATH" >> \$(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}"
}

929
Config.in

File diff suppressed because it is too large Load diff

View file

@ -1,3 +1,5 @@
$Id$
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.
@ -180,6 +182,10 @@ wrt_do_ica_work():
From common/libs/func_compare.sh.
Description:
--------------------------------------------------------------------------
wrt_do_farce_work():
From common/libs/func_compare.sh.
Description:
--------------------------------------------------------------------------
wrt_logs():
From common/libs/func_compare.sh.
Description:
@ -240,6 +246,86 @@ clean_builddir():
From common/common-functions.
Description:
--------------------------------------------------------------------------
function dohelp():
From extras/farce.
Description:
--------------------------------------------------------------------------
function emessage():
From extras/farce.
Description:
--------------------------------------------------------------------------
function expected():
From extras/farce.
Description:
--------------------------------------------------------------------------
function failure():
From extras/farce.
Description:
--------------------------------------------------------------------------
function fatal():
From extras/farce.
Description:
--------------------------------------------------------------------------
function filetype():
From extras/farce.
Description:
--------------------------------------------------------------------------
function message():
From extras/farce.
Description:
--------------------------------------------------------------------------
function onlyone():
From extras/farce.
Description:
--------------------------------------------------------------------------
function testar():
From extras/farce.
Description:
--------------------------------------------------------------------------
function testgzip():
From extras/farce.
Description:
--------------------------------------------------------------------------
function testso():
From extras/farce.
Description:
--------------------------------------------------------------------------
function tokenize():
From extras/farce.
Description:
--------------------------------------------------------------------------
function tokenizeanddiff():
From extras/farce.
Description:
--------------------------------------------------------------------------
function validateargs():
From extras/farce.
Description:
--------------------------------------------------------------------------
process_toolchain():
From HLFS/master.sh.
Description: embryo,cocoon and butterfly need special handling
--------------------------------------------------------------------------
chapter3_Makefiles():
From HLFS/master.sh.
Description: Initialization of the system
--------------------------------------------------------------------------
chapter5_Makefiles():
From HLFS/master.sh.
Description: Bootstrap or temptools phase
--------------------------------------------------------------------------
chapter6_Makefiles():
From HLFS/master.sh.
Description: sysroot or chroot build phase
--------------------------------------------------------------------------
chapter7_Makefiles():
From HLFS/master.sh.
Description: Create a bootable system.. kernel, bootscripts..etc
--------------------------------------------------------------------------
build_Makefile():
From HLFS/master.sh.
Description: Construct a Makefile from the book scripts
--------------------------------------------------------------------------
simple_error():
From jhalfs.
Description: Basic error trap.... JUST DIE

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,5 +1,7 @@
#!/bin/bash
# $Id$
###################################
### FUNCTIONS ###
###################################
@ -8,199 +10,276 @@
#############################################################
#-------------------------#
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
#----------------------------#
chapter4_Makefiles() { #
#----------------------------#
echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter4 ( SETUP ) ${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
# 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
020-creatingtoolsdir:
@\$(call echo_message, Building)
@mkdir \$(MOUNT_PT)/tools && \\
rm -f /tools && \\
ln -s \$(MOUNT_PT)/tools /
@\$(call housekeeping)
echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter $1$N${R_arrow}"
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)
for file in ${dir}$N/* ; do
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 "LFS=\$(MOUNT_PT)" >> \$(LUSER_HOME)/.bashrc && \\
echo "LC_ALL=POSIX" >> \$(LUSER_HOME)/.bashrc && \\
echo "LFS_TGT=`uname -m`-lfs-linux-gnu" >> \$(LUSER_HOME)/.bashrc && \\
echo "PATH=/tools/bin:/bin:/usr/bin" >> \$(LUSER_HOME)/.bashrc && \\
echo "export LFS LC_ALL LFS_TGT PATH" >> \$(LUSER_HOME)/.bashrc && \\
echo "source $JHALFSDIR/envars" >> \$(LUSER_HOME)/.bashrc && \\
chown \$(LUSER):\$(LGROUP) \$(LUSER_HOME)/.bashrc && \\
touch envars && \\
chown \$(LUSER) envars
@\$(call housekeeping)
EOF
) > $MKFILE.tmp
chapter4=" 020-creatingtoolsdir 021-addinguser 022-settingenvironment"
}
#----------------------------#
chapter5_Makefiles() {
#----------------------------#
echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter5 ( LUSER ) ${R_arrow}"
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 are run, then TCL, Expect, DejaGNU and Check
# aren't needed (but building them does not hurt).
# Fix also locales creation when running chapter05 testsuites (ugly)
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 ;;
# *check) [[ "${TEST}" = "0" ]] && continue ;;
*stripping) [[ "${STRIP}" = "n" ]] && continue ;;
*glibc) [[ "${TEST}" = "3" ]] && \
sed -i 's@/usr/lib/locale@/tools/lib/locale@' $file ;;
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\}-@@' \
# First append each name of the script files to a list (this will become
# the names of the targets in the Makefile
# DO NOT append the changingowner script, it need be run as root.
# A hack is necessary: create script in chap5 BUT run as a dependency for
# SUDO target
case "${this_script}" in
*changingowner) runasroot="$runasroot ${this_script}" ;;
*) chapter5="$chapter5 ${this_script}" ;;
esac
# Grab the name of the target (minus the -pass1 or -pass2 in the case of gcc
# and binutils in chapter 5)
name=`echo ${this_script} | sed -e 's@[0-9]\{3\}-@@' \
-e 's@-pass[0-9]\{1\}@@' \
-e 's@-libstdc++@@' \
-e 's,'$N',,' \
-e 's@-32@@'`
-e 's@-libstdc++@@'`
# 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.
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
esac
eval $Makefile_target=\"\$$Makefile_target ${this_script}\"
# Set the dependency for the first target.
if [ -z $PREV ] ; then PREV=022-settingenvironment ; fi
#--------------------------------------------------------------------#
# >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
#--------------------------------------------------------------------#
#
# Find the name of the tarball and the version of the package
pkg_tarball=$(get_package_tarball_name $name)
pkg_version=$(get_package_version $pkg_tarball)
# 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
LUSER_wrt_target "${this_script}" "$PREV" "$pkg_version"
# 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
# Insert instructions for unpacking the package and to set the PKGDIR variable.
LUSER_wrt_unpack "$pkg_tarball"
# If the testsuites must be run, initialize the log file
[[ "$TEST" = "3" ]] && LUSER_wrt_test_log "${this_script}" "$pkg_version"
# 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.
# The changingowner script must be run as root.
case "${this_script}" in
*changingowner) wrt_RunAsRoot "$file" "$pkg_version" ;;
*) LUSER_wrt_RunAsUser "$file" "$pkg_version" ;;
esac
# Remove the build directory(ies) except if the package build fails
# (so we can review config.cache, config.log, etc.)
if [ "$pkg_tarball" != "" ] ; then
case "${name}" in
*xz-utils) LUSER_RemoveBuildDirs "xz" ;;
*) LUSER_RemoveBuildDirs "$name" ;;
esac
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() {
#----------------------------#
# 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}
# Suppress the mod of "test-installation.pl" because now
# the library path points to /usr/lib
if [[ ${script} =~ glibc ]]; then
sed '/DL=/,/unset DL/d' -i ${script}
fi
# 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 chapter06$N/*-bzip2$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 the "stripping" scripts if the user does not want to strip.
# Skip also linux-headers in iterative builds.
case "${this_script}" in
*stripping*) [[ "${STRIP}" = "n" ]] && continue ;;
*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',,'`
# Find the tarball corresponding to our script.
# If it doesn't, we skip it in iterations rebuilds (except stripping).
pkg_tarball=$(get_package_tarball_name $name)
pkg_version=$(get_package_version $pkg_tarball)
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)
# The kernfs script must be run as part of 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.
# In the mount of kernel filesystems we need to set LFS
# and not to use chroot.
case "${this_script}" in
*kernfs) LUSER_wrt_target "${this_script}" "$PREV" "$pkg_version" ;;
*) CHROOT_wrt_target "${this_script}" "$PREV" "$pkg_version" ;;
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
# 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" ;;
CHROOT_Unpack "$pkg_tarball"
# If the testsuites must be run, initialize the log file
case $name in
binutils | gcc | glibc | gmp | mpfr )
[[ "$TEST" != "0" ]] &&
CHROOT_wrt_test_log "${this_script}" "$pkg_version"
;;
* )
[[ "$TEST" = "2" ]] || [[ "$TEST" = "3" ]] &&
CHROOT_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
[[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
fi
# Some scriptlet have a special treatment; otherwise standard
# In the mount of kernel filesystems we need to set LFS
# and not to use chroot.
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
;;
*kernfs) wrt_RunAsRoot "$file" "$pkg_version" ;;
*) CHROOT_wrt_RunAsRoot "$file" "$pkg_version" ;;
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}"
case "${name}" in
*xz-utils) CHROOT_wrt_RemoveBuildDirs "xz" ;;
*) CHROOT_wrt_RemoveBuildDirs "$name" ;;
esac
if [ "${INSTALL_LOG}" = "y" ] && [ "x${N}" = "x" ] ; then
CHROOT_wrt_LogNewFiles "$name"
fi
fi
@ -214,59 +293,137 @@ 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"
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
# 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) [[ -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 ;;
esac
# First append each name of the script files to a list (this will become
# the names of the targets in the Makefile
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.
CHROOT_wrt_target "${this_script}" "$PREV"
# Find the bootscripts or networkscripts (for systemd)
# and kernel package names
case "${this_script}" in
*bootscripts)
name="lfs-bootscripts"
pkg_tarball=$(get_package_tarball_name $name)
if [ "${INSTALL_LOG}" = "y" ] ; then
CHROOT_wrt_TouchTimestamp
fi
CHROOT_Unpack "$pkg_tarball"
;;
*network-scripts)
name="lfs-network-scripts"
pkg_tarball=$(get_package_tarball_name $name)
if [ "${INSTALL_LOG}" = "y" ] ; then
CHROOT_wrt_TouchTimestamp
fi
CHROOT_Unpack "$pkg_tarball"
;;
*kernel)
name="linux"
pkg_tarball=$(get_package_tarball_name $name)
if [ "${INSTALL_LOG}" = "y" ] ; then
CHROOT_wrt_TouchTimestamp
fi
CHROOT_Unpack "$pkg_tarball"
# If using optimizations, use MAKEFLAGS (unless blacklisted)
# no setting of CFLAGS and friends.
[[ "$OPTIMIZE" != "0" ]] && wrt_makeflags "$name"
;;
esac
# Check if we have a real /etc/fstab file
case "${this_script}" in
*fstab) if [[ -n "$FSTAB" ]]; then
CHROOT_wrt_CopyFstab
else
CHROOT_wrt_RunAsRoot "$file"
fi
;;
*) CHROOT_wrt_RunAsRoot "$file"
;;
esac
case "${this_script}" in
*bootscripts) CHROOT_wrt_RemoveBuildDirs "dummy"
if [ "${INSTALL_LOG}" = "y" ] ; then
CHROOT_wrt_LogNewFiles "$name"
fi ;;
*network-scripts) CHROOT_wrt_RemoveBuildDirs "dummy"
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 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
@ -289,42 +446,32 @@ build_Makefile() { #
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
all: ck_UID mk_SETUP mk_LUSER mk_SUDO mk_CHROOT mk_BOOT create-sbu_du-report mk_BLFS_TOOL mk_CUSTOM_TOOLS
@sudo make do_housekeeping
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
@/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
EOF
) >> $MKFILE
fi
(
cat << EOF
@sudo make do_housekeeping
@echo $VERSION > lfs-release && \\
sudo mv lfs-release \$(MOUNT_PT)/etc && \\
sudo chown root:root \$(MOUNT_PT)/etc/lfs-release
@ -336,15 +483,6 @@ fi
> 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
@\$(call echo_finished,$VERSION)
ck_UID:
@ -355,174 +493,123 @@ 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
@( \$(SU_LUSER) "make -C \$(MOUNT_PT)/\$(SCRIPT_ROOT) 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")
@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) -c "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) BOOT")
@touch \$@
mk_BLFS_TOOL: create-sbu_du-report devices
mk_BLFS_TOOL: create-sbu_du-report
@if [ "\$(ADD_BLFS_TOOLS)" = "y" ]; then \\
\$(call sh_echo_PHASE,Building BLFS_TOOL); \\
(sudo \$(CHROOT1) -c "make -C $BLFS_ROOT/work"); \\
(sudo \$(CHROOT2) -c "make -C $BLFS_ROOT/work"); \\
fi;
@touch \$@
mk_CUSTOM_TOOLS: mk_BLFS_TOOL devices
mk_CUSTOM_TOOLS: mk_BLFS_TOOL
@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) -c "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; \\
sudo mount -v --bind /dev \$(MOUNT_PT)/dev
sudo mount -vt devpts devpts \$(MOUNT_PT)/dev/pts
sudo mount -vt proc proc \$(MOUNT_PT)/proc
sudo mount -vt sysfs sysfs \$(MOUNT_PT)/sys
sudo mount -vt tmpfs tmpfs \$(MOUNT_PT)/run
if [ -h \$(MOUNT_PT)/dev/shm ]; then \\
sudo mkdir -p \$(MOUNT_PT)/\$\$(readlink \$(MOUNT_PT)/dev/shm); \\
fi
EOF
) >> $MKFILE
fi
(
cat << EOF
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; \\
sudo umount -v \$(MOUNT_PT)/sys
sudo umount -v \$(MOUNT_PT)/proc
sudo umount -v \$(MOUNT_PT)/dev/pts
if mountpoint -q \$(MOUNT_PT)/run; then \\
sudo umount -v \$(MOUNT_PT)/run; \\
elif [ -h \$(MOUNT_PT)/dev/shm ]; then \\
link=\$\$(readlink \$(MOUNT_PT)/dev/shm); \\
sudo umount -v \$(MOUNT_PT)/\$\$link; \\
unset link; \\
else \\
sudo umount -v \$(MOUNT_PT)/dev/shm; \\
fi
EOF
) >> $MKFILE
fi
(
cat << EOF
chroot1: devices
-sudo \$(CHROOT1)
\$(MAKE) teardown
sudo umount -v \$(MOUNT_PT)/dev
chroot: devices
-sudo \$(CHROOT1)
sudo \$(CHROOT2)
\$(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
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); \\
sudo ./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
@-if mountpoint -q \$(MOUNT_PT)/run; then \\
umount \$(MOUNT_PT)/run; \\
elif [ -h \$(MOUNT_PT)/dev/shm ]; then \\
link=\$\$(readlink \$(MOUNT_PT)/dev/shm); \\
umount \$(MOUNT_PT)/\$\$link; \\
unset link; \\
else \\
umount \$(MOUNT_PT)/dev/shm; \\
fi
@-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,36 @@
# 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
-@cp -a configuration configuration.old
@$(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

466
README
View file

@ -1,268 +1,148 @@
$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.
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.
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 list of supported books can be found at
http://wiki.linuxfromscratch.org/alfs/wiki/SupportedBooks.
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 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.CLFS: supplementary instructions to use the CLFS book series.
- 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 (CLFS is not supported in that case), 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 xLFS
build, at the end of a xLFS 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 (only for LFS, patches welcome for CLFS...)
- README.HLFS: very short file explaining why you cannot use HLFS with the
present tool version.
Other sources of information are the context help in the menu interface,
and the LFS books themselves (both required readings of course!).
Other sources of information are the context help in the menu interface,
and the xLFS books themselves.
2. PREREQUISITES::
It is strongly advised that you first build manually a complete system
before attempting to automate the build.
As said elsewhere, it is strongly advised that you first build manually
a complete system before attempting to automate the build.
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.
Of course the "Host System Requirements" should be fulfilled. The needed
supplementary packages are detailed at the bottom of the page:
http://www.linuxfromscratch.org/alfs/download.html
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. You may want to move the files in this
directory to a convenient location, and then follow the instructions below.
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.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.
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/{c,}lfs.
You can change that default to anything you'd like in the menu, so you
may name it /mnt/lfs, or whatever you like. One important point is that
the user you are logged in as (and not the (c)lfs user) should have write
permission to the mounted directory. 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.
The tool can download the needed packages for you, or you may download
them yourself. The tool may optionally use a package archive directory
where the downloaded packages are stored. That directory name may be made
available to the tool in two ways: (i) export the SRC_ARCHIVE variable,
for example SRC_ARCHIVE=/usr/src, (ii) enter the name at the "Package
Archive Directory" menu prompt. Note that the user should have write
permission to that directory. If a needed package is found in that
directory, it is copied to /mnt/build_dir/sources, if not, it is
downloaded to that directory and copied to /mnt/build_dir/sources,
except if found in /mnt/build_dir/sources, in which case, it is just
copied to $SRC_ARCHIVE. If you want the tool to download packages and you
do not want to archive them, just unset SRC_ARCHIVE, and keep the
default entry for "Package Archive Directory". If you choose to download
the packages by yourself, you should download (or copy) them to
/mnt/build_dir/sources directly.
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>.
If you want to build the kernel as part of the automated build, select
"Build the kernel" in the menu. Then, a configuration file must be
provided. In order to do so, it is recommended to download the kernel
tarball, unpack it, run <make menuconfig>, configure the kernel as per
the book, and save the resulting .config file to a location where it can
be retrieved later on (a convenient location and name is
$SRC_ARCHIVE/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.
Another file you may provide is the fstab file. To use it, select
"Use a custom fstab file" in the menu interface, and enter the name of
the file where asked. As for the kernel configuration, this file has to
be prepared before running the menu. A convenient location and name is
$SRC_ARCHIVE/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.
At a more advanced level, you may want to supply custom commands
to be run at the end of (C)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.
5. RUNNING::
IMPORTANT::
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 command <make> will launch a menu based configuration program. The
underlying menu code was borrowed from BusyBox and slightly modified for
our use.
The command <make> will launch a menu based configuration program,
similar to the kernel "menuconfig" configuration tool.
Help on parameter function is available from the on-line help. Please
make use of that feature: it may contain additional information not
duplicated in this file.
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.
You should first choose which book and flavour you want to build. Note
that when you choose the BLFS book, the tool will just install the BLFS
tool to your system. You'll have to run that installed tool to build
packages in BLFS. See README.BLFS to know how. If you choose any other
book, you'll have to configure the settings and the build parameters
from the menu. Note that you may choose to 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.
MENU "BOOK Settings"
The "General Settings" menu is where the "Build Directory" name is to be
entered. Other entries in that menu select what the tool should do. The
"Run the Makefile" entry selects whether the tool will start the build
automatically after generating the needed files. The "Rebuild files" selects
whether to clean the build directory before doing anything else. To protect
against removing important files, this can only be done in an empty directory,
or a directory previously populated by the tool.
Use BOOK: You have three choices: LFS System V, LFS systemd, BLFS.
The BLFS part is described in README.BLFS
The "Build Settings" menu is where various options for the build can be
selected. Two options, "Use a custom fstab file" and "Build the kernel",
have been described above. "Do not use/display progress_bar", if set, will
prevent a progress bar to be displayed during the build. That may be useful
on slow machine. The other options should be self explanatory, using either
the online help or book reading.
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.
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
Build method: two choices: chroot (as in book), boot
Presently, the "boot" method is not implemented, so keep the default.
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.
Add custom tools support (see README.CUSTOM)
MENU "General Settings"
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.
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
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.
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.
MENU "Build Settings"
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.
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).
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
The "Advanced Features" menu is for various maintenance tasks, like
testing the build instructions or reporting build statistics. One useful
option is "Optimization and parallelisation". It is not recommended to use
it for setting compiler optimization flags, although it is possible, but
if you select it, you'll be able to select the number of parallel `make'
jobs, which allows much faster builds on modern multicore CPUs.
Once you have set the parameters and saved the configuration, the script
is launched. Its aim is to extract instructions from the selected book
@ -279,80 +159,89 @@
have used the default parameters (see the layout under $BUILDDIR in the
Q&A below).
IMPORTANT::
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 "jhalfs_user" in /etc/sudoers could be
jhalfs_user ALL=(ALL) NOPASSWD:ALL
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)
/BLFS (see README.BLFS)
/CLFS/master.sh
/clfs.xsl
/CLFS2/master.sh
/clfs2.xsl
/CLFS3/master.sh
/clfs3.xsl
/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,
following: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. 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
an old version of the book, you may have to downgrade you jahlfs
version.
Q. "How do I specify the build location?"
@ -365,7 +254,8 @@
$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 +263,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.
@ -390,9 +280,41 @@
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
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 those
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 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
as the break point. For example:

View file

@ -1,3 +1,5 @@
$Id$
1. INTRODUCTION::
To automate package builds from the BLFS book instructions is a huge
@ -11,11 +13,6 @@
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::
@ -25,8 +22,8 @@
- 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)
cut and paste commands from the book), subversion (to update the book
sources), openssl (used by wget for all https:// sites)
Note that the optional dependencies are recommended for ease of use of the
tool.
@ -52,42 +49,34 @@
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.
The tracking directory (see below) is initialized but not created: before
the installation, you should ensure the tracking directory (default location
/var/lib/jhalfs/BLFS) exists and is writable by the user. After the
intallation, you should perform the following additional steps:
- Configure sudo, adding the needed privileges for the user. For
newer sudo version, do not forget to add a line `Defaults secure_path='
containing /sbin and /usr/sbin (in /etc/sudoers), otherwise some
executables are not found.
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
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 xLFS SYSTEM
3.2 INSTALLATION ON A JUST BUILT LFS SYSTEM
For books that support it (only LFS),
For books that support it (only LFS for jhalfs version 2.4),
there is an option to install the BLFS tools right after building
the LFS system: just tick `BOOK Settings/Add blfs-tool support' in
the xLFS 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
(default /blfs_root) on the xLFS 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
(TODO: blfs-tools have not been tested with current (version 3.0) of CLFS,
and certainly need some adaptation to run)
After booting the new xLFS 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
@ -104,55 +93,43 @@
- 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.
We assume that the BLFS tools will be used on a booted xLFS 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.
blfs-xml/* SVN tree of the selected BLFS book version
lib/constants.inc functions libraries
/func_dependencies for building the dependency tree
menu/* lxdialog and 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
/scripts.xsl XSL stylesheet to generate the scriptlets from
book.xml
/bump.xsl XSL stylesheet to update the tracking file
README.BLFS this file
TODO developers notes (well, not updated often)
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
gen-special.sh Helper script for generating the package database
Makefile Used by make to update the package database from
the SVN 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.
envars.conf envars needed when running the target build scripts
Working files: several files are generated when first running the tool:
Working files: several files are generated when first running the tool
packages.xml auto-generated package database
packages.xml auto-generated packages database
Config.in input file for the menu driven choices
configuration file generated by the menuconfig process
dependencies/* files recording the dependency tree
@ -171,7 +148,7 @@
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
custom tools or blfs dependencies, right after xLFS. 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).
@ -188,16 +165,22 @@
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:
Due to the complexity of the BLFS book, the scripts and Makefile
generation is done in several steps:
4.1 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. This is not necessary if
you just built xLFS, and you can skip to step 3.4.
To do that, run "make update". It may happen that the subversion
version of your building host is older than the version you just
built. This may generate weird errors like "'.' omitted". The easiest
thing to do in that case, is to completely remove the blfs-xml directory
and run "make update". With recent versions of subversion, you can also
run "svn upgrade" from inside the blfs-xml directory.
On the next configuration run, packages already installed but listed
with a new version in the book will be available for target selection
@ -209,35 +192,17 @@
build order for one or several packages.
Run <make> to launch the configuration interface. The main menu contains
four blocks: individual package selection, Build settings, Build layout,
and Optimization.
two blocks: 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
In the build options section, the dependencies 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.
Those settings are saved to be reused in future configuration runs.
Note that you may select as many targets as you want, not just one
as in the previous version of this tool. But we suggest to not select
too many at a time to be able to sort issues!
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 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.
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.
Note that there are help strings associated to those menus. Please
read them for details!
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
@ -256,7 +221,7 @@
Furthermore, there is a directory "scripts", which contains the generated
scriptlets.
There is yet another directory, "dependencies" that contains files
There is also another directory, "dependencies" that contains files
generated while resolving dependencies.
4.3 EDITING BUILD SCRIPTS::
@ -270,17 +235,17 @@
"bar" before "foo" package and the "foo" script is named "064-z-foo", you
just 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.
Also, review and edit envars.conf. This file is used to set global envars
needed by the build scripts.
4.4 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. Create an empty directory (for example "mkdir work") and cd
to that directory. Then run ../gen-makefile.sh
Review the Makefile, and, if all looks sane, start the build by running
"make".
@ -312,7 +277,7 @@
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
bash startup files are modified. The shipped 'envars.conf' contains a
line 'source /etc/profile', which ensures that the proper environment
variables are used.
@ -333,7 +298,7 @@
breaks those pages into individual pages for each packages in the linear
book. Also, the menu gives the choice to select each package individually.
To build the whole Xorg7 chapter, select xinit. The (recommended)
To build the whole Xorg7 chapter, select twm. The (recommended)
dependency chain brings in the whole set of Xorg packages.
5.5 PATCHES
@ -346,25 +311,28 @@
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.
necessary root privilege commands are visible in your PATH. Or use
the `Defaults secure_path=' in /etc/sudoers.
For commands necessitating root privileges, the generated scripts wrap
them with the construct:
sudo -E sh -e << ROOT_EOF
sudo -E sh << 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.
The -E switch 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. 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.
WARNING: One variable from the environment is not passed through the
-E switch, namely PATH. This is because "sudo" always reset the PATH to
the default "secure_path". If you need to have the same PATH as the user
"root" would have, you may want to add "source /etc/profile" at the
beginning of the commands to be executed as root.
Due to book layout issues, some sudo commands may be missing.

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,8 +1,11 @@
#
# $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.
@ -34,7 +37,7 @@ able to boot and run. Each of those areas are handled in a different way.
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.
@ -56,7 +59,7 @@ 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.
@ -95,6 +98,13 @@ or to support specific hardware, or to install basic utilities that are
needed 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
configuration scripts and a few examples. A switch has been added to the
@ -103,15 +113,16 @@ configuration file which enables/disables the inclusion of custom 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.
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 +132,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 +173,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"
@ -203,6 +204,8 @@ 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 +263,4 @@ echo "JUST A USELESS TRACE"
xEOFx
) > tmp

6
README.HLFS Normal file
View file

@ -0,0 +1,6 @@
$Id$
::::NOTICE::::
HLFS has not be updated for a very long time. Since then, jhalfs has evolved
and is now incompatible with HLFS.

View file

@ -1,5 +1,6 @@
TITLE : Package management in jhalfs
BY : Pierre Labastie (work in progress)
$Id$
1. INTRODUCTION:
@ -18,11 +19,12 @@ BY : Pierre Labastie (work in progress)
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).
style one (the book layout makes it rather difficult). I have not attempted
to adapt this tool for the other flavours of LFS (TODO).
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
a "DESTDIR install" for all pages in chapter 6, 7 and 8 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.
@ -43,7 +45,7 @@ BY : Pierre Labastie (work in progress)
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).
implemented yet.
3. DETAILS:
@ -60,7 +62,7 @@ BY : Pierre Labastie (work in progress)
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).
chapter 5 (temporary installation in /tools) and chapter 6 (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

19
TODO
View file

@ -1,6 +1,23 @@
jhalfs TODO
---------------
Remove RUN_ICA (it is redundant with COMPARE)
MASTER SCRIPT
-------------
- Add a way to choose the network configuration (ip, gateway, etc).
- [CLFS] Add a switch to choose between static or DHCP network configuration
for CLFS.
xLFS MODULES
------------
- Add a way to choose the network configuration (ip, gateway, etc).
- [CLFS] Add a switch to choose between static or DHCP network configuration
for CLFS.
BLFS MODULE (See BLFS/TODO)
-----------

View file

@ -1,21 +1,20 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- $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">
<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')]">
test="descendant::screen/userinput[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=')"/>
@ -40,58 +39,14 @@
<!-- 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:apply-templates select=".//userinput[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:apply-templates/>
<xsl:text>&#xA;</xsl:text>
</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
}
@ -49,7 +49,7 @@ 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 &&
if $(ls -d $BUILDDIR/* > /dev/null 2>&1) &&
[ "$(ls $BUILDDIR)" != "lost+found" ]; then
# Test to make sure that the build directory was populated by jhalfs
if [ ! -d $JHALFSDIR ] || [ ! -d $BUILDDIR/sources ] ; then
@ -60,17 +60,9 @@ if [ "${CLEAN}" = "y" ]; then
echo "Looks like kernel filesystems are still 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.
# First delete proc and sys directories, if exist.
# Both should be empty. If not, we exit, and the rmdir command
# has generated an error message
if [ -d $BUILDDIR/proc ] ; then
@ -79,7 +71,7 @@ if [ "${CLEAN}" = "y" ]; then
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/{bin,boot,dev,etc,home,lib{,64},media,mnt,run}
sudo rm -rf $BUILDDIR/{opt,root,sbin,srv,tmp,tools,cross-tools,usr,var}
echo "done"
if [[ "${BLFS_TOOL}" = "y" ]] ; then
@ -93,10 +85,31 @@ if [ "${CLEAN}" = "y" ]; then
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 "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 " ..."

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,20 @@ 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`
FIRSTLOG=`grep -l "^Totalseconds:" $LOGSDIR/* | head -n1`
BASELOG=`grep -l "^Totalseconds:" $LOGSDIR/???-binutils* | 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 +71,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 +81,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')';`
@ -134,7 +119,7 @@ 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`
DU1=`du -skx --exclude=jhalfs --exclude=lost+found $LOGSDIR/../.. | cut -f1`
DU1MB=`perl -e 'printf "%.3f" , ('$DU1' / '1024')';`
INSTALL=`perl -e 'print ('$DU1' - '$DU1PREV')';`
INSTALLMB=`perl -e 'printf "%.3f" , ('$DU1MB' - '$DU1MBPREV')';`

View file

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- $Id$ -->
<!-- Extracts minimal versions from LFS book host requirements,
and generates a script containing statements of the
form MIN_prog_VERSION=xx.yy.zz.

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

@ -1,37 +1,65 @@
#!/bin/bash
# $Id$
#----------------------------#
get_book() { #
#----------------------------#
cd $JHALFSDIR
if [ -z "$WORKING_COPY" ] ; then
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.\"
exit 1"
case $PROGNAME in
lfs | hlfs)
test `type -p svn` || eval "echo \"This feature requires Subversion.\"
exit 1"
;;
clfs*)
test `type -p git` || eval "echo \"This feature requires Git.\"
exit 1"
;;
esac
echo -n "Downloading the lfs document, branch/tag/commit: $COMMIT... "
echo -n "Downloading the $PROGNAME document, $LFSVRS version... "
case $PROGNAME in
lfs) svn_root="LFS" ;;
hlfs) svn_root="HLFS" ;;
clfs*) ;;
*) 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
if [ $PROGNAME == "lfs" ] || [ $PROGNAME == "hlfs" ] &&
[ ! -d ${PROGNAME}-${LFSVRS}/.svn ]; then
svn co $SVN/${svn_root}/${TREE} ${PROGNAME}-$LFSVRS >>$LOGDIR/$LOG 2>&1
elif [ $PROGNAME == "clfs" ] || [ $PROGNAME == "clfs2" ] ||
[ $PROGNAME == "clfs3" ] && [ ! -d ${PROGNAME}-${LFSVRS}/.git ]; then
echo $TREE
git clone $GIT ${PROGNAME}-$LFSVRS >>$LOGDIR/$LOG 2>&1
if [ ! $TREE == "development" ]; then
pushd ${PROGNAME}-$LFSVRS > /dev/null
echo "Checking out $LFSVRS at $PWD in $TREE"
git checkout ${TREE} >>$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
fi
cd ${PROGNAME}-$LFSVRS
case $PROGNAME in
clfs*)
# If the repo is in "detached head" state, git pull fails, so get
# back first to master:
git checkout master >>$LOGDIR/$LOG 2>&1
git pull >>$LOGDIR/$LOG 2>&1
if [ ! $TREE == "development" ]; then
git checkout ${TREE} >>$LOGDIR/$LOG 2>&1
fi
;;
lfs | hlfs) svn up >>$LOGDIR/$LOG 2>&1 ;;
*) ;;
esac
fi
echo -ne "done\n"
@ -45,136 +73,205 @@ extract_commands() { #
#----------------------------#
cd $JHALFSDIR
case $PROGNAME in
clfs*)
VERSION=$(xmllint --noent $BOOK/BOOK/prologue/$ARCH/bookinfo.xml 2>/dev/null | grep subtitle | sed -e 's/^.*ion //' -e 's/<\/.*//') ;;
lfs)
if [ "$INITSYS" = "sysv" ] ; then
VERSION=$(grep 'ENTITY version ' $BOOK/general.ent| cut -d\" -f2)
else
VERSION=$(grep 'ENTITY versiond' $BOOK/general.ent| cut -d\" -f2)
fi
;;
*)
VERSION=$(xmllint --noent $BOOK/prologue/bookinfo.xml 2>/dev/null | grep subtitle | sed -e 's/^.*ion //' -e 's/<\/.*//') ;;
esac
# Clean
rm -rf "$COMMANDS"
rm -rf ${PROGNAME}-commands
# Extract the commands
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
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 \
--stringparam x86 $TARGET \
--stringparam mips $TARGET \
-o ./${PROGNAME}-commands/ \
$XSL \
$BOOK/BOOK/$ARCH-index.xml >>$LOGDIR/$LOG 2>&1
;;
if [ "$ALL_CORES" = "y" ]; then
JOBS="\$(nproc)"
else
JOBS="$N_PARALLEL"
fi
if [ "$REALSBU" = y ]; then JOBSBP1=1; else JOBSBP1="$JOBS"; fi
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 \
--output ./${PROGNAME}-commands/ \
$XSL \
$BOOK/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
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 \
--output ./${PROGNAME}-commands/ \
$XSL \
$BOOK/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 \
--output ./${PROGNAME}-commands/ \
$XSL \
$BOOK/index.xml >>$LOGDIR/$LOG 2>&1
;;
lfs)
echo -n " ${L_arrow}${BOLD}LFS${R_arrow} build... "
pushd $BOOK > /dev/null
if [ -f process-scripts.sh ]; then
bash process-scripts.sh >> $LOGDIR/$LOG 2>&1
fi
popd > /dev/null
xsltproc --nonet \
--xinclude \
--stringparam revision $INITSYS \
--stringparam testsuite $TEST \
--stringparam bomb-testsuite $BOMB_TEST \
--stringparam vim-lang $VIMLANG \
--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 \
--output ./${PROGNAME}-commands/ \
$XSL \
$BOOK/index.xml >> $LOGDIR/$LOG 2>&1
;;
*) echo -n " ${L_arrow}${PROGNAME}${R_arrow} book invalid, terminate build... "
exit 1 ;;
esac
# 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
chmod -R +x $JHALFSDIR/${PROGNAME}-commands
# 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/')
# Create the packages file. We need it for proper Makefile creation
create_package_list
create_chroot_scripts
# Done. Moving on...
get_sources
}
#----------------------------#
create_chroot_scripts() { #
create_package_list() { #
#----------------------------#
rm -rf chroot-scripts
# Create the packages file. We need it for proper Makefile creation
rm -f pkg_tarball_list
echo -n "Creating <${PROGNAME}> list of tarball names for $BOOK"
if [ ! -z $ARCH ] ; then echo -n " $ARCH" ; fi
echo -n "... "
case ${PROGNAME} in
clfs*)
xsltproc --nonet --xinclude \
-o pkg_tarball_list \
packages.xsl \
$BOOK/BOOK/materials/${ARCH}-chapter.xml >>$LOGDIR/$LOG 2>&1
;;
hlfs)
xsltproc --nonet --xinclude \
--stringparam model $MODEL \
--stringparam kernel $KERNEL \
--output pkg_tarball_list \
packages.xsl \
$BOOK/chapter04/chapter04.xml >>$LOGDIR/$LOG 2>&1
;;
lfs)
xsltproc --nonet --xinclude \
--stringparam pkgmngt $PKGMNGT \
--stringparam revision $INITSYS \
--output pkg_tarball_list \
packages.xsl \
$BOOK/chapter03/chapter03.xml >>$LOGDIR/$LOG 2>&1
;;
*)
esac
echo "done"
}
#----------------------------#
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
case ${PROGNAME} in
clfs*)
xsltproc --nonet --xinclude \
-o chroot-scripts/ chroot.xsl \
$BOOK/BOOK/${ARCH}-index.xml >> $LOGDIR/$LOG 2>&1
;;
hlfs)
xsltproc --nonet --xinclude \
-o chroot-scripts/ chroot.xsl \
$BOOK/index.xml >> $LOGDIR/$LOG 2>&1
;;
lfs)
xsltproc --nonet --xinclude \
-o chroot-scripts/ chroot.xsl \
$BOOK/chapter06/chapter06.xml >> $LOGDIR/$LOG 2>&1
;;
*)
esac
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,8 +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=" "
declare -r spaceSTR=" "
shopt -s extglob #needed for ${x##*(0)} below
@ -50,12 +51,10 @@ 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+"
# echo -ne "$TXT:\t${L_arrow}${BOLD}${tst_version}${OFF}${R_arrow}"
IFS=".-(pab" # Split up w.x.y.z as well as w.x.y-rc (catch release candidates)
set -- $ref_version # set positional parameters to minimum ver values
ref_major=$1; ref_minor=$2; ref_revision=$3
#
@ -67,22 +66,23 @@ inline_doc
#
# Compare against minimum acceptable version..
(( major > ref_major )) &&
echo " ${spaceSTR1:${#tst_version}}${GREEN}OK${OFF} (Min version: ${ref_version})" &&
echo " ${spaceSTR:${#tst_version}}${GREEN}OK${OFF} (Min version: ${ref_version})" &&
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})" &&
echo " ${spaceSTR:${#tst_version}}${GREEN}OK${OFF} (Min version: ${ref_version})" &&
return
# minor=ref_minor
(( revision >= ref_revision )) &&
echo " ${spaceSTR1:${#tst_version}}${GREEN}OK${OFF} (Min version: ${ref_version})" &&
echo " ${spaceSTR:${#tst_version}}${GREEN}OK${OFF} (Min version: ${ref_version})" &&
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() { #
@ -95,7 +95,7 @@ check_prerequisites() { #
local LC_ALL=C
export LC_ALL
# LFS prerequisites
# LFS/HLFS/CLFS prerequisites
if [ -n "$MIN_Linux_VER" ]; then
check_version "$MIN_Linux_VER" "`uname -r`" "KERNEL"
fi
@ -103,10 +103,10 @@ check_prerequisites() { #
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++"
check_version "$MIN_GCC_VER" "`gcc -dumpversion`" "GCC"
check_version "$MIN_GCC_VER" "`g++ -dumpversion`" "G++"
elif [ ! -z $MIN_Gcc_VER ]; then
check_version "$MIN_Gcc_VER" "`gcc -dumpfullversion -dumpversion`" "GCC"
check_version "$MIN_Gcc_VER" "`gcc -dumpversion`" "GCC"
fi
if [ -n "$MIN_Glibc_VER" ]; then
check_version "$MIN_Glibc_VER" "$(ldd --version | head -n1 | awk '{print $NF}')" "GLIBC"
@ -163,9 +163,6 @@ check_prerequisites() { #
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
}
#----------------------------#
@ -230,12 +227,23 @@ inline_doc
echo "${nl_}\"${RED}xsltproc${OFF}\" ${BOLD}must be installed on your system for jhalfs to run"
exit 1
fi
}
#----------------------------#
check_blfs_tools() { #
#----------------------------#
: << inline_doc
In addition to the tools needed for the LFS part, docbook-xml
is needed for installing the BLFS tools
inline_doc
# Avoid translation of version strings
local LC_ALL=C
export LC_ALL
# 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'?>
<?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 +254,10 @@ inline_doc
</sect1>
</article>"
if echo $XML_FILE | xmllint -nonet -noout -postvalid - 2>/dev/null ; then
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 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
echo "Error: you need the Docbook XML DTD for installing BLFS tools"
exit 2
fi
}

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,19 +53,18 @@ 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 FARCELOGDIR=/${SCRIPT_ROOT}/logs/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_copy_files "$PRUNEPATH" $ROOT_DIR $DEST_ICA/$ITERATION >>logs/\$@ 2>&1 && \\
extras/do_ica_prep $DEST_ICA/$ITERATION >>logs/\$@ 2>&1
EOF
) >> $MKFILE.tmp
@ -73,6 +72,19 @@ EOF
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 >>logs/\$@ 2>&1 && \\
extras/filelist $DEST_FARCE/$ITERATION $DEST_FARCE/filelist-$ITERATION >>logs/\$@ 2>&1
EOF
) >> $MKFILE.tmp
if [[ "$ITERATION" != "iteration-1" ]] ; then
wrt_do_farce_work "$PREV_IT" "$ITERATION" "$DEST_FARCE"
fi
fi
}
#----------------------------------#
@ -81,6 +93,17 @@ wrt_do_ica_work() { #
echo -e "\t@extras/do_ica_work $1 $2 $ICALOGDIR $3 >>logs/\$@ 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 >>logs/\$@ 2>&1" >> $MKFILE.tmp
}
#----------------------------------#
wrt_logs() { #
#----------------------------------#
@ -97,12 +120,12 @@ wrt_logs() { #
for file in \`ls .\` ; do \\
mv -f \$\$file \`echo \$\$file | sed -e 's,-$build,,'\` ; \\
done ; \\
fi
fi ;
@cd /\$(SCRIPT_ROOT)
@if [ -d test-logs ] ; then \\
cd test-logs && \\
mkdir $build && \\
mv -f `echo ${system_build} | sed 's/ /* /g'`* $build && \\
mv -f ${system_build} $build && \\
if [ ! $build = build_1 ] ; then \\
cd $build && \\
for file in \`ls .\` ; do \\

View file

@ -1,5 +1,7 @@
#!/bin/bash
# $Id$
#----------------------------------#
wrt_CustomTools_target() { # Add any users supplied scripts
#----------------------------------#
@ -22,8 +24,16 @@ wrt_CustomTools_target() { # Add any users supplied scripts
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}"
case $PROGNAME in
clfs2 | clfs3 )
LUSER_wrt_target "${this_script}" "$PREV"
LUSER_wrt_RunAsUser "custom-tools/${this_script}"
;;
*)
CHROOT_wrt_target "${this_script}" "$PREV"
CHROOT_wrt_RunAsRoot "custom-tools/${this_script}"
;;
esac
wrt_touch
# Create the build script file
@ -38,11 +48,22 @@ xEOFx
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
case $PROGNAME in
clfs2 | clfs3 )
LUSER_wrt_target "${this_script}" "$PREV"
LUSER_wrt_unpack "${PKG_FILE}"
LUSER_wrt_RunAsUser "custom-tools/${this_script}"
LUSER_RemoveBuildDirs "${PKG}"
echo -e "\t@touch \$(MOUNT_PT)$TRACKING_DIR/${PKG}-${PKG_VERSION}" >> $MKFILE.tmp
;;
*)
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
;;
esac
wrt_touch
# Create the build script file
@ -72,6 +93,7 @@ xEOFx
#----------------------------------#
add_CustomToolsURLS() { # Add any users supplied scripts URL information
#----------------------------------#
local BLFS_SERVER="${SERVER}/pub/blfs/conglomeration/"
local this_script
local URL PKG PKG_VERSION PKG_FILE MD5
@ -85,10 +107,10 @@ add_CustomToolsURLS() { # Add any users supplied scripts URL informat
# A cmd only script had no PKG defined
[[ "x${PKG}" = "x" ]] && continue
echo "${URL} ${MD5}" >> urls.lst.tmp
echo "${URL} ${BLFS_SERVER}${PKG}/${PKG_FILE} ${MD5}" >> urls.lst.tmp
# Add any patches..
for PATCH in PATCH{1..10}; do
[[ -n ${!PATCH} ]] && echo "${!PATCH} CUSTOM-PATCH-MD5SUM" >> urls.lst.tmp
[[ -n ${!PATCH} ]] && echo "dummy-url ${!PATCH}" >> urls.lst.tmp
done
done
cat urls.lst.tmp >> $BUILDDIR/sources/urls.lst

View file

@ -1,13 +1,13 @@
#!/bin/bash
# $Id$
#----------------------------#
get_sources() { # Download file, write name to MISSING_FILES.DMP if an error
#----------------------------#
# Test if the packages must be downloaded
[ "$GETPKG" = y ] || return 0
local URL FILE BOOKMD5 MD5 HAVEMD5 fromARCHIVE WGETPARAM MAYBEMORE
local saveIFS=$IFS
local IFS line URL1 URL2 FILE BOOKMD5 MD5 HAVEMD5 fromARCHIVE WGETPARAM
WGETPARAM=""
if [[ "${RETRYSRCDOWNLOAD}" = "y" ]] ; then
@ -16,6 +16,9 @@ get_sources() { # Download file, write name to MISSING_FILES.DMP if
WGETPARAM+=" --tries ${RETRYDOWNLOADCNT}"
WGETPARAM+=" --timeout ${DOWNLOADTIMEOUT}"
# Test if the packages must be downloaded
[ ! "$GETPKG" = "y" ] && return
gs_wrt_message(){
echo "${RED}$1${OFF}"
echo "$1" >> MISSING_FILES.DMP
@ -23,44 +26,59 @@ get_sources() { # Download file, write name to MISSING_FILES.DMP if
# Housekeeping
[[ ! -d $BUILDDIR/sources ]] && mkdir $BUILDDIR/sources
cd $BUILDDIR/sources
# If using CLFS, /sources is writable by all, but with sticky bit,
# and user does not hold MD5SUMS nor the other files, so use sudo
[[ -f MD5SUMS ]] && sudo rm MD5SUMS
[[ -f MISSING_FILES.DMP ]] && sudo rm MISSING_FILES.DMP
[[ -f urls.lst ]] && sudo 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
*/tree* | */gcc-testsuite* ) #unneeded now?
[[ "$TEST" = "0" ]] && continue
;;
*/vim-*-lang* )
[[ "$VIMLANG" = "0" ]] && 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
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}"
# If the file does not exist yet in /sources download a fresh one
if [ ! -f $FILE ] ; then
if [[ ! ("$SRC_ARCHIVE" = "") ]] ; then
echo "${BOLD}${YELLOW}$FILE: not found in ${SRC_ARCHIVE} or ${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 ! wget $URL1 $WGETPARAM && ! wget $URL2 $WGETPARAM ; then
gs_wrt_message "$FILE not found in the SRC_ARCHIVE or on any server..SKIPPING"
continue
fi
else
@ -68,22 +86,22 @@ get_sources() { # Download file, write name to MISSING_FILES.DMP if
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
# Deal with udev and bootscripts m5sum issue
[[ $BOOKMD5 = "BOOTSCRIPTS-MD5SUM" ]] && continue
[[ $BOOKMD5 = "UDEV-MD5SUM" ]] && continue
[[ $BOOKMD5 = "LFS-NETSCRIPTS-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 $WGETPARAM && ! wget $URL1 $WGETPARAM ; then
gs_wrt_message "$FILE not found on the servers.. SKIPPING"
continue
fi
fi
@ -96,7 +114,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 +124,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,14 +147,42 @@ 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 \
urls.xsl \
$BOOK/BOOK/materials/$ARCH-chapter.xml >>$LOGDIR/$LOG 2>&1
echo " ...OK"
;;
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 \
urls.xsl \
$BOOK/chapter04/chapter04.xml >>$LOGDIR/$LOG 2>&1
echo " ...OK"
;;
lfs)
echo -n "Creating LFS specific URLs file"
xsltproc --nonet --xinclude \
--stringparam server $SERVER \
--stringparam family lfs \
--stringparam pkgmngt $PKGMNGT \
--stringparam revision $INITSYS \
--output ../sources/urls.lst \
urls.xsl \
$BOOK/chapter03/chapter03.xml >>$LOGDIR/$LOG 2>&1
echo " ...OK"
;;
esac
cd $BUILDDIR/sources

View file

@ -1,27 +1,35 @@
#!/bin/bash
# $Id$
#----------------------------# 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}"
}
[[ ! -d ${BUILDDIR}${BLFS_ROOT} ]] && mkdir -pv ${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/' \
sed -e 's/PKGDIR/UNPACKDIR/' \
-e 's/PKG_DEST/PKG_DIR/' \
$PKGMNGTDIR/packInstall.sh > ${BUILDDIR}${BLFS_ROOT}/packInstall.sh
fi
# Clean-up
make -C ${BUILDDIR}${BLFS_ROOT}/menu clean
rm -rf ${BUILDDIR}${BLFS_ROOT}/libs/.svn
rm -rf ${BUILDDIR}${BLFS_ROOT}/xsl/.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@tracking-dir@$TRACKING_DIR@ \
${BUILDDIR}${BLFS_ROOT}/{Makefile,gen-makefile.sh,gen_pkg_book.sh}
${BUILDDIR}${BLFS_ROOT}/{Makefile,gen-makefile.sh}
sed -i s@trunk/BOOK@$BLFS_TREE@ \
${BUILDDIR}${BLFS_ROOT}/Makefile
# If we have a working copy, copy it:
if [[ "$BLFS_WORKING_COPY" = "y" ]]; then
@ -30,46 +38,18 @@ echo "copying the local BLFS working copy (may take some time)"
# 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
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} \
sudo make -j1 -C $BUILDDIR$BLFS_ROOT \
REV=$INITSYS \
TRACKING_DIR=$BUILDDIR$TRACKING_DIR \
$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
@ -111,47 +91,40 @@ if [ "$DEP_GPM" = y ]; then
else
LINE_GPM='#CONFIG_gpm is not set'
fi
if [ "$DEP_GIT" = y ]; then
LINE_GIT='CONFIG_git=y'
if [ "$DEP_SVN" = y ]; then
LINE_SVN='CONFIG_subversion=y'
else
LINE_GIT='#CONFIG_git is not set'
LINE_SVN='#CONFIG_subversion is not set'
fi
if [ "$DEP_OPENSSL" = y ]; then
LINE_OPENSSL='CONFIG_openssl=y'
else
LINE_OPENSSL='#CONFIG_openssl is not set'
fi
if [ "$DEP_PYTHON" = y ]; then
LINE_PYTHON='CONFIG_python2=y'
else
LINE_PYTHON='#CONFIG_python2 is not set'
fi
cat >$BUILDDIR$BLFS_ROOT/configuration <<EOF
$LINE_OPENSSL
$LINE_PYTHON
$LINE_LIBXML
$LINE_LIBXSLT
$LINE_WGET
$LINE_GIT
$LINE_SVN
$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
yes "yes" | $BUILDDIR$BLFS_ROOT/gen_pkg_book.sh $BUILDDIR$BLFS_ROOT
# Move the scriptlets where they should be
sudo rm -rf $BUILDDIR$BLFS_ROOT/scripts
@ -160,17 +133,17 @@ 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
cp $PACKAGE $SRC_ARCHIVE
p}' \
-e '/|[ ]*md5sum/p' \
-e '/PACKAGE1=/,/^fi/{/^fi/a\
[ ! -f "$JH_SRC_ARCHIVE/$PACKAGE1" ] && cp $PACKAGE1 $JH_SRC_ARCHIVE
cp $PACKAGE1 $SRC_ARCHIVE
p}' \
-e '/PATCH=/,/^fi/{/^fi/a\
[ ! -f "$JH_SRC_ARCHIVE/$PATCH" ] && cp $PATCH $JH_SRC_ARCHIVE
cp $PACKAGE1 $SRC_ARCHIVE
p}' \
-e '/URL=/,/^fi/{/^fi/a\
[ ! -f "$JH_SRC_ARCHIVE/$BOOTPACKG" ] && cp $BOOTPACKG $JH_SRC_ARCHIVE
cp $PACKAGE1 $SRC_ARCHIVE
p}' \
$BUILDDIR$BLFS_ROOT/scripts/* >> $BUILDDIR$BLFS_ROOT/download_script
chmod u+x $BUILDDIR$BLFS_ROOT/download_script
@ -180,7 +153,8 @@ 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} \
FTP_SERVER=$SERVER/pub/blfs/ \
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 .
@ -196,7 +170,7 @@ if [ "$DEP_LIBXSLT" = y ]; then
# 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.
# Sorry for sed synthax.
sed -i '\@^[[:space:]]*/etc/xml/catalog$@{
n
:a
@ -210,6 +184,15 @@ fi
if [ "$DEP_SUDO" = y ]; then
sed -i '/cat.*pam.d/i mkdir -p /etc/pam.d' $BUILDDIR$BLFS_ROOT/scripts/*sudo
fi
if [ "$DEP_SVN" = y ]; then
sed -i -e /javahl/d -e /swig/d $BUILDDIR$BLFS_ROOT/scripts/*subversion
fi
if [ "$DEP_LYNX" = y ]; then
if [ "$DEP_OPENSSL" = y -o "$DEP_WGET" = y ]; then
sed -e 's/configure/& --with-ssl/' \
-i $BUILDDIR$BLFS_ROOT/scripts/*lynx
fi
fi
# At last generates the build Makefile
mkdir -p $BUILDDIR$BLFS_ROOT/work
pushd $BUILDDIR$BLFS_ROOT/work
@ -218,50 +201,19 @@ pushd $BUILDDIR$BLFS_ROOT/work
# 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 '/^all/s@$@ update@' \
-e 's/touch/@touch/' Makefile
cat >> Makefile << EOF
update: all
update:
@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/'); \\
@for file in *-*; do \\
xsltproc --stringparam packages ../packages.xml \\
--stringparam package LFS-Release \\
--stringparam version \$\$VERSION \\
-o track.tmp \\
../xsl/bump.xsl \$(TRACKING_FILE); \\
--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; \\
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

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,49 @@ 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 \
SERVER RETRYSRCDOWNLOAD RETRYDOWNLOADCNT DOWNLOADTIMEOUT \
RUNMAKE"
local -r BUILD_chroot="TEST STRIP"
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 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"
local -r LFS_build="$BUILD_chroot VIMLANG $BUILD_common PKGMNGT FULL_LOCALE WRAP_INSTALL"
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"
# System Settings by book
local -r LFS_system="HOSTNAME INTERFACE IP_ADDR GATEWAY PREFIX BROADCAST DOMAIN DNS1 DNS2 FONT KEYMAP LOCAL LOG_LEVEL"
# System Settings by book (only LFS for now)
local -r LFS_system="HOSTNAME INTERFACE IP_ADDR GATEWAY PREFIX BROADCAST DOMAIN DNS1 DNS2 FONT CONSOLE_MAP UNICODE KEYMAP"
# 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 lfs_PARAM_LIST="$LFS_book $GENERAL_common $LFS_build $LFS_system $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 \
BLFS_TREE BLFS_BRANCH_ID BLFS_ROOT BLFS_XML TRACKING_DIR \
DEP_LIBXML DEP_LIBXSLT DEP_DBXML DEP_LYNX DEP_SUDO DEP_WGET \
DEP_GIT DEP_GPM"
DEP_SVN DEP_GPM DEP_OPENSSL DEP_PYTHON"
local -r custom_tool_PARAM_LIST="TRACKING_DIR"
# Internal variables
@ -121,19 +141,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`" ;;
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`" ;;
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`" ;;
# Envars that requires some validation
LUSER) echo -e "`eval echo $PARAM_VALS`"
@ -154,7 +176,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 +188,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!" &&
@ -203,7 +225,7 @@ inline_doc
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 ===
#----------------------------------#
@ -25,26 +27,24 @@ SCRIPT_ROOT = $SCRIPT_ROOT
BASEDIR = \$(MOUNT_PT)
SRCSDIR = \$(BASEDIR)/sources
CMDSDIR = \$(BASEDIR)/\$(SCRIPT_ROOT)/$COMMANDS
CMDSDIR = \$(BASEDIR)/\$(SCRIPT_ROOT)/$PROGNAME-commands
LOGDIR = \$(BASEDIR)/\$(SCRIPT_ROOT)/$LOGDIRBASE
TESTLOGDIR = \$(BASEDIR)/\$(SCRIPT_ROOT)/$TESTLOGDIRBASE
crCMDSDIR = /\$(SCRIPT_ROOT)/$COMMANDS
crCMDSDIR = /\$(SCRIPT_ROOT)/$PROGNAME-commands
crLOGDIR = /\$(SCRIPT_ROOT)/$LOGDIRBASE
crTESTLOGDIR = /\$(SCRIPT_ROOT)/$TESTLOGDIRBASE
crFILELOGDIR = /\$(SCRIPT_ROOT)/$FILELOGDIRBASE
SU_LUSER = sudo -H -u \$(LUSER) sh -c
SU_LUSER = sudo -u \$(LUSER) -i 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"
PRT_DU_CR = echo -e "\nKB: \`du -skx --exclude=\$(SCRIPT_ROOT) --exclude=lost+found / \`\n"
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
@ -58,6 +58,102 @@ EOF
#=======================
#==== PACKAGES NAMES AND VERSIONS ====
#----------------------------------#
get_package_tarball_name() { #
#----------------------------------#
local script_name=`echo ${1} | sed -e 's@^[0-9]\{1\}-@@'`
# The use of 'head' is necessary to limit the return value to the FIRST match..
# hopefully this will not cause problems.
#
case $script_name in
tcl) echo $(grep "^tcl" $JHALFSDIR/pkg_tarball_list | head -n1 )
;;
iputils) echo $(grep "^iputils" $JHALFSDIR/pkg_tarball_list | head -n1 )
;;
powerpc-utils) echo $(grep "^powerpc-utils" $JHALFSDIR/pkg_tarball_list | head -n1 )
;;
uClibc)
if [[ "${PROGNAME}" = "clfs3" ]]; then
echo $(grep "^uClibc-" $JHALFSDIR/pkg_tarball_list | head -n1 )
else
echo $(grep "^$script_name-[[:digit:]]" $JHALFSDIR/pkg_tarball_list | head -n1 )
fi
;;
linux-headers)
if [[ "${PROGNAME}" = "lfs" ]] || [[ "${PROGNAME}" = "hlfs" ]] || [[ "${PROGNAME}" = "clfs" ]]; then
# Uses kernel headers directly
echo $(grep "^linux-[[:digit:]]" $JHALFSDIR/pkg_tarball_list | head -n1 )
else
# CLFS{2,3} used to use massaged headers package
# echo $(grep "^linux-headers-[[:digit:]]" $JHALFSDIR/pkg_tarball_list | head -n1 )
echo $(grep "^linux-[[:digit:]]" $JHALFSDIR/pkg_tarball_list | head -n1 )
fi
;;
expect) echo $(grep "^expect" $JHALFSDIR/pkg_tarball_list | head -n1 )
;;
e2fsprogs-libs) echo $(grep "^e2fsprogs" $JHALFSDIR/pkg_tarball_list | head -n1 )
;;
libcap) echo $(grep "^libcap" $JHALFSDIR/pkg_tarball_list | head -n1 )
;;
util-linux-libs | util-linux-pass1) echo $(grep "^util-linux" $JHALFSDIR/pkg_tarball_list | head -n1 )
;;
xz-utils) echo $(grep "^xz" $JHALFSDIR/pkg_tarball_list | head -n1 )
;;
sqlite) echo $(grep "^sqlite" $JHALFSDIR/pkg_tarball_list | head -n1 )
;;
udev) echo $(grep "^systemd" $JHALFSDIR/pkg_tarball_list | head -n1 )
;;
xml-parser) echo $(grep "^XML" $JHALFSDIR/pkg_tarball_list | head -n1 )
;;
libdbus) echo $(grep "^dbus" $JHALFSDIR/pkg_tarball_list | head -n1 )
;;
*) echo $(grep "^$script_name[_-][[:digit:]]" $JHALFSDIR/pkg_tarball_list | head -n1 )
;;
esac
}
#----------------------------------#
get_package_version() { #
#----------------------------------#
# Those hacks may change depending on the invention of devs for tarball names.
# Normally, we expect -digit to signal the beginning of the version field
# but it may happen that there is no '-' (tcl, expect), that the version
# field is ddd-d (pkg-config-lite-028-1, since sed is greedy, it finds only
# the second dash) or that the first character of the version is not a digit
# (iputils-s20121221)...
case ${1} in
tcl*|expect*|tzdata*|xmlts*|unzip*|lynx*)
echo ${1} | sed -e 's@^[^[:digit:]]*@@' \
-e 's@\(-src\)*\.tar.*@@'
;;
iputils*) echo ${1} | sed -e 's@^.*-@@' \
-e 's@\.tar.*@@'
;;
LVM*) echo ${1} | sed -e 's@^[^.]*\.@@' \
-e 's@\.tgz.*@@'
;;
iproute*) echo ${1} | sed -e 's@^[^-]*-@@' \
-e 's@\.tar.*@@'
;;
pkg*|udev*|Singular*|XML*)
echo ${1} | sed -e 's@^.*[a-z]-\([[:digit:]]\)@\1@' \
-e 's@\.tar.*@@' \
-e 's@\.zip.*@@'
;;
*) echo ${1} | sed -e 's@^.*[-_]\([[:digit:]]\)@\1@' \
-e 's@\.tar.*@@' \
-e 's@\.zip.*@@'
;;
esac
}
#=======================
#==== TARGET HEADER ====
#----------------------------------#
@ -76,7 +172,7 @@ $i: $PREV
@\$(call echo_message, Building)
${NO_PROGRESS} @export BASHBIN=\$(SHELL) && \$(SHELL) progress_bar.sh \$@ \$\$PPID &
@echo "\$(nl_)\`date\`\$(nl_)" >logs/\$@$version
@ : > envars
@\$(PRT_DU) >>logs/\$@$version
EOF
) >> $MKFILE.tmp
}
@ -97,7 +193,7 @@ $i: $PREV
@\$(call echo_message, Building)
${NO_PROGRESS} @export BASHBIN=\$(SHELL) && \$(SHELL) progress_bar.sh \$@ \$\$PPID &
@echo "\$(nl_)\`date\`\$(nl_)" >logs/\$@$version
@ : > envars
@\$(PRT_DU_CR) >>logs/\$@$version
EOF
) >> $MKFILE.tmp
}
@ -110,12 +206,8 @@ EOF
#----------------------------------#
LUSER_wrt_unpack() { # Unpack and set 'ROOT' var
#----------------------------------#
local FILE="$1"
local optSAVE_PREVIOUS="$2"
local version
if [ "$3" != "" ]; then
version=-"$3"
fi
local FILE=$1
local optSAVE_PREVIOUS=$2
if [[ "${optSAVE_PREVIOUS}" != "1" ]]; then
(
@ -127,7 +219,6 @@ EOF
(
cat << EOF
@\$(PRT_DU) >>logs/\$@$version
@\$(call unpack,$FILE)
@\$(call get_pkg_root_LUSER)
EOF
@ -139,10 +230,6 @@ CHROOT_Unpack() { #
#----------------------------------#
local FILE=$1
local optSAVE_PREVIOUS=$2
local version
if [ "$3" != "" ]; then
version=-"$3"
fi
if [ "${optSAVE_PREVIOUS}" != "1" ]; then
(
@ -151,10 +238,8 @@ cat << EOF
EOF
) >> $MKFILE.tmp
fi
(
cat << EOF
@\$(PRT_DU_CR) >>logs/\$@$version
cat << EOF
@\$(call unpack2,$FILE)
@\$(call get_pkg_root2)
EOF
@ -213,10 +298,20 @@ wrt_RunAsRoot() { # Some scripts must be run as root..
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) && \\
${PROGNAME}-commands/`dirname $file`/\$@ >>logs/\$@$version 2>&1 && \\
\$(PRT_DU) >>logs/\$@$version
EOF
) >> $MKFILE.tmp
}
@ -233,7 +328,8 @@ LUSER_wrt_RunAsUser() { # Calculate time with perl, footer to log fil
(
cat << EOF
@source ~/.bashrc && \\
\$(CMDSDIR)/`dirname $file`/\$@ >> \$(LOGDIR)/\$@$version 2>&1
\$(CMDSDIR)/`dirname $file`/\$@ >> logs/\$@$version 2>&1 && \\
\$(PRT_DU) >>logs/\$@$version
EOF
) >> $MKFILE.tmp
}
@ -249,7 +345,8 @@ CHROOT_wrt_RunAsRoot() { #
(
cat << EOF
@source envars && \\
\$(crCMDSDIR)/`dirname $file`/\$@ >>\$(crLOGDIR)/\$@$version 2>&1
\$(crCMDSDIR)/`dirname $file`/\$@ >>logs/\$@$version 2>&1 && \\
\$(PRT_DU_CR) >>logs/\$@$version
EOF
) >> $MKFILE.tmp
@ -310,9 +407,10 @@ EOF
#----------------------------------#
LUSER_wrt_LogNewFiles() { #
#----------------------------------#
local name=`echo ${1} | sed 's/[0-9]-//'`
(
cat << EOF
@\$(call log_new_files_LUSER,$1)
@\$(call log_new_files_LUSER,$name)
EOF
) >> $MKFILE.tmp
}
@ -320,9 +418,10 @@ EOF
#----------------------------------#
CHROOT_wrt_LogNewFiles() { #
#----------------------------------#
local name=`echo ${1} | sed 's/[0-9]-//'`
(
cat << EOF
@\$(call log_new_files,$1)
@\$(call log_new_files,$name)
EOF
) >> $MKFILE.tmp
}

View file

@ -1,3 +1,6 @@
# $Id$
BOLD = ""
RED = ""
GREEN = ""
@ -31,21 +34,21 @@ 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 sudo will request a password in order to execute all high privilege commands
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
@ -112,9 +115,7 @@ define get_pkg_root2
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; \
echo "export -f wrapInstall" >> envars; \
fi;
endef
@ -182,7 +183,7 @@ define echo_report
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 file to $(BOLD)jhalfs-reports@linuxfromscratch.org$(WHITE) ; \
echo ; \
echo That will help us to keep more accurate SBU and ; \
echo disk usage values into the book. Thanks. ; \
@ -203,15 +204,21 @@ define echo_finished
@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,
@echo $(tab_) " /etc/hosts,"
@echo $(tab_) " /etc/sysconfig/clock,"
@echo $(tab_) " /etc/sysconfig/console,"
@echo $(tab_) " /etc/sysconfig/network,"
@echo $(tab_) " /etc/sysconfig/ifconfig.eth0,"
@echo $(tab_) " /etc/resolv.conf"
@echo $(tab_)and any other configuration file required to suit your needs.
@echo
@echo $(tab_)- Set-up the boot loader.
@echo $(tab_)- Set-up the boot loader, except if building CLFS with METHOD=boot.
@echo
@echo $(tab_)You can set-up the new boot-loader installed on the new system
@echo $(tab_)or the host bootloader.

View file

@ -1,10 +1,18 @@
<?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 libc model used for HLFS -->
<xsl:param name="model" select="'glibc'"/>
<!-- The kernel series used for HLFS -->
<xsl:param name="kernel" select="'2.6'"/>
<!-- Should we include a package manager? -->
<xsl:param name="pkgmngt" select="'n'"/>
@ -12,9 +20,7 @@
<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:apply-templates select="//para"/>
<xsl:if test="$pkgmngt='y'">
<xsl:apply-templates
select="document('packageManager.xml')//sect1[@id='package']//para"/>
@ -22,13 +28,21 @@
</xsl:template>
<xsl:template match="para">
<xsl:if test="contains(string(),'Download:') and
(ancestor::varlistentry[@condition=$model]
or not(ancestor::varlistentry[@condition])) and
(ancestor::varlistentry[@revision=$revision]
or not(ancestor::varlistentry[@revision])) and
(ancestor::varlistentry[@vendor=$kernel]
or not(ancestor::varlistentry[@vendor]))">
<xsl:call-template name="package_name">
<xsl:with-param name="url" select="ulink/@url"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
<xsl:template name="package_name">
<xsl:param name="url" select="'foo'"/>
<xsl:param name="url" select="foo"/>
<xsl:variable name="sub-url" select="substring-after($url,'/')"/>
<xsl:choose>
<xsl:when test="contains($sub-url,'/') and

View file

@ -1,4 +1,5 @@
# shellcheck shell=bash
# $Id$
set -e
@ -14,9 +15,11 @@ 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
@ -46,22 +49,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,10 +1,24 @@
<?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'"/>
<!-- Do we use a package manager? -->
<xsl:param name="pkgmngt" select="'n'"/>
@ -24,7 +38,11 @@
<!-- 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
<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') or
contains(@url, '.xz') or contains(@url, '.lzma')) and
not(ancestor-or-self::*/@condition = 'pdf')">
@ -34,6 +52,16 @@
<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,'?')">
@ -43,6 +71,49 @@
<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:when test="contains($dirname, 'iputils')">
<xsl:text>iputils/</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="../following-sibling::para/literal"/>

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,3 +1,6 @@
#
# $Id$
#
PKG="libffi"
PKG_VERSION="3.2.1"
PKG_FILE="libffi-3.2.1.tar.gz"

View file

@ -1,3 +1,6 @@
#
# $Id$
#
PKG="pcre"
PKG_VERSION="8.37"
PKG_FILE="pcre-8.37.tar.bz2"
@ -6,7 +9,7 @@ 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"
PATCH1="http://www.linuxfromscratch.org/patches/blfs/7.8/pcre-8.37-upstream_fixes-1.patch 718c4314fba52ed559c75ff7660cc391"
( cat << "xEOFx"
patch -Np1 -i ../pcre-8.37-upstream_fixes-1.patch &&

View file

@ -1,3 +1,6 @@
#
# $Id$
#
PKG="python3"
PKG_VERSION="3.4.3"
PKG_FILE="Python-3.4.3.tar.xz"

View file

@ -1,3 +1,6 @@
#
# $Id$
#
PKG="glib"
PKG_VERSION="2.44.1"
PKG_FILE="glib-2.44.1.tar.xz"

View file

@ -1,3 +1,6 @@
#
# $Id$
#
PKG="mc"
PKG_VERSION="4.8.14"
PKG_FILE="mc-4.8.14.tar.xz"

View file

@ -1,3 +1,6 @@
#
# $Id$
#
# 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.

View file

@ -1,3 +1,6 @@
#
# $Id$
#
# The OpenSSL package contains management tools and libraries
# relating to cryptography. These are useful for providing
# cryptography functions to other packages, notably OpenSSH,

View file

@ -1,18 +1,19 @@
#
# $Id$
#
PKG="gpm"
PKG_VERSION="1.20.7"
PKG_FILE="gpm-${PKG_VERSION}.tar.bz2"
URL="https://anduin.linuxfromscratch.org/BLFS/gpm/${PKG_FILE}"
URL="http://www.nico.schottelius.org/software/gpm/archives/${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 &&
./autogen.sh &&
./configure --prefix=/usr --sysconfdir=/etc &&
make
make install &&
@ -20,15 +21,14 @@ 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 -m755 -d /usr/share/doc/gpm-${PKG_FILE}/support &&
install -v -m644 doc/support/* \
/usr/share/doc/gpm-1.20.7/support &&
/usr/share/doc/gpm-${PKG_FILE}/support &&
install -v -m644 doc/{FAQ,HACK_GPM,README*} \
/usr/share/doc/gpm-1.20.7
/usr/share/doc/gpm-${PKG_FILE}
# The normal cmd to install the boot script for gpm
# --- PUT THIS CMD INSIDE 999-blfs_bootscripts

View file

@ -1,3 +1,6 @@
#
# $Id$
#
# Lynx is a text based web browser.
#

View file

@ -1,3 +1,6 @@
#
# $Id$
#
# 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.

View file

@ -1,3 +1,5 @@
#
# $Id$
# NASM (Netwide Assembler) is an 80x86 assembler designed
# for portability and modularity. It includes a
# disassembler as well.

View file

@ -1,3 +1,6 @@
#
# $Id$
#
# 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

View file

@ -1,3 +1,6 @@
#
# $Id$
#
PKG="blfs-bootscripts"
PKG_VERSION="20150924"
PKG_FILE="blfs-bootscripts-${PKG_VERSION}.tar.bz2"

View file

@ -0,0 +1,49 @@
#
# $Id$
#
# Code taken from CLFS-Embedded
# Chapter 12 Beyond CLFS Embedded
#
# Dropbear is a relatively small SSH 2 server and client.
# Dropbear has a small memory footprint suitable for memory-constrained
# environments, while still having the same features as OpenSSH. It
# does not depend on OpenSSL and it has a MIT style license. Optionally
# it can even be made smaller.
#
PKG="DROPBEAR"
PKG_VERSION="0.48.1"
PKG_FILE="${PKG}-${PKG_VERSION}.tar.gz"
URL="http://matt.ucc.asn.au/dropbear/releases/${PKG_FILE}"
MD5="ca8e53a766faec831882831364568421"
for i in PATCH{1..10}; do
unset $i
done
PATCH1="http://svn.cross-lfs.org/svn/repos/cross-lfs/branches/clfs-embedded/patches/dropbear-0.48.1-autotool-1.patch"
( cat << "xEOFx"
patch -Np1 -i ../dropbear-0.48.1-autotool-1.patch
cp Makefile.in{,.orig}
sed -e s/@LD@/@CC@/ Makefile.in.orig > Makefile.in
CC="${CC} ${BUILD}" ./configure --prefix=/usr --host=${CLFS_TARGET}
cp -v options.h options.h.backup
sed -e "s@/dev/random@/dev/urandom@" options.h.backup > options.h
make MULTI=1 PROGRAMS="dropbear dbclient dropbearkey dropbearconvert scp"
make MULTI=1 PROGRAMS="dropbear dbclient dropbearkey dropbearconvert scp" install DESTDIR=${CLFS}
ln -svf ../../usr/bin/dropbearmulti ${CLFS}/usr/sbin/dropbear
ln -svf ../../usr/bin/dropbearmulti ${CLFS}/usr/bin/dbclient
ln -svf ../../usr/bin/dropbearmulti ${CLFS}/usr/bin/dropbearkey
ln -svf ../../usr/bin/dropbearmulti ${CLFS}/usr/bin/dropbearconvert
ln -svf ../../usr/bin/dropbearmulti ${CLFS}/usr/bin/scp
install -dv ${CLFS}/etc/ssh
xEOFx
) > tmp

View file

@ -0,0 +1,42 @@
#
# $Id$
#
# Code taken from CLFS-Embedded
# Chapter 12 Beyond CLFS Embedded
#
# iptables is the userspace command line program
# used to configure the Linux firewall.
#
PKG="iptables"
PKG_VERSION="1.3.7"
PKG_FILE="${PKG}-${PKG_VERSION}.tar.bz2"
URL=" http://www.netfilter.org/projects/iptables/files/iptables-1.3.7.tar.bz2"
MD5="077e886a9c90a11bb47f3d7a4fc4a689"
for i in PATCH{1..10}; do
unset $i
done
PATCH1="http://svn.cross-lfs.org/svn/repos/cross-lfs/branches/clfs-embedded/patches/iptables-1.3.7-do_multi-1.patch"
( cat << "xEOFx"
patch -Np1 -i ../iptables-1.3.7-do_multi-1.patch
make CC="${CC} ${BUILD}" \
COPT_FLAGS="-Os" \
LD=${LD} DO_MULTI=1 \
PREFIX=/usr \
KERNEL_DIR=${CLFS}/lib/modules/2.6.19.2/build \
LIBDIR=/lib \
BINDIR=/sbin
make CC="${CC} ${BUILD}" \
COPT_FLAGS="-Os" \
LD=${LD} DO_MULTI=1 \
PREFIX=/usr \
KERNEL_DIR=${CLFS}/lib/modules/2.6.19.2/build \
LIBDIR=/lib BINDIR=/sbin \
DESTDIR=${CLFS} install
xEOFx
) > tmp

View file

@ -1,3 +1,6 @@
#
# $Id$
#
# Any comments you wish to add
#
@ -10,16 +13,8 @@ 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,19 +1,17 @@
#!/bin/bash
# $Id$
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)
(default /var/lib/jhalfs/BLFS)
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)
BLFS_BRANCH_ID: development, branch-xxx, xxx (where xxx is a valid tag)
(default development)
INITSYS : which book do you want? 'sysv' or 'systemd' (default sysv)
Examples:
1 - If you plan to use the tools to build BLFS on top of LFS, but you did not
use jhalfs, or forgot to include the jhalfs-blfs tools:
@ -67,14 +65,13 @@ fi
if [ "$BOOK_BLFS" = y ]; then
## Read variables and sanity checks
[[ "$BRANCH" = y ]] && BLFS_COMMIT=$COMMIT
[[ "$relSVN" = y ]] && BLFS_BRANCH_ID=development
[[ "$BRANCH" = y ]] && BLFS_BRANCH_ID=$BRANCH_ID
[[ "$WORKING_COPY" = y ]] && BLFS_BOOK=$BOOK
[[ "$BRANCH_ID" = "**EDIT ME**" ]] &&
echo You have not set the book version or branch && exit 1
[[ "$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
echo You have not set the working copy location && exit 1
fi
COMMON_DIR="common"
@ -84,22 +81,15 @@ 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_BRANCH_ID=${BLFS_BRANCH_ID:=development}
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"
PARAMS="BLFS_ROOT TRACKING_DIR INITSYS BLFS_XML"
if [ "$WORKING_COPY" = y ]; then
PARAMS="$PARAMS WORKING_COPY BLFS_BOOK"
PARAMS="$PARAMS WORKING_COPY 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"
PARAMS="$PARAMS BLFS_BRANCH_ID"
fi
# Format for displaying parameters:
declare -r PARAM_VALS='${config_param}${dotSTR:${#config_param}} ${L_arrow}${BOLD}${!config_param}${OFF}${R_arrow}'
@ -118,20 +108,27 @@ fi
[[ $VERBOSITY > 0 ]] && echo "${SD_BORDER}${nl_}"
#*******************************************************************#
[[ $VERBOSITY > 0 ]] && echo -n "Loading function <func_check_version.sh> ..."
[[ $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 "OK"
[[ $VERBOSITY > 0 ]] && echo "${SD_BORDER}${nl_}"
case $BLFS_BRANCH_ID in
development ) BLFS_TREE=trunk/BOOK ;;
branch-* ) BLFS_TREE=branches/${BLFS_BRANCH_ID#branch-} ;;
* ) BLFS_TREE=tags/${BLFS_BRANCH_ID} ;;
esac
# Check for build prerequisites.
echo
check_alfs_tools
check_blfs_tools
echo "${SD_BORDER}${nl_}"
# Install the files
[[ $VERBOSITY > 0 ]] && echo -n "Populating the ${BUILDDIR}${BLFS_ROOT} directory "
[[ $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}
@ -141,14 +138,18 @@ cp README.BLFS ${BUILDDIR}${BLFS_ROOT}
[[ $VERBOSITY > 0 ]] && echo "... OK"
# Clean-up
[[ $VERBOSITY > 0 ]] && echo -n "Cleaning the ${BUILDDIR}${BLFS_ROOT} directory "
[[ $VERBOSITY > 0 ]] && echo Cleaning the ${BUILDDIR}${BLFS_ROOT} directory
make -C ${BUILDDIR}${BLFS_ROOT}/menu clean
rm -rf ${BUILDDIR}${BLFS_ROOT}/libs/.svn
rm -rf ${BUILDDIR}${BLFS_ROOT}/xsl/.svn
rm -rf ${BUILDDIR}${BLFS_ROOT}/menu/.svn
rm -rf ${BUILDDIR}${BLFS_ROOT}/menu/lxdialog/.svn
# 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}
${BUILDDIR}${BLFS_ROOT}/{Makefile,gen-makefile.sh}
# Ensures the tracking directory exists.
# Throws an error if it does not exist and the user does not
@ -157,28 +158,18 @@ sed -i s@tracking-dir@$TRACKING_DIR@ \
mkdir -p $TRACKING_DIR
[[ $VERBOSITY > 0 ]] && echo "... OK"
[[ $VERBOSITY > 0 ]] &&
echo "Retrieving and validating the book (may take some time)"
[[ -z "$BLFS_BOOK" ]] ||
[[ $BLFS_BOOK = $BUILDDIR$BLFS_ROOT/$BLFS_XML ]] || {
[[ $VERBOSITY > 0 ]] && echo -n "Retrieving BLFS working copy (may take some time) "
[[ $BLFS_BOOK = $BUILDDIR$BLFS_ROOT/$BLFS_XML ]] ||
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} \
SVN=svn://svn.linuxfromscratch.org/BLFS/$BLFS_TREE \
$BUILDDIR$BLFS_ROOT/packages.xml
[[ $VERBOSITY > 0 ]] && echo "... OK"

480
jhalfs
View file

@ -1,25 +1,31 @@
#!/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 +37,20 @@ 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
LASTLINE="$1"
LASTERR="$2"
LASTFUNC="$3"
LASTSOURCE="$4"
# echo -e "\n${RED}ERROR:${GREEN} basic error trapped!${OFF}\n" >&2
echo -e "\n${RED}ERROR:${GREEN} Error $LASTERR at $LASTSOURCE line ${LASTLINE}!${OFF}\n" >&2
fi
exit $LASTERR
}
see_ya() {
printf '\n%b%bjhalfs%b exit%b\n' "$L_arrow" "$BOLD" "$R_arrow" "$OFF"
echo -e "\n${L_arrow}${BOLD}jhalfs${R_arrow} exit${OFF}\n"
}
##### Simple error TRAPS
# ctrl-c SIGINT
@ -54,95 +66,51 @@ 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 '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\"${OFF} builder tool (development) \$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, Manuel Canales Esparcia, Pierre Labastie,
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}
See the ${BOLD}LICENCE${OFF} file in this directory.
"
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 ;;
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
if [ $(ls -l --time-style='+%Y%m%d%H%M%S' configuration.old | cut -d' ' -f 6) \
-ge $(ls -l --time-style='+%Y%m%d%H%M%S' configuration | cut -d' ' -f 6) ]
then echo -n "Do you want to run jhalfs? yes/no (yes): "
read ANSWER
if [ x${ANSWER:0:1} = "xn" -o x${ANSWER:0:1} = "xN" ] ; then
echo "${nl_}Exiting gracefully.${nl_}"
exit
fi
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
@ -153,13 +121,14 @@ load_file configuration "Loading config params from <configuration>"
RUNMAKE=${RUNMAKE:-n}
GETPKG=${GETPKG:-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}
VIMLANG=${VIMLANG:-n}
FULL_LOCALE=${FULL_LOCALE:-n}
GRSECURITY_HOST=${GRSECURITY_HOST:-n}
CUSTOM_TOOLS=${CUSTOM_TOOLS:-n}
@ -174,84 +143,168 @@ 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="#"
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 sources envars
BRANCH_ID=${BRANCH_ID:=development}
case $BRANCH_ID in
development )
case $PROGNAME in
clfs* ) TREE="" ;;
* ) 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-* )
case $PROGNAME in
lfs )
LFSVRS=${BRANCH_ID}
TREE=branches/${BRANCH_ID#branch-}
if [ ${BRANCH_ID#branch-} = 6 ]; then
TREE=${TREE}/BOOK
fi
;;
clfs* )
LFSVRS=${BRANCH_ID}
TREE=${BRANCH_ID#branch-}
;;
esac
;;
* )
case $PROGNAME in
lfs )
LFSVRS=${BRANCH_ID}
TREE=tags/${BRANCH_ID}
if (( ${BRANCH_ID:0:1} < 7 )) ; then
TREE=${TREE}/BOOK
fi
;;
hlfs )
LFSVRS=${BRANCH_ID}
TREE=tags/${BRANCH_ID}/BOOK
;;
clfs* )
LFSVRS=${BRANCH_ID}
TREE=clfs-${BRANCH_ID}
;;
* )
esac
;;
esac
# Set the document location...
BOOK=${BOOK:=$JHALFSDIR/book-source}
BOOK=${BOOK:=$JHALFSDIR/$PROGNAME-$LFSVRS}
#--- Envars not sourced from configuration
# shellcheck disable=SC2034
declare -r REPO=https://git.linuxfromscratch.org/lfs.git
case $PROGNAME in
clfs ) declare -r GIT="git://git.clfs.org/cross-lfs" ;;
clfs2 ) declare -r GIT="git://git.clfs.org/clfs-sysroot" ;;
clfs3 ) declare -r GIT="git://git.clfs.org/clfs-embedded" ;;
*) declare -r SVN="svn://svn.linuxfromscratch.org" ;;
esac
declare -r LOG=000-masterscript.log
declare -r COMMANDS=lfs-commands
# Needed for fetching BLFS book sources when building CLFS
declare -r SVN_2="svn://svn.linuxfromscratch.org"
# Set true internal variables
COMMON_DIR="common"
PACKAGE_DIR=LFS
PACKAGE_DIR=$(echo $PROGNAME | tr '[a-z]' '[A-Z]')
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_}"
[[ $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_}"
#*******************************************************************#
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
[[ $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"
simple_message "${SD_BORDER}${nl_}"
simple_message "Checking tools required for jhalfs${nl_}"
[[ $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_}"
[[ $VERBOSITY > 0 ]] && echo Checking tools required for jhalfs
check_alfs_tools
simple_message "${SD_BORDER}${nl_}"
[[ $VERBOSITY > 0 ]] && echo "${SD_BORDER}${nl_}"
# blfs-tool envars
BLFS_TOOL=${BLFS_TOOL:-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}
[[ $VERBOSITY > 0 ]] && echo Checking supplementary tools for installing BLFS
check_blfs_tools
[[ $VERBOSITY > 0 ]] && echo "${SD_BORDER}${nl_}"
BLFS_SVN=${BLFS_SVN:-n}
BLFS_WORKING_COPY=${BLFS_WORKING_COPY:-n}
if [[ "${BLFS_WORKING_COPY}" = "y" ]] &&
[[ ! -d "$BLFS_WC_LOCATION/postlfs" ]] ; then
BLFS_BRANCH=${BLFS_BRANCH:-n}
if [[ "${BLFS_SVN}" = "y" ]]; then
BLFS_BRANCH_ID=development
BLFS_TREE=trunk/BOOK
elif [[ "${BLFS_WORKING_COPY}" = "y" ]]; then
[[ -d "$BLFS_WC_LOCATION" ]] &&
[[ -d "$BLFS_WC_LOCATION/postlfs" ]] || {
echo " BLFS tools: This is not a working copy: $BLFS_WC_LOCATION."
echo " Please rerun make and fix the configuration."
exit 2
}
BLFS_TREE=$(cd $BLFS_WC_LOCATION; svn info | grep '^URL' | sed 's@.*BLFS/@@')
BLFS_BRANCH_ID=$(echo $BLFS_TREE | sed -e 's@trunk/BOOK@development@' \
-e 's@branches/@branch-@' \
-e 's@tags/@@' \
-e 's@/BOOK@@')
elif [[ "${BLFS_BRANCH}" = "y" ]] ; then
case $BLFS_BRANCH_ID in
*EDIT* ) echo " You forgot to set the BLFS branch or stable book version."
echo " Please rerun make and fix the configuration."
exit 2 ;;
branch-systemd ) BLFS_TREE=branches/systemd ;;
branch-* ) BLFS_TREE=branches/${BLFS_BRANCH_ID#branch-}/BOOK ;;
6.2* | 7.* ) BLFS_TREE=tags/${BLFS_BRANCH_ID} ;;
* ) BLFS_TREE=tags/${BLFS_BRANCH_ID}/BOOK ;;
esac
fi
load_file "${COMMON_DIR}/libs/func_install_blfs"
[[ $VERBOSITY > 0 ]] && echo -n "Loading blfs tools installation function..."
source $COMMON_DIR/libs/func_install_blfs
[[ $? > 0 ]] && echo "function module did not load.." && exit 1
[[ $VERBOSITY > 0 ]] && echo "OK"
fi
###################################
@ -262,8 +315,8 @@ fi
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
fi
@ -272,134 +325,135 @@ 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'
[[ $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
#
# 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
[[ $VERBOSITY > 0 ]] && echo -n "Loading optimization module..."
source optimize/optimize_functions
[[ $? > 0 ]] && echo " optimize/optimize_functions did not load.." && exit
[[ $VERBOSITY > 0 ]] && echo "OK"
#
# optimize configurations
load_file optimize/opt_config 'Loading optimization config'
[[ $VERBOSITY > 0 ]] && echo -n "Loading optimization config..."
source optimize/opt_config
[[ $? > 0 ]] && echo " optimize/opt_config did not load.." && exit
[[ $VERBOSITY > 0 ]] && echo "OK"
# The number of parallel jobs is taken from configuration now
MAKEFLAGS="-j${N_PARALLEL}"
# 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}"
fi
#
if [[ "$REBUILD_MAKEFILE" = "n" ]] ; then
# If requested, clean the build directory
# 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"
# 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/"
>$LOGDIR/$LOG
#
# Copy common helper files
cp $COMMON_DIR/{makefile-functions,progress_bar.sh} $JHALFSDIR/
# Copy needed stylesheets
cp $COMMON_DIR/{packages.xsl,chroot.xsl} $JHALFSDIR/
#
# Fix the XSL book parser
case $PROGNAME in
clfs* ) sed 's,FAKEDIR,'${BOOK}/BOOK',' ${PACKAGE_DIR}/${XSL} > $JHALFSDIR/${XSL} ;;
lfs | hlfs ) sed 's,FAKEDIR,'$BOOK',' $PACKAGE_DIR/$XSL > $JHALFSDIR/${XSL} ;;
* ) ;;
esac
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 packageManager.xml, if needed
[[ "$PKGMNGT" = "y" ]] && [[ "$PROGNAME" = "lfs" ]] && {
cp $PKGMNGTDIR/packageManager.xml $JHALFSDIR/
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
#
# Copy urls.xsl, if needed
[[ "$GETPKG" = "y" ]] && cp $COMMON_DIR/urls.xsl $JHALFSDIR/
#
# 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/"
cp $COMMON_DIR/create-sbu_du-report.sh $JHALFSDIR/
# After making 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 optimize files, if needed
[[ "$OPTIMIZE" != "0" ]] && cp optimize/opt_override $JHALFSDIR/
#
# 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
#
# 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"
mkdir -p $JHALFSDIR/custom-commands
cp -f custom/config/* $JHALFSDIR/custom-commands
fi
#
# 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
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.
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
fi
fi
# shellcheck disable=SC2034
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/')
if [[ "$REBUILD_MAKEFILE" = "y" ]] ; then
case $PROGNAME in
clfs* )
VERSION=$(xmllint --noent $JHALFSDIR/$BOOK/prologue/$ARCH/bookinfo.xml 2>/dev/null | grep subtitle | sed -e 's/^.*ion //' -e 's/<\/.*//') ;;
lfs)
if [[ "$INITSYS" = "sysv" ]] ; then
VERSION=$(grep 'ENTITY version ' $JHALFSDIR/$BOOK/general.ent| cut -d\" -f2)
else
VERSION=$(grep 'ENTITY versiond' $JHALFSDIR/$BOOK/general.ent| cut -d\" -f2)
fi
;;
*)
VERSION=$(xmllint --noent $JHALFSDIR/$BOOK/prologue/bookinfo.xml 2>/dev/null | grep subtitle | sed -e 's/^.*ion //' -e 's/<\/.*//') ;;
esac
fi
build_Makefile
@ -408,7 +462,7 @@ echo "${SD_BORDER}${nl_}"
# Check for build prerequisites.
echo
cd "$CWD"
cd $CWD
check_prerequisites
echo "${SD_BORDER}${nl_}"
# All is well, run the build (if requested)

View file

@ -0,0 +1,507 @@
diff -Npr menu-bb/conf.c menu/conf.c
*** menu-bb/conf.c 2006-03-22 16:16:18.000000000 -0500
--- menu/conf.c 2006-07-26 17:26:45.000000000 -0400
*************** int main(int ac, char **av)
*** 535,554 ****
conf_parse(name);
//zconfdump(stdout);
switch (input_mode) {
- case set_default:
- if (!defconfig_file)
- defconfig_file = conf_get_default_confname();
- if (conf_read(defconfig_file)) {
- printf("***\n"
- "*** Can't find default configuration \"%s\"!\n"
- "***\n", defconfig_file);
- exit(1);
- }
- break;
case ask_silent:
if (stat(".config", &tmpstat)) {
printf("***\n"
! "*** You have not yet configured BusyBox!\n"
"***\n"
"*** Please run some configurator (e.g. \"make oldconfig\" or\n"
"*** \"make menuconfig\" or \"make config\").\n"
--- 535,544 ----
conf_parse(name);
//zconfdump(stdout);
switch (input_mode) {
case ask_silent:
if (stat(".config", &tmpstat)) {
printf("***\n"
! "*** You have not yet configured JHALFS!\n"
"***\n"
"*** Please run some configurator (e.g. \"make oldconfig\" or\n"
"*** \"make menuconfig\" or \"make config\").\n"
*************** int main(int ac, char **av)
*** 576,582 ****
check_conf(&rootmenu);
} while (conf_cnt);
if (conf_write(NULL)) {
! fprintf(stderr, "\n*** Error during writing of the BusyBox configuration.\n\n");
return 1;
}
return 0;
--- 566,572 ----
check_conf(&rootmenu);
} while (conf_cnt);
if (conf_write(NULL)) {
! fprintf(stderr, "\n*** Error during writing of the JHALFS configuration.\n\n");
return 1;
}
return 0;
diff -Npr menu-bb/confdata.c menu/confdata.c
*** menu-bb/confdata.c 2006-03-22 16:16:18.000000000 -0500
--- menu/confdata.c 2006-07-26 17:26:45.000000000 -0400
***************
*** 13,24 ****
#define LKC_DIRECT_LINK
#include "lkc.h"
! const char conf_def_filename[] = ".config";
const char conf_defname[] = "defconfig";
const char *conf_confnames[] = {
! ".config",
conf_defname,
NULL,
};
--- 13,24 ----
#define LKC_DIRECT_LINK
#include "lkc.h"
! const char conf_def_filename[] = "configuration";
const char conf_defname[] = "defconfig";
const char *conf_confnames[] = {
! "configuration",
conf_defname,
NULL,
};
*************** static char *conf_expand_value(const cha
*** 49,70 ****
return res_value;
}
- char *conf_get_default_confname(void)
- {
- struct stat buf;
- static char fullname[PATH_MAX+1];
- char *env, *name;
-
- name = conf_expand_value(conf_defname);
- env = getenv(SRCTREE);
- if (env) {
- sprintf(fullname, "%s/%s", env, name);
- if (!stat(fullname, &buf))
- return fullname;
- }
- return name;
- }
-
int conf_read(const char *name)
{
FILE *in = NULL;
--- 49,54 ----
*************** struct menu *next_menu(struct menu *menu
*** 271,277 ****
int conf_write(const char *name)
{
! FILE *out, *out_h;
struct symbol *sym;
struct menu *menu;
const char *basename;
--- 255,261 ----
int conf_write(const char *name)
{
! FILE *out;
struct symbol *sym;
struct menu *menu;
const char *basename;
*************** int conf_write(const char *name)
*** 279,288 ****
int type, l;
const char *str;
- /* busybox`s code */
- const char *opt_name;
- int use_flg;
-
dirname[0] = 0;
if (name && name[0]) {
struct stat st;
--- 263,268 ----
*************** int conf_write(const char *name)
*** 309,342 ****
out = fopen(newname, "w");
if (!out)
return 1;
- out_h = NULL;
- if (!name) {
- out_h = fopen(".tmpconfig.h", "w");
- if (!out_h)
- return 1;
- }
fprintf(out, "#\n"
! "# Automatically generated make config: don't edit\n"
"#\n");
- /* busybox`s code */
- if (out_h) {
- fprintf(out_h, "#ifndef BB_CONFIG_H\n#define BB_CONFIG_H\n");
- fprintf(out_h, "/*\n"
- " * Automatically generated header file: don't edit\n"
- " */\n\n"
- "/* Version Number */\n"
- "#define BB_VER \"%s\"\n"
- "#define BB_BT \"%s\"\n",
- getenv("VERSION"),
- getenv("BUILDTIME"));
- if (getenv("EXTRA_VERSION"))
- fprintf(out_h, "#define BB_EXTRA_VERSION \"%s\"\n",
- getenv("EXTRA_VERSION"));
- fprintf(out_h, "\n");
- }
- /* end busybox`s code */
-
if (!sym_change_count)
sym_clear_all_valid();
--- 289,299 ----
out = fopen(newname, "w");
if (!out)
return 1;
fprintf(out, "#\n"
! "# Automatically generated configuration: don't edit\n"
! "# use make menuconfig or make config to make changes\n"
"#\n");
if (!sym_change_count)
sym_clear_all_valid();
*************** int conf_write(const char *name)
*** 357,367 ****
"#\n"
"# %s\n"
"#\n", str);
- if (out_h)
- fprintf(out_h, "\n"
- "/*\n"
- " * %s\n"
- " */\n", str);
} else if (!(sym->flags & SYMBOL_CHOICE)) {
sym_calc_value(sym);
if (!(sym->flags & SYMBOL_FORCEWRITE))
--- 314,319 ----
*************** int conf_write(const char *name)
*** 375,388 ****
type = S_BOOLEAN;
}
- /* busybox`s code */
- opt_name = strchr(sym->name, '_');
- if(opt_name == NULL)
- opt_name = sym->name;
- else
- opt_name++;
- use_flg = 1;
- /* end busybox`s code */
switch (type) {
case S_BOOLEAN:
--- 327,332 ----
*************** int conf_write(const char *name)
*** 390,410 ****
switch (sym_get_tristate_value(sym)) {
case no:
fprintf(out, "# %s is not set\n", sym->name);
- if (out_h)
- fprintf(out_h, "#undef %s\n", sym->name);
- use_flg = 0; /* busybox`s code */
break;
case mod:
- #if 0 /* busybox`s code */
fprintf(out, "%s=m\n", sym->name);
- if (out_h)
- fprintf(out_h, "#define %s_MODULE 1\n", sym->name);
- #endif /* busybox`s code */
break;
case yes:
fprintf(out, "%s=y\n", sym->name);
- if (out_h)
- fprintf(out_h, "#define %s 1\n", sym->name);
break;
}
break;
--- 334,345 ----
*************** int conf_write(const char *name)
*** 412,473 ****
// fix me
str = sym_get_string_value(sym);
fprintf(out, "%s=\"", sym->name);
- if (out_h)
- fprintf(out_h, "#define %s \"", sym->name);
do {
l = strcspn(str, "\"\\");
if (l) {
fwrite(str, l, 1, out);
- if (out_h)
- fwrite(str, l, 1, out_h);
}
str += l;
while (*str == '\\' || *str == '"') {
fprintf(out, "\\%c", *str);
- if (out_h)
- fprintf(out_h, "\\%c", *str);
str++;
}
} while (*str);
fputs("\"\n", out);
- if (out_h)
- fputs("\"\n", out_h);
break;
case S_HEX:
str = sym_get_string_value(sym);
if (str[0] != '0' || (str[1] != 'x' && str[1] != 'X')) {
fprintf(out, "%s=%s\n", sym->name, *str ? str : "0");
- if (out_h)
- fprintf(out_h, "#define %s 0x%s\n", sym->name, str);
break;
}
case S_INT:
str = sym_get_string_value(sym);
fprintf(out, "%s=%s\n", sym->name, *str ? str : "0");
- if (out_h)
- fprintf(out_h, "#define %s %s\n", sym->name, str);
break;
}
- /* busybox`s code */
- if (out_h) {
- fprintf(out_h, "#define ENABLE_%s %d\n", opt_name, use_flg);
- fprintf(out_h, "#define USE_%s(...)%s\n", opt_name,
- (use_flg ? " __VA_ARGS__" : ""));
- fprintf(out_h, "#define SKIP_%s(...)%s\n\n", opt_name,
- (use_flg ? "" : " __VA_ARGS__"));
- }
- /* end busybox`s code */
}
next:
menu = next_menu(menu);
}
fclose(out);
- if (out_h) {
- fprintf(out_h, "#endif /* BB_CONFIG_H */\n"); /* busybox`s code */
- fclose(out_h);
- rename(".tmpconfig.h", "include/bb_config.h"); /* busybox`s config name */
- file_write_dep(NULL);
- }
if (!name || basename != conf_def_filename) {
if (!name)
name = conf_def_filename;
--- 347,381 ----
diff -Npr menu-bb/Makefile menu/Makefile
*** menu-bb/Makefile 2006-03-22 16:16:18.000000000 -0500
--- menu/Makefile 2006-07-26 18:06:25.000000000 -0400
***************
*** 1,11 ****
# Makefile for BusyBox
#
# Copyright (C) 2002 Erik Andersen <andersen@codepoet.org>
- top_srcdir=../..
- top_builddir=../..
- srcdir=$(top_srcdir)/scripts/config
- include $(top_srcdir)/Rules.mak
all: ncurses conf mconf
--- 1,30 ----
# Makefile for BusyBox
#
# Copyright (C) 2002 Erik Andersen <andersen@codepoet.org>
+ # Modified by George Boudreau georgeb@LinuxFromScratch.org
+
+ top_srcdir=.
+ top_builddir=.
+ srcdir=$(top_srcdir)
+
+ # Select the compiler needed to build binaries for your development system
+ HOSTCC = gcc
+ HOSTCFLAGS= -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
+
+ # Ensure consistent sort order, 'gcc -print-search-dirs' behavior, etc.
+ LC_ALL:= C
+
+ SED ?= sed
+ SECHO := @-false
+ DISP := pur
+ Q := @
+
+ show_objs = $(subst $(top_builddir)/,,$(subst ../,,$@))
+ pur_disp_compile.h = echo " "HOSTCC $(show_objs)
+ disp_compile.h = $($(DISP)_disp_compile.h)
+ cmd_compile.h = $(HOSTCC) $(HOSTCFLAGS) -c -o $@ $<
+ compile.h = @$(disp_compile.h) ; $(cmd_compile.h)
all: ncurses conf mconf
diff -Npr menu-bb/mconf.c menu/mconf.c
*** menu-bb/mconf.c 2006-03-22 16:16:18.000000000 -0500
--- menu/mconf.c 2006-07-26 17:26:45.000000000 -0400
*************** static char menu_backtitle[128];
*** 32,38 ****
static const char mconf_readme[] =
"Overview\n"
"--------\n"
! "Some features may be built directly into BusyBox. Some features\n"
"may be completely removed altogether. There are also certain\n"
"parameters which are not really features, but must be\n"
"entered in as decimal or hexadecimal numbers or possibly text.\n"
--- 32,38 ----
static const char mconf_readme[] =
"Overview\n"
"--------\n"
! "Some features may be built directly into JHALFS. Some features\n"
"may be completely removed altogether. There are also certain\n"
"parameters which are not really features, but must be\n"
"entered in as decimal or hexadecimal numbers or possibly text.\n"
*************** load_config_text[] =
*** 194,204 ****
"last retrieved. Leave blank to abort.",
load_config_help[] =
"\n"
! "For various reasons, one may wish to keep several different BusyBox\n"
"configurations available on a single machine.\n"
"\n"
"If you have saved a previous configuration in a file other than the\n"
! "BusyBox's default, entering the name of the file here will allow you\n"
"to modify that configuration.\n"
"\n"
"If you are uncertain, then you have probably never used alternate\n"
--- 194,204 ----
"last retrieved. Leave blank to abort.",
load_config_help[] =
"\n"
! "For various reasons, one may wish to keep several different JHALFS\n"
"configurations available on a single machine.\n"
"\n"
"If you have saved a previous configuration in a file other than the\n"
! "JHALFS's default, entering the name of the file here will allow you\n"
"to modify that configuration.\n"
"\n"
"If you are uncertain, then you have probably never used alternate\n"
*************** save_config_text[] =
*** 208,214 ****
"as an alternate. Leave blank to abort.",
save_config_help[] =
"\n"
! "For various reasons, one may wish to keep different BusyBox\n"
"configurations available on a single machine.\n"
"\n"
"Entering a file name here will allow you to later retrieve, modify\n"
--- 208,214 ----
"as an alternate. Leave blank to abort.",
save_config_help[] =
"\n"
! "For various reasons, one may wish to keep different JHALFS\n"
"configurations available on a single machine.\n"
"\n"
"Entering a file name here will allow you to later retrieve, modify\n"
*************** int main(int ac, char **av)
*** 940,946 ****
sym = sym_lookup("VERSION", 0);
sym_calc_value(sym);
! snprintf(menu_backtitle, 128, "BusyBox v%s Configuration",
sym_get_string_value(sym));
mode = getenv("MENUCONFIG_MODE");
--- 940,946 ----
sym = sym_lookup("VERSION", 0);
sym_calc_value(sym);
! snprintf(menu_backtitle, 128, "JHALFS v%s Configuration",
sym_get_string_value(sym));
mode = getenv("MENUCONFIG_MODE");
*************** int main(int ac, char **av)
*** 961,976 ****
init_dialog();
do {
stat = dialog_yesno(NULL,
! "Do you wish to save your new BusyBox configuration?", 5, 60);
} while (stat < 0);
end_dialog();
if (stat == 0) {
conf_write(NULL);
printf("\n"
! "*** End of BusyBox configuration.\n");
} else
! printf("\n\nYour BusyBox configuration changes were NOT saved.\n\n");
return 0;
}
--- 961,976 ----
init_dialog();
do {
stat = dialog_yesno(NULL,
! "Do you wish to save your new JHALFS configuration?", 5, 60);
} while (stat < 0);
end_dialog();
if (stat == 0) {
conf_write(NULL);
printf("\n"
! "*** End of JHALFS configuration.\n");
} else
! printf("\n\nYour JHALFS configuration changes were NOT saved.\n\n");
return 0;
}
diff -Npr menu-bb/zconf.tab.c_shipped menu/zconf.tab.c_shipped
*** menu-bb/zconf.tab.c_shipped 2006-03-22 16:16:18.000000000 -0500
--- menu/zconf.tab.c_shipped 2006-07-26 17:26:45.000000000 -0400
*************** void conf_parse(const char *name)
*** 1925,1931 ****
sym_init();
menu_init();
modules_sym = sym_lookup("MODULES", 0);
! rootmenu.prompt = menu_add_prop(P_MENU, "BusyBox Configuration", NULL, NULL);
//zconfdebug = 1;
zconfparse();
--- 1925,1931 ----
sym_init();
menu_init();
modules_sym = sym_lookup("MODULES", 0);
! rootmenu.prompt = menu_add_prop(P_MENU, "JHALFS Configuration", NULL, NULL);
//zconfdebug = 1;
zconfparse();
diff -Npr menu-bb/zconf.y menu/zconf.y
*** menu-bb/zconf.y 2006-03-22 16:16:18.000000000 -0500
--- menu/zconf.y 2006-07-26 17:26:45.000000000 -0400
*************** void conf_parse(const char *name)
*** 487,493 ****
sym_init();
menu_init();
modules_sym = sym_lookup("MODULES", 0);
! rootmenu.prompt = menu_add_prop(P_MENU, "BusyBox Configuration", NULL, NULL);
//zconfdebug = 1;
zconfparse();
--- 487,493 ----
sym_init();
menu_init();
modules_sym = sym_lookup("MODULES", 0);
! rootmenu.prompt = menu_add_prop(P_MENU, "JHALFS Configuration", NULL, NULL);
//zconfdebug = 1;
zconfparse();

255
menu/Kconfig-language.txt Normal file
View file

@ -0,0 +1,255 @@
Introduction
------------
The configuration database is collection of configuration options
organized in a tree structure:
+- Code maturity level options
| +- Prompt for development and/or incomplete code/drivers
+- General setup
| +- Networking support
| +- System V IPC
| +- BSD Process Accounting
| +- Sysctl support
+- Loadable module support
| +- Enable loadable module support
| +- Set version information on all module symbols
| +- Kernel module loader
+- ...
Every entry has its own dependencies. These dependencies are used
to determine the visible of an entry. Any child entry is only
visible if its parent entry is also visible.
Menu entries
------------
Most entries define a config option, all other entries help to organize
them. A single configuration option is defined like this:
config MODVERSIONS
bool "Set version information on all module symbols"
depends MODULES
help
Usually, modules have to be recompiled whenever you switch to a new
kernel. ...
Every line starts with a key word and can be followed by multiple
arguments. "config" starts a new config entry. The following lines
define attributes for this config option. Attributes can be the type of
the config option, input prompt, dependencies, help text and default
values. A config option can be defined multiple times with the same
name, but every definition can have only a single input prompt and the
type must not conflict.
Menu attributes
---------------
A menu entry can have a number of attributes. Not all of them are
applicable everywhere (see syntax).
- type definition: "bool"/"tristate"/"string"/"hex"/"integer"
Every config option must have a type. There are only two basic types:
tristate and string, the other types base on these two. The type
definition optionally accepts an input prompt, so these two examples
are equivalent:
bool "Networking support"
and
bool
prompt "Networking support"
- input prompt: "prompt" <prompt> ["if" <expr>]
Every menu entry can have at most one prompt, which is used to display
to the user. Optionally dependencies only for this prompt can be added
with "if".
- default value: "default" <symbol> ["if" <expr>]
A config option can have any number of default values. If multiple
default values are visible, only the first defined one is active.
Default values are not limited to the menu entry, where they are
defined, this means the default can be defined somewhere else or be
overriden by an earlier definition.
The default value is only assigned to the config symbol if no other
value was set by the user (via the input prompt above). If an input
prompt is visible the default value is presented to the user and can
be overridden by him.
Optionally dependencies only for this default value can be added with
"if".
- dependencies: "depends on"/"requires" <expr>
This defines a dependency for this menu entry. If multiple
dependencies are defined they are connected with '&&'. Dependencies
are applied to all other options within this menu entry (which also
accept "if" expression), so these two examples are equivalent:
bool "foo" if BAR
default y if BAR
and
depends on BAR
bool "foo"
default y
- help text: "help"
This defines a help text. The end of the help text is determined by
the level indentation, this means it ends at the first line which has
a smaller indentation than the first line of the help text.
Menu dependencies
-----------------
Dependencies define the visibility of a menu entry and can also reduce
the input range of tristate symbols. The tristate logic used in the
expressions uses one more state than normal boolean logic to express the
module state. Dependency expressions have the following syntax:
<expr> ::= <symbol> (1)
<symbol> '=' <symbol> (2)
<symbol> '!=' <symbol> (3)
'(' <expr> ')' (4)
'!' <expr> (5)
<expr> '||' <expr> (6)
<expr> '&&' <expr> (7)
Expressions are listed in decreasing order of precedence.
(1) Convert the symbol into an expression. Boolean and tristate symbols
are simply converted into the respective expression values. All
other symbol types result in 'n'.
(2) If the values of both symbols are equal, it returns 'y',
otherwise 'n'.
(3) If the values of both symbols are equal, it returns 'n',
otherwise 'y'.
(4) Returns the value of the expression. Used to override precedence.
(5) Returns the result of (2-/expr/).
(6) Returns the result of min(/expr/, /expr/).
(7) Returns the result of max(/expr/, /expr/).
An expression can have a value of 'n', 'm' or 'y' (or 0, 1, 2
respectively for calculations). A menu entry becomes visible when it's
expression evaluates to 'm' or 'y'.
There are two type of symbols: constant and nonconstant symbols.
Nonconstant symbols are the most common ones and are defined with the
'config' statement. Nonconstant symbols consist entirely of alphanumeric
characters or underscores.
Constant symbols are only part of expressions. Constant symbols are
always surrounded by single or double quotes. Within the quote any
other character is allowed and the quotes can be escaped using '\'.
Menu structure
--------------
The position of a menu entry in the tree is determined in two ways. First
it can be specified explicitely:
menu "Network device support"
depends NET
config NETDEVICES
...
endmenu
All entries within the "menu" ... "endmenu" block become a submenu of
"Network device support". All subentries inherit the dependencies from
the menu entry, e.g. this means the dependency "NET" is added to the
dependency list of the config option NETDEVICES.
The other way to generate the menu structure is done by analyzing the
dependencies. If a menu entry somehow depends on the previous entry, it
can be made a submenu of it. First the the previous (parent) symbol must
be part of the dependency list and then one of these two condititions
must be true:
- the child entry must become invisible, if the parent is set to 'n'
- the child entry must only be visible, if the parent is visible
config MODULES
bool "Enable loadable module support"
config MODVERSIONS
bool "Set version information on all module symbols"
depends MODULES
comment "module support disabled"
depends !MODULES
MODVERSIONS directly depends on MODULES, this means it's only visible if
MODULES is different from 'n'. The comment on the other hand is always
visible when MODULES it's visible (the (empty) dependency of MODULES is
also part of the comment dependencies).
Kconfig syntax
--------------
The configuration file describes a series of menu entries, where every
line starts with a keyword (except help texts). The following keywords
end a menu entry:
- config
- choice/endchoice
- comment
- menu/endmenu
- if/endif
- source
The first four also start the definition of a menu entry.
config:
"config" <symbol>
<config options>
This defines a config symbol <symbol> and accepts any of above
attributes as options.
choices:
"choice"
<choice options>
<choice block>
"endchoice"
This defines a choice group and accepts any of above attributes as
options. A choice can only be of type bool or tristate, while a boolean
choice only allows a single config entry to be selected, a tristate
choice also allows any number of config entries to be set to 'm'. This
can be used if multiple drivers for a single hardware exists and only a
single driver can be compiled/loaded into the kernel, but all drivers
can be compiled as modules.
A choice accepts another option "optional", which allows to set the
choice to 'n' and no entry needs to be selected.
comment:
"comment" <prompt>
<comment options>
This defines a comment which is displayed to the user during the
configuration process and is also echoed to the output files. The only
possible options are dependencies.
menu:
"menu" <prompt>
<menu options>
<menu block>
"endmenu"
This defines a menu block, see "Menu structure" above for more
information. The only possible options are dependencies.
if:
"if" <expr>
<if block>
"endif"
This defines an if block. The dependency expression <expr> is appended
to all enclosed menu entries.
source:
"source" <prompt>
This reads the specified configuration file. This file is always parsed.

View file

@ -1,5 +0,0 @@
Copyright (c) 2011-2019, Ulf Magnusson <ulfalizer@gmail.com>
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

145
menu/Makefile Normal file
View file

@ -0,0 +1,145 @@
# Makefile for BusyBox
#
# Copyright (C) 2002 Erik Andersen <andersen@codepoet.org>
# Modified by George Boudreau georgeb@LinuxFromScratch.org
top_srcdir=.
top_builddir=.
srcdir=$(top_srcdir)
# Select the compiler needed to build binaries for your development system
HOSTCC = gcc
HOSTCFLAGS= -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
# Ensure consistent sort order, 'gcc -print-search-dirs' behavior, etc.
LC_ALL:= C
SED ?= sed
SECHO := @-false
DISP := pur
Q := @
show_objs = $(subst $(top_builddir)/,,$(subst ../,,$@))
pur_disp_compile.h = echo " "HOSTCC $(show_objs)
disp_compile.h = $($(DISP)_disp_compile.h)
cmd_compile.h = $(HOSTCC) $(HOSTCFLAGS) -c -o $@ $<
compile.h = @$(disp_compile.h) ; $(cmd_compile.h)
all: ncurses conf mconf
ifeq ($(shell uname),SunOS)
LIBS = -lcurses
else
LIBS = -lncurses
endif
ifeq (/usr/include/ncurses/ncurses.h, $(wildcard /usr/include/ncurses/ncurses.h))
HOSTNCURSES += -I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>"
else
ifeq (/usr/include/ncurses/curses.h, $(wildcard /usr/include/ncurses/curses.h))
HOSTNCURSES += -I/usr/include/ncurses -DCURSES_LOC="<ncurses/curses.h>"
else
ifeq (/usr/local/include/ncurses/ncurses.h, $(wildcard /usr/local/include/ncurses/ncurses.h))
HOSTCFLAGS += -I/usr/local/include/ncurses -DCURSES_LOC="<ncurses.h>"
else
ifeq (/usr/local/include/ncurses/curses.h, $(wildcard /usr/local/include/ncurses/curses.h))
HOSTCFLAGS += -I/usr/local/include/ncurses -DCURSES_LOC="<ncurses/curses.h>"
else
ifeq (/usr/include/ncurses.h, $(wildcard /usr/include/ncurses.h))
HOSTNCURSES += -DCURSES_LOC="<ncurses.h>"
else
HOSTNCURSES += -DCURSES_LOC="<curses.h>"
endif
endif
endif
endif
endif
ifeq (/usr/include/locale.h, $(wildcard /usr/include/locale.h))
HOSTNCURSES += -DLOCALE=1
endif
CONF_SRC = conf.c
MCONF_SRC = mconf.c
LXD_SRC = lxdialog/checklist.c lxdialog/menubox.c lxdialog/textbox.c \
lxdialog/yesno.c lxdialog/inputbox.c lxdialog/util.c \
lxdialog/msgbox.c
SHARED_SRC = zconf.tab.c
SHARED_DEPS := $(srcdir)/lkc.h $(srcdir)/lkc_proto.h \
lkc_defs.h $(srcdir)/expr.h zconf.tab.h
CONF_OBJS = $(patsubst %.c,%.o, $(CONF_SRC))
MCONF_OBJS = $(patsubst %.c,%.o, $(MCONF_SRC) $(LXD_SRC))
SHARED_OBJS = $(patsubst %.c,%.o, $(SHARED_SRC))
conf: $(CONF_OBJS) $(SHARED_OBJS)
$(SECHO) " "HOSTCC $@ ; true
$(Q)$(HOSTCC) $(NATIVE_LDFLAGS) $^ -o $@
mconf: $(MCONF_OBJS) $(SHARED_OBJS)
$(SECHO) " "HOSTCC $@ ; true
$(Q)$(HOSTCC) $(NATIVE_LDFLAGS) $^ -o $@ $(LIBS)
$(CONF_OBJS): %.o : $(srcdir)/%.c $(SHARED_DEPS)
$(compile.h) -I.
$(MCONF_OBJS): %.o : $(srcdir)/%.c $(SHARED_DEPS)
@[ -d $(@D) ] || mkdir $(@D)
$(compile.h) $(HOSTNCURSES) -I.
lkc_defs.h: $(srcdir)/lkc_proto.h
@$(SED) < $< > $@ 's/P(\([^,]*\),.*/#define \1 (\*\1_p)/'
###
# The following requires flex/bison
# By default we use the _shipped versions, uncomment the
# following line if you are modifying the flex/bison src.
#LKC_GENPARSER := 1
ifdef LKC_GENPARSER
%.tab.c %.tab.h: $(srcdir)/%.y
bison -t -d -v -b $* -p $(notdir $*) $<
lex.%.c: $(srcdir)/%.l
flex -P$(notdir $*) -o$@ $<
else
lex.zconf.o: lex.zconf.c $(SHARED_DEPS)
$(compile.h) -I$(srcdir)
lex.zconf.c: $(srcdir)/lex.zconf.c_shipped
$(Q)cp $< $@
zconf.tab.c: $(srcdir)/zconf.tab.c_shipped
$(Q)cp $< $@
zconf.tab.h: $(srcdir)/zconf.tab.h_shipped
$(Q)cp $< $@
endif
zconf.tab.o: zconf.tab.c lex.zconf.c $(srcdir)/confdata.c $(srcdir)/expr.c \
$(srcdir)/symbol.c $(srcdir)/menu.c $(SHARED_DEPS)
$(compile.h) -I$(srcdir) -I.
.PHONY: ncurses
ncurses:
@echo "int main() {}" > lxtemp.c
@if $(HOSTCC) lxtemp.c $(LIBS) ; then \
rm -f lxtemp.c a.out; \
else \
rm -f lxtemp.c; \
echo -e "\007" ;\
echo ">> Unable to find the Ncurses libraries." ;\
echo ">>" ;\
echo ">> You must have Ncurses installed in order" ;\
echo ">> to use 'make menuconfig'" ;\
echo ;\
exit 1 ;\
fi
clean:
rm -f *.o *~ core $(TARGETS) $(MCONF_OBJS) $(CONF_OBJS) \
conf mconf zconf.tab.c zconf.tab.h lex.zconf.c lkc_defs.h

View file

@ -1,4 +0,0 @@
The files in this directory come from
https://github.com/ulfalizer/Kconfiglib.git
They are subjected to the ISC license.
See the file LICENSE.txt

571
menu/conf.c Normal file
View file

@ -0,0 +1,571 @@
/*
* Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
* Released under the terms of the GNU GPL v2.0.
*/
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <time.h>
#include <sys/stat.h>
#define LKC_DIRECT_LINK
#include "lkc.h"
static void conf(struct menu *menu);
static void check_conf(struct menu *menu);
enum {
ask_all,
ask_new,
ask_silent,
set_default,
set_yes,
set_mod,
set_no,
set_random
} input_mode = ask_all;
char *defconfig_file;
static int indent = 1;
static int valid_stdin = 1;
static int conf_cnt;
static char line[128];
static struct menu *rootEntry;
static char nohelp_text[] = "Sorry, no help available for this option yet.\n";
static void strip(char *str)
{
char *p = str;
int l;
while ((isspace(*p)))
p++;
l = strlen(p);
if (p != str)
memmove(str, p, l + 1);
if (!l)
return;
p = str + l - 1;
while ((isspace(*p)))
*p-- = 0;
}
static void check_stdin(void)
{
if (!valid_stdin && input_mode == ask_silent) {
printf("aborted!\n\n");
printf("Console input/output is redirected. ");
printf("Run 'make oldconfig' to update configuration.\n\n");
exit(1);
}
}
static void conf_askvalue(struct symbol *sym, const char *def)
{
enum symbol_type type = sym_get_type(sym);
tristate val;
if (!sym_has_value(sym))
printf("(NEW) ");
line[0] = '\n';
line[1] = 0;
if (!sym_is_changable(sym)) {
printf("%s\n", def);
line[0] = '\n';
line[1] = 0;
return;
}
switch (input_mode) {
case ask_new:
case ask_silent:
if (sym_has_value(sym)) {
printf("%s\n", def);
return;
}
check_stdin();
case ask_all:
fflush(stdout);
fgets(line, 128, stdin);
return;
case set_default:
printf("%s\n", def);
return;
default:
break;
}
switch (type) {
case S_INT:
case S_HEX:
case S_STRING:
printf("%s\n", def);
return;
default:
;
}
switch (input_mode) {
case set_yes:
if (sym_tristate_within_range(sym, yes)) {
line[0] = 'y';
line[1] = '\n';
line[2] = 0;
break;
}
case set_mod:
if (type == S_TRISTATE) {
if (sym_tristate_within_range(sym, mod)) {
line[0] = 'm';
line[1] = '\n';
line[2] = 0;
break;
}
} else {
if (sym_tristate_within_range(sym, yes)) {
line[0] = 'y';
line[1] = '\n';
line[2] = 0;
break;
}
}
case set_no:
if (sym_tristate_within_range(sym, no)) {
line[0] = 'n';
line[1] = '\n';
line[2] = 0;
break;
}
case set_random:
do {
val = (tristate)(random() % 3);
} while (!sym_tristate_within_range(sym, val));
switch (val) {
case no: line[0] = 'n'; break;
case mod: line[0] = 'm'; break;
case yes: line[0] = 'y'; break;
}
line[1] = '\n';
line[2] = 0;
break;
default:
break;
}
printf("%s", line);
}
int conf_string(struct menu *menu)
{
struct symbol *sym = menu->sym;
const char *def, *help;
while (1) {
printf("%*s%s ", indent - 1, "", menu->prompt->text);
printf("(%s) ", sym->name);
def = sym_get_string_value(sym);
if (sym_get_string_value(sym))
printf("[%s] ", def);
conf_askvalue(sym, def);
switch (line[0]) {
case '\n':
break;
case '?':
/* print help */
if (line[1] == '\n') {
help = nohelp_text;
if (menu->sym->help)
help = menu->sym->help;
printf("\n%s\n", help);
def = NULL;
break;
}
default:
line[strlen(line)-1] = 0;
def = line;
}
if (def && sym_set_string_value(sym, def))
return 0;
}
}
static int conf_sym(struct menu *menu)
{
struct symbol *sym = menu->sym;
tristate oldval, newval;
const char *help;
while (1) {
printf("%*s%s ", indent - 1, "", menu->prompt->text);
if (sym->name)
printf("(%s) ", sym->name);
(void)sym_get_type(sym);
putchar('[');
oldval = sym_get_tristate_value(sym);
switch (oldval) {
case no:
putchar('N');
break;
case mod:
putchar('M');
break;
case yes:
putchar('Y');
break;
}
if (oldval != no && sym_tristate_within_range(sym, no))
printf("/n");
if (oldval != mod && sym_tristate_within_range(sym, mod))
printf("/m");
if (oldval != yes && sym_tristate_within_range(sym, yes))
printf("/y");
if (sym->help)
printf("/?");
printf("] ");
conf_askvalue(sym, sym_get_string_value(sym));
strip(line);
switch (line[0]) {
case 'n':
case 'N':
newval = no;
if (!line[1] || !strcmp(&line[1], "o"))
break;
continue;
case 'm':
case 'M':
newval = mod;
if (!line[1])
break;
continue;
case 'y':
case 'Y':
newval = yes;
if (!line[1] || !strcmp(&line[1], "es"))
break;
continue;
case 0:
newval = oldval;
break;
case '?':
goto help;
default:
continue;
}
if (sym_set_tristate_value(sym, newval))
return 0;
help:
help = nohelp_text;
if (sym->help)
help = sym->help;
printf("\n%s\n", help);
}
}
static int conf_choice(struct menu *menu)
{
struct symbol *sym, *def_sym;
struct menu *child;
bool is_new;
sym = menu->sym;
(void)sym_get_type(sym);
is_new = !sym_has_value(sym);
if (sym_is_changable(sym)) {
conf_sym(menu);
sym_calc_value(sym);
switch (sym_get_tristate_value(sym)) {
case no:
return 1;
case mod:
return 0;
case yes:
break;
}
} else {
switch (sym_get_tristate_value(sym)) {
case no:
return 1;
case mod:
printf("%*s%s\n", indent - 1, "", menu_get_prompt(menu));
return 0;
case yes:
break;
}
}
while (1) {
int cnt, def;
printf("%*s%s\n", indent - 1, "", menu_get_prompt(menu));
def_sym = sym_get_choice_value(sym);
cnt = def = 0;
line[0] = '0';
line[1] = 0;
for (child = menu->list; child; child = child->next) {
if (!menu_is_visible(child))
continue;
if (!child->sym) {
printf("%*c %s\n", indent, '*', menu_get_prompt(child));
continue;
}
cnt++;
if (child->sym == def_sym) {
def = cnt;
printf("%*c", indent, '>');
} else
printf("%*c", indent, ' ');
printf(" %d. %s", cnt, menu_get_prompt(child));
if (child->sym->name)
printf(" (%s)", child->sym->name);
if (!sym_has_value(child->sym))
printf(" (NEW)");
printf("\n");
}
printf("%*schoice", indent - 1, "");
if (cnt == 1) {
printf("[1]: 1\n");
goto conf_childs;
}
printf("[1-%d", cnt);
if (sym->help)
printf("?");
printf("]: ");
switch (input_mode) {
case ask_new:
case ask_silent:
if (!is_new) {
cnt = def;
printf("%d\n", cnt);
break;
}
check_stdin();
case ask_all:
fflush(stdout);
fgets(line, 128, stdin);
strip(line);
if (line[0] == '?') {
printf("\n%s\n", menu->sym->help ?
menu->sym->help : nohelp_text);
continue;
}
if (!line[0])
cnt = def;
else if (isdigit(line[0]))
cnt = atoi(line);
else
continue;
break;
case set_random:
def = (random() % cnt) + 1;
case set_default:
case set_yes:
case set_mod:
case set_no:
cnt = def;
printf("%d\n", cnt);
break;
}
conf_childs:
for (child = menu->list; child; child = child->next) {
if (!child->sym || !menu_is_visible(child))
continue;
if (!--cnt)
break;
}
if (!child)
continue;
if (line[strlen(line) - 1] == '?') {
printf("\n%s\n", child->sym->help ?
child->sym->help : nohelp_text);
continue;
}
sym_set_choice_value(sym, child->sym);
if (child->list) {
indent += 2;
conf(child->list);
indent -= 2;
}
return 1;
}
}
static void conf(struct menu *menu)
{
struct symbol *sym;
struct property *prop;
struct menu *child;
if (!menu_is_visible(menu))
return;
sym = menu->sym;
prop = menu->prompt;
if (prop) {
const char *prompt;
switch (prop->type) {
case P_MENU:
if (input_mode == ask_silent && rootEntry != menu) {
check_conf(menu);
return;
}
case P_COMMENT:
prompt = menu_get_prompt(menu);
if (prompt)
printf("%*c\n%*c %s\n%*c\n",
indent, '*',
indent, '*', prompt,
indent, '*');
default:
;
}
}
if (!sym)
goto conf_childs;
if (sym_is_choice(sym)) {
conf_choice(menu);
if (sym->curr.tri != mod)
return;
goto conf_childs;
}
switch (sym->type) {
case S_INT:
case S_HEX:
case S_STRING:
conf_string(menu);
break;
default:
conf_sym(menu);
break;
}
conf_childs:
if (sym)
indent += 2;
for (child = menu->list; child; child = child->next)
conf(child);
if (sym)
indent -= 2;
}
static void check_conf(struct menu *menu)
{
struct symbol *sym;
struct menu *child;
if (!menu_is_visible(menu))
return;
sym = menu->sym;
if (sym) {
if (sym_is_changable(sym) && !sym_has_value(sym)) {
if (!conf_cnt++)
printf("*\n* Restart config...\n*\n");
rootEntry = menu_get_parent_menu(menu);
conf(rootEntry);
}
if (sym_is_choice(sym) && sym_get_tristate_value(sym) != mod)
return;
}
for (child = menu->list; child; child = child->next)
check_conf(child);
}
int main(int ac, char **av)
{
int i = 1;
const char *name;
struct stat tmpstat;
if (ac > i && av[i][0] == '-') {
switch (av[i++][1]) {
case 'o':
input_mode = ask_new;
break;
case 's':
input_mode = ask_silent;
valid_stdin = isatty(0) && isatty(1) && isatty(2);
break;
case 'd':
input_mode = set_default;
break;
case 'D':
input_mode = set_default;
defconfig_file = av[i++];
if (!defconfig_file) {
printf("%s: No default config file specified\n",
av[0]);
exit(1);
}
break;
case 'n':
input_mode = set_no;
break;
case 'm':
input_mode = set_mod;
break;
case 'y':
input_mode = set_yes;
break;
case 'r':
input_mode = set_random;
srandom(time(NULL));
break;
case 'h':
case '?':
printf("%s [-o|-s] config\n", av[0]);
exit(0);
}
}
name = av[i];
if (!name) {
printf("%s: configuration file missing\n", av[0]);
}
conf_parse(name);
//zconfdump(stdout);
switch (input_mode) {
case ask_silent:
if (stat(".config", &tmpstat)) {
printf("***\n"
"*** You have not yet configured JHALFS!\n"
"***\n"
"*** Please run some configurator (e.g. \"make oldconfig\" or\n"
"*** \"make menuconfig\" or \"make config\").\n"
"***\n");
exit(1);
}
case ask_all:
case ask_new:
conf_read(NULL);
break;
default:
break;
}
if (input_mode != ask_silent) {
rootEntry = &rootmenu;
conf(&rootmenu);
if (input_mode == ask_all) {
input_mode = ask_silent;
valid_stdin = 1;
}
}
do {
conf_cnt = 0;
check_conf(&rootmenu);
} while (conf_cnt);
if (conf_write(NULL)) {
fprintf(stderr, "\n*** Error during writing of the JHALFS configuration.\n\n");
return 1;
}
return 0;
}

392
menu/confdata.c Normal file
View file

@ -0,0 +1,392 @@
/*
* Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
* Released under the terms of the GNU GPL v2.0.
*/
#include <sys/stat.h>
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#define LKC_DIRECT_LINK
#include "lkc.h"
const char conf_def_filename[] = "configuration";
const char conf_defname[] = "defconfig";
const char *conf_confnames[] = {
"configuration",
conf_defname,
NULL,
};
static char *conf_expand_value(const char *in)
{
struct symbol *sym;
const char *src;
static char res_value[SYMBOL_MAXLENGTH];
char *dst, name[SYMBOL_MAXLENGTH];
res_value[0] = 0;
dst = name;
while ((src = strchr(in, '$'))) {
strncat(res_value, in, src - in);
src++;
dst = name;
while (isalnum(*src) || *src == '_')
*dst++ = *src++;
*dst = 0;
sym = sym_lookup(name, 0);
sym_calc_value(sym);
strcat(res_value, sym_get_string_value(sym));
in = src;
}
strcat(res_value, in);
return res_value;
}
int conf_read(const char *name)
{
FILE *in = NULL;
char line[1024];
char *p, *p2;
int lineno = 0;
struct symbol *sym;
struct property *prop;
struct expr *e;
int i;
if (name) {
in = zconf_fopen(name);
} else {
const char **names = conf_confnames;
while ((name = *names++)) {
name = conf_expand_value(name);
in = zconf_fopen(name);
if (in) {
printf("#\n"
"# using defaults found in %s\n"
"#\n", name);
break;
}
}
}
if (!in)
return 1;
for_all_symbols(i, sym) {
sym->flags |= SYMBOL_NEW | SYMBOL_CHANGED;
sym->flags &= ~SYMBOL_VALID;
switch (sym->type) {
case S_INT:
case S_HEX:
case S_STRING:
free(sym->user.val);
default:
sym->user.val = NULL;
sym->user.tri = no;
}
}
while (fgets(line, sizeof(line), in)) {
lineno++;
sym = NULL;
switch (line[0]) {
case '#':
if (line[1]!=' ')
continue;
p = strchr(line + 2, ' ');
if (!p)
continue;
*p++ = 0;
if (strncmp(p, "is not set", 10))
continue;
sym = sym_find(line + 2);
if (!sym) {
fprintf(stderr, "%s:%d: trying to assign nonexistent symbol %s\n", name, lineno, line + 2);
break;
}
switch (sym->type) {
case S_BOOLEAN:
case S_TRISTATE:
sym->user.tri = no;
sym->flags &= ~SYMBOL_NEW;
break;
default:
;
}
break;
case 'A' ... 'Z':
p = strchr(line, '=');
if (!p)
continue;
*p++ = 0;
p2 = strchr(p, '\n');
if (p2)
*p2 = 0;
sym = sym_find(line);
if (!sym) {
fprintf(stderr, "%s:%d: trying to assign nonexistent symbol %s\n", name, lineno, line);
break;
}
switch (sym->type) {
case S_TRISTATE:
if (p[0] == 'm') {
sym->user.tri = mod;
sym->flags &= ~SYMBOL_NEW;
break;
}
case S_BOOLEAN:
if (p[0] == 'y') {
sym->user.tri = yes;
sym->flags &= ~SYMBOL_NEW;
break;
}
if (p[0] == 'n') {
sym->user.tri = no;
sym->flags &= ~SYMBOL_NEW;
break;
}
break;
case S_STRING:
if (*p++ != '"')
break;
for (p2 = p; (p2 = strpbrk(p2, "\"\\")); p2++) {
if (*p2 == '"') {
*p2 = 0;
break;
}
memmove(p2, p2 + 1, strlen(p2));
}
if (!p2) {
fprintf(stderr, "%s:%d: invalid string found\n", name, lineno);
exit(1);
}
case S_INT:
case S_HEX:
if (sym_string_valid(sym, p)) {
sym->user.val = strdup(p);
sym->flags &= ~SYMBOL_NEW;
} else {
fprintf(stderr, "%s:%d: symbol value '%s' invalid for %s\n", name, lineno, p, sym->name);
exit(1);
}
break;
default:
;
}
break;
case '\n':
break;
default:
continue;
}
if (sym && sym_is_choice_value(sym)) {
struct symbol *cs = prop_get_symbol(sym_get_choice_prop(sym));
switch (sym->user.tri) {
case no:
break;
case mod:
if (cs->user.tri == yes)
/* warn? */;
break;
case yes:
if (cs->user.tri != no)
/* warn? */;
cs->user.val = sym;
break;
}
cs->user.tri = E_OR(cs->user.tri, sym->user.tri);
cs->flags &= ~SYMBOL_NEW;
}
}
fclose(in);
if (modules_sym)
sym_calc_value(modules_sym);
for_all_symbols(i, sym) {
sym_calc_value(sym);
if (sym_has_value(sym) && !sym_is_choice_value(sym)) {
if (sym->visible == no)
sym->flags |= SYMBOL_NEW;
switch (sym->type) {
case S_STRING:
case S_INT:
case S_HEX:
if (!sym_string_within_range(sym, sym->user.val))
sym->flags |= SYMBOL_NEW;
default:
break;
}
}
if (!sym_is_choice(sym))
continue;
prop = sym_get_choice_prop(sym);
for (e = prop->expr; e; e = e->left.expr)
if (e->right.sym->visible != no)
sym->flags |= e->right.sym->flags & SYMBOL_NEW;
}
sym_change_count = 1;
return 0;
}
struct menu *next_menu(struct menu *menu)
{
if (menu->list) return menu->list;
do {
if (menu->next) {
menu = menu->next;
break;
}
} while ((menu = menu->parent));
return menu;
}
#define SYMBOL_FORCEWRITE (1<<31)
int conf_write(const char *name)
{
FILE *out;
struct symbol *sym;
struct menu *menu;
const char *basename;
char dirname[128], tmpname[128], newname[128];
int type, l;
const char *str;
dirname[0] = 0;
if (name && name[0]) {
struct stat st;
char *slash;
if (!stat(name, &st) && S_ISDIR(st.st_mode)) {
strcpy(dirname, name);
strcat(dirname, "/");
basename = conf_def_filename;
} else if ((slash = strrchr(name, '/'))) {
int size = slash - name + 1;
memcpy(dirname, name, size);
dirname[size] = 0;
if (slash[1])
basename = slash + 1;
else
basename = conf_def_filename;
} else
basename = name;
} else
basename = conf_def_filename;
sprintf(newname, "%s.tmpconfig.%d", dirname, (int)getpid());
out = fopen(newname, "w");
if (!out)
return 1;
fprintf(out, "#\n"
"# Automatically generated configuration: don't edit\n"
"# use make menuconfig or make config to make changes\n"
"#\n");
if (!sym_change_count)
sym_clear_all_valid();
/* Force write of all non-duplicate symbols. */
/* Write out everything by default. */
for(menu = rootmenu.list; menu; menu = next_menu(menu))
if (menu->sym) menu->sym->flags |= SYMBOL_FORCEWRITE;
menu = rootmenu.list;
while (menu) {
sym = menu->sym;
if (!sym) {
if (!menu_is_visible(menu))
goto next;
str = menu_get_prompt(menu);
fprintf(out, "\n"
"#\n"
"# %s\n"
"#\n", str);
} else if (!(sym->flags & SYMBOL_CHOICE)) {
sym_calc_value(sym);
if (!(sym->flags & SYMBOL_FORCEWRITE))
goto next;
sym->flags &= ~SYMBOL_FORCEWRITE;
type = sym->type;
if (type == S_TRISTATE) {
sym_calc_value(modules_sym);
if (modules_sym->curr.tri == no)
type = S_BOOLEAN;
}
switch (type) {
case S_BOOLEAN:
case S_TRISTATE:
switch (sym_get_tristate_value(sym)) {
case no:
fprintf(out, "# %s is not set\n", sym->name);
break;
case mod:
fprintf(out, "%s=m\n", sym->name);
break;
case yes:
fprintf(out, "%s=y\n", sym->name);
break;
}
break;
case S_STRING:
// fix me
str = sym_get_string_value(sym);
fprintf(out, "%s=\"", sym->name);
do {
l = strcspn(str, "\"\\");
if (l) {
fwrite(str, l, 1, out);
}
str += l;
while (*str == '\\' || *str == '"') {
fprintf(out, "\\%c", *str);
str++;
}
} while (*str);
fputs("\"\n", out);
break;
case S_HEX:
str = sym_get_string_value(sym);
if (str[0] != '0' || (str[1] != 'x' && str[1] != 'X')) {
fprintf(out, "%s=%s\n", sym->name, *str ? str : "0");
break;
}
case S_INT:
str = sym_get_string_value(sym);
fprintf(out, "%s=%s\n", sym->name, *str ? str : "0");
break;
}
}
next:
menu = next_menu(menu);
}
fclose(out);
if (!name || basename != conf_def_filename) {
if (!name)
name = conf_def_filename;
sprintf(tmpname, "%s.old", name);
rename(name, tmpname);
}
sprintf(tmpname, "%s%s", dirname, basename);
if (rename(newname, tmpname))
return 1;
sym_change_count = 0;
return 0;
}

1099
menu/expr.c Normal file

File diff suppressed because it is too large Load diff

195
menu/expr.h Normal file
View file

@ -0,0 +1,195 @@
/*
* Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
* Released under the terms of the GNU GPL v2.0.
*/
#ifndef EXPR_H
#define EXPR_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h>
#ifndef __cplusplus
#include <stdbool.h>
#endif
struct file {
struct file *next;
struct file *parent;
char *name;
int lineno;
int flags;
};
#define FILE_BUSY 0x0001
#define FILE_SCANNED 0x0002
#define FILE_PRINTED 0x0004
typedef enum tristate {
no, mod, yes
} tristate;
enum expr_type {
E_NONE, E_OR, E_AND, E_NOT, E_EQUAL, E_UNEQUAL, E_CHOICE, E_SYMBOL, E_RANGE
};
union expr_data {
struct expr *expr;
struct symbol *sym;
};
struct expr {
enum expr_type type;
union expr_data left, right;
};
#define E_OR(dep1, dep2) (((dep1)>(dep2))?(dep1):(dep2))
#define E_AND(dep1, dep2) (((dep1)<(dep2))?(dep1):(dep2))
#define E_NOT(dep) (2-(dep))
struct expr_value {
struct expr *expr;
tristate tri;
};
struct symbol_value {
void *val;
tristate tri;
};
enum symbol_type {
S_UNKNOWN, S_BOOLEAN, S_TRISTATE, S_INT, S_HEX, S_STRING, S_OTHER
};
struct symbol {
struct symbol *next;
char *name;
char *help;
enum symbol_type type;
struct symbol_value curr, user;
tristate visible;
int flags;
struct property *prop;
struct expr *dep, *dep2;
struct expr_value rev_dep;
};
#define for_all_symbols(i, sym) for (i = 0; i < 257; i++) for (sym = symbol_hash[i]; sym; sym = sym->next) if (sym->type != S_OTHER)
#define SYMBOL_YES 0x0001
#define SYMBOL_MOD 0x0002
#define SYMBOL_NO 0x0004
#define SYMBOL_CONST 0x0007
#define SYMBOL_CHECK 0x0008
#define SYMBOL_CHOICE 0x0010
#define SYMBOL_CHOICEVAL 0x0020
#define SYMBOL_PRINTED 0x0040
#define SYMBOL_VALID 0x0080
#define SYMBOL_OPTIONAL 0x0100
#define SYMBOL_WRITE 0x0200
#define SYMBOL_CHANGED 0x0400
#define SYMBOL_NEW 0x0800
#define SYMBOL_AUTO 0x1000
#define SYMBOL_CHECKED 0x2000
#define SYMBOL_CHECK_DONE 0x4000
#define SYMBOL_WARNED 0x8000
#define SYMBOL_MAXLENGTH 256
#define SYMBOL_HASHSIZE 257
#define SYMBOL_HASHMASK 0xff
enum prop_type {
P_UNKNOWN, P_PROMPT, P_COMMENT, P_MENU, P_DEFAULT, P_CHOICE, P_SELECT, P_RANGE
};
struct property {
struct property *next;
struct symbol *sym;
enum prop_type type;
const char *text;
struct expr_value visible;
struct expr *expr;
struct menu *menu;
struct file *file;
int lineno;
};
#define for_all_properties(sym, st, tok) \
for (st = sym->prop; st; st = st->next) \
if (st->type == (tok))
#define for_all_defaults(sym, st) for_all_properties(sym, st, P_DEFAULT)
#define for_all_choices(sym, st) for_all_properties(sym, st, P_CHOICE)
#define for_all_prompts(sym, st) \
for (st = sym->prop; st; st = st->next) \
if (st->text)
struct menu {
struct menu *next;
struct menu *parent;
struct menu *list;
struct symbol *sym;
struct property *prompt;
struct expr *dep;
unsigned int flags;
//char *help;
struct file *file;
int lineno;
void *data;
};
#define MENU_CHANGED 0x0001
#define MENU_ROOT 0x0002
#ifndef SWIG
extern struct file *file_list;
extern struct file *current_file;
struct file *lookup_file(const char *name);
extern struct symbol symbol_yes, symbol_no, symbol_mod;
extern struct symbol *modules_sym;
extern int cdebug;
struct expr *expr_alloc_symbol(struct symbol *sym);
struct expr *expr_alloc_one(enum expr_type type, struct expr *ce);
struct expr *expr_alloc_two(enum expr_type type, struct expr *e1, struct expr *e2);
struct expr *expr_alloc_comp(enum expr_type type, struct symbol *s1, struct symbol *s2);
struct expr *expr_alloc_and(struct expr *e1, struct expr *e2);
struct expr *expr_alloc_or(struct expr *e1, struct expr *e2);
struct expr *expr_copy(struct expr *org);
void expr_free(struct expr *e);
int expr_eq(struct expr *e1, struct expr *e2);
void expr_eliminate_eq(struct expr **ep1, struct expr **ep2);
tristate expr_calc_value(struct expr *e);
struct expr *expr_eliminate_yn(struct expr *e);
struct expr *expr_trans_bool(struct expr *e);
struct expr *expr_eliminate_dups(struct expr *e);
struct expr *expr_transform(struct expr *e);
int expr_contains_symbol(struct expr *dep, struct symbol *sym);
bool expr_depends_symbol(struct expr *dep, struct symbol *sym);
struct expr *expr_extract_eq_and(struct expr **ep1, struct expr **ep2);
struct expr *expr_extract_eq_or(struct expr **ep1, struct expr **ep2);
void expr_extract_eq(enum expr_type type, struct expr **ep, struct expr **ep1, struct expr **ep2);
struct expr *expr_trans_compare(struct expr *e, enum expr_type type, struct symbol *sym);
void expr_fprint(struct expr *e, FILE *out);
struct gstr; /* forward */
void expr_gstr_print(struct expr *e, struct gstr *gs);
static inline int expr_is_yes(struct expr *e)
{
return !e || (e->type == E_SYMBOL && e->left.sym == &symbol_yes);
}
static inline int expr_is_no(struct expr *e)
{
return e && (e->type == E_SYMBOL && e->left.sym == &symbol_no);
}
#endif
#ifdef __cplusplus
}
#endif
#endif /* EXPR_H */

File diff suppressed because it is too large Load diff

3692
menu/lex.zconf.c_shipped Normal file

File diff suppressed because it is too large Load diff

123
menu/lkc.h Normal file
View file

@ -0,0 +1,123 @@
/*
* Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
* Released under the terms of the GNU GPL v2.0.
*/
#ifndef LKC_H
#define LKC_H
#include "expr.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifdef LKC_DIRECT_LINK
#define P(name,type,arg) extern type name arg
#else
#include "lkc_defs.h"
#define P(name,type,arg) extern type (*name ## _p) arg
#endif
#include "lkc_proto.h"
#undef P
#define SRCTREE "srctree"
int zconfparse(void);
void zconfdump(FILE *out);
extern int zconfdebug;
void zconf_starthelp(void);
FILE *zconf_fopen(const char *name);
void zconf_initscan(const char *name);
void zconf_nextfile(const char *name);
int zconf_lineno(void);
char *zconf_curname(void);
/* confdata.c */
extern const char conf_def_filename[];
extern char conf_filename[];
char *conf_get_default_confname(void);
/* kconfig_load.c */
void kconfig_load(void);
/* menu.c */
void menu_init(void);
void menu_add_menu(void);
void menu_end_menu(void);
void menu_add_entry(struct symbol *sym);
void menu_end_entry(void);
void menu_add_dep(struct expr *dep);
struct property *menu_add_prop(enum prop_type type, char *prompt, struct expr *expr, struct expr *dep);
void menu_add_prompt(enum prop_type type, char *prompt, struct expr *dep);
void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep);
void menu_add_symbol(enum prop_type type, struct symbol *sym, struct expr *dep);
void menu_finalize(struct menu *parent);
void menu_set_type(int type);
/* util.c */
struct file *file_lookup(const char *name);
int file_write_dep(const char *name);
struct gstr {
size_t len;
char *s;
};
struct gstr str_new(void);
struct gstr str_assign(const char *s);
void str_free(struct gstr *gs);
void str_append(struct gstr *gs, const char *s);
void str_printf(struct gstr *gs, const char *fmt, ...);
const char *str_get(struct gstr *gs);
/* symbol.c */
void sym_init(void);
void sym_clear_all_valid(void);
void sym_set_changed(struct symbol *sym);
struct symbol *sym_check_deps(struct symbol *sym);
struct property *prop_alloc(enum prop_type type, struct symbol *sym);
struct symbol *prop_get_symbol(struct property *prop);
static inline tristate sym_get_tristate_value(struct symbol *sym)
{
return sym->curr.tri;
}
static inline struct symbol *sym_get_choice_value(struct symbol *sym)
{
return (struct symbol *)sym->curr.val;
}
static inline bool sym_set_choice_value(struct symbol *ch, struct symbol *chval)
{
return sym_set_tristate_value(chval, yes);
}
static inline bool sym_is_choice(struct symbol *sym)
{
return sym->flags & SYMBOL_CHOICE ? true : false;
}
static inline bool sym_is_choice_value(struct symbol *sym)
{
return sym->flags & SYMBOL_CHOICEVAL ? true : false;
}
static inline bool sym_is_optional(struct symbol *sym)
{
return sym->flags & SYMBOL_OPTIONAL ? true : false;
}
static inline bool sym_has_value(struct symbol *sym)
{
return sym->flags & SYMBOL_NEW ? false : true;
}
#ifdef __cplusplus
}
#endif
#endif /* LKC_H */

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