Re: INSTKERNNAME= foolproof check



On Thu, Oct 11, 2007 at 10:53:12PM +0400, Dmitry Morozovsky wrote:
Colleagues,

Today I successfully shoot myself in the foot by typing

make installkernel KERNCONF=GENERIC INSTKERNNAME=

instead of usual

make installkernel KERNCONF=GENERIC INSTKERNNAME=GENERIC

Empty INSTKERNNAME leads to wiping /boot completely - rather annoying,
especially in my case, where I had some non-trivial (and, of course, no backups
;-) loader.conf

What do you think about the following patch?

Index: Makefile.inc1
===================================================================
RCS file: /home/ncvs/src/Makefile.inc1,v
retrieving revision 1.588.2.1
diff -u -r1.588.2.1 Makefile.inc1
--- Makefile.inc1 11 Oct 2007 06:08:51 -0000 1.588.2.1
+++ Makefile.inc1 11 Oct 2007 18:49:19 -0000
@@ -742,6 +742,10 @@
@echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
false
.endif
+.if empty(INSTKERNNAME)
+ @echo "ERROR: Kernel install directory is empty."; \
+ false
+.endif
@echo "--------------------------------------------------------------"
@echo ">>> Installing kernel"
@echo "--------------------------------------------------------------"

There's a better place to fix this, so a classical config/make
method is fixed as well. Though, this is only one of the many
possibilities to shoot yourself in the foot.

%%%
Index: kern.pre.mk
===================================================================
RCS file: /home/ncvs/src/sys/conf/kern.pre.mk,v
retrieving revision 1.92
diff -u -p -r1.92 kern.pre.mk
--- kern.pre.mk 8 Aug 2007 19:12:06 -0000 1.92
+++ kern.pre.mk 12 Oct 2007 08:41:23 -0000
@@ -10,7 +10,9 @@ SRCCONF?= /etc/src.conf

# Can be overridden by makeoptions or /etc/make.conf
KERNEL_KO?= kernel
-KERNEL?= kernel
+.if !defined(KERNEL) || empty(KERNEL)
+KERNEL= kernel
+.endif
KODIR?= /boot/${KERNEL}

M= ${MACHINE_ARCH}
%%%


Cheers,
--
Ruslan Ermilov
ru@xxxxxxxxxxx
FreeBSD committer
_______________________________________________
freebsd-current@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscribe@xxxxxxxxxxx"



Relevant Pages

  • Re: INSTKERNNAME= foolproof check
    ... make installkernel KERNCONF=GENERIC INSTKERNNAME=GENERIC ... Empty INSTKERNNAME leads to wiping /boot completely - rather annoying, ...
    (freebsd-current)
  • INSTKERNNAME= foolproof check
    ... make installkernel KERNCONF=GENERIC INSTKERNNAME=GENERIC ... Empty INSTKERNNAME leads to wiping /boot completely - rather annoying, ...
    (freebsd-current)