diff --git a/libexec/rtld-elf/Makefile b/libexec/rtld-elf/Makefile index db8955e4bf74..e3750cc7dfdd 100644 --- a/libexec/rtld-elf/Makefile +++ b/libexec/rtld-elf/Makefile @@ -42,3 +42,15 @@ dyn_hack.so: .PATH: ${.CURDIR}/${MACHINE_ARCH} .include + +# Keep the previous version of the dynamic linker for recovery +# purposes. This must come after the include of so that +# BINDIR is set for the exists(...) constructs. +beforeinstall: +.if exists(${DESTDIR}${BINDIR}/${PROG}) + -chflags noschg ${DESTDIR}${BINDIR}/${PROG} +.if exists(${DESTDIR}${BINDIR}/${PROG}.old) + -chflags noschg ${DESTDIR}${BINDIR}/${PROG}.old +.endif + cp -p ${DESTDIR}${BINDIR}/${PROG} ${DESTDIR}${BINDIR}/${PROG}.old +.endif