Ignore:
Timestamp:
Aug 21, 2009, 1:47:12 AM (15 years ago)
Author:
Bruno Cornec
Message:
  • Adds LZMA support (Fix #309)
  • Change
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.10/mondo/src/common/libmondo-cli.c

    r2334 r2338  
    100100        bkpinfo->media_size[j] = 650;
    101101    }                           /* default */
    102     res =
    103         retrieve_switches_from_command_line(argc, argv, flag_val,
    104                                             flag_set);
     102    res = retrieve_switches_from_command_line(argc, argv, flag_val, flag_set);
    105103    retval += res;
    106104    if (!retval) {
     
    807805        }
    808806        if (bkpinfo->include_paths != NULL) {
     807            mr_strip_spaces(bkpinfo->include_paths);
    809808            log_msg(1, "include_paths is now '%s'", bkpinfo->include_paths);
    810809        }
    811810        if (bkpinfo->exclude_paths != NULL) {
     811            mr_strip_spaces(bkpinfo->exclude_paths);
    812812            log_msg(1, "exclude_paths is now '%s'", bkpinfo->exclude_paths);
    813813        }
     
    815815    }
    816816
    817     if (g_kernel_version >= 2.6 && !flag_set['d']
    818         && (flag_set['c'] || flag_set['w']) && (! bkpinfo->restore_data)) {
    819         fatal_error
    820             ("If you are using the 2.6.x kernel, please specify the CD-R(W) device.");
     817    if (g_kernel_version >= 2.6 && !flag_set['d'] && (flag_set['c'] || flag_set['w']) && (! bkpinfo->restore_data)) {
     818        fatal_error("If you are using the 2.6.x kernel, please specify the CD-R(W) device.");
    821819    }
    822820
     
    825823        if (flag_set['I']) {
    826824            retval++;
    827             log_to_screen
    828                 ("Please do not use -J in combination with -I. If you want to make a list of files to backup, that's fine, use -J <filename> but please don't muddy the waters by combining -J with -I. Thanks. :-)");
     825            log_to_screen("Please do not use -J in combination with -I. If you want to make a list of files to backup, that's fine, use -J <filename> but please don't muddy the waters by combining -J with -I. Thanks. :-)");
    829826        }
    830827        bkpinfo->make_filelist = FALSE;
     
    833830
    834831    if ((flag_set['c'] || flag_set['w'] || flag_set['C'] || flag_set['r']) && (! bkpinfo->restore_data)) {
    835         if (!flag_set['r'] && g_kernel_version <= 2.5
    836             && strstr(flag_val['d'], "/dev/")) {
    837             fatal_error
    838                 ("Please don't give a /dev entry. Give a SCSI node for the parameter of the -d flag.");
    839         }
    840         if (flag_set['r'] && g_kernel_version <= 2.5
    841             && !strstr(flag_val['d'], "/dev/")) {
    842             fatal_error
    843                 ("Please give a /dev entry, not a SCSI node, as the parameter of the -d flag.");
     832        if (!flag_set['r'] && g_kernel_version <= 2.5 && strstr(flag_val['d'], "/dev/")) {
     833            fatal_error("Please don't give a /dev entry. Give a SCSI node for the parameter of the -d flag.");
     834        }
     835        if (flag_set['r'] && g_kernel_version <= 2.5 && !strstr(flag_val['d'], "/dev/")) {
     836            fatal_error("Please give a /dev entry, not a SCSI node, as the parameter of the -d flag.");
    844837        }
    845838        if (g_kernel_version >= 2.6 && !strstr(flag_val['d'], "/dev/")) {
    846             log_to_screen
    847                 ("Linus says 2.6 has a broken ide-scsi module. Proceed at your own risk...");
    848         }
    849 
    850         if (system("which cdrecord > /dev/null 2> /dev/null")
    851             && system("which dvdrecord > /dev/null 2> /dev/null")) {
    852             fatal_error
    853                 ("Please install dvdrecord/cdrecord and try again.");
     839            log_to_screen("Linus says 2.6 has a broken ide-scsi module. Proceed at your own risk...");
     840        }
     841
     842        if (system("which cdrecord > /dev/null 2> /dev/null") && system("which dvdrecord > /dev/null 2> /dev/null")) {
     843            fatal_error("Please install dvdrecord/cdrecord and try again.");
    854844        }
    855845        if (flag_set['C']) {
    856846            bkpinfo->cdrw_speed = atoi(flag_val['C']);
    857847            if (bkpinfo->cdrw_speed < 1) {
    858                 fatal_error
    859                     ("You specified a silly speed for a CD-R[W] drive");
     848                fatal_error("You specified a silly speed for a CD-R[W] drive");
    860849            }
    861850            if (!flag_set['L']) {
    862                 log_to_screen
    863                     ("You must use -L with -C. Therefore I am setting it for you.");
     851                log_to_screen("You must use -L with -C. Therefore I am setting it for you.");
    864852                flag_set['L'] = 1;
    865853                flag_val['L'][0] = '\0';
     
    868856            log_msg(3, "flag_val['c'] = %s", flag_val['c']);
    869857            log_msg(3, "flag_val['w'] = %s", flag_val['w']);
    870             // log_msg(3, "flag_set['r'] = %i", flag_set['r'] );
    871858            if (flag_set['c']) {
    872859                bkpinfo->cdrw_speed = atoi(flag_val['c']);
     
    878865
    879866            if (bkpinfo->cdrw_speed < 1) {
    880                 fatal_error
    881                     ("You specified a silly speed for a CD-R[W] drive");
     867                fatal_error("You specified a silly speed for a CD-R[W] drive");
    882868            }
    883869        }
     
    901887    {
    902888        if (! flag_set['d']) {
    903             fatal_error
    904                 ("You need to specify a device file with -d for bootable USB device usage");
     889            fatal_error("You need to specify a device file with -d for bootable USB device usage");
    905890        }
    906891        if ((!flag_set['s']) && (! bkpinfo->restore_data)) {
     
    912897    {
    913898        if (flag_set['m']) {
    914             fatal_error
    915                 ("Manual CD tray (-m) not yet supported in conjunction w/ DVD drives. Drop -m.");
     899            fatal_error("Manual CD tray (-m) not yet supported in conjunction w/ DVD drives. Drop -m.");
    916900        }
    917901        if (!flag_set['d']) {
     
    957941            if (flag_set['s']) {
    958942                if (flag_set['t']) {
    959                     fatal_error
    960                         ("For the moment, please don't specify a tape size. Mondo should handle end-of-tape gracefully anyway.");
     943                    fatal_error("For the moment, please don't specify a tape size. Mondo should handle end-of-tape gracefully anyway.");
    961944                }
    962945                if (process_the_s_switch(flag_val['s'])) {
     
    11751158        log_msg(1, "Internal tape block size is now %ld bytes", itbs);
    11761159        if (itbs % 512 != 0 || itbs < 256 || itbs > 1024L * 1024) {
    1177             fatal_error
    1178                 ("Are you nuts? Silly, your internal tape block size is. Abort, I shall.");
     1160            fatal_error("Are you nuts? Silly, your internal tape block size is. Abort, I shall.");
    11791161        }
    11801162        bkpinfo->internal_tape_block_size = itbs;
     
    11851167//      bkpinfo->differential = atoi (flag_val['D']);
    11861168        if ((bkpinfo->differential < 1) || (bkpinfo->differential > 9)) {
    1187             fatal_error
    1188                 ("The D option should be between 1 and 9 inclusive");
     1169            fatal_error("The D option should be between 1 and 9 inclusive");
    11891170        }
    11901171    }
     
    12791260        retval++;
    12801261        log_to_screen("Please specify the backup device/directory.\n");
    1281         fatal_error
    1282             ("You didn't use -d to specify the backup device/directory.");
     1262        fatal_error("You didn't use -d to specify the backup device/directory.");
    12831263    }
    12841264
     
    13651345        if (run_program_and_log_output("which lzop", 2)) {
    13661346            retval++;
    1367             log_to_screen
    1368                 ("Please install LZOP. You can't use '-L' until you do.\n");
     1347            log_to_screen("Please install LZOP. You can't use '-L' until you do.\n");
    13691348        }
    13701349    }
     
    13741353        if (run_program_and_log_output("which gzip", 2)) {
    13751354            retval++;
    1376             log_to_screen
    1377                 ("Please install gzip. You can't use '-G' until you do.\n");
     1355            log_to_screen("Please install gzip. You can't use '-G' until you do.\n");
     1356        }
     1357    }
     1358
     1359    if ((flag_set['Y']) && (! bkpinfo->restore_data)) {
     1360        bkpinfo->use_lzma = TRUE;
     1361        if (run_program_and_log_output("which lzma", 2)) {
     1362            retval++;
     1363            log_to_screen("Please install lzma. You can't use '-Y' until you do.\n");
    13781364        }
    13791365    }
     
    13911377    if ((!is_this_a_valid_disk_format("vfat")) && (! bkpinfo->restore_data)) {
    13921378        bkpinfo->make_cd_use_lilo = TRUE;
    1393         log_to_screen
    1394             ("Your kernel appears not to support vfat filesystems. I am therefore");
    1395         log_to_screen
    1396             ("using LILO instead of SYSLINUX as the media boot loader.");
     1379        log_to_screen("Your kernel appears not to support vfat filesystems. I am therefore");
     1380        log_to_screen("using LILO instead of SYSLINUX as the media boot loader.");
    13971381    }
    13981382    if ((run_program_and_log_output("which mkfs.vfat", 2)) && (! bkpinfo->restore_data)) {
    13991383        bkpinfo->make_cd_use_lilo = TRUE;
    14001384#ifdef __IA32__
    1401         log_to_screen
    1402             ("Your filesystem is missing 'mkfs.vfat', so I cannot use SYSLINUX as");
    1403         log_to_screen
    1404             ("your boot loader. I shall therefore use LILO instead.");
     1385        log_to_screen("Your filesystem is missing 'mkfs.vfat', so I cannot use SYSLINUX as");
     1386        log_to_screen("your boot loader. I shall therefore use LILO instead.");
    14051387#endif
    14061388#ifdef __IA64__
    1407         log_to_screen
    1408             ("Your filesystem is missing 'mkfs.vfat', so I cannot prepare the EFI");
     1389        log_to_screen("Your filesystem is missing 'mkfs.vfat', so I cannot prepare the EFI");
    14091390        log_to_screen("environment correctly. Please install it.");
    14101391        fatal_error("Aborting");
     
    14261407
    14271408    if ((! bkpinfo->restore_data) && (flag_set['Z'])) {
    1428             fatal_error
    1429                 ("The -Z switch is only valid in restore mode");
     1409            fatal_error("The -Z switch is only valid in restore mode");
    14301410    }
    14311411
     
    14661446 * @return The number of problems with the command line (0 for success).
    14671447 */
    1468 int
    1469 retrieve_switches_from_command_line(int argc, char *argv[],
    1470                                     char flag_val[128][MAX_STR_LEN],
    1471                                     bool flag_set[128])
     1448int retrieve_switches_from_command_line(int argc, char *argv[], char flag_val[128][MAX_STR_LEN], bool flag_set[128])
    14721449{
    14731450    /*@ ints ** */
     
    14861463        flag_set[i] = FALSE;
    14871464    }
    1488     while ((opt =
    1489             getopt(argc, argv, MONDO_OPTIONS))
    1490            != -1) {
     1465    while ((opt = getopt(argc, argv, MONDO_OPTIONS)) != -1) {
    14911466        if (opt == '?') {
    14921467            bad_switches = TRUE;
Note: See TracChangeset for help on using the changeset viewer.