Merge remote-tracking branch 'upstream/trunk' into mihari-dev

This commit is contained in:
Euiseo Cha 2023-11-26 14:31:01 +09:00
commit 41e5e3f5d8
Signed by: zeroday0619
GPG Key ID: 220CC17AA79A0AEA
25 changed files with 745 additions and 319 deletions

View File

@ -116,7 +116,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
@ -170,7 +170,25 @@ EOF
<!-- End dependencies -->
</module>
EOF
cat >> tmpfile << EOF
# cat >> tmpfile << EOF
# <xsl:element name="dependency">
# <xsl:attribute name="status">
# <xsl:value-of select="\$status"/>
# </xsl:attribute>
# <xsl:attribute name="build">
# <xsl:value-of select="\$build"/>
# </xsl:attribute>
# <xsl:attribute name="name">$packname</xsl:attribute>
# <xsl:attribute name="type">ref</xsl:attribute>
# </xsl:element>
#EOF
precpack=$packname
done
cat >>$SPECIAL_FILE << EOF
</package>
</xsl:when>
EOF
cat >> tmpfile << EOF
<xsl:element name="dependency">
<xsl:attribute name="status">
<xsl:value-of select="\$status"/>
@ -181,13 +199,6 @@ EOF
<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:when>
EOF
done

View File

