Ignore:
Timestamp:
Oct 21, 2007, 3:06:22 AM (17 years ago)
Author:
Bruno Cornec
Message:
  • Remove useless copy from mindi to mondo at end of USB handling
  • Fix PB macro vs tools/*2build issue
  • make_usb_fs change of interface (doesn't need a parameter)
  • Fix USB support in mondo to avoid multiple copies of files
  • Use first partiion in mondo for USB device
  • Fixes for USB CLI for both mondo/mindi
  • Try to add USB support for mondoarchive with new functions
  • du => deb for similarity with other distro type under pbconf
  • migrate gento build files under pb
  • remove now obsolete rpm spec file and gentoo build files from distributions
  • Remove DOCDIR usage in mindi + various build fixes

(merge -r1680:1692 $SVN_M/branches/2.2.5)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/stable/mondo/src/common/libmondo-archive.c

    r1671 r1693  
    533533    /*@ buffer ************************************************************ */
    534534    char *tmp = NULL;
     535    char *tmp1 = NULL;
     536    char *tmp2 = NULL;
    535537    char *command = NULL;
    536538    char *bootldr_str = NULL;
     
    15341536    }
    15351537    close_evalcall_form();
     1538}
     1539
     1540
     1541/**
     1542 * Create a USB image in @c destfile, from files in @c bkpinfo->scratchdir.
     1543 *
     1544 * @param bkpinfo The backup information structure. Fields used:
     1545 * - @c backup_media_type
     1546 * - @c nonbootable_backup
     1547 * - @c scratchdir
     1548 *
     1549 * @param destfile Where to put the generated USB image.
     1550 * @return The number of errors encountered (0 for success)
     1551 */
     1552int make_usb_fs()
     1553{
     1554    /*@ int ********************************************** */
     1555    int retval = 0;
     1556    int res;
     1557
     1558    /*@ buffers ****************************************** */
     1559    char *tmp = NULL;
     1560    char *tmp1 = NULL;
     1561    char *result_sz = NULL;
     1562    char *message_to_screen = NULL;
     1563    char *old_pwd;
     1564
     1565    malloc_string(old_pwd);
     1566    assert(bkpinfo != NULL);
     1567
     1568    log_msg(2, "make_usb_fs --- scratchdir=%s", bkpinfo->scratchdir);
     1569    (void) getcwd(old_pwd, MAX_STR_LEN - 1);
     1570    asprintf(&tmp, "chmod 755 %s", bkpinfo->scratchdir);
     1571    run_program_and_log_output(tmp, FALSE);
     1572    paranoid_free(tmp);
     1573    chdir(bkpinfo->scratchdir);
     1574
     1575    asprintf(&message_to_screen, "Copying data to make %s #%d",
     1576                media_descriptor_string(bkpinfo->backup_media_type),
     1577                g_current_media_number);
     1578    log_msg(1, message_to_screen);
     1579
     1580    if (is_this_device_mounted(bkpinfo->media_device)) {
     1581        log_msg(1, "USB device mounted. Remounting it at the right place");
     1582        asprintf(&tmp, "umount %s", bkpinfo->media_device);
     1583        run_program_and_log_output(tmp, FALSE);
     1584        paranoid_free(tmp);
     1585    }
     1586    log_msg(1, "Mounting USB device.");
     1587    asprintf(&tmp1, "%s/usb", bkpinfo->tmpdir);
     1588    asprintf(&tmp, "mkdir -p %s", tmp1);
     1589    run_program_and_log_output(tmp, FALSE);
     1590    paranoid_free(tmp);
     1591    /* Mindi always create one single parition on the USB dev */
     1592    asprintf(&tmp, "mount %s1 %s", bkpinfo->media_device, tmp1);
     1593    run_program_and_log_output(tmp, FALSE);
     1594    paranoid_free(tmp);
     1595
     1596    if (bkpinfo->nonbootable_backup) {
     1597        log_msg(1, "Making nonbootable USB backup not implemented yet");
     1598    } else {
     1599        log_msg(1, "Making bootable backup");
     1600
     1601        /* Command to execute */
     1602        asprintf(&tmp,"mv %s/.??* %s/* %s", bkpinfo->scratchdir, bkpinfo->scratchdir, tmp1);
     1603        res = eval_call_to_make_USB(tmp, message_to_screen);
     1604        if (res) {
     1605            asprintf(&result_sz, "%s ...failed",tmp);
     1606        } else {
     1607            asprintf(&result_sz, "%s ...OK",tmp);
     1608        }
     1609        log_to_screen(result_sz);
     1610        paranoid_free(result_sz);
     1611        paranoid_free(tmp);
     1612        retval += res;
     1613    }
     1614    paranoid_free(message_to_screen);
     1615    paranoid_free(tmp1);
     1616
     1617    if (is_this_device_mounted(bkpinfo->media_device)) {
     1618        asprintf(&tmp, "umount %s1", bkpinfo->media_device);
     1619        run_program_and_log_output(tmp, FALSE);
     1620        paranoid_free(tmp);
     1621    }
     1622
     1623    chdir(old_pwd);
     1624    if (retval) {
     1625        log_msg(1, "WARNING - make_usb_fs returned an error");
     1626    }
     1627    paranoid_free(old_pwd);
     1628    return (retval);
    15361629}
    15371630
     
    31543247            res = make_iso_fs(isofile);
    31553248        } else {
     3249            res = make_usb_fs();
    31563250        }
    31573251        if (g_current_media_number == 1 && !res
Note: See TracChangeset for help on using the changeset viewer.