From 60d1f118c9218973c099ea1baf4c0aa2f21f6c30 Mon Sep 17 00:00:00 2001 From: James Meyer <james.meyer@operamail.com> Date: Thu, 25 Jun 2009 22:23:23 -0500 Subject: linhes-config: try to write a valid partition table if one doesn't exist. Works for new disks. --- abs/core-testing/LinHES-config/PKGBUILD | 2 +- abs/core-testing/LinHES-config/mv_install.py | 31 +++++++++++++++++++++------- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/abs/core-testing/LinHES-config/PKGBUILD b/abs/core-testing/LinHES-config/PKGBUILD index 676c13f..cc67e21 100755 --- a/abs/core-testing/LinHES-config/PKGBUILD +++ b/abs/core-testing/LinHES-config/PKGBUILD @@ -1,6 +1,6 @@ pkgname=LinHES-config pkgver=2.0 -pkgrel=25 +pkgrel=26 conflicts=(MythVantage-config MythVantage-config-dev LinHES-config-dev ) pkgdesc="Install and configure your system" depends=(bc libstatgrab mysql-python expect curl dnsutils parted sg3_utils nmbscan system-templates rsync python-parted ddcxinfo) diff --git a/abs/core-testing/LinHES-config/mv_install.py b/abs/core-testing/LinHES-config/mv_install.py index 87fbaae..9d70a55 100755 --- a/abs/core-testing/LinHES-config/mv_install.py +++ b/abs/core-testing/LinHES-config/mv_install.py @@ -219,16 +219,33 @@ def umount_bind_chroot(): runcmd(cmd) +def blank_table(diskdevice): + logging.debug(" writing new parition table for %s", diskdevice) + logging.debug("parition table before:") + cmd = "fdisk -l %s" %diskdevice + runcmd(cmd) + + cmd = "echo w |fdisk %s" %diskdevice + runcmd(cmd) + + logging.debug("parition table after:") + cmd = "fdisk -l %s" %diskdevice + runcmd(cmd) + def partitions_removeall(diskdevice, label): logging.info("Removing all partitions for %s %s", label, diskdevice) - device = parted.getDevice(diskdevice) - partdisk = parted.Disk(device) - partdisk.deleteAllPartitions() - if data_config.NOOPDEBUG == "FALSE": - partdisk.commit() + try: + device = parted.getDevice(diskdevice) + partdisk = parted.Disk(device) + partdisk.deleteAllPartitions() + if data_config.NOOPDEBUG == "FALSE": + partdisk.commit() + for partition in partdisk.partitions: + print "type: %s" %partition.type + except: + logging.debug(" Error reading parition table, attempting to write a blank one") + blank_table(diskdevice) - for partition in partdisk.partitions: - print "type: %s" %partition.type def create_partitions(diskdevice, size, ptype, startsector): logging.debug("_____Create partitions______") -- cgit v0.12