add --prefix into the command setup, and add separate boot partition support into grub-install.
This commit is contained in:
parent
0bcf40674e
commit
c6c180757e
4 changed files with 110 additions and 23 deletions
21
ChangeLog
21
ChangeLog
|
@ -1,3 +1,24 @@
|
|||
2000-09-26 OKUJI Yoshinori <okuji@gnu.org>
|
||||
|
||||
* util/grub-install.in (bootdir_device): New variable. If
|
||||
$bootdir_device is not the same as $root_device, set root_device
|
||||
and grubdir to $bootdir_device and "/grub", respectively.
|
||||
Add --prefix=$grubdir into the command "setup".
|
||||
|
||||
2000-09-26 OKUJI Yoshinori <okuji@gnu.org>
|
||||
|
||||
Add --prefix=DIR to the command "setup".
|
||||
|
||||
* stage2/builtins.c (setup_func): New nested function,
|
||||
check_file checks if the file FILE exists.
|
||||
Remove the prefix "/boot/grub" in STAGE1_5_MAP.
|
||||
Don't hardcode "/boot/grub/stage1", "/boot/grub/stage2", or
|
||||
"/boot/grub/menu.lst". Instead, check if ARG contains
|
||||
"--prefix=", and if specified, set PREFIX to the value.
|
||||
If not specified, check "/boot/grub/stage1" and, if not found,
|
||||
check "/grub/stage1". If a stage1 was found, set PREFIX to the
|
||||
directory which contains the stage1.
|
||||
|
||||
2000-09-12 OKUJI Yoshinori <okuji@gnu.org>
|
||||
|
||||
Add additional magic to avoid a bug in Linux. *sigh*
|
||||
|
|
7
NEWS
7
NEWS
|
@ -35,6 +35,13 @@ New in 0.5.96 - XXXX-XX-XX:
|
|||
* New command, "savedefault". Now you can save current entry number to
|
||||
your disk with this command and then you can set the default boot
|
||||
entry to it by the command "default saved".
|
||||
* Add a new option `--prefix' into the command "setup", so that you can
|
||||
specify the name of a directory which contains GRUB images. And, the
|
||||
behavior of this command changed slightly, that is, this command now
|
||||
searchs stage1 automatically under "/boot/grub" and "/grub", unless
|
||||
you specify the option `--prefix'.
|
||||
* The utility `grub-install' recognizes a separate boot partition
|
||||
automatically.
|
||||
|
||||
New in 0.5.95 - 2000-06-27:
|
||||
* NetBSD ELF kernel support is added. You have to specify the new option
|
||||
|
|
|
@ -3124,8 +3124,28 @@ setup_func (char *arg, int flags)
|
|||
char *buffer = (char *) RAW_ADDR (0x100000);
|
||||
int is_force_lba = 0;
|
||||
char *stage2_arg = 0;
|
||||
char *prefix = 0;
|
||||
|
||||
static void sprint_device (int drive, int partition)
|
||||
auto int check_file (char *file);
|
||||
auto void sprint_device (int drive, int partition);
|
||||
|
||||
/* Check if the file FILE exists like Autoconf. */
|
||||
int check_file (char *file)
|
||||
{
|
||||
int ret;
|
||||
|
||||
grub_printf (" Checking if \"%s\" exists... ", file);
|
||||
ret = grub_open (file);
|
||||
if (ret)
|
||||
grub_printf ("yes\n");
|
||||
else
|
||||
grub_printf ("no\n");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Construct a device name in DEVICE. */
|
||||
void sprint_device (int drive, int partition)
|
||||
{
|
||||
grub_sprintf (device, "(%cd%d",
|
||||
(drive & 0x80) ? 'h' : 'f',
|
||||
|
@ -3151,18 +3171,13 @@ setup_func (char *arg, int flags)
|
|||
};
|
||||
struct stage1_5_map stage1_5_map[] =
|
||||
{
|
||||
{"ext2fs", "/boot/grub/e2fs_stage1_5"},
|
||||
{"ffs", "/boot/grub/ffs_stage1_5"},
|
||||
{"fat", "/boot/grub/fat_stage1_5"},
|
||||
{"minix", "/boot/grub/minix_stage1_5"},
|
||||
{"reiserfs", "/boot/grub/reiserfs_stage1_5"}
|
||||
{"ext2fs", "/e2fs_stage1_5"},
|
||||
{"ffs", "/ffs_stage1_5"},
|
||||
{"fat", "/fat_stage1_5"},
|
||||
{"minix", "/minix_stage1_5"},
|
||||
{"reiserfs", "/reiserfs_stage1_5"}
|
||||
};
|
||||
|
||||
/* Initialize some strings. */
|
||||
grub_strcpy (stage1, "/boot/grub/stage1");
|
||||
grub_strcpy (stage2, "/boot/grub/stage2");
|
||||
grub_strcpy (config_filename, "/boot/grub/menu.lst");
|
||||
|
||||
tmp_drive = saved_drive;
|
||||
tmp_partition = saved_partition;
|
||||
|
||||
|
@ -3174,6 +3189,12 @@ setup_func (char *arg, int flags)
|
|||
is_force_lba = 1;
|
||||
arg = skip_to (0, arg);
|
||||
}
|
||||
else if (grub_memcmp ("--prefix=", arg, sizeof ("--prefix=") - 1) == 0)
|
||||
{
|
||||
prefix = arg + sizeof ("--prefix=") - 1;
|
||||
arg = skip_to (0, arg);
|
||||
nul_terminate (prefix);
|
||||
}
|
||||
#ifdef GRUB_UTIL
|
||||
else if (grub_memcmp ("--stage2=", arg, sizeof ("--stage2=") - 1) == 0)
|
||||
{
|
||||
|
@ -3220,14 +3241,37 @@ setup_func (char *arg, int flags)
|
|||
if (! open_device ())
|
||||
goto fail;
|
||||
|
||||
/* Check for stage1 and stage2. We hardcode the filenames, so
|
||||
if the user installed GRUB in a uncommon directory, this never
|
||||
succeed. */
|
||||
if (! grub_open (stage1))
|
||||
/* Check if stage1 exists. If the user doesn't specify the option
|
||||
`--prefix', attempt /boot/grub and /grub. */
|
||||
/* NOTE: It is dangerous to run this command without `--prefix' in the
|
||||
grub shell, since that affects `--stage2'. */
|
||||
if (! prefix)
|
||||
{
|
||||
prefix = "/boot/grub";
|
||||
grub_sprintf (stage1, "%s%s", prefix, "/stage1");
|
||||
if (! check_file (stage1))
|
||||
{
|
||||
errnum = ERR_NONE;
|
||||
prefix = "/grub";
|
||||
grub_sprintf (stage1, "%s%s", prefix, "/stage1");
|
||||
if (! check_file (stage1))
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_sprintf (stage1, "%s%s", prefix, "/stage1");
|
||||
if (! check_file (stage1))
|
||||
goto fail;
|
||||
}
|
||||
grub_close ();
|
||||
|
||||
if (! grub_open (stage2))
|
||||
/* The prefix was determined. */
|
||||
grub_sprintf (stage2, "%s%s", prefix, "/stage2");
|
||||
grub_sprintf (config_filename, "%s%s", prefix, "/menu.lst");
|
||||
|
||||
/* Check if stage2 exists. */
|
||||
if (! check_file (stage2))
|
||||
goto fail;
|
||||
grub_close ();
|
||||
|
||||
|
@ -3244,13 +3288,16 @@ setup_func (char *arg, int flags)
|
|||
if (grub_strcmp (fsys, stage1_5_map[i].fsys) == 0)
|
||||
{
|
||||
/* OK, check if the Stage 1.5 exists. */
|
||||
if (grub_open (stage1_5_map[i].name))
|
||||
char stage1_5[64];
|
||||
|
||||
grub_sprintf (stage1_5, "%s%s", prefix, stage1_5_map[i].name);
|
||||
if (check_file (stage1_5))
|
||||
{
|
||||
int blocksize = (filemax + SECTOR_SIZE - 1) >> SECTOR_BITS;
|
||||
|
||||
grub_close ();
|
||||
grub_strcpy (config_filename, stage2);
|
||||
grub_strcpy (stage2, stage1_5_map[i].name);
|
||||
grub_strcpy (stage2, stage1_5);
|
||||
|
||||
if (installed_partition == 0xFFFFFF)
|
||||
{
|
||||
|
@ -3344,7 +3391,7 @@ static struct builtin builtin_setup =
|
|||
"setup",
|
||||
setup_func,
|
||||
BUILTIN_CMDLINE,
|
||||
"setup [--stage2=STAGE2_FILE] [--force-lba] INSTALL_DEVICE [IMAGE_DEVICE]",
|
||||
"setup [--prefix=DIR] [--stage2=STAGE2_FILE] [--force-lba] INSTALL_DEVICE [IMAGE_DEVICE]",
|
||||
"Set up the installation of GRUB automatically. This command uses"
|
||||
" the more flexible command \"install\" in the backend and installs"
|
||||
" GRUB into the device INSTALL_DEVICE. If IMAGE_DEVICE is specified,"
|
||||
|
|
|
@ -228,7 +228,19 @@ esac
|
|||
# Get the root drive.
|
||||
# For now, this uses the program `df' to get the device name, but is
|
||||
# this really portable?
|
||||
root_device=`df ${rootdir}/ | grep /dev/ | sed 's%.*\(/dev/[a-z0-9]*\).*%\1%'`
|
||||
root_device=`df ${rootdir}/ | grep /dev/ \
|
||||
| sed 's%.*\(/dev/[a-z0-9]*\).*%\1%'`
|
||||
bootdir_device=`df ${bootdir} | grep /dev/ \
|
||||
| sed 's%.*\(/dev/[a-z0-9]*\).*%\1%'`
|
||||
|
||||
# Check if the boot directory is in the same device as the root directory.
|
||||
if test "x$root_device" != "x$bootdir_device"; then
|
||||
# Perhaps the user has a separate boot partition.
|
||||
root_device=$bootdir_device
|
||||
grubdir="/grub"
|
||||
fi
|
||||
|
||||
# Convert the root device to a GRUB drive.
|
||||
root_drive=`convert "$root_device"`
|
||||
if test "x$root_drive" = x; then
|
||||
exit 1
|
||||
|
@ -262,7 +274,7 @@ test -x /bin/tempfile && log_file=`tempfile --prefix=grub`
|
|||
# Now perform the installation.
|
||||
$grub_shell --batch --device-map=$device_map <<EOF >$log_file
|
||||
root $root_drive
|
||||
setup $force_lba --stage2=$grubdir/stage2 $install_drive
|
||||
setup $force_lba --stage2=$grubdir/stage2 --prefix=$grubdir $install_drive
|
||||
quit
|
||||
EOF
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue