summaryrefslogtreecommitdiffstats
path: root/image.py
blob: d8da84fdcc2aa7698e9ba249aa11dec9ba240cb7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# Install method for disk image installs (CD & NFS)

from comps import ComponentSet, HeaderListFromFile
from installmethod import InstallMethod
import iutil
import os
import isys
import string
from translate import _

class ImageInstallMethod(InstallMethod):

    def readComps(self, hdlist):
	return ComponentSet(self.tree + '/RedHat/base/comps', hdlist)

    def getFilename(self, h):
	return self.tree + "/RedHat/RPMS/" + h[1000000]

    def readHeaders(self):
	return HeaderListFromFile(self.tree + "/RedHat/base/hdlist")

    def __init__(self, tree):
	InstallMethod.__init__(self)
	self.tree = tree

class CdromInstallMethod(ImageInstallMethod):

    def systemMounted(self, fstab, mntPoint):
	self.mntPoint = mntPoint
	target = "%s/rhinstall-stage2.img" % mntPoint
	iutil.copyFile("%s/RedHat/base/stage2.img" % self.tree, target,
			(self.progressWindow, _("Copying File"),
			_("Transferring install image to hard drive...")))
	isys.makeDevInode("loop0", "/tmp/loop")
	isys.lochangefd("/tmp/loop", target)

    def getFilename(self, h):
	if h[1000002] != self.currentDisc:
	    self.currentDisc = h[1000002]
	    isys.makeDevInode(self.device, "/tmp/cdrom")
	    isys.umount("/mnt/source")
	    #isys.eject("/tmp/cdrom")
	    self.messageWindow(_("Change CDROM"), 
		    _("Please insert disc %d to continue.") % self.currentDisc)
	    isys.mount("/tmp/cdrom", "/mnt/source", fstype = "iso9660",
		       readOnly = 1)

	return self.tree + "/RedHat/RPMS/" + h[1000000]

    def filesDone(self):
	# this isn't the exact right place, but it's close enough
	target = "%s/rhinstall-stage2.img" % self.mntPoint
	os.unlink(target)

    def __init__(self, url, messageWindow, progressWindow):
	(self.device, tree) = string.split(url, "/", 1)
	self.messageWindow = messageWindow
	self.progressWindow = progressWindow
	self.currentDisc = 1
	ImageInstallMethod.__init__(self, "/" + tree)

class NfsInstallMethod(ImageInstallMethod):

    def __init__(self, tree):
	ImageInstallMethod.__init__(self, tree)