@ -28,6 +28,7 @@ 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
@ -38,6 +39,7 @@ declare WRAP_INSTALL
declare PACK_INSTALL
declare DEL_LA_FILES
declare STATS
declare DEP_CHECK
declare SRC_ARCHIVE
declare SRC_SUBDIRS
declare BUILD_ROOT
@ -69,6 +71,7 @@ parse_configuration() { #
PACK_INSTALL=* | \
DEL_LA_FILES=* | \
STATS=* | \
DEP_CHECK=* | \
LANGUAGE=* | \
SUDO=* | \
SRC_ARCHIVE=* | \
@ -108,7 +111,7 @@ parse_configuration() { #
validate_configuration() { #
#--------------------------#
local -r dotSTR=".................."
local -r PARAM_LIST="DEP_LEVEL SUDO LANGUAGE MAIL_SERVER WRAP_INSTALL PACK_INSTALL DEL_LA_FILES STATS SRC_ARCHIVE SRC_SUBDIRS BUILD_ROOT BUILD_SUBDIRS KEEP_FILES JOBS CFG_CFLAGS CFG_CXXFLAGS CFG_LDFLAGS"
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_VALS='${config_param}${dotSTR:${#config_param}} ${L_arrow}${BOLD}${!config_param}${OFF}${R_arrow}'
local config_param
local -i index
@ -294,4 +297,50 @@ xsltproc --xinclude --nonet \
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

@ -522,7 +522,13 @@ while read prio_of_dep build_of_dep id_of_dep; do
# 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]
parentNode=$(grep ^"${otherlink[*]}"\$ -l *)
# 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
fi
else # not circular: prune tree (but not .dep, since it may happen that

View File

@ -89,21 +89,42 @@ menu "Build settings"
path.
config DEL_LA_FILES
bool "Remove libtool .la files after package installation"
default y
help
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
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"

25
BLFS/xsl/list_lfs.xsl Normal file
View File

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

@ -16,6 +16,7 @@
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')">
]>

View File

@ -123,6 +123,33 @@
<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/>

View File

@ -302,7 +302,7 @@ cd $SRC_DIR</xsl:text>
<xsl:apply-templates select="bridgehead[@renderas='sect3']"/>
</xsl:when><!-- @role="package" -->
<xsl:when test="@role = 'qt4-prefix' or @role = 'qt5-prefix'">
<xsl:when test="@role = 'qt5-prefix' or @role = 'qt6-prefix'">
<xsl:apply-templates select=".//screen[./userinput]"/>
</xsl:when>
@ -441,10 +441,6 @@ echo Start Time: ${SECONDS} >> $INFOLOG
</xsl:with-param>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="first_letter"
select="translate(substring($package,1,1),
'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
'abcdefghijklmnopqrstuvwxyz')"/>
<xsl:text>&#xA;</xsl:text>
<xsl:value-of select="$varname"/>
<xsl:text>=</xsl:text>
@ -460,24 +456,9 @@ echo Start Time: ${SECONDS} >> $INFOLOG
<xsl:text>" "$</xsl:text>
<xsl:value-of select="$varname"/>
<xsl:text>"
else&#xA;</xsl:text>
<!-- Download from upstream http -->
<xsl:if test="string-length($httpurl) &gt; 10">
<xsl:text> wget -T 30 -t 5 "</xsl:text>
<xsl:value-of select="$httpurl"/>
<xsl:text>" ||&#xA;</xsl:text>
</xsl:if>
<!-- Download from upstream ftp -->
<xsl:if test="string-length($ftpurl) &gt; 10">
<xsl:text> wget -T 30 -t 5 "</xsl:text>
<xsl:value-of select="$ftpurl"/>
<xsl:text>" ||&#xA;</xsl:text>
</xsl:if>
<!-- The FTP_SERVER mirror as a last resort -->
<xsl:text> wget -T 30 -t 5 "${JH_FTP_SERVER}svn/</xsl:text>
<xsl:value-of select="$first_letter"/>
<xsl:text>/$</xsl:text>
<xsl:value-of select="$varname"/>
else<!-- Download from upstream http -->
wget -T 30 -t 5 "</xsl:text>
<xsl:value-of select="$httpurl"/>
<xsl:text>"
fi
fi</xsl:text>
@ -722,9 +703,13 @@ cd $BOOTUNPACKDIR</xsl:text>
<xsl:template match="screen" mode="config">
<xsl:if test="preceding-sibling::para[1]/xref[@linkend='bootscripts']">
<!-- if the preceding "screen" tag is role="root", and we are role="root"
the end-root has not been called. So do it -->
the end-root has not been called, except if the preceding "screen"
tag is itself preceded by a <para> containing and <xref> to
bootscripts. So close it only if needed -->
<xsl:if
test="preceding-sibling::screen[1][@role='root'] and @role='root'">
test="preceding-sibling::screen[1][@role='root'] and
@role='root' and
not(preceding-sibling::screen[1]/preceding-sibling::para[1]/xref[@linkend='bootscripts'])">
<xsl:call-template name="end-root"/>
</xsl:if>
<xsl:call-template name="set-bootpkg-dir">
@ -733,17 +718,21 @@ cd $BOOTUNPACKDIR</xsl:text>
select="id('bootscripts')//itemizedlist//ulink/@url"/>
</xsl:call-template>
<!-- if the preceding "screen" tag is role="root", and we are role="root"
the begin-root will not be called. So do it -->
the begin-root will not be called. So do it.-->
<xsl:if
test="preceding-sibling::screen[1][@role='root'] and @role='root'">
test="preceding-sibling::screen[1][@role='root'] and
@role='root'">
<xsl:call-template name="begin-root"/>
</xsl:if>
</xsl:if>
<xsl:if test="preceding-sibling::para[1]/xref[@linkend='systemd-units']">
<!-- if the preceding "screen" tag is role="root", and we are role="root"
the end-root has not been called. So do it -->
the end-root has not been called. So do it, except if it was already a
unit install -->
<xsl:if
test="preceding-sibling::screen[1][@role='root'] and @role='root'">
test="preceding-sibling::screen[1][@role='root'] and
@role='root' and
not(preceding-sibling::screen[1]/preceding-sibling::para[1]/xref[@linkend='systemd-units'])">
<xsl:call-template name="end-root"/>
</xsl:if>
<xsl:call-template name="set-bootpkg-dir">
@ -752,9 +741,10 @@ cd $BOOTUNPACKDIR</xsl:text>
select="id('systemd-units')//itemizedlist//ulink/@url"/>
</xsl:call-template>
<!-- if the preceding "screen" tag is role="root", and we are role="root"
the begin-root will not be called. So do it -->
the begin-root will not be called. So do it. -->
<xsl:if
test="preceding-sibling::screen[1][@role='root'] and @role='root'">
test="preceding-sibling::screen[1][@role='root'] and
@role='root'">
<xsl:call-template name="begin-root"/>
</xsl:if>
</xsl:if>
@ -762,7 +752,7 @@ cd $BOOTUNPACKDIR</xsl:text>
<xsl:if test="preceding-sibling::para[1]/xref[@linkend='bootscripts' or
@linkend='systemd-units']">
<!-- if the next "screen" tag is role="root", and we are role="root"
the end-root has not been called. So do it -->
the end-root has not been called. -->
<xsl:if
test="following-sibling::screen[1][@role='root'] and @role='root'">
<xsl:call-template name="end-root"/>
@ -770,9 +760,12 @@ cd $BOOTUNPACKDIR</xsl:text>
<xsl:text>
popd</xsl:text>
<!-- if the next "screen" tag is role="root", and we are role="root"
the begin-root will not be called. So do it -->
the begin-root will not be called. So do it, except if the next
<screen> is itself a unit or bootscript install -->
<xsl:if
test="following-sibling::screen[1][@role='root'] and @role='root'">
test="following-sibling::screen[1][@role='root'] and
@role='root' and
not(following-sibling::screen[1]/preceding-sibling::para[1]/xref[@linkend='bootscripts' or @linkend='systemd-units'])">
<xsl:call-template name="begin-root"/>
</xsl:if>
</xsl:if>
@ -918,28 +911,22 @@ echo Size after install: $(sudo du -skx --exclude home $BUILD_DIR) >> $INFOLOG
<xsl:template match="userinput" mode="destdir">
<xsl:text>
</xsl:text>
<xsl:choose>
<xsl:when test="./literal">
<xsl:call-template name="outputpkgdest">
<xsl:with-param name="outputstring" select="text()[1]"/>
</xsl:call-template>
<xsl:apply-templates select="literal"/>
<xsl:call-template name="outputpkgdest">
<xsl:with-param name="outputstring" select="text()[2]"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="outputpkgdest">
<xsl:with-param name="outputstring" select="string()"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
<xsl:for-each select="./literal">
<xsl:call-template name="outputpkgdest">
<xsl:with-param name="outputstring" select="preceding-sibling::text()[1]"/>
</xsl:call-template>
<xsl:apply-templates select="."/>
</xsl:for-each>
<xsl:call-template name="outputpkgdest">
<xsl:with-param name="outputstring" select="text()[last()]"/>
</xsl:call-template>
</xsl:template>
<xsl:template name="outputpkgdest">
<xsl:param name="outputstring" select="'foo'"/>
<xsl:choose>
<xsl:when test="contains($outputstring,'make ')">
<xsl:when test="contains(normalize-space($outputstring),' make ') or
starts-with($outputstring, 'make ')">
<xsl:choose>
<xsl:when test="not(starts-with($outputstring,'make'))">
<xsl:call-template name="outputpkgdest">

