Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 27 Mar 2002 22:19:14 +0200
From:      Ruslan Ermilov <ru@FreeBSD.org>
To:        John Baldwin <jhb@FreeBSD.org>, Makoto Matsushita <matusita@jp.FreeBSD.org>, Takahashi Yoshihiro <nyan@FreeBSD.org>
Cc:        current@FreeBSD.org
Subject:   Re: cvs commit: src/usr.sbin/sysinstall Makefile
Message-ID:  <20020327201914.GA52094@sunbay.com>
In-Reply-To: <XFMail.20020315103426.jhb@FreeBSD.org>
References:  <200203151127.g2FBRlM03640@freefall.freebsd.org> <XFMail.20020315103426.jhb@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, Mar 15, 2002 at 10:34:26AM -0500, John Baldwin wrote:
> 
> On 15-Mar-2002 Ruslan Ermilov wrote:
> > ru          2002/03/15 03:27:47 PST
> > 
> >   Modified files:
> >     usr.sbin/sysinstall  Makefile 
> >   Log:
> >   Embed boot images built as part of buildworld rather than the
> >   installed ones under /boot (which we may not even have in the
> >   case of a cross build).
> 
> Cool.
> 
> >   This introduced chicken and egg problem - we need boot images
> >   early in the "depend" stage but they have not yet been built.
> >   Work around this by excluding the generated makeboot.c source
> >   from the "depend" list; it's okay because we hardcode all its
> >   dependencies explicitly.  We actually lose the dependency bit
> >   on <sys/types.h> but it's probably okay too as the only thing
> >   we use is the u_char datatype and this is unlikely to change.
> >   After all, it's normal for sloppy cleaning to cause problems.
> >   
> >   beast.FreeBSD.org running 5.0-CURRENT alpha has been able to
> >   cross build i386 world with this patch.
> >   
> >   Prodded by:     gallatin
> 
> Thanks for fixing this.  Long term, I would like someone to fix
> sysinstall so it reads these files out of /boot like we do for
> boot{1,2} instead of hardcoding them into the binary.  Junior
> Sysinstall Hacker task I suppose. :)
> 
Here's the patch.  Please review.

%%%
Index: release/Makefile
===================================================================
RCS file: /home/ncvs/src/release/Makefile,v
retrieving revision 1.661
diff -u -p -u -p -r1.661 Makefile
--- release/Makefile	26 Mar 2002 18:12:26 -0000	1.661
+++ release/Makefile	27 Mar 2002 19:57:06 -0000
@@ -637,6 +637,9 @@ release.8:
 	-test -f ${.CURDIR}/install.cfg && cp ${.CURDIR}/install.cfg ${RD}/mfsfd
 	@mkdir -p ${RD}/mfsfd/boot
 	@cp /boot/boot* ${RD}/mfsfd/boot
+.if ${MACHINE} == "i386"
+	@cp /boot/mbr ${RD}/mfsfd/boot
+.endif
 	@cp /boot/loader.help ${RD}/mfsfd/boot
 	@cd ${.CURDIR} && ${MAKE} createBOOTMFS 
 .if exists(${.CURDIR}/${MACHINE}/drivers.conf)
Index: usr.sbin/sysinstall/Makefile
===================================================================
RCS file: /home/ncvs/src/usr.sbin/sysinstall/Makefile,v
retrieving revision 1.121
diff -u -p -u -p -r1.121 Makefile
--- usr.sbin/sysinstall/Makefile	15 Mar 2002 11:27:47 -0000	1.121
+++ usr.sbin/sysinstall/Makefile	27 Mar 2002 19:57:06 -0000
@@ -54,46 +54,6 @@ makedevs.c:	Makefile rtermcap
 		file2c 'const char termcap_xterm[] = {' ',0};' \
 		>> makedevs.c
 
-.if ${MACHINE_ARCH} == i386
-# XXX boot images aren't yet ready when "make depend" is run
-.if !make(depend)
-SRCS+=	makeboot.c
-.endif
-CLEANFILES+= makeboot.c
-.if exists(${.OBJDIR}/../../sys/boot/${MACHINE}/boot0/boot0)
-BOOT0=	${.OBJDIR}/../../sys/boot/${MACHINE}/boot0/boot0
-.else
-BOOT0=	/boot/boot0
-.endif
-makeboot.c: ${BOOT0}
-.if ${MACHINE} == "i386"
-.if exists(${.OBJDIR}/../../sys/boot/i386/mbr/mbr)
-MBR=	${.OBJDIR}/../../sys/boot/i386/mbr/mbr
-.else
-MBR=	/boot/mbr
-.endif
-makeboot.c: ${MBR}
-.elif ${MACHINE} == "pc98"
-.if exists(${.OBJDIR}/../../sys/boot/pc98/boot0.5/boot0.5)
-BOOT05=	${.OBJDIR}/../../sys/boot/pc98/boot0.5/boot0.5
-.else
-BOOT05=	/boot/boot0.5
-.endif
-makeboot.c: ${BOOT05}
-.endif
-makeboot.c: Makefile
-	echo '#include <sys/types.h>' > makeboot.c
-	file2c 'u_char boot0[] = {' '};' < ${BOOT0} >> makeboot.c
-	echo "size_t boot0_size = sizeof(boot0);" >> makeboot.c
-.if ${MACHINE} == i386
-	file2c 'u_char mbr[] = {' '};' < ${MBR} >> makeboot.c
-	echo "size_t mbr_size = sizeof(mbr);" >> makeboot.c
-.elif ${MACHINE} == "pc98"
-	file2c 'u_char boot05[] = {' '};' < ${BOOT05} >> makeboot.c
-	echo "size_t boot05_size = sizeof(boot05);" >> makeboot.c
-.endif
-.endif
-
 build-tools:	rtermcap
 
 rtermcap:	rtermcap.c
