initrd: don't leave an empty /rescue after switching location
authorAaron LI <liweitianux@live.com>
Sat, 9 Jun 2018 08:45:48 +0000 (16:45 +0800)
committerAaron LI <liweitianux@live.com>
Sat, 9 Jun 2018 09:00:17 +0000 (17:00 +0800)
The recent initrd change will remove the rescue tools from their old
location (/usr/share/initrd) but leave an empty /rescue directory.  Avoid
such a situation by building the rescue tools after installworld if /rescue
is empty.

Suggested-by: Fran├žois Tigeot
Makefile.inc1

index 06335e8..c93d1c4 100644 (file)
@@ -489,6 +489,16 @@ installworld: installcheck
 
        cd ${.CURDIR}; ${IMAKE} re${.TARGET:S/world$//}
        ${INSTALL} -o root -g wheel -m 644 ${.CURDIR}/Makefile_upgrade.inc ${DESTDIR}/etc/upgrade/
+
+       # Do not leave an empty /rescue directory when switching the rescue
+       # tools from /usr/share/initrd to /rescue.
+       @(if ! test -x ${DESTDIR}/rescue/rescue; then \
+           echo "--------------------------------------------------------------"; \
+           echo ">>> build and install rescue tools"; \
+           echo "--------------------------------------------------------------"; \
+           cd ${.CURDIR}; make rescue; \
+       fi)
+
        sync
        @echo "--------------------------------------------------------------"
        @echo ">>> installworld target complete"