201
Config.in
View File

@ -1,3 +1,11 @@
# Check for "nproc" presence:
config HAVE_NPROC
def_bool $(shell,if nproc &>/dev/null; then echo y; else echo n; fi)
# Check for "cpuset controller in cgroup v2" presence:
config HAVE_CGROUP
def_bool $(shell,if grep -q cpuset /sys/fs/cgroup/cgroup.controllers 2>/dev/null; then echo y; else echo n; fi)
menu "BOOK Settings"
#--- BOOK/script
@ -421,16 +429,6 @@ depends on !BOOK_BLFS
#-- Number of seconds to wait for a download to start before
# timing out.
config SERVER
string "FTP mirror"
default "http://ftp.osuosl.org"
depends on GETPKG
help
#-- FTP mirror to download packages and patches if not found
# in $SRC_ARCHIVE
# As a last resort, the files will downloaded from upstream,
# if possible.
config RUNMAKE
bool "Run the makefile"
default n
@ -451,6 +449,62 @@ endmenu
menu "Build Settings"
depends on !BOOK_BLFS
#--- Parallelism
menu "Parallelism settings"
if HAVE_NPROC
config ALL_CORES
bool "Use all cores"
default y
help
If you answer y, MAKEFLAGS will be set to "-j$(nproc)" at the
beginning of each package script, and book instructions will not
be changed otherwise. This will run the scripts with the same
settings as in the book since version r12.0-87 included. Before
that version, this will run the builds with all cores, but some
test suites may still be run sequentially. You'll be asked for
a CPU set to use, so that the number of jobs can still be limited
in this way (useful for measuring SBU values at -j4, for
example).
If you answer n, then jhalfs will fall back to a static number
of cores, defined below.
if ALL_CORES && HAVE_CGROUP
config CPUSET
string "set of cpus to use, or 'all' for all cpus"
default "all"
help
See "List format" in cpuset(7). Choosing cpus depend
on the topology of your processors. Sometimes two
hyperthreads on the same core are numbered consecutively.
For example for using all cores and no hyperthreading on
a Haswell, use "0,2,4,6". Other brands may have a different
topology, and may require e.g. "0-3" to use the first 4 cores.
If not sure, keep the default.
endif
endif # HAVE_NPROC
if !HAVE_NPROC
config ALL_CORES
bool
default n
endif
config N_PARALLEL
int "Number of parallel `make' jobs"
depends on !ALL_CORES
default 1
help
#-- The usual recommandation is (number of CPU cores)+1
# Do not set for meaningful SBU calculations.
config REALSBU
bool "Build Binutils pass1 without parallelism (Real SBU)"
default n
help
#-- Use -j1 in make invokation for Binutils pass1 to
# get a valid SBU value.
endmenu # parallelism
#--- Test Suites
config CONFIG_TESTS
bool "Run testsuites"
@ -467,9 +521,8 @@ depends on !BOOK_BLFS
# out. If you select 'n' here, the commented test instructions
# do not stop on test suite failures.
menu "Test settings"
depends on CONFIG_TESTS
choice
depends on CONFIG_TESTS
prompt "Tests level"
default TST_1
@ -490,8 +543,6 @@ depends on !BOOK_BLFS
endchoice
endmenu # test settings
config TEST
int
default "0" if !CONFIG_TESTS
@ -556,13 +607,6 @@ depends on !BOOK_BLFS
bool "Strip Installed Binaries/Libraries"
default n
config DEL_LA_FILES
bool "Remove libtool .la files"
default y
help
#-- Remove files libxxx.la installed by libtool. For a rationale
# see https://blog.flameeyes.eu/tags/lafiles/
config NO_PROGRESS_BAR
bool "DO NOT use/display progress_bar"
default n
@ -611,6 +655,13 @@ menu "System configuration"
#-- Fully qualified path to a kernel config file
# The config file will be copied to ${BUILD_DIR}/sources
# and renamed 'kernel-config'
#
# Important: if the config file is out of date (missing
# option), the kernel build will timeout instead of
# waiting forever for an input. This will generate error
# 124. In this case, update your config file,
# copy it to $BUILD_DIR/sources/kernel-config, and
# restart the build.
#--- End Kernel
config NCURSES5
@ -763,20 +814,59 @@ endmenu #--- System configuration
menu "Advanced Features"
depends on !BOOK_BLFS
#--- Optimizations
config CONFIG_OPTIMIZE
bool "Optimization"
default n
help
# Opens a menu for various optimization settings:
# Actual optimization flags MUST be defined in ./optimize/*
# before activating this option.
#
# WARNING: The use of build optimizations may lead to build issues.
# If the system doesn't work as expected, please rebuild
# without optimizations before asking for support.
menu "Optimization settings"
depends on CONFIG_OPTIMIZE
choice
prompt "Optimization level"
default OPT_1
help
#-- Optimization values are set in optimize/* files
config OPT_1
bool "Final system only"
config OPT_2
bool "Both temp tools and final system"
endchoice
endmenu # Optimization settings
config OPTIMIZE
int
default "0" if !CONFIG_OPTIMIZE
default "1" if OPT_1
default "2" if OPT_2
#--- End Optimizations
config REPORT
bool "Create SBU and disk usage report"
default y
config SAVE_CH5
bool "Save Chapter 5 work"
bool "Save temporary system work"
depends on BOOK_LFS || BOOK_LFS_SYSD
default n
help
Save the state of jhalfs at the end of chapter 5:
Save the state of jhalfs after finishing building the temporary
system
if you tick this item, the whole $LFS directory is
saved when chapter 5 is finished. It'll be in an xz
compressed tarball in the $LFS/jhalfs directory
saved when chapter 7 is finished. It'll be in a .tar
file in the $BUILD_DIR/jhalfs directory
#--- ICA
config COMPARE
@ -809,59 +899,6 @@ depends on !BOOK_BLFS
#--- End ICA
#--- Optimizations
config CONFIG_OPTIMIZE
bool "Optimization and parallelization"
default n
help
# Opens a menu for various optimization settings:
# Actual optimization flags MUST be defined in ./optimize/*
# before activating this option.
#
# WARNING: The use of build optimizations may lead to build issues.
# If the system doesn't work as expected, please rebuild
# without optimizations before asking for support.
menu "Parallelization and Optimization settings"
depends on CONFIG_OPTIMIZE
config N_PARALLEL
int "Number of parallel `make' jobs"
default 1
help
#-- The usual recommandation is (number of CPU cores)+1
# Do not set for meaningful SBU calculations.
choice
prompt "Optimization level"
default OPT_1
help
#-- Optimization values are set in optimize/* files
config OPT_1
bool "Final system only"
config OPT_2
bool "Both temp tools and final system"
endchoice
config REALSBU
bool "Build Binutls pass1 without optimization (Real SBU)"
depends on OPT_2
default n
help
#-- Use -j1 in make invokation for Binutils pass1 to
# get a valid SBU value.
endmenu # Optimization settings
config OPTIMIZE
int
default "0" if !CONFIG_OPTIMIZE
default "1" if OPT_1
default "2" if OPT_2
#--- End Optimizations
#-- Internal Settings
menu "Internal Settings (WARNING: for jhalfs developers only)"
@ -913,6 +950,14 @@ depends on !BOOK_BLFS
string "Package contents list"
default "unpacked"
config DEL_LA_FILES
bool "Remove libtool .la files"
default y
help
#-- Remove files libxxx.la installed by libtool. Only set to
# "n" if you know what you are doing. For a rationale
# see https://blog.flameeyes.eu/tags/lafiles/
#--- End Internal Settings
endmenu

