]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
installer: Install GRUB2 instead of GRUB legacy.
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 24 Jul 2014 12:22:22 +0000 (14:22 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 24 Jul 2014 13:14:27 +0000 (15:14 +0200)
lfs/grub
src/install+setup/install/hw.c
src/install+setup/install/hw.h
src/install+setup/install/main.c

index 2c5920f70ef98552f861047d1ab274714317b6f8..23f6dd3fd25fdc86db2a04c6b102bb089c8a4f8e 100644 (file)
--- a/lfs/grub
+++ b/lfs/grub
@@ -79,7 +79,7 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
                        --prefix=/usr \
                        --sysconfdir=/etc \
                        --with-platform=pc \
-                       --with-grubdir=grub2 \
+                       --with-grubdir=grub \
                        --program-transform-name=s,grub,grub, \
                        --disable-grub-mount \
                        --disable-werror
index 1863dfc90fac5d944c1d7fc8788b5b1a0e270d3b..77d024535a3597bf229dd5221095550b7ed2fbc6 100644 (file)
@@ -47,6 +47,14 @@ const char* other_filesystems[] = {
        NULL
 };
 
+static int system_chroot(const char* path, const char* cmd) {
+       char chroot_cmd[STRING_SIZE];
+
+       snprintf(chroot_cmd, sizeof(chroot_cmd), "/usr/sbin/chroot %s %s", path, cmd);
+
+       return mysystem(chroot_cmd);
+}
+
 struct hw* hw_init() {
        struct hw* hw = malloc(sizeof(*hw));
        assert(hw);
@@ -460,7 +468,7 @@ int hw_create_partitions(struct hw_destination* dest) {
        else if (dest->part_table == HW_PART_TABLE_GPT)
                asprintf(&cmd, "%s mklabel gpt", cmd);
 
-       unsigned long long part_start = 0 * 1024 * 1024; // 1MB
+       unsigned long long part_start = 1 * 1024 * 1024; // 1MB
 
        if (*dest->part_boot) {
                asprintf(&cmd, "%s mkpart %s ext2 %lluMB %lluMB", cmd,
@@ -707,7 +715,7 @@ int hw_setup_raid(struct hw_destination* dest) {
 
        assert(dest->is_raid);
 
-       asprintf(&cmd, "echo \"y\" | /sbin/mdadm --create --verbose --metadata=0.9 %s", dest->path);
+       asprintf(&cmd, "echo \"y\" | /sbin/mdadm --create --verbose --metadata=1.2 %s", dest->path);
 
        switch (dest->raid_level) {
                case 1:
@@ -752,3 +760,32 @@ int hw_setup_raid(struct hw_destination* dest) {
 int hw_stop_all_raid_arrays() {
        return mysystem("/sbin/mdadm --stop --scan");
 }
+
+int hw_install_bootloader(struct hw_destination* dest) {
+       char cmd[STRING_SIZE];
+       int r;
+
+       // Generate configuration file
+       snprintf(cmd, sizeof(cmd), "/usr/sbin/grub-mkconfig -o /boot/grub/grub.cfg");
+       r = system_chroot(DESTINATION_MOUNT_PATH, cmd);
+       if (r)
+               return r;
+
+       char cmd_grub[STRING_SIZE];
+       snprintf(cmd_grub, sizeof(cmd_grub), "/usr/sbin/grub-install --no-floppy --recheck");
+
+       if (dest->is_raid) {
+               snprintf(cmd, sizeof(cmd), "%s %s", cmd_grub, dest->disk1->path);
+               r = system_chroot(DESTINATION_MOUNT_PATH, cmd);
+               if (r)
+                       return r;
+
+               snprintf(cmd, sizeof(cmd), "%s %s", cmd_grub, dest->disk2->path);
+               r = system_chroot(DESTINATION_MOUNT_PATH, cmd);
+       } else {
+               snprintf(cmd, sizeof(cmd), "%s %s", cmd_grub, dest->path);
+               r = system_chroot(DESTINATION_MOUNT_PATH, cmd);
+       }
+
+       return r;
+}
index eb2908cb61cc9e046c2994dcc416c06daabde90e..5cd4fe02602cd2411310c8f97598518098d33815 100644 (file)
@@ -116,4 +116,6 @@ int hw_umount_filesystems(struct hw_destination* dest, const char* prefix);
 int hw_setup_raid(struct hw_destination* dest);
 int hw_stop_all_raid_arrays();
 
+int hw_install_bootloader(struct hw_destination* dest);
+
 #endif /* HEADER_HW_H */
index d5fe422df3e203488167ae85c77bba00365961ca..cc886bf2d3e01d5581016d9b9fa7eded2218ea3c 100644 (file)
@@ -528,31 +528,19 @@ int main(int argc, char *argv[]) {
        snprintf(commandstring, STRING_SIZE, "/bin/sed -i -e \"s#DEVICE4#UUID=$(/sbin/blkid %s -sUUID | /usr/bin/cut -d'\"' -f2)#g\" /harddisk/etc/fstab", destination->part_data);
        system(commandstring);
 
-       replace("/harddisk/boot/grub/grub.conf", "KVER", KERNEL_VERSION);
-
-       snprintf(commandstring, STRING_SIZE, "/bin/sed -i -e \"s#root=ROOT#root=UUID=$(/sbin/blkid %s -sUUID | /usr/bin/cut -d'\"' -f2)#g\" /harddisk/boot/grub/grub.conf", destination->part_root);
-       system(commandstring);
-
-       mysystem("ln -s grub.conf /harddisk/boot/grub/menu.lst");
-
        system("/bin/sed -e 's#/harddisk#/#g' -e 's#//#/#g'  < /proc/mounts > /harddisk/etc/mtab");
 
-       /*
-        * Generate device.map to help grub finding the device to install itself on.
-        */
-       FILE *f = NULL;
-       if (f = fopen("/harddisk/boot/grub/device.map", "w")) {
-               fprintf(f, "(hd0) %s\n", destination->path);
-               fclose(f);
-       }
+       // Installing bootloader...
+       statuswindow(60, 4, title, ctr[TR_INSTALLING_GRUB]);
 
-       snprintf(commandstring, STRING_SIZE, 
-                "/usr/sbin/chroot /harddisk /usr/sbin/grub-install --no-floppy %s", destination->path);
-       if (runcommandwithstatus(commandstring, ctr[TR_INSTALLING_GRUB])) {
+       rc = hw_install_bootloader(destination);
+       if (rc) {
                errorbox(ctr[TR_UNABLE_TO_INSTALL_GRUB]);
                goto EXIT;
        }
 
+       newtPopWindow();
+
        /* Serial console ? */
        if (serialconsole) {
                /* grub */