summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fsset.py2
-rw-r--r--harddrive.py4
-rw-r--r--installmethod.py9
-rw-r--r--instdata.py13
-rw-r--r--livecd.py7
-rw-r--r--partedUtils.py4
-rw-r--r--partitions.py36
-rw-r--r--upgrade.py2
-rw-r--r--yuminstall.py2
9 files changed, 39 insertions, 40 deletions
diff --git a/fsset.py b/fsset.py
index 93dd47593..b50bb27db 100644
--- a/fsset.py
+++ b/fsset.py
@@ -1650,7 +1650,7 @@ MAILADDR root
self.migratedfs = 1
def mountFilesystems(self, anaconda, raiseErrors = 0, readOnly = 0, skiprootfs = 0):
- protected = anaconda.method.protectedPartitions()
+ protected = anaconda.id.partitions.protectedPartitions()
for entry in self.entries:
# Don't try to mount a protected partition, since it will already
diff --git a/harddrive.py b/harddrive.py
index b60c457b8..1a0921d3d 100644
--- a/harddrive.py
+++ b/harddrive.py
@@ -129,10 +129,6 @@ class HardDriveInstallMethod(ImageInstallMethod):
except:
log.warning("unable to unmount media")
- # we cannot remove the partition we are hosting hard drive install from
- def protectedPartitions(self):
- return [self.device]
-
def __init__(self, method, rootPath, intf):
"""@param method hd://device:fstype:/path"""
method = method[5:]
diff --git a/installmethod.py b/installmethod.py
index 8a5c4247e..cfe8ae782 100644
--- a/installmethod.py
+++ b/installmethod.py
@@ -25,15 +25,6 @@ log = logging.getLogger("anaconda")
# subclasses, though things like mountCD, unmountCD, ejectCD, and the cleanup
# methods may not need to be redefined. By default, most methods pass.
class InstallMethod:
- ## Return the list of protected partitions.
- # Protected partitions are the installation source for the hard drive
- # installation method. Partitions on this list may be mounted, but may
- # not be formatted.
- #
- # @return The list of protected partitions, or an empty list otherwise.
- def protectedPartitions(self):
- return []
-
## Perform method-specific actions to mount any installation media.
# @param fsset An instance of FileSystemSet.
# @param mntPoint The root of the filesystem to mount the media onto.
diff --git a/instdata.py b/instdata.py
index 8c1d1dcbd..784fdb65f 100644
--- a/instdata.py
+++ b/instdata.py
@@ -70,7 +70,7 @@ class InstallData:
# XXX move fsset and/or diskset into Partitions object?
self.fsset.reset()
self.diskset = partedUtils.DiskSet(self.anaconda)
- self.partitions = partitions.Partitions()
+ self.partitions = partitions.Partitions(self.anaconda)
self.bootloader = bootloader.getBootloader()
self.upgradeRoot = None
self.rootParts = None
@@ -84,6 +84,17 @@ class InstallData:
# XXX I still expect this to die when kickstart is the data store.
self.ksdata = None
+ # We don't have install methods anymore, but put things that depend on
+ # the methodstr here.
+ if os.path.exists("/dev/live") and \
+ stat.S_ISBLK(os.stat("/dev/live")[stat.ST_MODE]):
+ target = os.readlink("/dev/live")
+ self.partitions.protected = [target]
+ elif self.methodstr.startswith("hd://"):
+ method = self.methodstr[5:]
+ device = method.split(":", 3)[0]
+ self.partitions.protected = [device]
+
def setInstallProgressClass(self, c):
self.instProgress = c
diff --git a/livecd.py b/livecd.py
index a804d23b0..d718bfee9 100644
--- a/livecd.py
+++ b/livecd.py
@@ -122,13 +122,6 @@ class LiveCDImageMethod(installmethod.InstallMethod):
except Exception, e:
log.error("Unable to unmount filesystems.")
- def protectedPartitions(self):
- if os.path.exists("/dev/live") and \
- stat.S_ISBLK(os.stat("/dev/live")[stat.ST_MODE]):
- target = os.readlink("/dev/live")
- return [target]
- return []
-
def getLiveBlockDevice(self):
return self.osimg
diff --git a/partedUtils.py b/partedUtils.py
index 8a3a83bdf..ae095e6c9 100644
--- a/partedUtils.py
+++ b/partedUtils.py
@@ -380,7 +380,7 @@ def hasProtectedPartitions(drive, anaconda):
return rc
try:
- for protected in anaconda.method.protectedPartitions():
+ for protected in anaconda.id.partitions.protectedPartitions():
if protected.startswith(drive):
part = protected[len(drive):]
if part[0] == "p":
@@ -838,7 +838,7 @@ class DiskSet:
drives = self.disks.keys()
drives.sort()
- protected = self.anaconda.method.protectedPartitions()
+ protected = self.anaconda.id.partitions.protectedPartitions()
for drive in drives:
disk = self.disks[drive]
diff --git a/partitions.py b/partitions.py
index 101b3f926..955b2766d 100644
--- a/partitions.py
+++ b/partitions.py
@@ -128,11 +128,13 @@ def partitioningComplete(anaconda):
class Partitions:
"""Defines all of the partition requests and delete requests."""
- def __init__ (self, diskset = None):
+ def __init__ (self, anaconda, readDisks=False):
"""Initializes a Partitions object.
Can pass in the diskset if it already exists.
"""
+ self.anaconda = anaconda
+
self.requests = []
"""A list of RequestSpec objects for all partitions."""
@@ -159,6 +161,11 @@ class Partitions:
self.zeroMbr = 0
"""Should the mbr be zero'd?"""
+ self.protected = []
+ """A list of partitions that are the installation source for hard
+ drive or livecd installs. Partitions on this list may not be
+ formatted."""
+
# partition method to be used. not to be touched externally
self.useAutopartitioning = 1
self.useFdisk = 0
@@ -167,10 +174,12 @@ class Partitions:
# and its useful to be able to differentiate between the two
self.isKickstart = 0
- if diskset:
- diskset.refreshDevices()
- self.setFromDisk(diskset)
+ if readDisks:
+ self.anaconda.id.diskset.refreshDevices()
+ self.setFromDisk(self.anaconda.id.diskset)
+ def protectedPartitions(self):
+ return self.protected
def setFromDisk(self, diskset):
"""Clear the delete list and set self.requests to reflect disk."""
@@ -1135,19 +1144,17 @@ class Partitions:
def setProtected(self, dispatch):
"""Set any partitions which should be protected to be so."""
- protected = dispatch.method.protectedPartitions()
- if protected:
- for device in protected:
- log.info("%s is a protected partition" % (device))
- request = self.getRequestByDeviceName(device)
- if request is not None:
- request.setProtected(1)
- else:
- log.info("no request, probably a removable drive")
+ for device in self.protectedPartitions():
+ log.info("%s is a protected partition" % (device))
+ request = self.getRequestByDeviceName(device)
+ if request is not None:
+ request.setProtected(1)
+ else:
+ log.info("no request, probably a removable drive")
def copy (self):
"""Deep copy the object."""
- new = Partitions()
+ new = Partitions(self.anaconda)
for request in self.requests:
new.addRequest(request)
for delete in self.deletes:
@@ -1159,6 +1166,7 @@ class Partitions:
new.useAutopartitioning = self.useAutopartitioning
new.useFdisk = self.useFdisk
new.reinitializeDisks = self.reinitializeDisks
+ new.protected = self.protected
return new
def getClearPart(self):
diff --git a/upgrade.py b/upgrade.py
index e06bf2c39..4276e63f1 100644
--- a/upgrade.py
+++ b/upgrade.py
@@ -161,7 +161,7 @@ def mountRootPartition(anaconda, rootInfo, oldfsset, allowDirty = 0,
lvm.vgscan()
lvm.vgactivate()
- if root in anaconda.method.protectedPartitions() and hasattr(anaconda.method, "isoDir"):
+ if root in anaconda.id.partitions.protectedPartitions() and hasattr(anaconda.method, "isoDir"):
root = anaconda.method.isoDir
bindMount = 1
diff --git a/yuminstall.py b/yuminstall.py
index e68d7cb64..bdcee1e51 100644
--- a/yuminstall.py
+++ b/yuminstall.py
@@ -1029,7 +1029,7 @@ class YumBackend(AnacondaBackend):
# If there are any protected partitions we want to mount, create their
# mount points now.
- protected = self.method.protectedPartitions()
+ protected = anaconda.id.partitions.protectedPartitions()
if protected:
for protectedDev in protected:
request = anaconda.id.partitions.getRequestByDeviceName(protectedDev)