Call kernel filesystem scripts from Makefile

Instead of having them inside the Makefile, which implies editing
them (automatically), which is not robust if anything changes:
it got broken when a test for a mountpoint was added...
This commit is contained in:
Pierre Labastie 2022-10-06 10:26:29 +02:00
parent 87eb9e9a94
commit 3722d3164c

View file

@ -286,30 +286,13 @@ build_Makefile() { #
i=`expr $i + 1` i=`expr $i + 1`
done 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|\$|; \\\\|' \
-e 's|then|& :|' \
-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)|'`
# Drop in the main target 'all:' and the chapter targets with each sub-target # Drop in the main target 'all:' and the chapter targets with each sub-target
# as a dependency. # as a dependency.
( (
cat << EOF cat << EOF
all: ck_UID ck_terminal mk_SETUP mk_LUSER mk_SUDO mk_CHROOT mk_BOOT create-sbu_du-report mk_BLFS_TOOL mk_CUSTOM_TOOLS all: ck_UID ck_terminal mk_SETUP mk_LUSER mk_SUDO mk_CHROOT mk_BOOT create-sbu_du-report mk_BLFS_TOOL mk_CUSTOM_TOOLS
$teardownat @sudo env LFS=\$(MOUNT_PT) kernfs-scripts/teardown.sh
@sudo make do_housekeeping @sudo make do_housekeeping
@echo $VERSION > lfs-release && \\ @echo $VERSION > lfs-release && \\
sudo mv lfs-release \$(MOUNT_PT)/etc && \\ sudo mv lfs-release \$(MOUNT_PT)/etc && \\
@ -394,7 +377,7 @@ mk_CUSTOM_TOOLS: mk_BLFS_TOOL
@touch \$@ @touch \$@
devices: ck_UID devices: ck_UID
$devices sudo env LFS=\$(MOUNT_PT) kernfs-scripts/devices.sh
EOF EOF
) >> $MKFILE ) >> $MKFILE
if [ "$INITSYS" = systemd ]; then if [ "$INITSYS" = systemd ]; then
@ -409,7 +392,7 @@ fi
cat << EOF cat << EOF
teardown: teardown:
$teardown sudo env LFS=\$(MOUNT_PT) kernfs-scripts/teardown.sh
chroot1: devices chroot1: devices
sudo \$(CHROOT1) sudo \$(CHROOT1)