Teach sysinstall(8) how to read boot managers out of /boot
instead of hardcoding them into the binary. This replaces the work-around in usr.sbin/sysinstall/Makefile,v 1.121. Suggested by: jhb MFC in: 1 week
This commit is contained in:
parent
5a1b52129d
commit
702cd91226
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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, size_t *bootipl_size,
|
||||
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 **bootCode, size_t *bootCodeSize)
|
||||
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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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, size_t *bootipl_size,
|
||||
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 **bootCode, size_t *bootCodeSize)
|
||||
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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user