Index: usr.sbin/sysinstall/disks.c
===================================================================
RCS file: /home/ncvs/src/usr.sbin/sysinstall/disks.c,v
retrieving revision 1.129
diff -u -p -u -p -r1.129 disks.c
--- usr.sbin/sysinstall/disks.c	22 Sep 2001 23:17:37 -0000	1.129
+++ usr.sbin/sysinstall/disks.c	27 Mar 2002 19:57:06 -0000
@@ -58,6 +58,7 @@ static struct chunk *chunk_info[16];
 static int current_chunk;
 
 static void	diskPartitionNonInteractive(Device *dev);
+static u_char *	bootalloc(char *name, size_t *size);
 
 static void
 record_chunks(Disk *d)
@@ -168,10 +169,10 @@ static void
 getBootMgr(char *dname, u_char **bootipl, size_t *bootipl_size,
 	   u_char **bootmenu, size_t *bootmenu_size)
 {
-    extern u_char boot0[];
-    extern size_t boot0_size;
-    extern u_char boot05[];
-    extern size_t boot05_size;
+    static u_char *boot0;
+    static size_t boot0_size;
+    static u_char *boot05;
+    static size_t boot05_size;
 
     char str[80];
     char *cp;
@@ -192,8 +193,10 @@ getBootMgr(char *dname, u_char **bootipl
     if (cp || i) {
 	switch (BootMgr) {
 	case 0:
+	    if (!boot0) boot0 = bootalloc("boot0", &boot0_size);
 	    *bootipl = boot0;
 	    *bootipl_size = boot0_size;
+	    if (!boot05) boot05 = bootalloc("boot0.5", &boot05_size);
 	    *bootmenu = boot05;
 	    *bootmenu_size = boot05_size;
 	    return;
@@ -212,8 +215,8 @@ static void
 getBootMgr(char *dname, u_char **bootCode, size_t *bootCodeSize)
 {
 #ifndef __alpha__	/* only meaningful on x86 */
-    extern u_char mbr[], boot0[];
-    extern size_t mbr_size, boot0_size;
+    static u_char *mbr, *boot0;
+    static size_t mbr_size, boot0_size;
     char str[80];
     char *cp;
     int i = 0;
@@ -236,10 +239,12 @@ getBootMgr(char *dname, u_char **bootCod
     if (cp || i) {
 	switch (BootMgr) {
 	case 0:
+	    if (!boot0) boot0 = bootalloc("boot0", &boot0_size);
 	    *bootCode = boot0;
 	    *bootCodeSize = boot0_size;
 	    return;
 	case 1:
+	    if (!mbr) mbr = bootalloc("mbr", &mbr_size);
 	    *bootCode = mbr;
 	    *bootCodeSize = mbr_size;
 	    return;
@@ -671,7 +676,7 @@ diskPartition(Device *dev)
 }
 
 static u_char *
-bootalloc(char *name)
+bootalloc(char *name, size_t *size)
 {
     char buf[FILENAME_MAX];
     struct stat sb;
@@ -692,6 +697,8 @@ bootalloc(char *name)
 		return NULL;
 	    }
 	    close(fd);
+	    if (size != NULL)
+		*size = sb.st_size;
 	    return cp;
 	}
 	msgDebug("bootalloc: couldn't open %s\n", buf);
@@ -815,11 +822,11 @@ diskPartitionWrite(dialogMenuItem *self)
 	    continue;
 
 #ifdef __alpha__
-	if (!boot1) boot1 = bootalloc("boot1");
+	if (!boot1) boot1 = bootalloc("boot1", NULL);
 	Set_Boot_Blocks(d, boot1, NULL);
 #else
-	if (!boot1) boot1 = bootalloc("boot1");
-	if (!boot2) boot2 = bootalloc("boot2");
+	if (!boot1) boot1 = bootalloc("boot1", NULL);
+	if (!boot2) boot2 = bootalloc("boot2", NULL);
 	Set_Boot_Blocks(d, boot1, boot2);
 #endif
 
%%%

-- 
Ruslan Ermilov		Sysadmin and DBA,
ru@sunbay.com		Sunbay Software AG,
ru@FreeBSD.org		FreeBSD committer,
+380.652.512.251	Simferopol, Ukraine

http://www.FreeBSD.org	The Power To Serve
http://www.oracle.com	Enabling The Information Age

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020327201914.GA52094>