diff --git a/BLFS/gen-special.sh b/BLFS/gen-special.sh index adaac4c..8b61d68 100755 --- a/BLFS/gen-special.sh +++ b/BLFS/gen-special.sh @@ -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 EOF - cat >> tmpfile << EOF +# cat >> tmpfile << EOF +# +# +# +# +# +# +# +# $packname +# ref +# +#EOF + precpack=$packname + done + cat >>$SPECIAL_FILE << EOF + + +EOF + cat >> tmpfile << EOF @@ -181,13 +199,6 @@ EOF $packname ref -EOF - done - cat >>$SPECIAL_FILE << EOF - - -EOF - cat >> tmpfile << EOF EOF done diff --git a/BLFS/gen_pkg_book.sh b/BLFS/gen_pkg_book.sh index e6aab30..e4dc8bb 100755 --- a/BLFS/gen_pkg_book.sh +++ b/BLFS/gen_pkg_book.sh @@ -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 <tail.tmp <script.tmp + cat head.tmp script.tmp tail.tmp >scripts/*${TARGET} + rm *.tmp +fi #clean_configuration diff --git a/BLFS/libs/func_dependencies b/BLFS/libs/func_dependencies index b2c082d..673d9f8 100644 --- a/BLFS/libs/func_dependencies +++ b/BLFS/libs/func_dependencies @@ -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 diff --git a/BLFS/xsl/gen_config.xsl b/BLFS/xsl/gen_config.xsl index f112926..63b3768 100644 --- a/BLFS/xsl/gen_config.xsl +++ b/BLFS/xsl/gen_config.xsl @@ -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" diff --git a/BLFS/xsl/list_lfs.xsl b/BLFS/xsl/list_lfs.xsl new file mode 100644 index 0000000..0ce91c6 --- /dev/null +++ b/BLFS/xsl/list_lfs.xsl @@ -0,0 +1,25 @@ + + + + + + + + bootscripts + lfs-bootscripts + kernel + porg + tzdata + + sudo + wget + + + + + + + + + diff --git a/BLFS/xsl/process-install.xsl b/BLFS/xsl/process-install.xsl index 619c72a..1f15028 100644 --- a/BLFS/xsl/process-install.xsl +++ b/BLFS/xsl/process-install.xsl @@ -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')"> ]> diff --git a/BLFS/xsl/process-replaceable.xsl b/BLFS/xsl/process-replaceable.xsl index e3e2331..ca61b60 100644 --- a/BLFS/xsl/process-replaceable.xsl +++ b/BLFS/xsl/process-replaceable.xsl @@ -123,6 +123,33 @@ $USER + + + /usr + + + + /opt/ + + + + + + + + en_GB + + + + + _ + + + + **EDITME diff --git a/BLFS/xsl/scripts.xsl b/BLFS/xsl/scripts.xsl index cb0cc70..ad6612a 100644 --- a/BLFS/xsl/scripts.xsl +++ b/BLFS/xsl/scripts.xsl @@ -302,7 +302,7 @@ cd $SRC_DIR - + @@ -441,10 +441,6 @@ echo Start Time: ${SECONDS} >> $INFOLOG - = @@ -460,24 +456,9 @@ echo Start Time: ${SECONDS} >> $INFOLOG " "$ " - else - - - wget -T 30 -t 5 " - - " || - - - - wget -T 30 -t 5 " - - " || - - - wget -T 30 -t 5 "${JH_FTP_SERVER}svn/ - - /$ - + else + wget -T 30 -t 5 " + " fi fi @@ -722,9 +703,13 @@ cd $BOOTUNPACKDIR + the end-root has not been called, except if the preceding "screen" + tag is itself preceded by a containing and to + bootscripts. So close it only if needed --> + test="preceding-sibling::screen[1][@role='root'] and + @role='root' and + not(preceding-sibling::screen[1]/preceding-sibling::para[1]/xref[@linkend='bootscripts'])"> @@ -733,17 +718,21 @@ cd $BOOTUNPACKDIR select="id('bootscripts')//itemizedlist//ulink/@url"/> + the begin-root will not be called. So do it.--> + test="preceding-sibling::screen[1][@role='root'] and + @role='root'"> + the end-root has not been called. So do it, except if it was already a + unit install --> + test="preceding-sibling::screen[1][@role='root'] and + @role='root' and + not(preceding-sibling::screen[1]/preceding-sibling::para[1]/xref[@linkend='systemd-units'])"> @@ -752,9 +741,10 @@ cd $BOOTUNPACKDIR select="id('systemd-units')//itemizedlist//ulink/@url"/> + the begin-root will not be called. So do it. --> + test="preceding-sibling::screen[1][@role='root'] and + @role='root'"> @@ -762,7 +752,7 @@ cd $BOOTUNPACKDIR + the end-root has not been called. --> @@ -770,9 +760,12 @@ cd $BOOTUNPACKDIR popd + the begin-root will not be called. So do it, except if the next + is itself a unit or bootscript install --> + 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'])"> @@ -918,28 +911,22 @@ echo Size after install: $(sudo du -skx --exclude home $BUILD_DIR) >> $INFOLOG - - - - - - - - - - - - - - - - + + + + + + + + + - + diff --git a/Config.in b/Config.in index 4bf1091..ef3779e 100644 --- a/Config.in +++ b/Config.in @@ -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 diff --git a/LFS/lfs.xsl b/LFS/lfs.xsl index c6075d6..d96aa60 100644 --- a/LFS/lfs.xsl +++ b/LFS/lfs.xsl @@ -28,6 +28,12 @@ --> + + + + + + @@ -415,6 +421,8 @@ echo -e "\n\nTotalseconds: $SECONDS\n" make mrproper cp -v ../kernel-config .config + timeout 60 make oldconfig ||\ + { echo kernel config is not up to date; exit 124; } @@ -615,6 +623,9 @@ unset OLD_PKGDIR + + + **EDITME @@ -1241,6 +1252,18 @@ tar -xf $PACKAGE cd $PKGDIR + +export MAKEFLAGS="-j + + + + + + + + + " + SECONDS=${PREV_SEC} # Start of LFS book script diff --git a/LFS/master.sh b/LFS/master.sh index ba06e7e..e3334d0 100644 --- a/LFS/master.sh +++ b/LFS/master.sh @@ -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 diff --git a/README b/README index 13d6f61..038c6f3 100644 --- a/README +++ b/README @@ -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 (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---). + 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 + (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---. - 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 + ALL=(ALL) NOPASSWD:ALL - The command will launch a menu based configuration program. The - underlying menu code was borrowed from BusyBox and slightly modified for - our use. + The command 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: diff --git a/common/chroot.xsl b/common/chroot.xsl index 75371c0..54e8601 100644 --- a/common/chroot.xsl +++ b/common/chroot.xsl @@ -6,6 +6,8 @@ extension-element-prefixes="exsl" version="1.0"> + + @@ -55,6 +57,13 @@ + + + + + diff --git a/common/kernfs.xsl b/common/kernfs.xsl index f47f665..d7043a0 100644 --- a/common/kernfs.xsl +++ b/common/kernfs.xsl @@ -16,9 +16,69 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + mountpoint -q + + || + + + + + + + + + mountpoint -q + + && + + + + + + + + + + + + + + + + + + + + + diff --git a/common/libs/func_book_parser b/common/libs/func_book_parser index 10115b8..3d83470 100644 --- a/common/libs/func_book_parser +++ b/common/libs/func_book_parser @@ -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" diff --git a/common/libs/func_compare.sh b/common/libs/func_compare.sh index fb368b8..2b6f9d1 100644 --- a/common/libs/func_compare.sh +++ b/common/libs/func_compare.sh @@ -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 } diff --git a/common/libs/func_download_pkgs b/common/libs/func_download_pkgs index 3d369d2..a6d9c7e 100644 --- a/common/libs/func_download_pkgs +++ b/common/libs/func_download_pkgs @@ -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 \ diff --git a/common/libs/func_install_blfs b/common/libs/func_install_blfs index 8a87b1b..b481c76 100644 --- a/common/libs/func_install_blfs +++ b/common/libs/func_install_blfs @@ -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 '\([^<]*\)<.*/\1/' | \\ diff --git a/common/libs/func_validate_configs.sh b/common/libs/func_validate_configs.sh index b14cf81..0a57cfc 100644 --- a/common/libs/func_validate_configs.sh +++ b/common/libs/func_validate_configs.sh @@ -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!" && diff --git a/common/libs/func_wrt_Makefile b/common/libs/func_wrt_Makefile index 78bb3e1..c694e76 100644 --- a/common/libs/func_wrt_Makefile +++ b/common/libs/func_wrt_Makefile @@ -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 diff --git a/common/run-in-cgroup.sh b/common/run-in-cgroup.sh new file mode 100755 index 0000000..3f57857 --- /dev/null +++ b/common/run-in-cgroup.sh @@ -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 diff --git a/common/urls.xsl b/common/urls.xsl index 3bfa072..185f07d 100644 --- a/common/urls.xsl +++ b/common/urls.xsl @@ -5,9 +5,6 @@ - - ftp://ftp.osuosl.org - diff --git a/jhalfs b/jhalfs index fc425af..9f2518c 100755 --- a/jhalfs +++ b/jhalfs @@ -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/" diff --git a/optimize/optimize_functions b/optimize/optimize_functions index 26d5043..1a73cd3 100644 --- a/optimize/optimize_functions +++ b/optimize/optimize_functions @@ -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" diff --git a/pkgmngt/packInstall.sh.porg b/pkgmngt/packInstall.sh.porg index b9d3f32..7aea2c0 100644 --- a/pkgmngt/packInstall.sh.porg +++ b/pkgmngt/packInstall.sh.porg @@ -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 }