View File

@ -28,6 +28,12 @@
-->
<xsl:param name="testsuite" select="1"/>
<!-- Parallelism (LFS >= 12.1) -->
<xsl:param name="jobs" select="1"/>
<!-- value of jobs for binutils-pass1 -->
<xsl:param name="jobs-bp1" select="1"/>
<!-- Install non wide character ncurses 5? -->
<xsl:param name="ncurses5" select="'n'"/>
@ -415,6 +421,8 @@ echo -e "\n\nTotalseconds: $SECONDS\n"
<xsl:text>make mrproper&#xA;</xsl:text>
<xsl:if test="ancestor::sect1[@id='ch-bootable-kernel']">
<xsl:text>cp -v ../kernel-config .config&#xA;</xsl:text>
<xsl:text>timeout 60 make oldconfig ||\&#xA;</xsl:text>
<xsl:text>{ echo kernel config is not up to date; exit 124; }&#xA;</xsl:text>
</xsl:if>
</xsl:when>
<!-- test instructions -->
@ -615,6 +623,9 @@ unset OLD_PKGDIR
<xsl:when test="contains(string(.),'&lt;lfs&gt;')">
<xsl:value-of select="$hostname"/>
</xsl:when>
<xsl:when test="contains(string(.),'$(nproc)')">
<xsl:value-of select="$jobs"/>
</xsl:when>
<xsl:otherwise>
<xsl:text>**EDITME</xsl:text>
<xsl:apply-templates/>
@ -1241,6 +1252,18 @@ tar -xf $PACKAGE
cd $PKGDIR
</xsl:text>
</xsl:if>
<xsl:text>
export MAKEFLAGS="-j</xsl:text>
<xsl:choose>
<xsl:when test="@id='ch-tools-binutils-pass1'">
<xsl:value-of select="$jobs-bp1"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$jobs"/>
</xsl:otherwise>
</xsl:choose>
<xsl:text>"
</xsl:text>
<xsl:text>SECONDS=${PREV_SEC}
# Start of LFS book script

