Do not auto build rescue tools when ${DESTDIR} != "/"
authorAaron LI <aly@aaronly.me>
Tue, 3 Jul 2018 12:15:17 +0000 (20:15 +0800)
committerAaron LI <aly@aaronly.me>
Wed, 4 Jul 2018 03:24:01 +0000 (11:24 +0800)
When installworld to an alternative root (i.e., ${DESTDIR} != "/"),
do not automatically build the rescue tools.

This change won't affect the nrelease build, since it will explicitly
do 'make initrd'.

Suggested-by: swildner
Makefile.inc1

index 5d792b0..a514702 100644 (file)
@@ -488,16 +488,18 @@ installworld: installcheck
            echo "Cannot write to ${AUTO_BACKUP} - world not backed up"
 
        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)
+       ${INSTALL} -o root -g wheel -m 644 ${.CURDIR}/Makefile_upgrade.inc \
+           ${DESTDIR}/etc/upgrade/
+
+.if !exists(/rescue/rescue) && \
+    (!defined(DESTDIR) || ${DESTDIR} == "" || ${DESTDIR} == "/")
+       # Do not leave an empty '/rescue' directory when switching the rescue
+       # tools from '/usr/share/initrd' to '/rescue'.
+       @echo "--------------------------------------------------------------"
+       @echo ">>> build and install rescue tools"
+       @echo "--------------------------------------------------------------"
+       (cd ${.CURDIR} && make rescue)
+.endif
 
        sync
        @echo "--------------------------------------------------------------"