diff --git a/sys/conf/Makefile.alpha b/sys/conf/Makefile.alpha index 51d69f6667ec..4f59a6e71ff1 100644 --- a/sys/conf/Makefile.alpha +++ b/sys/conf/Makefile.alpha @@ -276,13 +276,20 @@ kernel-install kernel-install.debug: exit 1 ; \ fi .if exists(${DESTDIR}${KODIR}) -.if exists(${DESTDIR}${KODIR}.old) - @-chflags -R noschg ${DESTDIR}${KODIR}.old - -rm -rf ${DESTDIR}${KODIR}.old -.endif - mv ${DESTDIR}${KODIR} ${DESTDIR}${KODIR}.old - [ "`sysctl -n kern.bootfile`" != "${DESTDIR}${KODIR}/kernel" ] || \ - sysctl kern.bootfile=${DESTDIR}${KODIR}.old/kernel + -thiskernel=`sysctl -n kern.bootfile` ; \ + if [ "$$thiskernel" = ${DESTDIR}${KODIR}.old/${KERNEL_KO} ] ; then \ + chflags -R noschg ${DESTDIR}${KODIR} ; \ + rm -rf ${DESTDIR}${KODIR} ; \ + else \ + if [ -d ${DESTDIR}${KODIR}.old ] ; then \ + chflags -R noschg ${DESTDIR}${KODIR}.old ; \ + rm -rf ${DESTDIR}${KODIR}.old ; \ + fi ; \ + mv ${DESTDIR}${KODIR} ${DESTDIR}${KODIR}.old ; \ + if [ "$$thiskernel" = ${DESTDIR}${KODIR}/${KERNEL_KO} ] ; then \ + sysctl -w kern.bootfile=${DESTDIR}${KODIR}.old/${KERNEL_KO} ; \ + fi; \ + fi .endif mkdir -p ${DESTDIR}${KODIR} install -c -m 555 -o root -g wheel \ diff --git a/sys/conf/Makefile.i386 b/sys/conf/Makefile.i386 index d9e1945362dd..0d72924e179a 100644 --- a/sys/conf/Makefile.i386 +++ b/sys/conf/Makefile.i386 @@ -234,13 +234,20 @@ kernel-install kernel-install.debug: exit 1 ; \ fi .if exists(${DESTDIR}${KODIR}) -.if exists(${DESTDIR}${KODIR}.old) - @-chflags -R noschg ${DESTDIR}${KODIR}.old - -rm -rf ${DESTDIR}${KODIR}.old -.endif - mv ${DESTDIR}${KODIR} ${DESTDIR}${KODIR}.old - [ "`sysctl -n kern.bootfile`" != "${DESTDIR}${KODIR}/kernel" ] || \ - sysctl kern.bootfile=${DESTDIR}${KODIR}.old/kernel + -thiskernel=`sysctl -n kern.bootfile` ; \ + if [ "$$thiskernel" = ${DESTDIR}${KODIR}.old/${KERNEL_KO} ] ; then \ + chflags -R noschg ${DESTDIR}${KODIR} ; \ + rm -rf ${DESTDIR}${KODIR} ; \ + else \ + if [ -d ${DESTDIR}${KODIR}.old ] ; then \ + chflags -R noschg ${DESTDIR}${KODIR}.old ; \ + rm -rf ${DESTDIR}${KODIR}.old ; \ + fi ; \ + mv ${DESTDIR}${KODIR} ${DESTDIR}${KODIR}.old ; \ + if [ "$$thiskernel" = ${DESTDIR}${KODIR}/${KERNEL_KO} ] ; then \ + sysctl -w kern.bootfile=${DESTDIR}${KODIR}.old/${KERNEL_KO} ; \ + fi; \ + fi .endif mkdir -p ${DESTDIR}${KODIR} install -c -m 555 -o root -g wheel \ diff --git a/sys/conf/Makefile.ia64 b/sys/conf/Makefile.ia64 index 0044e98ababb..6601f955cbb6 100644 --- a/sys/conf/Makefile.ia64 +++ b/sys/conf/Makefile.ia64 @@ -246,13 +246,20 @@ kernel-install kernel-install.debug: exit 1 ; \ fi .if exists(${DESTDIR}${KODIR}) -.if exists(${DESTDIR}${KODIR}.old) - @-chflags -R noschg ${DESTDIR}${KODIR}.old - -rm -rf ${DESTDIR}${KODIR}.old -.endif - mv ${DESTDIR}${KODIR} ${DESTDIR}${KODIR}.old - [ "`sysctl -n kern.bootfile`" != "${DESTDIR}${KODIR}/kernel" ] || \ - sysctl kern.bootfile=${DESTDIR}${KODIR}.old/kernel + -thiskernel=`sysctl -n kern.bootfile` ; \ + if [ "$$thiskernel" = ${DESTDIR}${KODIR}.old/${KERNEL_KO} ] ; then \ + chflags -R noschg ${DESTDIR}${KODIR} ; \ + rm -rf ${DESTDIR}${KODIR} ; \ + else \ + if [ -d ${DESTDIR}${KODIR}.old ] ; then \ + chflags -R noschg ${DESTDIR}${KODIR}.old ; \ + rm -rf ${DESTDIR}${KODIR}.old ; \ + fi ; \ + mv ${DESTDIR}${KODIR} ${DESTDIR}${KODIR}.old ; \ + if [ "$$thiskernel" = ${DESTDIR}${KODIR}/${KERNEL_KO} ] ; then \ + sysctl -w kern.bootfile=${DESTDIR}${KODIR}.old/${KERNEL_KO} ; \ + fi; \ + fi .endif mkdir -p ${DESTDIR}${KODIR} install -c -m 555 -o root -g wheel \ diff --git a/sys/conf/Makefile.pc98 b/sys/conf/Makefile.pc98 index 9990506e90ed..6237801ab0d5 100644 --- a/sys/conf/Makefile.pc98 +++ b/sys/conf/Makefile.pc98 @@ -237,13 +237,20 @@ kernel-install kernel-install.debug: exit 1 ; \ fi .if exists(${DESTDIR}${KODIR}) -.if exists(${DESTDIR}${KODIR}.old) - @-chflags -R noschg ${DESTDIR}${KODIR}.old - -rm -rf ${DESTDIR}${KODIR}.old -.endif - mv ${DESTDIR}${KODIR} ${DESTDIR}${KODIR}.old - [ "`sysctl -n kern.bootfile`" != "${DESTDIR}${KODIR}/kernel" ] || \ - sysctl kern.bootfile=${DESTDIR}${KODIR}.old/kernel + -thiskernel=`sysctl -n kern.bootfile` ; \ + if [ "$$thiskernel" = ${DESTDIR}${KODIR}.old/${KERNEL_KO} ] ; then \ + chflags -R noschg ${DESTDIR}${KODIR} ; \ + rm -rf ${DESTDIR}${KODIR} ; \ + else \ + if [ -d ${DESTDIR}${KODIR}.old ] ; then \ + chflags -R noschg ${DESTDIR}${KODIR}.old ; \ + rm -rf ${DESTDIR}${KODIR}.old ; \ + fi ; \ + mv ${DESTDIR}${KODIR} ${DESTDIR}${KODIR}.old ; \ + if [ "$$thiskernel" = ${DESTDIR}${KODIR}/${KERNEL_KO} ] ; then \ + sysctl -w kern.bootfile=${DESTDIR}${KODIR}.old/${KERNEL_KO} ; \ + fi; \ + fi .endif mkdir -p ${DESTDIR}${KODIR} install -c -m 555 -o root -g wheel \ diff --git a/sys/conf/Makefile.powerpc b/sys/conf/Makefile.powerpc index 7543189f3bd5..3bd46c6621e3 100644 --- a/sys/conf/Makefile.powerpc +++ b/sys/conf/Makefile.powerpc @@ -243,13 +243,20 @@ kernel-install kernel-install.debug: exit 1 ; \ fi .if exists(${DESTDIR}${KODIR}) -.if exists(${DESTDIR}${KODIR}.old) - @-chflags -R noschg ${DESTDIR}${KODIR}.old - -rm -rf ${DESTDIR}${KODIR}.old -.endif - mv ${DESTDIR}${KODIR} ${DESTDIR}${KODIR}.old - [ "`sysctl -n kern.bootfile`" != "${DESTDIR}${KODIR}/kernel" ] || \ - sysctl kern.bootfile=${DESTDIR}${KODIR}.old/kernel + -thiskernel=`sysctl -n kern.bootfile` ; \ + if [ "$$thiskernel" = ${DESTDIR}${KODIR}.old/${KERNEL_KO} ] ; then \ + chflags -R noschg ${DESTDIR}${KODIR} ; \ + rm -rf ${DESTDIR}${KODIR} ; \ + else \ + if [ -d ${DESTDIR}${KODIR}.old ] ; then \ + chflags -R noschg ${DESTDIR}${KODIR}.old ; \ + rm -rf ${DESTDIR}${KODIR}.old ; \ + fi ; \ + mv ${DESTDIR}${KODIR} ${DESTDIR}${KODIR}.old ; \ + if [ "$$thiskernel" = ${DESTDIR}${KODIR}/${KERNEL_KO} ] ; then \ + sysctl -w kern.bootfile=${DESTDIR}${KODIR}.old/${KERNEL_KO} ; \ + fi; \ + fi .endif mkdir -p ${DESTDIR}${KODIR} install -c -m 555 -o root -g wheel \ diff --git a/sys/conf/Makefile.sparc64 b/sys/conf/Makefile.sparc64 index a1447b8e3654..3c9a1e6b2767 100644 --- a/sys/conf/Makefile.sparc64 +++ b/sys/conf/Makefile.sparc64 @@ -251,13 +251,20 @@ kernel-install kernel-install.debug: exit 1 ; \ fi .if exists(${DESTDIR}${KODIR}) -.if exists(${DESTDIR}${KODIR}.old) - @-chflags -R noschg ${DESTDIR}${KODIR}.old - -rm -rf ${DESTDIR}${KODIR}.old -.endif - mv ${DESTDIR}${KODIR} ${DESTDIR}${KODIR}.old - [ "`sysctl -n kern.bootfile`" != "${DESTDIR}${KODIR}/kernel" ] || \ - sysctl kern.bootfile=${DESTDIR}${KODIR}.old/kernel + -thiskernel=`sysctl -n kern.bootfile` ; \ + if [ "$$thiskernel" = ${DESTDIR}${KODIR}.old/${KERNEL_KO} ] ; then \ + chflags -R noschg ${DESTDIR}${KODIR} ; \ + rm -rf ${DESTDIR}${KODIR} ; \ + else \ + if [ -d ${DESTDIR}${KODIR}.old ] ; then \ + chflags -R noschg ${DESTDIR}${KODIR}.old ; \ + rm -rf ${DESTDIR}${KODIR}.old ; \ + fi ; \ + mv ${DESTDIR}${KODIR} ${DESTDIR}${KODIR}.old ; \ + if [ "$$thiskernel" = ${DESTDIR}${KODIR}/${KERNEL_KO} ] ; then \ + sysctl -w kern.bootfile=${DESTDIR}${KODIR}.old/${KERNEL_KO} ; \ + fi; \ + fi .endif mkdir -p ${DESTDIR}${KODIR} install -c -m 555 -o root -g wheel \