View File

@ -127,14 +127,17 @@ chapter_targets() { #
# If using optimizations, write the instructions
case "${OPTIMIZE}$1${nb_chaps}${this_script}${REALSBU}" in
0* | *binutils-pass1y | 15* | 167* | 177*)
wrt_makeflags "$name" "-j1" "1" ;;
*kernel*) # No CFLAGS for kernel
wrt_makeflags "$name" "$JH_MAKEFLAGS" "$N_PARALLEL" ;;
*) wrt_optimize "$name" &&
wrt_makeflags "$name" "$JH_MAKEFLAGS" "$N_PARALLEL" ;;
0* | *binutils-pass1y | 15* | 167* | 177*) ;;
*kernel*) ;; # No CFLAGS for kernel
*) wrt_optimize "$name" ;;
esac
fi
# There is no need to tweak MAKEFLAGS anymore, this is done
# by lfs.xsl. But still, NINJAJOBS needs to be set if
# N_PARALLEL is defined.
if [ -n "N_PARALLEL" ]; then
wrt_makeflags "$name" "$JH_MAKEFLAGS" "$N_PARALLEL"
fi
fi # end of package specific instructions
# Some scriptlet have a special treatment; otherwise standard
case "${this_script}" in
@ -286,6 +289,17 @@ 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.
(
@ -368,24 +382,24 @@ mk_SUDO: mk_LUSER
@sudo make BREAKPOINT=\$(BREAKPOINT) SUDO
@touch \$@
mk_CHROOT: mk_SUDO
mk_CHROOT: mk_SUDO devices
@\$(call echo_CHROOT_request)
@( sudo \$(CHROOT1) -c "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) CHROOT")
@touch \$@
mk_BOOT: mk_CHROOT
mk_BOOT: mk_CHROOT devices
@\$(call echo_CHROOT_request)
@( sudo \$(CHROOT1) -c "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) BOOT")
@touch \$@
mk_BLFS_TOOL: create-sbu_du-report
mk_BLFS_TOOL: create-sbu_du-report devices
@if [ "\$(ADD_BLFS_TOOLS)" = "y" ]; then \\
\$(call sh_echo_PHASE,Building BLFS_TOOL); \\
(sudo \$(CHROOT1) -c "make -C $BLFS_ROOT/work"); \\
fi;
@touch \$@
mk_CUSTOM_TOOLS: mk_BLFS_TOOL
mk_CUSTOM_TOOLS: mk_BLFS_TOOL devices
@if [ "\$(ADD_CUSTOM_TOOLS)" = "y" ]; then \\
\$(call sh_echo_PHASE,Building CUSTOM_TOOLS); \\
sudo mkdir -p ${BUILDDIR}${TRACKING_DIR}; \\
@ -437,11 +451,11 @@ fi
cat << EOF
chroot1: devices
sudo \$(CHROOT1)
-sudo \$(CHROOT1)
\$(MAKE) teardown
chroot: devices
sudo \$(CHROOT1)
-sudo \$(CHROOT1)
\$(MAKE) teardown
SETUP: $SETUP_TGT

365
README
View File

@ -1,150 +1,268 @@
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.
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 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 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
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)
Other sources of information are the context help in the menu interface,
and the xLFS books themselves.
Other sources of information are the context help in the menu interface,
and the LFS books themselves (both required readings of course!).
2. PREREQUISITES::
As said elsewhere, it is strongly advised that you first build manually
a complete system before attempting to automate the build.
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. The needed
supplementary packages 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. Some
supplementary packages are needed for using jhalfs. They are detailed
at the bottom of the page:
https://www.linuxfromscratch.org/alfs/download.html. In short, you need
wget, sudo, libxml2, libxslt, docbook-4.5-xml, and docbook-xsl-nons.
3. INSTALLATION::
No installation is required. You may want to move the files in this
directory to a convenient location, and then follow the instructions below.
No installation is required. 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/{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. 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/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.
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.
For downloading packages, you can use the tool or download them
yourself. Even if using the tool, it is recommended to set up a source
repository where you store already downloaded packages. The tool will
automatically search a package in this repository before downloading it
if it is not found there. This repository cannot be the same as
/mnt/build_dir/sources. As an example, we'll use /usr/src. You should
arrange for the user running the tool to have write access to this
directory.
If you want to build the kernel as part of the automated build, 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> (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 (a convenient location and name is
$SRC_ARCHIVE/config-<arch>-<kernel version>-<config details>).
If you want to build the kernel as part of the automated build,
a configuration file must be provided. In order to do so, it is
recommended to download the kernel tarball, unpack it, run
<make menuconfig> (or any other *config), configure the kernel as per
the book, and save the resulting .config file to a location where it can
be retrieved later on. It is suggested to put it into the source
repository, with a versioned name, e.g.
/usr/src/config-<arch>-<kernel version>-<config details>.
Another file you may provide is the fstab file. 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.
Another file you may provide is the fstab file. As for the kernel
configuration, this file has to be prepared before running the menu.
You can copy-paste the file from the "Creating the /etc/fstab File"
page, then edit to suit the future lfs system layout, then save the
file. A convenient location and name is /usr/src/fstablfs.
At a more advanced level, you may want to supply custom commands
to be run at the end of (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.
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.
5. RUNNING::
IMPORTANT::
You must be logged as a normal user with sudo privileges to run
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
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.
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.
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
Once you have set the parameters and saved the configuration, the script
is launched. Its aim is to extract instructions from the selected book
@ -275,21 +393,6 @@
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:
cd $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. "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

@ -6,6 +6,8 @@
extension-element-prefixes="exsl"
version="1.0">
<xsl:param name="jobs_2" select="1"/>
<xsl:template match="/">
<xsl:apply-templates select="//sect1"/>
</xsl:template>
@ -55,6 +57,13 @@
<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">

View File

@ -16,9 +16,69 @@
</xsl:template>
<xsl:template match="userinput">
<xsl:apply-templates/>
<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

@ -63,6 +63,13 @@ extract_commands() { #
fi
popd > /dev/null
if [ "$ALL_CORES" = "y" ]; then
JOBS="\$(nproc)"
else
JOBS="$N_PARALLEL"
fi
if [ "$REALSBU" = y ]; then JOBSBP1=1; else JOBSBP1="$JOBS"; fi
# 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.
@ -102,6 +109,8 @@ extract_commands() { #
--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
@ -141,7 +150,8 @@ create_chroot_scripts() { #
if [ ! -z $ARCH ] ; then echo -n " $ARCH" ; fi
echo -n "... "
xsltproc --nonet --xinclude \
-o chroot-scripts/ chroot.xsl \
--stringparam jobs_2 "$JOBS_2" \
-o chroot-scripts/ chroot.xsl \
$BOOK/chapter0?/*chroot*.xml >> $LOGDIR/$LOG 2>&1
echo "done"

View File

@ -22,9 +22,11 @@ wrt_compare_targets() { #
local dir
printf -v dir chapter%02d "$1"
sed -i '/userdel/d' $dir/*revised*
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*
sed -i '/userdel/d' $dir-build_$N/*$REVISED*
done
}

View File

@ -132,8 +132,6 @@ create_urls() { #
echo -n "Creating URLs file... "
xsltproc --nonet --xinclude \
--stringparam server "$SERVER" \
--stringparam family lfs \
--stringparam pkgmngt "$PKGMNGT" \
--stringparam revision "$INITSYS" \
--output ../sources/urls.lst \

View File

@ -136,8 +136,9 @@ STATS=n
SRC_ARCHIVE=/sources
BUILD_ROOT=/sources
BUILD_SUBDIRS=y
JOBS=$(if [ -n "$N_PARALLEL" ]; then echo $N_PARALLEL; else echo 1; fi)
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
@ -179,7 +180,6 @@ pushd $BUILDDIR/sources
# Remove `unpacked' files if some have been left
sudo find . -name unpacked -exec rm \{\} \;
if [ "$GETPKG" = "y" ]; then
JH_FTP_SERVER=$SERVER/pub/blfs/ \
JH_SRC_ARCHIVE=${SRC_ARCHIVE:-/dev/null} \
$BUILDDIR$BLFS_ROOT/download_script
else # Save the download script in case the user wants to run it later
@ -218,10 +218,10 @@ 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/s@$@ update@' \
-e '/^all/i update:' \
-e 's/touch/@touch/' Makefile
cat >> Makefile << EOF
update:
update: all
@echo Updating the tracking file
@for pack in \$\$(grep '<productname' ../$LFS_XML/tmp/lfs-full.xml | \\
sed 's/.*>\([^<]*\)<.*/\1/' | \\

View File

@ -18,7 +18,7 @@ inline_doc
# Common settings by Config.in sections and books family
local -r BOOK_common="COMMIT BOOK CUSTOM_TOOLS"
local -r GENERAL_common="LUSER LGROUP LHOME BUILDDIR CLEAN GETPKG SRC_ARCHIVE \
SERVER RETRYSRCDOWNLOAD RETRYDOWNLOADCNT DOWNLOADTIMEOUT \
RETRYSRCDOWNLOAD RETRYDOWNLOADCNT DOWNLOADTIMEOUT \
RUNMAKE"
local -r BUILD_chroot="TEST STRIP"
local -r BUILD_common="FSTAB CONFIG TIMEZONE PAGE LANG INSTALL_LOG"
@ -29,13 +29,13 @@ inline_doc
local -r LFS_book="$BOOK_common INITSYS BLFS_TOOL"
# Build Settings by book
local -r LFS_build="$BUILD_chroot NCURSES5 DEL_LA_FILES $BUILD_common PKGMNGT FULL_LOCALE WRAP_INSTALL"
local -r LFS_build="$BUILD_chroot NCURSES5 $BUILD_common PKGMNGT FULL_LOCALE WRAP_INSTALL"
# System Settings by book
local -r LFS_system="HOSTNAME INTERFACE IP_ADDR GATEWAY PREFIX BROADCAST DOMAIN DNS1 DNS2 FONT KEYMAP LOCAL LOG_LEVEL"
# Full list of books settings
local -r lfs_PARAM_LIST="$LFS_book $GENERAL_common $LFS_build $LFS_system $ADVANCED_chroot N_PARALLEL REALSBU SAVE_CH5 $ADVANCED_common"
local -r lfs_PARAM_LIST="$LFS_book $GENERAL_common $LFS_build $LFS_system $ADVANCED_chroot ALL_CORES CPUSET N_PARALLEL REALSBU SAVE_CH5 $ADVANCED_common"
# local -r blfs_PARAM_LIST="BRANCH_ID BLFS_ROOT BLFS_XML TRACKING_DIR"
# Additional variables
@ -129,12 +129,11 @@ inline_doc
ITERATIONS) [[ "$COMPARE" = "y" ]] && echo -e "`eval echo $PARAM_VALS`" ;;
TARGET32) [[ -n "${TARGET32}" ]] && echo -e "`eval echo $PARAM_VALS`" ;;
MIPS_LEVEL) [[ "${ARCH}" = "mips" ]] && echo -e "`eval echo $PARAM_VALS`" ;;
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`" ;;
N_PARALLEL) [[ "$OPTIMIZE" -gt "0" ]] && echo -e "`eval echo $PARAM_VALS`" ;;
REALSBU) [[ "$OPTIMIZE" = "2" ]] && 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`"
@ -167,7 +166,7 @@ inline_doc
BOOT_CONFIG) [[ "${METHOD}" = "boot" ]] && validate_file -z -e -s ;;
# Treatment of LANG parameter
LANG ) # See it the locale value has been set
LANG ) # See if the locale value has been set
echo -n "`eval echo $PARAM_VALS`"
[[ -z "${!config_param}" ]] &&
echo " -- Variable $config_param cannot be empty!" &&

