diff options
author | Erik Troan <ewt@redhat.com> | 2002-01-25 14:32:16 +0000 |
---|---|---|
committer | Erik Troan <ewt@redhat.com> | 2002-01-25 14:32:16 +0000 |
commit | 2c3ee7417a53b444b69dbc195e7733818cc00187 (patch) | |
tree | d64427460dd9d10962c2644d817c861b7cb54d1d /image.py | |
parent | 0aa068f55f87b6f7b5138ce529b28dca764c123f (diff) | |
download | anaconda-2c3ee7417a53b444b69dbc195e7733818cc00187.tar.gz anaconda-2c3ee7417a53b444b69dbc195e7733818cc00187.tar.xz anaconda-2c3ee7417a53b444b69dbc195e7733818cc00187.zip |
added nfsiso method
Diffstat (limited to 'image.py')
-rw-r--r-- | image.py | 107 |
1 files changed, 107 insertions, 0 deletions
@@ -175,3 +175,110 @@ class NfsInstallMethod(ImageInstallMethod): def __init__(self, tree): ImageInstallMethod.__init__(self, tree) + +def findIsoImages(path, messageWindow): + files = os.listdir(path) + arch = iutil.getArch() + discImages = {} + + print "need to look at", files + + for file in files: + what = path + '/' + file + if not isys.isIsoImage(what): continue + + isys.makeDevInode("loop2", "/tmp/loop2") + + try: + isys.losetup("/tmp/loop2", what, readOnly = 1) + except SystemError: + continue + + try: + isys.mount("loop2", "/mnt/cdimage", fstype = "iso9660", + readOnly = 1) + for num in range(1, 10): + discTag = "/mnt/cdimage/.disc%d-%s" % (num, arch) + if os.access(discTag, os.R_OK): + import stat + + # warn user if images appears to be wrong size + if os.stat(what)[stat.ST_SIZE] % 2048: + rc = messageWindow(_("Warning"), + "The ISO image %s has a size which is not " + "a multiple of 2048 bytes. This may mean " + "it was corrupted on transfer to this computer." + "\n\nPress OK to continue (but installation will " + "probably fail), or Cancel to exit the " + "installer (RECOMMENDED). " % file, type = "okcancel") + if rc: + import sys + sys.exit(0) + + discImages[num] = file + + isys.umount("/mnt/cdimage") + except SystemError: + pass + + isys.makeDevInode("loop2", '/tmp/' + "loop2") + isys.unlosetup("/tmp/loop2") + + return discImages + +class NfsIsoInstallMethod(NfsInstallMethod): + + def getFilename(self, h, timer): + if self.imageMounted != h[1000002]: + self.umountImage() + self.mountImage(h[1000002]) + + return self.mntPoint + "/RedHat/RPMS/" + h[1000000] + + def umountImage(self): + if self.imageMounted: + isys.umount(self.mntPoint) + isys.makeDevInode("loop3", "/tmp/loop3") + isys.unlosetup("/tmp/loop3") + self.mntPoint = None + self.imageMounted = 0 + + def mountImage(self, cdNum): + if (self.imageMounted): + raise SystemError, "trying to mount already-mounted iso image!" + + isoImage = self.isoPath + '/' + self.discImages[cdNum] + + isys.makeDevInode("loop3", "/tmp/loop3") + isys.losetup("/tmp/loop3", isoImage, readOnly = 1) + + isys.mount("loop3", "/tmp/isomedia", fstype = 'iso9660', readOnly = 1); + self.mntPoint = "/tmp/isomedia/" + self.imageMounted = cdNum + + def filesDone(self): + self.umountImage() + + def writeCleanupPath(self, f): + isys.makeDevInode("loop0", "/tmp/loop0") + isys.makeDevInode("loop1", "/tmp/loop0") + f.write("umount /mnt/runtime\n") + f.write("lounsetup /tmp/loop0\n") + f.write("umount /mnt/source2\n") + f.write("lounsetup /tmp/loop1\n") + + def __init__(self, tree, messageWindow): + self.imageMounted = None + self.isoPath = tree + + # the tree points to the directory that holds the iso images + # even though we already have the main one mounted once, it's + # easiest to just mount it again so that we can treat all of the + # images the same way -- we use loop3 for everything + + self.discImages = findIsoImages(tree, messageWindow) + print "found", self.discImages, "in tree", tree + self.mountImage(1) + + ImageInstallMethod.__init__(self, self.mntPoint) + |