Get virtual kernel filesystem commands from the book, and really add

/run/systemd/resolve/resolv.conf after creating the kernel FS in chapter 6
This commit is contained in:
Pierre Labastie 2019-03-13 06:31:55 +00:00
parent 49ba78d711
commit 13c475babc
4 changed files with 100 additions and 31 deletions

View file

@ -445,12 +445,32 @@ build_Makefile() { #
i=`expr $i + 1`
done
# Store virtual kernel file systems commands:
devices=`cat ../kernfs-scripts/devices.sh | \
sed -e 's|^| |' \
-e 's|mount|sudo &|' \
-e 's|mkdir|sudo &|' \
-e 's|\\$|&&|g' \
-e 's|\$\$LFS|$(MOUNT_PT)|g'`
teardown=`cat ../kernfs-scripts/teardown.sh | \
sed -e 's|^| |' \
-e 's|umount|sudo &|' \
-e 's|\$LFS|$(MOUNT_PT)|'`
teardownat=`cat ../kernfs-scripts/teardown.sh | \
sed -e 's|^| |' \
-e 's|umount|@-sudo &|' \
-e 's|\$LFS|$(MOUNT_PT)|'`
#echo [DEBUG]
#echo devices=$devices
#echo teardown=$teardown
#echo teardownat=$teardownat
# Drop in the main target 'all:' and the chapter targets with each sub-target
# as a dependency.
(
cat << EOF
all: ck_UID mk_SETUP mk_LUSER mk_SUDO mk_CHROOT mk_BOOT create-sbu_du-report mk_BLFS_TOOL mk_CUSTOM_TOOLS
$teardownat
@sudo make do_housekeeping
EOF
) >> $MKFILE
@ -533,14 +553,7 @@ mk_CUSTOM_TOOLS: mk_BLFS_TOOL
@touch \$@
devices: ck_UID
sudo mount -v --bind /dev \$(MOUNT_PT)/dev
sudo mount -vt devpts devpts \$(MOUNT_PT)/dev/pts
sudo mount -vt proc proc \$(MOUNT_PT)/proc
sudo mount -vt sysfs sysfs \$(MOUNT_PT)/sys
sudo mount -vt tmpfs tmpfs \$(MOUNT_PT)/run
if [ -h \$(MOUNT_PT)/dev/shm ]; then \\
sudo mkdir -p \$(MOUNT_PT)/\$\$(readlink \$(MOUNT_PT)/dev/shm); \\
fi
$devices
EOF
) >> $MKFILE
if [ "$INITSYS" = systemd ]; then
@ -553,12 +566,9 @@ EOF
fi
(
cat << EOF
teardown:
sudo umount -v \$(MOUNT_PT)/dev/pts
sudo umount -v \$(MOUNT_PT)/dev
sudo umount -v \$(MOUNT_PT)/run
sudo umount -v \$(MOUNT_PT)/proc
sudo umount -v \$(MOUNT_PT)/sys
$teardown
chroot1: devices
sudo \$(CHROOT1)
@ -571,6 +581,19 @@ chroot: devices
SETUP: $chapter4
LUSER: $chapter5
SUDO: $runasroot
EOF
) >> $MKFILE
if [ "$INITSYS" = systemd ]; then
(
cat << EOF
sudo mkdir -pv \$(MOUNT_PT)/run/systemd/resolve
sudo cp -v /etc/resolv.conf \$(MOUNT_PT)/run/systemd/resolve
EOF
) >> $MKFILE
fi
(
cat << EOF
CHROOT: SHELL=/tools/bin/bash
CHROOT: $chapter6
BOOT: $chapter78
@ -597,26 +620,12 @@ restore-luser-env:
@\$(call housekeeping)
do_housekeeping:
@-umount \$(MOUNT_PT)/sys
@-umount \$(MOUNT_PT)/proc
@-if mountpoint -q \$(MOUNT_PT)/run; then \\
umount \$(MOUNT_PT)/run; \\
elif [ -h \$(MOUNT_PT)/dev/shm ]; then \\
link=\$\$(readlink \$(MOUNT_PT)/dev/shm); \\
umount \$(MOUNT_PT)/\$\$link; \\
unset link; \\
else \\
umount \$(MOUNT_PT)/dev/shm; \\
fi
@-umount \$(MOUNT_PT)/dev/pts
@-umount \$(MOUNT_PT)/dev
@-rm /tools
@-if [ ! -f luser-exist ]; then \\
userdel \$(LUSER); \\
rm -rf \$(LUSER_HOME); \\
fi;
EOF
) >> $MKFILE

23
common/kernfs.xsl Normal file
View file

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- $Id: kernfs.xsl 3776 2014-01-12 21:43:04Z pierre $ -->
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="text"/>
<xsl:template match="/">
<xsl:apply-templates select="//userinput[contains(string(),'--bind') or
contains(string(),'/proc') or
contains(string(),'readlink')]"/>
</xsl:template>
<xsl:template match="userinput">
<xsl:apply-templates/>
<xsl:text>
</xsl:text>
</xsl:template>
</xsl:stylesheet>

View file

@ -211,7 +211,10 @@ extract_commands() { #
# Create the packages file. We need it for proper Makefile creation
create_package_list
if [ "${PROGNAME}" = lfs ]; then
create_chroot_scripts
create_kernfs_scripts
fi
# Done. Moving on...
get_sources
@ -261,7 +264,7 @@ create_package_list() { #
create_chroot_scripts() { #
#----------------------------#
rm -rf chroot_scripts
rm -rf chroot-scripts
echo -n "Creating chroot commands scripts from $BOOK"
if [ ! -z $ARCH ] ; then echo -n " $ARCH" ; fi
echo -n "... "
@ -286,3 +289,37 @@ create_chroot_scripts() { #
echo "done"
}
#----------------------------#
create_kernfs_scripts() { #
#----------------------------#
rm -rf kernfs-scripts
mkdir kernfs-scripts
echo -n "Creating virtual kernel FS commands scripts from $BOOK"
if [ ! -z $ARCH ] ; then echo -n " $ARCH" ; fi
echo -n "... "
case ${PROGNAME} in
clfs*)
xsltproc --nonet --xinclude \
-o kernfs-scripts/ kernfs.xsl \
$BOOK/BOOK/${ARCH}-index.xml >> $LOGDIR/$LOG 2>&1
;;
hlfs)
xsltproc --nonet --xinclude \
-o kernfs-scripts/ kernfs.xsl \
$BOOK/index.xml >> $LOGDIR/$LOG 2>&1
;;
lfs)
xsltproc --nonet \
-o kernfs-scripts/devices.sh kernfs.xsl \
$BOOK/chapter06/kernfs.xml >> $LOGDIR/$LOG 2>&1
xsltproc --nonet \
-o kernfs-scripts/teardown.sh kernfs.xsl \
$BOOK/chapter09/reboot.xml >> $LOGDIR/$LOG 2>&1
;;
*)
esac
echo "done"
}

2
jhalfs
View file

@ -381,7 +381,7 @@ if [[ "$REBUILD_MAKEFILE" = "n" ]] ; then
cp $COMMON_DIR/{makefile-functions,progress_bar.sh} $JHALFSDIR/
# Copy needed stylesheets
cp $COMMON_DIR/{packages.xsl,chroot.xsl} $JHALFSDIR/
cp $COMMON_DIR/{packages.xsl,chroot.xsl,kernfs.xsl} $JHALFSDIR/
# Fix the XSL book parser
case $PROGNAME in