summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Fulbright <msf@redhat.com>2001-07-20 05:07:15 +0000
committerMike Fulbright <msf@redhat.com>2001-07-20 05:07:15 +0000
commitc9d4bac54e0d29664e5df0125d118836fcdecd79 (patch)
tree03dfabcc7458367bfdc6747a627f2f4344a5ccf8
parenta3a6f9b11794a0c834b3612ba449bffc26c5a156 (diff)
downloadanaconda-c9d4bac54e0d29664e5df0125d118836fcdecd79.tar.gz
anaconda-c9d4bac54e0d29664e5df0125d118836fcdecd79.tar.xz
anaconda-c9d4bac54e0d29664e5df0125d118836fcdecd79.zip
handle migration during upgrades and rewrite fstab appropriately
-rw-r--r--dispatch.py6
-rw-r--r--fsset.py62
-rw-r--r--installclasses/upgradeclass.py1
-rw-r--r--iw/upgrade_migratefs_gui.py17
-rw-r--r--packages.py7
-rw-r--r--partitioning.py6
-rw-r--r--textw/upgrade_text.py6
-rw-r--r--upgrade.py4
-rw-r--r--upgradeclass.py1
9 files changed, 89 insertions, 21 deletions
diff --git a/dispatch.py b/dispatch.py
index a484b6371..6b8b226c8 100644
--- a/dispatch.py
+++ b/dispatch.py
@@ -19,6 +19,7 @@ from constants import *
from packages import readPackages, checkDependencies, doInstall
from packages import handleX11Packages, writeConfiguration, writeXConfiguration
from packages import writeKSConfiguration, turnOnFilesystems
+from packages import doMigrateFilesystems
from packages import queryUpgradeContinue
from packages import doPreInstall, doPostInstall
from autopart import doAutoPartition
@@ -71,7 +72,7 @@ installSteps = [
("partitiondone", partitioningComplete, ("id.bootloader", "id.fsset",
"id.diskset", "id.partitions",
"intf", "instPath", "dir")),
- ("upgrademigfind", upgradeMigrateFind, ("dispatch", "id.partitions")),
+ ("upgrademigfind", upgradeMigrateFind, ("dispatch", "id.partitions", "id.fsset")),
("upgrademigratefs", ("id.fsset", "id.partitions")),
("bootloadersetup", bootloaderSetupChoices, ("dispatch", "id.bootloader",
"id.fsset", "id.diskset",
@@ -101,6 +102,9 @@ installSteps = [
("enablefilesystems", turnOnFilesystems, ("dir", "id.fsset",
"id.diskset", "id.upgrade",
"instPath")),
+ ("migratefilesystems", doMigrateFilesystems, ("dir", "id.fsset",
+ "id.diskset", "id.upgrade",
+ "instPath")),
("preinstallconfig", doPreInstall, ("method", "id", "intf", "instPath",
"dir")),
("installpackages", doInstall, ("method", "id", "intf", "instPath")),
diff --git a/fsset.py b/fsset.py
index d933ce7b1..c0d27b46a 100644
--- a/fsset.py
+++ b/fsset.py
@@ -524,7 +524,7 @@ class FileSystemSet:
return new
def fstab (self):
- format = "%-23s %-23s %-7s %-15s %d %d\n";
+ format = "%-23s %-23s %-7s %-15s %d %d\n"
fstab = ""
for entry in self.entries:
if entry.mountpoint:
@@ -564,6 +564,51 @@ class FileSystemSet:
open (prefix + "/etc/mtab", "w+")
f.close ()
+ def migratewrite(self, prefix):
+ fname = prefix + "/etc/fstab"
+ f = open (fname, "r")
+ lines = f.readlines()
+ f.close()
+
+ perms = os.stat(fname)[0] & 0777
+ os.rename(fname, fname + ".rpmsave")
+ f = open (fname, "w+")
+ os.chmod(fname, perms)
+
+ for line in lines:
+ fields = string.split(line)
+
+ # try to be smart like in fsset.py::readFstab()
+ if not fields or line[0] == "#":
+ f.write(line)
+ continue
+
+ if len (fields) < 4 or len (fields) > 6:
+ f.write(line)
+ continue
+
+ if string.find(fields[3], "noauto") != -1:
+ f.write(line)
+ continue
+
+ mntpt = fields[1]
+ entry = self.getEntryByMountPoint(mntpt)
+ if not entry or not entry.getMigrate():
+ f.write(line)
+ elif entry.origfsystem.getName() != fields[2]:
+ f.write(line)
+ else:
+ fields[2] = entry.fsystem.getName()
+ newline = "%-23s %-23s %-7s %-15s %s %s\n" % (fields[0],
+ fields[1],
+ fields[2],
+ fields[3],
+ fields[4],
+ fields[5])
+ f.write(newline)
+
+ f.close()
+
def rootOnLoop (self):
for entry in self.entries:
if (entry.mountpoint == '/'
@@ -745,9 +790,8 @@ class FileSystemSet:
for entry in self.entries:
if not entry.origfsystem:
continue
-
- if (not entry.origfsystem.isMigratable() or not entry.getMigrate()
- or entry.isMounted()):
+
+ if not entry.origfsystem.isMigratable() or not entry.getMigrate():
continue
try:
entry.origfsystem.migrateFileSystem(entry, self.progressWindow,
@@ -893,6 +937,9 @@ class FileSystemSetEntry:
self.mountpoint))
self.mountcount = self.mountcount - 1
+ def setFileSystemType(self, fstype):
+ self.fsystem = fstype
+
def setBadblocks(self, state):
self.badblocks = state
@@ -900,7 +947,7 @@ class FileSystemSetEntry:
return self.badblocks
def setFormat (self, state):
- if self.migrate:
+ if self.migrate and state:
raise ValueError, "Trying to set format bit on when migrate is set!"
self.format = state
@@ -908,7 +955,7 @@ class FileSystemSetEntry:
return self.format
def setMigrate (self, state):
- if self.format:
+ if self.format and state:
raise ValueError, "Trying to set migrate bit on when format is set!"
self.migrate = state
@@ -1206,7 +1253,8 @@ def readFstab (path):
else:
continue
- entry = FileSystemSetEntry(device, fields[1], fsystem, fields[3])
+ entry = FileSystemSetEntry(device, fields[1], fsystem, fields[3],
+ origfsystem=fsystem)
if label:
entry.setLabel(label)
fsset.add(entry)
diff --git a/installclasses/upgradeclass.py b/installclasses/upgradeclass.py
index 577398b55..033c7e8c1 100644
--- a/installclasses/upgradeclass.py
+++ b/installclasses/upgradeclass.py
@@ -38,6 +38,7 @@ class InstallClass(BaseInstallClass):
"dependencies",
"confirmupgrade",
"install",
+ "migratefilesystems",
"preinstallconfig",
"installpackages",
"postinstallconfig",
diff --git a/iw/upgrade_migratefs_gui.py b/iw/upgrade_migratefs_gui.py
index 9018aec95..1db36a30c 100644
--- a/iw/upgrade_migratefs_gui.py
+++ b/iw/upgrade_migratefs_gui.py
@@ -41,13 +41,19 @@ class UpgradeMigrateFSWindow (InstallWindow):
req.format = 0
req.migrate = 1
req.fstype = fileSystemTypeGet("ext3")
-
+
+ entry = self.fsset.getEntryByDeviceName(req.device)
+ entry.setFileSystemType(fileSystemTypeGet("ext3"))
+ entry.setFormat(0)
+ entry.setMigrate(1)
+
return None
def getScreen (self, fsset, partitions):
- self.migratereq = partitions.getMigratableRequests()
-
+ self.migratereq = partitions.getMigratableRequests(fsset)
+ self.fsset = fsset
+
box = GtkVBox (FALSE, 5)
box.set_border_width (5)
@@ -74,9 +80,10 @@ class UpgradeMigrateFSWindow (InstallWindow):
entry = fsset.getEntryByDeviceName(req.device)
if not entry:
- mntpt = ""
+ # only show partitions in current fstab
+ continue
else:
- mntpt =entry.mountpoint
+ mntpt = entry.mountpoint
cb = GtkCheckButton("%s - %s - %s" % (req.device,
req.origfstype.getName(),
diff --git a/packages.py b/packages.py
index 916babb18..1582ae98a 100644
--- a/packages.py
+++ b/packages.py
@@ -304,6 +304,10 @@ class rpmErrorClass:
def __init__(self, f):
self.f = f
+def doMigrateFilesystems(dir, thefsset, diskset, upgrade, instPath):
+ thefsset.migrateFilesystems (instPath)
+
+
def turnOnFilesystems(dir, thefsset, diskset, upgrade, instPath):
if dir == DISPATCH_BACK:
thefsset.umountFilesystems(instPath)
@@ -317,7 +321,6 @@ def turnOnFilesystems(dir, thefsset, diskset, upgrade, instPath):
thefsset.checkBadblocks(instPath)
thefsset.formatSwap(instPath)
thefsset.turnOnSwap(instPath)
- thefsset.migrateFilesystems (instPath)
thefsset.makeFilesystems (instPath)
thefsset.mountFilesystems (instPath)
@@ -425,6 +428,8 @@ def doPreInstall(method, id, intf, instPath, dir):
# write out the fstab
if not upgrade:
id.fsset.write(instPath)
+ else:
+ id.fsset.migratewrite(instPath)
def doInstall(method, id, intf, instPath):
if flags.test:
diff --git a/partitioning.py b/partitioning.py
index 30a5bf0c6..d678a6daf 100644
--- a/partitioning.py
+++ b/partitioning.py
@@ -822,7 +822,7 @@ class Partitions:
return 1
return 0
- def getMigratableRequests(self):
+ def getMigratableRequests(self, thefsset):
retval = []
for request in self.requests:
if request.type != REQUEST_PREEXIST:
@@ -830,7 +830,9 @@ class Partitions:
if request.origfstype:
if request.origfstype.isMigratable():
- retval.append(request)
+ entry = thefsset.getEntryByDeviceName(request.device)
+ if entry:
+ retval.append(request)
return retval
diff --git a/textw/upgrade_text.py b/textw/upgrade_text.py
index 4abd9c60c..7d3d61363 100644
--- a/textw/upgrade_text.py
+++ b/textw/upgrade_text.py
@@ -25,7 +25,7 @@ from translate import _
class UpgradeMigrateFSWindow:
def __call__ (self, screen, fsset, partitions):
- migratereq = partitions.getMigratableRequests()
+ migratereq = partitions.getMigratableRequests(fsset)
g = GridFormHelp(screen, _("Migrate Filesystems"), "upmigfs", 1, 4)
@@ -48,9 +48,9 @@ class UpgradeMigrateFSWindow:
entry = fsset.getEntryByDeviceName(req.device)
if not entry:
- mntpt = ""
+ # only show partitions in current fstab
else:
- mntpt =entry.mountpoint
+ mntpt = entry.mountpoint
partlist.append("%s - %s - %s" % (req.device,
req.origfstype.getName(),
diff --git a/upgrade.py b/upgrade.py
index 9fc363c4a..b6e041da1 100644
--- a/upgrade.py
+++ b/upgrade.py
@@ -78,8 +78,8 @@ def mountRootPartition(intf, rootInfo, oldfsset, instPath, allowDirty = 0,
oldfsset.mountFilesystems (instPath)
# returns None if no filesystem exist to migrate
-def upgradeMigrateFind(dispatch, partitions):
- migratereq = partitions.getMigratableRequests()
+def upgradeMigrateFind(dispatch, partitions, thefsset):
+ migratereq = partitions.getMigratableRequests(thefsset)
if not migratereq or len(migratereq) < 1:
dispatch.skipStep("upgrademigratefs")
else:
diff --git a/upgradeclass.py b/upgradeclass.py
index 577398b55..033c7e8c1 100644
--- a/upgradeclass.py
+++ b/upgradeclass.py
@@ -38,6 +38,7 @@ class InstallClass(BaseInstallClass):
"dependencies",
"confirmupgrade",
"install",
+ "migratefilesystems",
"preinstallconfig",
"installpackages",
"postinstallconfig",