dhcpcd: Move any existing files out of the dhcp chroot.
authorRoy Marples <roy@marples.name>
Mon, 1 Jun 2020 13:57:36 +0000 (13:57 +0000)
committerRoy Marples <roy@marples.name>
Mon, 1 Jun 2020 13:57:36 +0000 (13:57 +0000)
So it's empty once more.

etc/Makefile

index f92ad4a..e630867 100644 (file)
@@ -260,6 +260,19 @@ upgrade_base:      upgrade_check preupgrade remove-obsolete-files
                echo "  make install"; \
        fi
 
                echo "  make install"; \
        fi
 
+# Move the dhcpcd duid, secret and lease files back outside the chroot.
+# Then ensure the chroot is empty.
+       DHCPCD_DB="${DESTDIR}/var/db/dhcpcd"; \
+       DHCPCD_CHROOT=`pw -V ${DESTDIR}/etc usershow _dhcp | cut -d: -f9`; \
+       DHCPCD_CHROOT_DB="${DESTDIR}$$DHCPCD_CHROOT/var/db/dhcpcd"; \
+       if [ -f "$$DHCPCD_CHROOT_DB/duid" ] && \
+           [ ! -f "$$DHCPCD_DB/duid" ]; then \
+               mkdir -p "$$DHCPCD_DB" && \
+               mv "$$DHCPCD_CHROOT_DB"/* "$$DHCPCD_DB"; \
+               chown -R root:wheel "$$DHCPCD_DB"; \
+               rm -rf "$$DHCPCD_CHROOT"/*; \
+       fi
+
 upgrade_etc:   upgrade_base remove-deprecated-files
        @echo "Upgrade was successful"
 
 upgrade_etc:   upgrade_base remove-deprecated-files
        @echo "Upgrade was successful"