Ignore:
Timestamp:
Sep 29, 2013, 9:31:34 AM (11 years ago)
Author:
Bruno Cornec
Message:
  • Finish with backports from 3.1 for now. Still some work to do, but we will now make that version compile and work again and serve as a base

so the gettext patch can be added

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.1/mondo/src/mondorestore/mondo-rstr-tools.c

    r3161 r3193  
    9090    fatal_error("Cannot openin outfname");
    9191}
    92 for (mr_getline(incoming, fin); !feof(fin); mr_getline(incoming, fin)) {
     92for (mr_getline(incoming, fin); !feof(fin) && (incoming != NULL); mr_getline(incoming, fin)) {
    9393    mr_strip_spaces(incoming);
    9494
     
    140140}
    141141if (file[0] == '/' && file[1] == '/') {
    142     mr_asprintf(tmp, "%s", file);
    143     mr_free(file);
     142    tmp = file;
    144143
    145144    mr_asprintf(file, "%s", tmp + 1);
     
    174173* @return 0 for success, nonzero for failure.
    175174*/
    176 int iso_fiddly_bits(bool nuke_me_please)
    177 {
    178     char *mount_isodir_command = NULL;
    179     char *command = NULL;
    180     char *mds = NULL;
    181     int retval = 0, i;
    182     char *isodir_format = NULL;
     175int iso_fiddly_bits(bool nuke_me_please) {
     176
     177char *mount_isodir_command = NULL;
     178char *command = NULL;
     179char *mds = NULL;
     180int retval = 0, i;
     181char *isodir_format = NULL;
    183182
    184183g_ISO_restore_mode = TRUE;
     
    305304            mr_strcat(additional_parameters, "-o ro");
    306305        }
     306        mr_free(tmp);
     307
    307308        tmp = find_home_of_exe("setfattr");
    308309        if (tmp) {
     
    374375mr_free(mountpoint);
    375376
    376     return (res);
     377return (res);
    377378}
    378379/**************************************************************************
     
    418419            mr_free(tmp);
    419420            res = mount_device(mountlist->el[lino].device, mountlist->el[lino].mountpoint, mountlist->el[lino].format, writeable);
    420 
    421421            retval += res;
    422422            if (res) {
     
    660660assert(bkpinfo != NULL);
    661661assert(cfgf != NULL);
     662log_it("Entering read_cfg_file_into_bkpinfo");
    662663
    663664media_specified_by_user = bkpinfo->backup_media_type;   // or 'none', if not specified
     
    676677        bkpinfo->please_dont_eject = TRUE;
    677678    } else if (!strcmp(value, "iso")) {
    678         // Patch by Conor Daly - 2004/07/12
    679679        bkpinfo->backup_media_type = iso;
    680680        if (am_I_in_disaster_recovery_mode()) {
     
    687687                bkpinfo->backup_media_type = cdr;
    688688                run_program_and_log_output("umount -d "MNT_CDROM, 1);
    689                 log_it
    690                     ("Re-jigging configuration AGAIN. CD-R, not ISO.");
     689                log_it("Re-jigging configuration AGAIN. CD-R, not ISO.");
    691690            }
    692691        }
     
    698697            mr_asprintf(bkpinfo->prefix, "%s", STD_PREFIX);
    699698        }
     699        log_it("Setting Prefix to %s", bkpinfo->prefix);
    700700    } else if ((!strcmp(value, "netfs")) || (!strcmp(value, "nfs"))) {
    701701        /* Stay compatible with previous versions by allowing nfs as an entry here */
     
    727727        tmp = call_program_and_get_last_line_of_output("cat " CMDLINE,TRUE);
    728728        if (strstr(tmp, "pxe")) {
    729             /* We need to override prefix value in PXE mode as it's 
     729            /* We need to override prefix value in PXE mode as it's
    730730            * already done in start-netfs */
    731731            envtmp1 = getenv("imgname");
     
    754754        mr_free(bkpinfo->media_device);
    755755        mr_asprintf(bkpinfo->media_device, "/dev/cdrom");
    756         bkpinfo->media_size[0] = 1999 * 1024;
    757         bkpinfo->media_size[1] = 650;   /* good guess */
     756        bkpinfo->media_size = 650;  /* good guess */
    758757    } else if (bkpinfo->backup_media_type == usb) {
    759758        envtmp1 = getenv("MRUSBDEV");
     
    778777        value = read_cfg_var(cfg_file, "media-size");
    779778        if (value != NULL) {
    780             bkpinfo->media_size[1] = atol(value);
     779            bkpinfo->media_size = atol(value);
    781780            mr_free(value);
    782781        } else {
    783             bkpinfo->media_size[1] = 0L;
     782            bkpinfo->media_size = 0L;
    784783        }
    785784        log_msg(2, "Backup medium is TAPE --- dev=%s", bkpinfo->media_device);
     
    787786        mr_free(bkpinfo->media_device);
    788787        mr_asprintf(bkpinfo->media_device, "/dev/cdrom");   /* we don't really need this var */
    789         bkpinfo->media_size[0] = 1999 * 1024;   /* 650, probably, but we don't need this var anyway */
    790         bkpinfo->media_size[1] = 1999 * 1024;   /* 650, probably, but we don't need this var anyway */
    791         log_msg(2, "Backup medium is CD-R[W]");
     788        bkpinfo->media_size = 1999 * 1024;  /* 650, probably, but we don't need this var anyway */
     789        log_msg(2, "Backup medium is similar to CD-R[W]");
    792790    }
    793791} else {
     
    968966        mr_free(tmp1);
    969967    }
    970 
    971968} else if (bkpinfo->backup_media_type == iso) {
    972969    /* Patch by Conor Daly 23-june-2004
     
    10441041    if (! bkpinfo->disaster_recovery) {
    10451042        if (bkpinfo->backup_media_type != media_specified_by_user) {
    1046             log_msg(2,
    1047                     "bkpinfo->backup_media_type != media_specified_by_user, so I'd better ask :)");
     1043            log_msg(2, "bkpinfo->backup_media_type != media_specified_by_user, so I'd better ask :)");
    10481044            interactively_obtain_media_parameters_from_user(FALSE);
    10491045            media_specified_by_user = bkpinfo->backup_media_type;
     
    10861082int res = 0;
    10871083pid_t pid;
     1084bool extract_mountlist_stub = FALSE;
    10881085
    10891086assert(bkpinfo != NULL);
     
    12341231            popup_and_OK("You'll now be chrooted under your future / partition.\nEdit /etc/mkinitcpio.conf if needed and rebuild your initrd with the kernel preset name e.g.\nmkinitcpio -p kernel26\nThen type exit to finish.\n");
    12351232        } else {
    1236             popup_and_OK("You'll now be chrooted under your future / partition.\nGo under /boot and rebuild your initrd with\nmkinitrd -f -v initrd-2.x.y.img 2.x.y e.g.\nThen type exit to finish.");
     1233            popup_and_OK("You'll now be chrooted under your future / partition.\nGo under /boot and rebuild your init(rd|ramfs) with\nmkinitrd -f -v initrd-2.x.y.img 2.x.y e.g.\nor initramfs, dracut, ... Then type exit to finish.");
    12371234        }
    12381235        mvaddstr_and_log_it(g_currentY, 0, "Modifying initrd...");
     
    14351432
    14361433            if ((res) || (mntlistchg)) {
    1437                 popup_and_OK("GRUB installation failed. You will now edit fstab, mtab, device.map and menu.lst/grub.cfg in order to fix grub install");
    1438             } else {
    1439                 popup_and_OK("The mountlist was changed. You will now edit fstab, mtab, device.map and menu.lst/grub.cfg in order to fix grub install");
    1440             }
    1441             if (!g_text_mode) {
    1442                 newtSuspend();
    1443             }
    1444             mr_asprintf(tmp, "chroot %s %s /etc/fstab", MNT_RESTORING, editor);
    1445             paranoid_system(tmp);
    1446             mr_free(tmp);
    1447 
    1448             mr_asprintf(tmp, "chroot %s %s /etc/mtab", MNT_RESTORING, editor);
    1449             paranoid_system(tmp);
    1450             mr_free(tmp);
    1451 
    1452             if (does_file_exist(MNT_RESTORING"/boot/grub/menu.lst")) {
    1453                 mr_asprintf(tmp, "chroot %s %s /boot/grub/menu.lst", MNT_RESTORING, editor);
    1454             } else if (does_file_exist(MNT_RESTORING"/boot/grub/grub.cfg")) {
    1455                 mr_asprintf(tmp, "chroot %s %s /boot/grub/grub.cfg", MNT_RESTORING, editor);
    1456             } else if (does_file_exist(MNT_RESTORING"/boot/grub2/grub.cfg")) {
    1457                 mr_asprintf(tmp, "chroot %s %s /boot/grub2/grub.cfg", MNT_RESTORING, editor);
    1458             }
    1459             paranoid_system(tmp);
    1460             mr_free(tmp);
    1461 
    1462             if (does_file_exist(MNT_RESTORING"/boot/grub/device.map")) {
     1434                if (res) {
     1435                    popup_and_OK("GRUB installation failed. You will now edit fstab, mtab, device.map and menu.lst/grub.cfg in order to fix grub install");
     1436                } else {
     1437                    popup_and_OK("The mountlist was changed. You will now edit fstab, mtab, device.map and menu.lst/grub.cfg in order to fix grub install");
     1438                }
     1439                if (!g_text_mode) {
     1440                    newtSuspend();
     1441                }
     1442                mr_asprintf(editor, "%s", find_my_editor());
     1443                mr_asprintf(tmp, "chroot %s %s /etc/fstab", MNT_RESTORING, editor);
     1444                paranoid_system(tmp);
     1445                mr_free(tmp);
     1446
     1447                mr_asprintf(tmp, "chroot %s %s /etc/mtab", MNT_RESTORING, editor);
     1448                paranoid_system(tmp);
     1449                mr_free(tmp);
     1450   
     1451                if (does_file_exist(MNT_RESTORING"/boot/grub/menu.lst")) {
     1452                    mr_asprintf(tmp, "chroot %s %s /boot/grub/menu.lst", MNT_RESTORING, editor);
     1453                } else if (does_file_exist(MNT_RESTORING"/boot/grub/grub.cfg")) {
     1454                    mr_asprintf(tmp, "chroot %s %s /boot/grub/grub.cfg", MNT_RESTORING, editor);
     1455                } else if (does_file_exist(MNT_RESTORING"/boot/grub2/grub.cfg")) {
     1456                    mr_asprintf(tmp, "chroot %s %s /boot/grub2/grub.cfg", MNT_RESTORING, editor);
     1457                }
     1458                paranoid_system(tmp);
     1459                mr_free(tmp);
     1460   
     1461                if (does_file_exist(MNT_RESTORING"/boot/grub/device.map")) {
     1462                    mr_asprintf(tmp, "chroot %s %s /boot/grub/device.map", MNT_RESTORING, editor);
     1463                } else if (does_file_exist(MNT_RESTORING"/boot/grub2/device.map")) {
     1464                    mr_asprintf(tmp, "chroot %s %s /boot/grub2/device.map", MNT_RESTORING, editor);
     1465                }
     1466                paranoid_system(tmp);
     1467                mr_free(tmp);
     1468
     1469                if (!g_text_mode) {
     1470                    newtResume();
     1471                }
     1472                mr_asprintf(command, "stabgrub-me %s", boot_device);
     1473                res = run_program_and_log_output(command, 1);
     1474                mr_free(command);
     1475
     1476                if (res) {
     1477                    popup_and_OK("GRUB installation failed. Please fix the conf files so that a manual install using 'grub-install' or similar command works. You are now chroot()'ed to your restored system. Please type 'exit' when you are done.");
     1478                    newtSuspend();
     1479                    paranoid_system("chroot " MNT_RESTORING);
     1480                    newtResume();
     1481                    popup_and_OK("Thank you.");
     1482                } else {
     1483                    popup_and_OK("GRUB is now installed correctly");
     1484                    done = TRUE;
     1485                }
     1486                popup_and_OK("You will now edit fstab, mtab, device.map and menu.lst/grub.cfg");
     1487                if (!g_text_mode) {
     1488                    newtSuspend();
     1489                }
     1490   
     1491                mr_asprintf(tmp, "chroot %s %s /etc/fstab", MNT_RESTORING, editor);
     1492                paranoid_system(tmp);
     1493                mr_free(tmp);
     1494   
     1495                mr_asprintf(tmp, "chroot %s %s /etc/mtab", MNT_RESTORING, editor);
     1496                paranoid_system(tmp);
     1497                mr_free(tmp);
     1498   
     1499                if (does_file_exist(MNT_RESTORING"/boot/grub/menu.lst")) {
     1500                    mr_asprintf(tmp, "chroot %s %s /boot/grub/menu.lst", MNT_RESTORING, editor);
     1501                } else if (does_file_exist(MNT_RESTORING"/boot/grub/grub.cfg")) {
     1502                    mr_asprintf(tmp, "chroot %s %s /boot/grub/grub.cfg", MNT_RESTORING, editor);
     1503                }
     1504                paranoid_system(tmp);
     1505                mr_free(tmp);
     1506
    14631507                mr_asprintf(tmp, "chroot %s %s /boot/grub/device.map", MNT_RESTORING, editor);
    1464             } else if (does_file_exist(MNT_RESTORING"/boot/grub2/device.map")) {
    1465                 mr_asprintf(tmp, "chroot %s %s /boot/grub2/device.map", MNT_RESTORING, editor);
    1466             }
    1467             paranoid_system(tmp);
    1468             mr_free(tmp);
    1469 
    1470             if (!g_text_mode) {
    1471                 newtResume();
    1472             }
    1473             mr_asprintf(command, "stabgrub-me %s", boot_device);
    1474             res = run_program_and_log_output(command, 1);
    1475             mr_free(command);
    1476             if (res) {
    1477                 popup_and_OK("GRUB installation failed. Please fix the conf files so that a manual install using 'grub-install' or similar command works. You are now chroot()'ed to your restored system. Please type 'exit' when you are done.");
    1478                 newtSuspend();
    1479                 paranoid_system("chroot " MNT_RESTORING);
    1480                 newtResume();
    1481                 popup_and_OK("Thank you.");
    1482             } else {
    1483                 popup_and_OK("GRUB is now installed correctly");
    1484                 done = TRUE;
    1485             }
    1486             popup_and_OK("You will now edit fstab, mtab, device.map and menu.lst/grub.cfg");
    1487             if (!g_text_mode) {
    1488                 newtSuspend();
    1489             }
    1490             mr_asprintf(editor, "%s", find_my_editor());
    1491 
    1492             mr_asprintf(tmp, "chroot %s %s /etc/fstab", MNT_RESTORING, editor);
    1493             paranoid_system(tmp);
    1494             mr_free(tmp);
    1495 
    1496             mr_asprintf(tmp, "chroot %s %s /etc/mtab", MNT_RESTORING, editor);
    1497             paranoid_system(tmp);
    1498             mr_free(tmp);
    1499 
    1500             if (does_file_exist(MNT_RESTORING"/boot/grub/menu.lst")) {
    1501                 mr_asprintf(tmp, "chroot %s %s /boot/grub/menu.lst", MNT_RESTORING, editor);
    1502             } else if (does_file_exist(MNT_RESTORING"/boot/grub/grub.cfg")) {
    1503                 mr_asprintf(tmp, "chroot %s %s /boot/grub/grub.cfg", MNT_RESTORING, editor);
    1504             }
    1505             paranoid_system(tmp);
    1506             mr_free(tmp);
    1507 
    1508             mr_asprintf(tmp, "chroot %s %s /boot/grub/device.map", MNT_RESTORING, editor);
    1509             paranoid_system(tmp);
    1510             mr_free(tmp);
    1511             mr_free(editor);
    1512 
    1513             if (!g_text_mode) {
    1514                 newtResume();
     1508                paranoid_system(tmp);
     1509                mr_free(tmp);
     1510                mr_free(editor);
     1511   
     1512                if (!g_text_mode) {
     1513                    newtResume();
     1514                }
    15151515            }
    15161516        }
     
    15251525            log_msg(1, "WARNING - grub-MR not found; using grub-install");
    15261526        }
    1527         mvaddstr_and_log_it(g_currentY,
    1528                             0,
    1529                             "Running GRUB...                                                 ");
     1527        mvaddstr_and_log_it(g_currentY, 0, "Running GRUB...                                                 ");
    15301528        log_it("%s",command);
    15311529        res = run_program_and_log_output(command, 1);
     
    16111609                paranoid_system(tmp);
    16121610                mr_free(tmp);
    1613 
    16141611                mr_free(editor);
    16151612
     
    16881685                paranoid_system(tmp);
    16891686                mr_free(tmp);
    1690 
    16911687                mr_free(editor);
    16921688
     
    21142110    paranoid_free(raidlist);
    21152111}
    2116 
    2117 
Note: See TracChangeset for help on using the changeset viewer.