Re: INSTKERNNAME= foolproof check

From: Ruslan Ermilov <ru_at_freebsd.org>
Date: Fri, 12 Oct 2007 12:43:48 +0400
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
> _at__at_ -742,6 +742,10 _at__at_
>         _at_echo "ERROR: No kernel \"${KERNCONF}\" to install."; \
>         false
>  .endif
> +.if empty(INSTKERNNAME)
> +       _at_echo "ERROR: Kernel install directory is empty."; \
> +       false
> +.endif
>         _at_echo "--------------------------------------------------------------"
>         _at_echo ">>> Installing kernel"
>         _at_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
_at__at_ -10,7 +10,9 _at__at_ 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_at_FreeBSD.org
FreeBSD committer
Received on Fri Oct 12 2007 - 09:55:37 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:19 UTC