View File

@ -44,6 +44,7 @@ ADD_CUSTOM_TOOLS = $CUSTOM_TOOLS
ADD_BLFS_TOOLS = $BLFS_TOOL
PKGMNGT = $PKGMNGT
WRAP_INSTALL = $WRAP_INSTALL
CPUSET = $CPUSET
export PATH := \${PATH}:/usr/sbin

36
common/run-in-cgroup.sh Executable file
View File

@ -0,0 +1,36 @@
#!/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

@ -5,9 +5,6 @@
<xsl:output method="text"/>
<!-- The FTP server used as fallback -->
<xsl:param name="server">ftp://ftp.osuosl.org</xsl:param>
<!-- Do we use a package manager? -->
<xsl:param name="pkgmngt" select="'n'"/>

13
jhalfs
View File

@ -102,7 +102,7 @@ git_commit=$(git log -1 --format=format:"%h %ad")
version="
${BOLD} \"jhalfs\"${OFF} builder tool (development) $git_commit
Copyright (C) 2005-2021, the jhalfs team:
Copyright (C) 2005-2023, the jhalfs team:
Jeremy Huntwork
George Boudreau
Manuel Canales Esparcia
@ -175,6 +175,7 @@ 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}
@ -287,12 +288,14 @@ if [[ "$OPTIMIZE" != "0" ]]; then
#
# optimize configurations
load_file optimize/opt_config 'Loading optimization config'
# The number of parallel jobs is taken from configuration now
# shellcheck disable=SC2034
JH_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
@ -320,7 +323,7 @@ if [[ "$REBUILD_MAKEFILE" = "n" ]] ; then
true >"$LOGDIR/$LOG"
# Copy common helper files
cp "$COMMON_DIR"/{makefile-functions,progress_bar.sh} "$JHALFSDIR/"
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/"

