Bug 17698

Summary: [PATCH] Let Makefile.inc1 installkernel install multiple kernels
Product: Base System Reporter: k <k>
Component: kernAssignee: Marcel Moolenaar <marcel>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 4.0-RELEASE   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
file.diff none

Description k 2000-03-30 21:50:01 UTC
	Currently only the first kernel in ${KERNEL} get installed 
	by the installkernel target in ${SRC}/Makefile.inc1.
	Moreover, it gets installed as ${KERNEL} not 'kernel'
	It would be nice to be able to install multiple kernel and 
	have them named nicely.

	To do this I have added a new variable INSTKERNEL to
	${SRC}/sys/conf/Makefile.i386 (should be added to Makefile.alpha 
	and Makefile.pc98 as well but I can not test on these mashines).
	The kernel gets installed as ${INSTKERNEL} (which defaults to
	${KERNEL}) instead of ${KERNEL} in ${DESTDIR}.	

	I have also patched ${SRC}/Makefile.inc1 to install all valid
	kernels in ${KERNEL}. The first kernel is installed as ${INSTKERNEL} 
	(which defaults to 'kernel') and the following are installed as
	${INSTKERNEL}.${FOO} in ${DESTDIR}.

	
	w/o the attached patch
===============
numeri# make KERNEL='GENERIC NEWCARD' installkernel
cd /usr/obj/usr/src/sys/GENERIC;  MAKEOBJDIRPREFIX=/usr/obj  COMPILER_PATH=/usr/obj/usr/src/i386/usr/libexec:/usr/obj/usr/src/i386/usr/bin  LIBRARY_PATH=/usr/obj/usr/src/i386/usr/lib:/usr/obj/usr/src/i386/usr/lib  OBJFORMAT_PATH=/usr/obj/usr/src/i386/usr/libexec  PERL5LIB=/usr/obj/usr/src/i386/usr/libdata/perl/5.00503 MACHINE=i386 KERNEL=GENERIC  make install
install -c -m 555 -o root -g wheel -fschg  GENERIC /GENERIC
numeri#
===============

	w/ the attached patch (note that I've set INSTKERNEL=Kernel)
===============
numeri# make KERNEL='GENERIC NEWCARD GENERIC' INSTKERNEL=Kernel installkernel

--------------------------------------------------------------
Comment 1 Sheldon Hearn freebsd_committer freebsd_triage 2000-03-31 11:08:53 UTC
Responsible Changed
From-To: freebsd-bugs->sheldonh

I haven't looked at the patch yet, but if it works as advertised, 
it's exactly what we want. :-) 

Comment 2 Sheldon Hearn 2000-04-11 10:44:22 UTC
Hi Johan,

Just a quick note to let you know why this is taking so long.  The only
feedback I got from the Alpha camp is that this is broken for the Alpha
case.  The breakage makes no sense to me, so I'll have to test it for
myself.

Ciao,
Sheldon.
Comment 3 k 2000-06-18 17:29:55 UTC
Hi

I have redesigned my patch for the build/installkernel targets =

in Makefile.inc1. The new version is attached below.

This new version solves some more problems:
1: If 'KERNEL' is set to be mutliple kernels in /etc/make.conf the =

 # cd /sys/i386/conf ; config GENERIC; make depend; make all; make instal=
l
way will fail.
Solution: introduce 'KERNELS' used to specify multiple kernels.

2: This version knows that /modules is built/installed with the kernel an=
d
therefor sets NO_MODULES to true when installing more than one kernel.

3: sys/conf/Makefile.* assumed that modules always are installed =

in /modules and therefore only backed-up that dir.
Sulotion: Use 'KMODDIR' to get the location where modules will be install=
ed =

when
doing the backup.

4: When install a kernel and modules into an empty root =

(eg. DESTDIR=3D/usr/tmp/newroot) the install of modules would fail since =
some
dirs are missings. This can be a problem when doing
# make buildworld; make buildkernel; =

# make DESTDIR=3Dfoo installkernel; make DESTDIR=3Dfoo installworld
Solution: I have added  /usr/bin /usr/sbin /usr/share/man/man4 to the =

installkernel
target to work around this problem.



As in the prev patch the first kernel will be installed as ${DESTKERNEL} =

(default 'kernel') and the following as ${DESTKERNEL}.${FOO}.

I think this patch is a commit candidate BUT I can only test is on i386.


Sheldon, you mentioned that the prev version faild on alpha, have you =

been able to confirm that and know why it fails?

Brain, can you please try this patch and see if it solves the problem you=
 =

commited a fix for in Makefile.inc1 v 1.150. I changed some other locatio=
n =

which might suffer from the same problem.


Thanks
Johan K



--- Makefile.inc1.orig	Sat Jun 17 20:51:43 2000
+++ Makefile.inc1	Sun Jun 18 16:37:13 2000
@@ -341,6 +341,8 @@
 # properly.
 =

 KERNEL?=3D	GENERIC
+KERNELS?=3D	${KERNEL}
+DESTKERNEL?=3D	kernel
 =

 # The only exotic MACHINE_ARCH/MACHINE combination valid at this
 # time is i386/pc98. In all other cases set MACHINE equal to
@@ -359,11 +361,14 @@
 =

 BUILDKERNELS=3D
 INSTALLKERNEL=3D
-.for _kernel in ${KERNEL}
+INSTALLKERNELS=3D
+.for _kernel in ${KERNELS}
 .if exists(${KRNLCONFDIR}/${_kernel})
 BUILDKERNELS+=3D	${_kernel}
 .if empty(INSTALLKERNEL)
 INSTALLKERNEL=3D ${_kernel}
+.else
+INSTALLKERNELS+=3D ${_kernel}
 .endif
 .endif
 .endfor
@@ -391,22 +396,37 @@
 		    ${MAKE} -f ${KRNLSRCDIR}/dev/aic7xxx/Makefile
 .if !defined(NO_KERNELDEPEND)
 	cd ${KRNLOBJDIR}/${_kernel}; \
-		${WMAKEENV} MACHINE=3D${MACHINE} KERNEL=3D${_kernel} \
-		    ${MAKE} depend
+		${WMAKEENV} MACHINE=3D${MACHINE} \
+		    ${MAKE} KERNEL=3D${_kernel} depend
 .endif
 	cd ${KRNLOBJDIR}/${_kernel}; \
-		${WMAKEENV} MACHINE=3D${MACHINE} KERNEL=3D${_kernel} ${MAKE} all
+		${WMAKEENV} MACHINE=3D${MACHINE} ${MAKE} KERNEL=3D${_kernel} all
 .endfor
 =

 #
 # installkernel
 #
-# Install the kernel defined by INSTALLKERNEL
+# Install the kernel(s) defined by INSTALLKERNEL and INSTALLKERNELS
 #
 installkernel:
+	@echo
+	@echo "--------------------------------------------------------------"
+	@echo ">>> Installing kernel(s)"
+	@echo "--------------------------------------------------------------"
+	mkdir -p ${DESTDIR}/usr/share/man/man4
+	mkdir -p ${DESTDIR}/usr/bin
+	mkdir -p ${DESTDIR}/usr/sbin
+	@echo "=3D=3D=3D> ${INSTALLKERNEL} as ${DESTDIR}/${DESTKERNEL}"
 	cd ${KRNLOBJDIR}/${INSTALLKERNEL}; \
-		${IMAKEENV} MACHINE=3D${MACHINE} KERNEL=3D${INSTALLKERNEL} \
-		    ${MAKE} KERNEL=3D${INSTALLKERNEL} install
+		${IMAKEENV} MACHINE=3D${MACHINE} \
+		    ${MAKE} KERNEL=3D${INSTALLKERNEL} DESTKERNEL=3D${DESTKERNEL} insta=
ll
+.for _kernel in ${INSTALLKERNELS}
+	@echo "=3D=3D=3D> ${_kernel} as ${DESTDIR}/${DESTKERNEL}.${_kernel}"
+	cd ${KRNLOBJDIR}/${_kernel}; \
+		${IMAKEENV} MACHINE=3D${MACHINE} \
+		    ${MAKE} KERNEL=3D${_kernel} DESTKERNEL=3D${DESTKERNEL}.${_kernel} =
\
+		    NO_MODULES=3D1 install
+.endfor
 =

 #
 # update
--- sys/conf/Makefile.alpha.orig	Sat Jun 17 20:55:20 2000
+++ sys/conf/Makefile.alpha	Sun Jun 18 17:57:20 2000
@@ -21,6 +21,7 @@
 =

 # Can be overridden by makeoptions or /etc/make.conf
 KERNEL?=3D	kernel
+DESTKERNEL?=3D	${KERNEL}
 STD8X16FONT?=3D	iso
 =

 .if !defined(S)
@@ -263,16 +264,16 @@
 		echo "You must build a kernel first." ; \
 		exit 1 ; \
 	fi
-.if exists(${DESTDIR}/${KERNEL})
-	-chflags noschg ${DESTDIR}/${KERNEL}
-	mv ${DESTDIR}/${KERNEL} ${DESTDIR}/${KERNEL}.old
+.if exists(${DESTDIR}/${DESTKERNEL})
+	-chflags noschg ${DESTDIR}/${DESTKERNEL}
+	mv ${DESTDIR}/${DESTKERNEL} ${DESTDIR}/${DESTKERNEL}.old
 .endif
 	install -c -m 555 -o root -g wheel -fschg \
-		${KERNEL}${.TARGET:S/kernel-install//} ${DESTDIR}/${KERNEL}
+		${KERNEL}${.TARGET:S/kernel-install//} ${DESTDIR}/${DESTKERNEL}
 =

 kernel-reinstall kernel-reinstall.debug:
 	install -c -m 555 -o root -g wheel -fschg \
-		${KERNEL}${.TARGET:S/kernel-reinstall//} ${DESTDIR}/${KERNEL}
+		${KERNEL}${.TARGET:S/kernel-reinstall//} ${DESTDIR}/${DESTKERNEL}
 =

 .if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists($S/mo=
dules)
 all:	modules
@@ -301,11 +302,14 @@
 modules-tags:
 	cd $S/modules && env MAKEOBJDIRPREFIX=3D${.OBJDIR}/modules ${MAKE} tags=

 =

+# we need ${KMODDIR} to tell us where modules get installed
+.include <bsd.own.mk>
+
 modules-install modules-install.debug:
 .if !defined(NO_MODULES_OLD)
-	if [ -d ${DESTDIR}/modules -a -n "`ls ${DESTDIR}/modules`" ]; then \
-		mkdir -p ${DESTDIR}/modules.old ; \
-		cp -p ${DESTDIR}/modules/* ${DESTDIR}/modules.old ; \
+	if [ -d ${DESTDIR}${KMODDIR} -a -n "`ls ${DESTDIR}${KMODDIR}`" ]; then =
\
+		mkdir -p ${DESTDIR}${KMODDIR}.old; \
+		cp -p ${DESTDIR}${KMODDIR}/* ${DESTDIR}${KMODDIR}.old; \
 	fi;
 .endif
 	cd $S/modules && env MAKEOBJDIRPREFIX=3D${.OBJDIR}/modules ${MAKE} inst=
all
--- sys/conf/Makefile.i386.orig	Sat Jun 17 20:55:20 2000
+++ sys/conf/Makefile.i386	Sun Jun 18 00:57:30 2000
@@ -21,6 +21,7 @@
 =

 # Can be overridden by makeoptions or /etc/make.conf
 KERNEL?=3D	kernel
+DESTKERNEL?=3D	${KERNEL}
 STD8X16FONT?=3D	iso
 =

 .if !defined(S)
@@ -218,16 +219,16 @@
 		echo "You must build a kernel first." ; \
 		exit 1 ; \
 	fi
-.if exists(${DESTDIR}/${KERNEL})
-	-chflags noschg ${DESTDIR}/${KERNEL}
-	mv ${DESTDIR}/${KERNEL} ${DESTDIR}/${KERNEL}.old
+.if exists(${DESTDIR}/${DESTKERNEL})
+	-chflags noschg ${DESTDIR}/${DESTKERNEL}
+	mv ${DESTDIR}/${DESTKERNEL} ${DESTDIR}/${DESTKERNEL}.old
 .endif
 	install -c -m 555 -o root -g wheel -fschg \
-		${KERNEL}${.TARGET:S/kernel-install//} ${DESTDIR}/${KERNEL}
+		${KERNEL}${.TARGET:S/kernel-install//} ${DESTDIR}/${DESTKERNEL}
 =

 kernel-reinstall kernel-reinstall.debug:
 	install -c -m 555 -o root -g wheel -fschg \
-		${KERNEL}${.TARGET:S/kernel-reinstall//} ${DESTDIR}/${KERNEL}
+		${KERNEL}${.TARGET:S/kernel-reinstall//} ${DESTDIR}/${DESTKERNEL}
 =

 .if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists($S/mo=
dules)
 all:	modules
@@ -260,11 +261,14 @@
 modules-tags:
 	cd $S/modules && env MAKEOBJDIRPREFIX=3D${.OBJDIR}/modules ${MAKE} tags=

 =

+# we need ${KMODDIR} to tell us where modules get installed
+.include <bsd.own.mk>
+
 modules-install modules-install.debug:
 .if !defined(NO_MODULES_OLD)
-	if [ -d ${DESTDIR}/modules -a -n "`ls ${DESTDIR}/modules`" ]; then \
-		mkdir -p ${DESTDIR}/modules.old; \
-		cp -p ${DESTDIR}/modules/* ${DESTDIR}/modules.old; \
+	if [ -d ${DESTDIR}${KMODDIR} -a -n "`ls ${DESTDIR}${KMODDIR}`" ]; then =
\
+		mkdir -p ${DESTDIR}${KMODDIR}.old; \
+		cp -p ${DESTDIR}${KMODDIR}/* ${DESTDIR}${KMODDIR}.old; \
 	fi;
 .endif
 	cd $S/modules && env MAKEOBJDIRPREFIX=3D${.OBJDIR}/modules ${MAKE} inst=
all
--- sys/conf/Makefile.pc98.orig	Sat Jun 17 20:55:20 2000
+++ sys/conf/Makefile.pc98	Sun Jun 18 17:58:17 2000
@@ -23,6 +23,7 @@
 =

 # Can be overridden by makeoptions or /etc/make.conf
 KERNEL?=3D	kernel
+DESTKERNEL?=3D	${KERNEL}
 #STD8X16FONT?=3D	iso
 =

 .if !defined(S)
@@ -221,16 +222,16 @@
 		echo "You must build a kernel first." ; \
 		exit 1 ; \
 	fi
-.if exists(${DESTDIR}/${KERNEL})
-	-chflags noschg ${DESTDIR}/${KERNEL}
-	mv ${DESTDIR}/${KERNEL} ${DESTDIR}/${KERNEL}.old
+.if exists(${DESTDIR}/${DESTKERNEL})
+	-chflags noschg ${DESTDIR}/${DESTKERNEL}
+	mv ${DESTDIR}/${DESTKERNEL} ${DESTDIR}/${DESTKERNEL}.old
 .endif
 	install -c -m 555 -o root -g wheel -fschg \
-		${KERNEL}${.TARGET:S/kernel-install//} ${DESTDIR}/${KERNEL}
+		${KERNEL}${.TARGET:S/kernel-install//} ${DESTDIR}/${DESTKERNEL}
 =

 kernel-reinstall kernel-reinstall.debug:
 	install -c -m 555 -o root -g wheel -fschg \
-		${KERNEL}${.TARGET:S/kernel-reinstall//} ${DESTDIR}/${KERNEL}
+		${KERNEL}${.TARGET:S/kernel-reinstall//} ${DESTDIR}/${DESTKERNEL}
 =

 .if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists($S/mo=
dules)
 all:	modules
@@ -263,11 +264,14 @@
 modules-tags:
 	cd $S/modules && env MAKEOBJDIRPREFIX=3D${.OBJDIR}/modules ${MAKE} tags=

 =

+# we need ${KMODDIR} to tell us where modules get installed
+.include <bsd.own.mk>
+
 modules-install modules-install.debug:
 .if !defined(NO_MODULES_OLD)
-	if [ -d ${DESTDIR}/modules -a -n "`ls ${DESTDIR}/modules`" ]; then \
-		mkdir -p ${DESTDIR}/modules.old; \
-		cp -p ${DESTDIR}/modules/* ${DESTDIR}/modules.old; \
+	if [ -d ${DESTDIR}${KMODDIR} -a -n "`ls ${DESTDIR}${KMODDIR}`" ]; then =
\
+		mkdir -p ${DESTDIR}${KMODDIR}.old; \
+		cp -p ${DESTDIR}${KMODDIR}/* ${DESTDIR}${KMODDIR}.old; \
 	fi;
 .endif
 	cd $S/modules && env MAKEOBJDIRPREFIX=3D${.OBJDIR}/modules ${MAKE} inst=
all
Comment 4 Brian Somers 2000-06-19 09:52:34 UTC
> Hi
> 
> I have redesigned my patch for the build/installkernel targets 
> in Makefile.inc1. The new version is attached below.

Hi.

I'm not sure that this works for people that want to have a central 
build machine and the ability to do nfs installs onto other machines.

In this scenario (actually the one I'm using) I want to build several 
kernels, but I only want to install one of them (the other machines 
will mount src & obj and have different KERNEL settings in their 
make.conf files so that they install their own kernels).

I think the previous method was almost correct here in that it set 
INSTALLKENREL to what it wants to install, it just wasn't passing the 
information down to the other ${MAKE} properly.

From my experience, I can't say if the INSTALLKERNELS bit is going to 
be useful for anyone.

Cheers (and sorry to be so un-constructive).

-- 
Brian <brian@Awfulhak.org>                        <brian@[uk.]FreeBSD.org>
      <http://www.Awfulhak.org>                   <brian@[uk.]OpenBSD.org>
Don't _EVER_ lose your sense of humour !
Comment 5 k 2000-06-19 21:51:45 UTC
At Mon, 19 Jun 2000 09:52:34 BST, Brian Somers wrote:
>> Hi
>> 
>> I have redesigned my patch for the build/installkernel targets 
>> in Makefile.inc1. The new version is attached below.
>
>Hi.
>
>I'm not sure that this works for people that want to have a central 
>build machine and the ability to do nfs installs onto other machines.
>
>In this scenario (actually the one I'm using) I want to build several 
>kernels, but I only want to install one of them (the other machines 
>will mount src & obj and have different KERNEL settings in their 
>make.conf files so that they install their own kernels).
>

Ok this can be achived by setting
KERNELS=A B C D 
on the buildmachine
and 
KERNEL=B
on the machine that want to install B

However, KERNELS may not be set on the install machine
or it has set KERNELS to B only.

 
>I think the previous method was almost correct here in that it set 
>INSTALLKENREL to what it wants to install, it just wasn't passing the 
>information down to the other ${MAKE} properly.

Does that really work, I think that INSTALLKERNEL is overwritten by 
Makefile.inc1 and therefor is should not work.

Morover, if you set KERNEL to multiple kernels the 'old' kernel
build way fails.

>
>From my experience, I can't say if the INSTALLKERNELS bit is going to 
>be useful for anyone.

I realy think it is usefull :-)
I want to both install my custom kernel and GENERIC when I 
upgrade world. I want to use GENERIC as a backup is I have 
screwed my custom kernel.

/Johan K

>
>Cheers (and sorry to be so un-constructive).
>
>-- 
>Brian <brian@Awfulhak.org>                        <brian@[uk.]FreeBSD.org>
>      <http://www.Awfulhak.org>                   <brian@[uk.]OpenBSD.org>
>Don't _EVER_ lose your sense of humour !
>
>
Comment 6 Brian Somers 2000-06-19 23:33:47 UTC
> At Mon, 19 Jun 2000 09:52:34 BST, Brian Somers wrote:
> >> Hi
> >> 
> >> I have redesigned my patch for the build/installkernel targets 
> >> in Makefile.inc1. The new version is attached below.
> >
> >Hi.
> >
> >I'm not sure that this works for people that want to have a central 
> >build machine and the ability to do nfs installs onto other machines.
> >
> >In this scenario (actually the one I'm using) I want to build several 
> >kernels, but I only want to install one of them (the other machines 
> >will mount src & obj and have different KERNEL settings in their 
> >make.conf files so that they install their own kernels).
> >
> 
> Ok this can be achived by setting
> KERNELS=A B C D 
> on the buildmachine
> and 
> KERNEL=B
> on the machine that want to install B

Ah ok, I get it.

[.....]
> Morover, if you set KERNEL to multiple kernels the 'old' kernel
> build way fails.

Yep.

> >From my experience, I can't say if the INSTALLKERNELS bit is going to 
> >be useful for anyone.
> 
> I realy think it is usefull :-)
> I want to both install my custom kernel and GENERIC when I 
> upgrade world. I want to use GENERIC as a backup is I have 
> screwed my custom kernel.

Ah, ok.  This makes sense I guess :-)

> /Johan K

I'd go along with these changes in that case, but I think Sheldon 
is probably the best person to get comments from.

Thanks.

-- 
Brian <brian@Awfulhak.org>                        <brian@[uk.]FreeBSD.org>
      <http://www.Awfulhak.org>                   <brian@[uk.]OpenBSD.org>
Don't _EVER_ lose your sense of humour !
Comment 7 Sheldon Hearn 2000-06-20 08:58:59 UTC
On Mon, 19 Jun 2000 23:33:47 +0100, Brian Somers wrote:

> I'd go along with these changes in that case, but I think Sheldon 
> is probably the best person to get comments from.

I'm just catching up on mail after 2 weeks of leave.  I probably won't
get to this until next week. :-(

Ciao,
Sheldon.
Comment 8 Sheldon Hearn freebsd_committer freebsd_triage 2000-06-22 10:26:39 UTC
Responsible Changed
From-To: sheldonh->freebsd-bugs

I need to release this one back into the general domain, since 
I have another project for FreeBSD which must receive my  
undivided attention.  Sorry about this, Johan.  You may wish to 
solicit interest in this one by mailing committers@FreeBSD.org.
Comment 9 Marcel Moolenaar freebsd_committer freebsd_triage 2000-07-11 19:05:13 UTC
Responsible Changed
From-To: freebsd-bugs->marcel

My plate.
Comment 10 Marcel Moolenaar freebsd_committer freebsd_triage 2000-07-23 19:05:10 UTC
State Changed
From-To: open->closed

It has been decided that we don't support multiple kernels 
at this time. A new naming scheme has been proposed and 
until that has been materialized, it's best to leave things 
as they are. The ability to install multiple kernels will 
therefore exist one day...