summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Wilson <msw@redhat.com>2001-07-10 05:31:55 +0000
committerMatt Wilson <msw@redhat.com>2001-07-10 05:31:55 +0000
commit29b597426254f3bebe9bc81c80f8b58d4bb7a5f5 (patch)
treed9716aa37d604f51311c4af1c387a93780244d14
parent8ca97ad035ea12820e7b2d1876e6d68e5363ceff (diff)
downloadanaconda-29b597426254f3bebe9bc81c80f8b58d4bb7a5f5.tar.gz
anaconda-29b597426254f3bebe9bc81c80f8b58d4bb7a5f5.tar.xz
anaconda-29b597426254f3bebe9bc81c80f8b58d4bb7a5f5.zip
renable the creation and activation of swap files on upgrade
-rw-r--r--fsset.py19
-rw-r--r--iw/upgrade_swap_gui.py4
-rw-r--r--textw/upgrade_text.py5
-rw-r--r--upgrade.py44
4 files changed, 38 insertions, 34 deletions
diff --git a/fsset.py b/fsset.py
index 564521edc..f00e8fa5c 100644
--- a/fsset.py
+++ b/fsset.py
@@ -557,11 +557,10 @@ class FileSystemSet:
def formatSwap (self, chroot):
for entry in self.entries:
if (not entry.fsystem or not entry.fsystem.getName() == "swap"
- or not entry.getFormat()):
+ or not entry.getFormat() or entry.isMounted()):
continue
try:
- entry.fsystem.formatDevice(entry, self.progressWindow,
- chroot)
+ self.formatEntry(entry, chroot)
except SystemError:
if self.messageWindow:
self.messageWindow(_("Error"),
@@ -576,7 +575,8 @@ class FileSystemSet:
def turnOnSwap (self, chroot):
for entry in self.entries:
- if entry.fsystem and entry.fsystem.getName() == "swap":
+ if (entry.fsystem and entry.fsystem.getName() == "swap"
+ and not entry.isMounted()):
try:
entry.mount(chroot)
except SystemError, (errno, msg):
@@ -592,7 +592,10 @@ class FileSystemSet:
"system.")
% (entry.device.getDevice(), msg))
sys.exit(0)
-
+
+ def formatEntry(self, entry, chroot):
+ entry.fsystem.formatDevice(entry, self.progressWindow, chroot)
+
def formattablePartitions(self):
list = []
for entry in self.entries:
@@ -605,8 +608,8 @@ class FileSystemSet:
if (not entry.fsystem.isFormattable() or not entry.getFormat()
or entry.isMounted()):
continue
- try:
- entry.fsystem.formatDevice(entry, self.progressWindow, chroot)
+ try:
+ self.formatEntry(entry, chroot)
except SystemError:
if self.messageWindow:
self.messageWindow(_("Error"),
@@ -962,7 +965,7 @@ class SwapFileDevice(Device):
if self.size:
isys.ddfile(file, self.size, None)
else:
- raise SystemError, ("swap file creation necessary, but "
+ raise SystemError, (0, "swap file creation necessary, but "
"required size is unknown.")
return file
diff --git a/iw/upgrade_swap_gui.py b/iw/upgrade_swap_gui.py
index a92d9d3f8..039c1b164 100644
--- a/iw/upgrade_swap_gui.py
+++ b/iw/upgrade_swap_gui.py
@@ -62,9 +62,7 @@ class UpgradeSwapWindow (InstallWindow):
else:
if flags.setupFilesystems:
- # XXX fix me
- # upgrade.createSwapFile(instPath, fsset, mnt, val)
- pass
+ upgrade.createSwapFile(self.instPath, self.fsset, mnt, val)
return None
diff --git a/textw/upgrade_text.py b/textw/upgrade_text.py
index 02ff54ce1..5ccdd953b 100644
--- a/textw/upgrade_text.py
+++ b/textw/upgrade_text.py
@@ -177,10 +177,7 @@ class UpgradeSwapWindow:
else:
screen.popWindow()
if flags.setupFilesystems:
- # XXX fix me
- # upgrade.createSwapFile(todo.instPath, todo.fstab,
- # mnt, val)
- pass
+ upgrade.createSwapFile(instPath, fsset, mnt, val)
return INSTALL_OK
raise ValueError
diff --git a/upgrade.py b/upgrade.py
index 903ee3bea..76eb4f282 100644
--- a/upgrade.py
+++ b/upgrade.py
@@ -18,12 +18,12 @@ import _balkan
import os
import raid
import iutil
-import fsset
import time
import rpm
import sys
import os.path
from flags import flags
+from fsset import *
from partitioning import *
from log import log
from translate import _
@@ -50,7 +50,7 @@ def mountRootPartition(intf, rootInfo, oldfsset, instPath, allowDirty = 0,
mdList = raid.startAllRaid(diskset.driveList())
if rootFs == "vfat":
- fsset.mountLoopbackRoot(root)
+ mountLoopbackRoot(root)
else:
isys.mount(root, '/mnt/sysimage', rootFs)
@@ -60,7 +60,7 @@ def mountRootPartition(intf, rootInfo, oldfsset, instPath, allowDirty = 0,
oldfsset.add(entry)
if rootFs == "vfat":
- fsset.unmountLoopbackRoot()
+ unmountLoopbackRoot()
else:
isys.umount('/mnt/sysimage')
@@ -116,7 +116,7 @@ def upgradeSwapSuggestion(dispatch, id, instPath):
space = isys.pathSpaceAvailable("/mnt/loophost")
for entry in fsset.entries:
- if entry.mountpoint != '/':
+ if entry.mountpoint != '/' or space <= 16:
continue
info = (entry.mountpoint, entry.device.getDevice(), space)
@@ -129,8 +129,9 @@ def upgradeSwapSuggestion(dispatch, id, instPath):
if flags.setupFilesystems and not entry.isMounted():
continue
space = isys.pathSpaceAvailable(instPath + entry.mountpoint)
- info = (entry.mountpoint, entry.device.getDevice(), space)
- fsList.append(info)
+ if space > 16:
+ info = (entry.mountpoint, entry.device.getDevice(), space)
+ fsList.append(info)
suggestion = mem * 2 - swap
suggSize = 0
@@ -148,11 +149,10 @@ def swapfileExists(swapname):
except:
return 0
-# XXX fix me.
-def createSwapFile(instPath, thefsset, mntPoint, size):
+def createSwapFile(instPath, theFsset, mntPoint, size):
fstabPath = instPath + "/etc/fstab"
prefix = ""
- if thefsset.rootOnLoop():
+ if theFsset.rootOnLoop():
instPath = "/mnt/loophost"
prefix = "/initrd/loopfs"
@@ -161,11 +161,10 @@ def createSwapFile(instPath, thefsset, mntPoint, size):
else:
file = "/SWAP"
- existingSwaps = thefsset.swapList(files = 1)
swapFileDict = {}
- for n in existingSwaps:
- dev = n[0]
- swapFileDict[dev] = 1
+ for entry in theFsset.entries:
+ if entry.fsystem.getName() == "swap":
+ swapFileDict[entry.device.getName()] = 1
count = 0
while (swapfileExists(instPath + file) or
@@ -177,12 +176,19 @@ def createSwapFile(instPath, thefsset, mntPoint, size):
else:
file = tmpFile
- theFstab.addMount(file, size, "swap")
- theFstab.turnOnSwap(instPath)
+ device = SwapFileDevice(file)
+ device.setSize(size)
+ fsystem = fileSystemTypeGet("swap")
+ entry = FileSystemSetEntry(device, "swap", fsystem)
+ entry.setFormat(1)
+ theFsset.add(entry)
+ theFsset.formatEntry(entry, instPath)
+ theFsset.turnOnSwap(instPath)
+ # XXX generalize fstab modification
f = open(fstabPath, "a")
- f.write(fstab.fstabFormatString % (prefix + file, "swap", "swap", "defaults",
- 0, 0))
+ format = "%-23s %-23s %-7s %-15s %d %d\n";
+ f.write(format % (prefix + file, "swap", "swap", "defaults", 0, 0))
f.close()
# XXX handle going backwards
@@ -261,7 +267,7 @@ def upgradeFindPackages (intf, method, id, instPath):
_("Rebuild of RPM database failed. "
"You may be out of disk space?"))
if flags.setupFilesystems:
- fsset.umountFilesystems (instPath)
+ umountFilesystems (instPath)
sys.exit(0)
rpm.addMacro("_dbpath", id.dbpath)
@@ -275,7 +281,7 @@ def upgradeFindPackages (intf, method, id, instPath):
_("An error occured when finding the packages to "
"upgrade."))
if flags.setupFilesystems:
- fsset.umountFilesystems (instPath)
+ umountFilesystems (instPath)
sys.exit(0)
# Turn off all comps