View File

@ -16,9 +16,8 @@ validate_opt_settings() { # Show optimize setting and wait user agreeme
echo -e "expected, please rebuild without optimizations before"
echo -e "asking for support.${OFF}\n"
echo -e "MAKEFLAGS: ${L_arrow}${BOLD}${JH_MAKEFLAGS}${OFF}${R_arrow}"
[ -n "$JH_MAKEFLAGS" ] && \
echo -e "BLACK_LIST: ${L_arrow}${BOLD}${BLACK_LIST}${OFF}${R_arrow}\n"
# [ -n "$JH_MAKEFLAGS" ] && \
# echo -e "BLACK_LIST: ${L_arrow}${BOLD}${BLACK_LIST}${OFF}${R_arrow}\n"
echo -e "DEF_OPT_MODE: ${L_arrow}${BOLD}${DEF_OPT_MODE}${OFF}${R_arrow}\n"

View File

@ -121,7 +121,7 @@ PACKAGE=${PACKAGE,,}
# name is not normalized, several hacks are necessary (now in function
# extract_version)...
VERSION=$(extract_version $PCKGVRS)
porg -+ -lp ${PACKAGE}-${VERSION} sh -e << PORG_EOF
porg -+ -lp ${PACKAGE}-${VERSION} -- sh -e << PORG_EOF
$*
PORG_EOF
}