summaryrefslogtreecommitdiffstats
path: root/installmethod.py
blob: 7ba5ad5771e827d1a8a4f779bb5c3d7e7740e0c0 (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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#
# installmethod.py - Base class for install methods
#
# Copyright 1999-2002 Red Hat, Inc.
#
# This software may be freely redistributed under the terms of the GNU
# library public license.
#
# You should have received a copy of the GNU Library Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#

import os
import string
from constants import *

import logging
log = logging.getLogger("anaconda")

class FileCopyException(Exception):
    def __init__(self, s = ""):
        self.args = s
        

class InstallMethod:

    # find best match from several locations for a file
    def findBestFileMatch(self, file):
	# look in /tmp/updates first
	rc = None
	tryloc = ["/tmp/updates"]
	if self.tree is not None:
	    tryloc.append("%s/RHupdates" %(self.tree,))
	    tryloc.append("%s/%s/base" % (self.tree, productPath))
	    
	for pre in tryloc:
	    tmpname = pre + "/" + file
	    if os.access(tmpname, os.R_OK):
		log.info("Using file://%s", tmpname)
		return "file://%s" %(tmpname,)

	log.error("Unable to find %s", file)
	return None
	
    def protectedPartitions(self):
        return None

    def getTempPath(self):
	root = self.rootPath
	pathlist = [ "/var/tmp", "/tmp",
		     "/." ]
        tmppath = None
	for p in pathlist:
	    if (os.access(root + p, os.X_OK)):
		tmppath = root + p + "/"
		break

        if tmppath is None:
            log.warning("Unable to find temp path, going to use ramfs path")
            return "/tmp/"

        return tmppath

    def getFilename(self, filename, callback=None, destdir=None, retry=1):
	pass

    def getRPMFilename(self, filename, mediano, timer, callback=None):
	pass

    def systemUnmounted(self):
	pass

    def systemMounted(self, fstab, mntPoint):
	pass

    def filesDone(self):
	pass

    def unlinkFilename(self, fullName):
	pass

    def __init__(self, method, rootpath, intf):
        self.rootPath = rootpath
        self.intf = intf
        self.tree = None
        self.splitmethod = False

    def getMethodUri(self):
        pass

    def getSourcePath(self):
        pass

    def unmountCD(self):
        pass

    def ejectCD(self):
        pass


# this handles any cleanup needed for the method.  it occurs *very* late
# (ie immediately before the congratulations screen).  main use right now
# is ejecting the cdrom
def doMethodComplete(method, fsset):
    method.ejectCD()

    mtab = "/dev/root / ext3 ro 0 0\n"
    for ent in fsset.entries:
        if ent.mountpoint == "/":
            mtab = "/dev/root / %s ro 0 0\n" %(ent.fsystem.name,)
    
    f = open(method.rootPath + "/etc/mtab", "w+")
    f.write(mtab)
    f.close()