Nimbin[12]?Mirrors & Forks / jhalfs / commits / 262e174

jhalfs git · trunk

jhalfs LFS build automation (mirror)

lfs mirror bash · first commit 2005-09-11 · last commit 2024-02-13 (2 years ago) · synced 3 days ago · upstream: git.linuxfromscratch.org/jhalfs

Python 78.4% Shell 19.8% Makefile 1.8%
git clone https://git.christianimmanuel.de/mirrors-forks/jhalfs.gitwget https://git.christianimmanuel.de/mirrors-forks/jhalfs/archive/jhalfs.tar.gz

systemd: copy /etc/resolv.conf from the host

Pierre Labastie · 2022-10-06 08:39 · 262e174aa1abfc72a0148d94a32ccfc88b269817

when entering chroot. This allows using the network in chroot.
 LFS/master.sh | 51 +++++++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 47 insertions(+), 4 deletions(-)

diff --git a/LFS/master.sh b/LFS/master.sh
index 0013c0f..f83bafb 100644
--- a/LFS/master.sh
+++ b/LFS/master.sh
@@ -293,6 +293,21 @@ build_Makefile() {           #
 
 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
 	@sudo env LFS=\$(MOUNT_PT) kernfs-scripts/teardown.sh
+EOF
+) >> $MKFILE
+# With systemd, the commands in chapter 9 do not create a
+# valid /etc/resolv.conf, so that if blfs_tools are installed, and
+# make-ca is run, it cannot connect. In this case, resolv.conf
+# from the host has been copied, and we need to remove it now.
+if [ "$INITSYS" = systemd ]; then
+(
+    cat << EOF
+	@sudo rm -v \$(MOUNT_PT)/etc/resolv.conf
+EOF
+) >> $MKFILE
+fi
+(
+    cat << EOF
 	@sudo make do_housekeeping
 	@echo $VERSION > lfs-release && \\
 	sudo mv lfs-release \$(MOUNT_PT)/etc && \\
@@ -380,11 +395,17 @@ devices: ck_UID
 	sudo env LFS=\$(MOUNT_PT) kernfs-scripts/devices.sh
 EOF
 ) >> $MKFILE
+# With systemd, the commands in chapter 9 do not create a
+# valid /etc/resolv.conf, so that if we want to enter chroot,
+# and systemd has not yet been run (otherwise /etc/resolv.conf
+# exists), we just copy resolv.conf from the host.
 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
+	if ! [ -e \$(MOUNT_PT)/etc/resolv.conf ]; then \\
+	  sudo cp -v /etc/resolv.conf \$(MOUNT_PT)/etc; \\
+	  sudo touch \$(MOUNT_PT)/etc/.host-resolvconf; \\
+	fi
 EOF
 ) >> $MKFILE
 fi
@@ -393,6 +414,25 @@ fi
 
 teardown:
 	sudo env LFS=\$(MOUNT_PT) kernfs-scripts/teardown.sh
+EOF
+) >> $MKFILE
+# With systemd, the commands in chapter 9 do not create a
+# valid /etc/resolv.conf, so that if we want to enter chroot,
+# and systemd has not yet been run (otherwise /etc/resolv.conf
+# exists), we just copy resolv.conf from the host.
+# We need to remove it now, if it has been created.
+if [ "$INITSYS" = systemd ]; then
+(
+    cat << EOF
+	if [ -e \$(MOUNT_PT)/etc/.host-resolvconf ]; then \\
+	  sudo rm -v \$(MOUNT_PT)/etc/resolv.conf; \\
+	  sudo rm -v \$(MOUNT_PT)/etc/.host-resolvconf; \\
+	fi
+EOF
+) >> $MKFILE
+fi
+(
+    cat << EOF
 
 chroot1: devices
 	sudo \$(CHROOT1)
@@ -407,11 +447,14 @@ LUSER:        $LUSER_TGT
 SUDO:         $SUDO_TGT
 EOF
 ) >> $MKFILE
+# With systemd, the commands in chapter 9 do not create a
+# valid /etc/resolv.conf, so that if blfs_tools are installed, and
+# make-ca is run, it cannot connect. We just copy resolv.conf
+# from the host. We'll remove it at the end.
 if [ "$INITSYS" = systemd ]; then
 (
     cat << EOF
-	mkdir -pv \$(MOUNT_PT)/run/systemd/resolve
-	cp -v /etc/resolv.conf \$(MOUNT_PT)/run/systemd/resolve
+	@cp -v /etc/resolv.conf \$(MOUNT_PT)/etc
 
 EOF
 ) >> $MKFILE