Get completely rid of PROGNAME

There is only one PROGNAME: lfs, so no need for a variable.
This commit is contained in:
Pierre Labastie 2022-03-30 17:45:35 +02:00
parent 2bd2fb81d0
commit 8825e69592
6 changed files with 88 additions and 151 deletions

View file

@ -45,10 +45,6 @@ menu "BOOK Settings"
default "sysv" if BOOK_LFS || BLFS_SYSV default "sysv" if BOOK_LFS || BLFS_SYSV
default "systemd" if BOOK_LFS_SYSD || BLFS_SYSD default "systemd" if BOOK_LFS_SYSD || BLFS_SYSD
config PROGNAME
string
default "lfs" if BOOK_LFS || BOOK_LFS_SYSD
config RUN_ME config RUN_ME
string string
default "./jhalfs run" if BOOK_LFS || BOOK_LFS_SYSD default "./jhalfs run" if BOOK_LFS || BOOK_LFS_SYSD
@ -936,7 +932,7 @@ depends on !BOOK_BLFS
config XSL config XSL
string "XSL stylesheet" string "XSL stylesheet"
default "$PROGNAME.xsl" default "lfs.xsl"
config PKG_LST config PKG_LST
string "Package contents list" string "Package contents list"

View file

@ -10,7 +10,7 @@ get_book() { #
test `type -p git` || eval "echo \"This feature requires Git.\" test `type -p git` || eval "echo \"This feature requires Git.\"
exit 1" exit 1"
echo -n "Downloading the lfs document, $COMMIT commit... " echo -n "Downloading the lfs document, $COMMIT branch/tag/commit... "
# Grab a fresh book if it's missing, otherwise, update it from the # Grab a fresh book if it's missing, otherwise, update it from the
# repo. If we've already extracted the commands, move on to getting the # repo. If we've already extracted the commands, move on to getting the
@ -50,123 +50,82 @@ extract_commands() { #
# Extract the commands # Extract the commands
echo -n "Extracting commands for" echo -n "Extracting commands for"
case ${PROGNAME} in echo -n " ${L_arrow}${BOLD}LFS${R_arrow} build... "
# The scripts pages are xincluded by the book, so must
# be generated for running xsltproc
pushd $BOOK > /dev/null
if [ -f process-scripts.sh ]; then
bash process-scripts.sh >> $LOGDIR/$LOG 2>&1
fi
# Recent git versions need version.ent to be generated
if [ -f git-version.sh ]; then
bash git-version.sh "$INITSYS" >> $LOGDIR/$LOG 2>&1
fi
popd > /dev/null
lfs) # First profile the book, for revision and arch. Note that
echo -n " ${L_arrow}${BOLD}LFS${R_arrow} build... " # MULTIBLIB is set to "default" if pure 64 bit book. In this case,
# The scripts pages are xincluded by the book, so must # profiling on arch is useless, but does not hurt either.
# be generated for running xsltproc xsltproc --nonet \
pushd $BOOK > /dev/null --xinclude \
if [ -f process-scripts.sh ]; then --stringparam profile.revision "$INITSYS" \
bash process-scripts.sh >> $LOGDIR/$LOG 2>&1 --stringparam profile.arch "$MULTILIB" \
fi --output prbook.xml \
# Recent git versions need version.ent to be generated $BOOK/stylesheets/lfs-xsl/profile.xsl \
if [ -f git-version.sh ]; then $BOOK/index.xml >> $LOGDIR/$LOG 2>&1
bash git-version.sh "$INITSYS" >> $LOGDIR/$LOG 2>&1
fi
popd > /dev/null
# First profile the book, for revision and arch. Note that # Use the profiled book for generating the scriptlets
# MULTIBLIB is set to "default" if pure 64 bit book. In this xsltproc --nonet \
# profiling on arch is useless, but does not hurt either. --stringparam testsuite "$TEST" \
xsltproc --nonet \ --stringparam bomb-testsuite "$BOMB_TEST" \
--xinclude \ --stringparam ncurses5 "$NCURSES5" \
--stringparam profile.revision "$INITSYS" \ --stringparam strip "$STRIP" \
--stringparam profile.arch "$MULTILIB" \ --stringparam del-la-files "$DEL_LA_FILES" \
--output prbook.xml \ --stringparam full-locale "$FULL_LOCALE" \
$BOOK/stylesheets/lfs-xsl/profile.xsl \ --stringparam timezone "$TIMEZONE" \
$BOOK/index.xml >> $LOGDIR/$LOG 2>&1 --stringparam page "$PAGE" \
--stringparam lang "$LANG" \
# Use the profiled book for generating the scriptlets --stringparam pkgmngt "$PKGMNGT" \
xsltproc --nonet \ --stringparam wrap-install "$WRAP_INSTALL" \
--stringparam testsuite "$TEST" \ --stringparam hostname "$HOSTNAME" \
--stringparam bomb-testsuite "$BOMB_TEST" \ --stringparam interface "$INTERFACE" \
--stringparam ncurses5 "$NCURSES5" \ --stringparam ip "$IP_ADDR" \
--stringparam strip "$STRIP" \ --stringparam gateway "$GATEWAY" \
--stringparam del-la-files "$DEL_LA_FILES" \ --stringparam prefix "$PREFIX" \
--stringparam full-locale "$FULL_LOCALE" \ --stringparam broadcast "$BROADCAST" \
--stringparam timezone "$TIMEZONE" \ --stringparam domain "$DOMAIN" \
--stringparam page "$PAGE" \ --stringparam nameserver1 "$DNS1" \
--stringparam lang "$LANG" \ --stringparam nameserver2 "$DNS2" \
--stringparam pkgmngt "$PKGMNGT" \ --stringparam font "$FONT" \
--stringparam wrap-install "$WRAP_INSTALL" \ --stringparam fontmap "$FONTMAP" \
--stringparam hostname "$HOSTNAME" \ --stringparam unicode "$UNICODE" \
--stringparam interface "$INTERFACE" \ --stringparam keymap "$KEYMAP" \
--stringparam ip "$IP_ADDR" \ --stringparam local "$LOCAL" \
--stringparam gateway "$GATEWAY" \ --stringparam log-level "$LOG_LEVEL" \
--stringparam prefix "$PREFIX" \ --stringparam script-root "$SCRIPT_ROOT" \
--stringparam broadcast "$BROADCAST" \ --output "./${COMMANDS}/" \
--stringparam domain "$DOMAIN" \ $XSL \
--stringparam nameserver1 "$DNS1" \ prbook.xml >> $LOGDIR/$LOG 2>&1
--stringparam nameserver2 "$DNS2" \ # Remove flags requesting user action in some cases. Much easier here than
--stringparam font "$FONT" \ # in the stylesheet...
--stringparam fontmap "$FONTMAP" \ sed -i 's/-iv /-v /' "./${COMMANDS}/"chapter??/*kernel*
--stringparam unicode "$UNICODE" \
--stringparam keymap "$KEYMAP" \
--stringparam local "$LOCAL" \
--stringparam log-level "$LOG_LEVEL" \
--stringparam script-root "$SCRIPT_ROOT" \
--output "./${COMMANDS}/" \
$XSL \
prbook.xml >> $LOGDIR/$LOG 2>&1
# Remove flags requesting user action in some cases. Much easier here than
# in the stylesheet...
sed -i 's/-iv /-v /' "./${COMMANDS}/"chapter??/*kernel*
;;
*) echo -n " ${L_arrow}${PROGNAME}${R_arrow} book invalid, terminate build... "
exit 1 ;;
esac
echo "done" echo "done"
# Make the scripts executable. # Make the scripts executable.
chmod -R +x "$JHALFSDIR/${COMMANDS}" chmod -R +x "$JHALFSDIR/${COMMANDS}"
create_chroot_scripts
# Create the packages file. We need it for proper Makefile creation create_kernfs_scripts
# lfs does not use this anymore, but this is taken care in the
# function body
create_package_list
# On the other hand, lfs needs two auxiliary files
if [ "${PROGNAME}" = lfs ]; then
create_chroot_scripts
create_kernfs_scripts
fi
# we create the VERSION variable here. Should maybe go into its own # we create the VERSION variable here. Should maybe go into its own
# function. But at this point we can use the profiled xml to get # function. But at this point we can use the profiled xml to get
# version from lfs-release in the lfs case. # version from lfs-release in the lfs case.
case $PROGNAME in VERSION=$(grep 'echo.*lfs-release' prbook.xml | sed 's/.*echo[ ]*\([^ ]*\).*/\1/')
lfs)
VERSION=$(grep 'echo.*lfs-release' prbook.xml | sed 's/.*echo[ ]*\([^ ]*\).*/\1/')
;;
*)
VERSION=$(xmllint --noent $BOOK/prologue/bookinfo.xml 2>/dev/null | grep subtitle | sed -e 's/^.*ion //' -e 's/<\/.*//') ;;
esac
# Done. Moving on... # Done. Moving on...
get_sources get_sources
} }
#----------------------------#
create_package_list() { #
#----------------------------#
# Create the packages file. We need it for proper Makefile creation
rm -f pkg_tarball_list
echo -n "Creating <${PROGNAME}> list of tarball names for $BOOK"
if [ ! -z "$ARCH" ] ; then echo -n " $ARCH" ; fi
echo -n "... "
case ${PROGNAME} in
lfs)
# lfs does not use the package list anymore
;;
*)
esac
echo "done"
}
#----------------------------# #----------------------------#
create_chroot_scripts() { # create_chroot_scripts() { #
#----------------------------# #----------------------------#
@ -175,14 +134,9 @@ create_chroot_scripts() { #
echo -n "Creating chroot commands scripts from $BOOK" echo -n "Creating chroot commands scripts from $BOOK"
if [ ! -z $ARCH ] ; then echo -n " $ARCH" ; fi if [ ! -z $ARCH ] ; then echo -n " $ARCH" ; fi
echo -n "... " echo -n "... "
case ${PROGNAME} in xsltproc --nonet --xinclude \
lfs) -o chroot-scripts/ chroot.xsl \
xsltproc --nonet --xinclude \ $BOOK/chapter0?/*chroot*.xml >> $LOGDIR/$LOG 2>&1
-o chroot-scripts/ chroot.xsl \
$BOOK/chapter0?/*chroot*.xml >> $LOGDIR/$LOG 2>&1
;;
*)
esac
echo "done" echo "done"
} }
@ -196,17 +150,13 @@ create_kernfs_scripts() { #
echo -n "Creating virtual kernel FS commands scripts from $BOOK" echo -n "Creating virtual kernel FS commands scripts from $BOOK"
if [ ! -z $ARCH ] ; then echo -n " $ARCH" ; fi if [ ! -z $ARCH ] ; then echo -n " $ARCH" ; fi
echo -n "... " echo -n "... "
case ${PROGNAME} in xsltproc --nonet \
lfs) -o kernfs-scripts/devices.sh kernfs.xsl \
xsltproc --nonet \ $BOOK/*/kernfs.xml >> $LOGDIR/$LOG 2>&1
-o kernfs-scripts/devices.sh kernfs.xsl \ xsltproc --nonet \
$BOOK/*/kernfs.xml >> $LOGDIR/$LOG 2>&1 -o kernfs-scripts/teardown.sh kernfs.xsl \
xsltproc --nonet \ $BOOK/chapter??/reboot.xml >> $LOGDIR/$LOG 2>&1
-o kernfs-scripts/teardown.sh kernfs.xsl \
$BOOK/chapter??/reboot.xml >> $LOGDIR/$LOG 2>&1
;;
*)
esac
echo "done" echo "done"
} }

View file

@ -130,20 +130,16 @@ create_urls() { #
#----------------------------# #----------------------------#
cd $JHALFSDIR cd $JHALFSDIR
case ${PROGNAME} in echo -n "Creating URLs file... "
lfs) xsltproc --nonet --xinclude \
echo -n "Creating LFS specific URLs file" --stringparam server "$SERVER" \
xsltproc --nonet --xinclude \ --stringparam family lfs \
--stringparam server "$SERVER" \ --stringparam pkgmngt "$PKGMNGT" \
--stringparam family lfs \ --stringparam revision "$INITSYS" \
--stringparam pkgmngt "$PKGMNGT" \ --output ../sources/urls.lst \
--stringparam revision "$INITSYS" \ urls.xsl \
--output ../sources/urls.lst \ $BOOK/chapter03/chapter03.xml >>$LOGDIR/$LOG 2>&1
urls.xsl \ echo "OK"
$BOOK/chapter03/chapter03.xml >>$LOGDIR/$LOG 2>&1
echo " ...OK"
;;
esac
cd $BUILDDIR/sources cd $BUILDDIR/sources

View file

@ -5,12 +5,10 @@ declare -r dotSTR=".................."
validate_config() { # Are the config values sane (within reason) validate_config() { # Are the config values sane (within reason)
#----------------------------# #----------------------------#
: <<inline_doc : <<inline_doc
Validates the configuration parameters. The global var PROGNAME selects the Validates the configuration parameters.
parameter list.
input vars: none input vars: none
externals: color constants externals: color constants
PROGNAME (lfs only as of February 28th, 2022)
modifies: none modifies: none
returns: nothing returns: nothing
on error: write text to console and dies on error: write text to console and dies
@ -18,7 +16,7 @@ validate_config() { # Are the config values sane (within reason)
inline_doc inline_doc
# Common settings by Config.in sections and books family # Common settings by Config.in sections and books family
local -r BOOK_common="BOOK CUSTOM_TOOLS" local -r BOOK_common="COMMIT BOOK CUSTOM_TOOLS"
local -r GENERAL_common="LUSER LGROUP LHOME BUILDDIR CLEAN GETPKG SRC_ARCHIVE \ local -r GENERAL_common="LUSER LGROUP LHOME BUILDDIR CLEAN GETPKG SRC_ARCHIVE \
SERVER RETRYSRCDOWNLOAD RETRYDOWNLOADCNT DOWNLOADTIMEOUT \ SERVER RETRYSRCDOWNLOAD RETRYDOWNLOADCNT DOWNLOADTIMEOUT \
RUNMAKE" RUNMAKE"
@ -123,8 +121,7 @@ inline_doc
} }
set +e set +e
PARAM_GROUP=${PROGNAME}_PARAM_LIST for config_param in $lfs_PARAM_LIST; do
for config_param in ${!PARAM_GROUP}; do
case $config_param in case $config_param in
# Envvars that depend on other settings to be displayed # Envvars that depend on other settings to be displayed
COMPARE) [[ ! "$COMPARE" = "y" ]] && echo -e "`eval echo $PARAM_VALS`" ;; COMPARE) [[ ! "$COMPARE" = "y" ]] && echo -e "`eval echo $PARAM_VALS`" ;;
@ -208,7 +205,7 @@ inline_doc
fi fi
fi fi
;; ;;
# Display non-validated envars found in ${PROGNAME}_PARAM_LIST # Display non-validated envars found in lfs_PARAM_LIST
* ) echo -e "`eval echo $PARAM_VALS`" ;; * ) echo -e "`eval echo $PARAM_VALS`" ;;
esac esac

View file

@ -233,7 +233,6 @@ LUSER_wrt_RunAsUser() { # Calculate time with perl, footer to log fil
cat << EOF cat << EOF
@source ~/.bashrc && \\ @source ~/.bashrc && \\
\$(CMDSDIR)/`dirname $file`/\$@ >> \$(LOGDIR)/\$@$version 2>&1 && \\ \$(CMDSDIR)/`dirname $file`/\$@ >> \$(LOGDIR)/\$@$version 2>&1 && \\
if [ "${PROGNAME}" != lfs ]; then \$(PRT_DU) >>logs/\$@$version; fi
EOF EOF
) >> $MKFILE.tmp ) >> $MKFILE.tmp
} }
@ -250,7 +249,6 @@ CHROOT_wrt_RunAsRoot() { #
cat << EOF cat << EOF
@source envars && \\ @source envars && \\
\$(crCMDSDIR)/`dirname $file`/\$@ >>\$(crLOGDIR)/\$@$version 2>&1 && \\ \$(crCMDSDIR)/`dirname $file`/\$@ >>\$(crLOGDIR)/\$@$version 2>&1 && \\
if [ "${PROGNAME}" != lfs ]; then \$(PRT_DU_CR) >>logs/\$@$version; fi
EOF EOF
) >> $MKFILE.tmp ) >> $MKFILE.tmp

4
jhalfs
View file

@ -204,7 +204,7 @@ declare -r COMMANDS=lfs-commands
# Set true internal variables # Set true internal variables
COMMON_DIR="common" COMMON_DIR="common"
PACKAGE_DIR=$(echo "$PROGNAME" | tr '[:lower:]' '[:upper:]') PACKAGE_DIR=LFS
MODULE=$PACKAGE_DIR/master.sh MODULE=$PACKAGE_DIR/master.sh
PKGMNGTDIR="pkgmngt" PKGMNGTDIR="pkgmngt"
# The name packageManager.xml is hardcoded in *.xsl, so no variable. # The name packageManager.xml is hardcoded in *.xsl, so no variable.
@ -342,7 +342,7 @@ if [[ "$REBUILD_MAKEFILE" = "n" ]] ; then
export XSL=$JHALFSDIR/${XSL} export XSL=$JHALFSDIR/${XSL}
# Copy packageManager.xml, if needed # Copy packageManager.xml, if needed
[[ "$PKGMNGT" = "y" ]] && [[ "$PROGNAME" = "lfs" ]] && { [[ "$PKGMNGT" = "y" ]] && {
sed s@BOOK@"$BOOK"@ "$PKGMNGTDIR/packageManager.xml" > \ sed s@BOOK@"$BOOK"@ "$PKGMNGTDIR/packageManager.xml" > \
"$JHALFSDIR/"packageManager.xml "$JHALFSDIR/"packageManager.xml
cp "$PKGMNGTDIR/packInstall.sh" "$JHALFSDIR/" cp "$PKGMNGTDIR/packInstall.sh" "$JHALFSDIR/"