~mvo/update-manager/not-automatic

605 by Michael Vogt
* DistUpgrade/UpgradeTestBackend.py:
1
# TargetNonInteractive.py
2
#
3
# abstraction for non-interactive backends (like chroot, qemu)
4
#
5
611 by Michael Vogt
* DistUpgrade/UpgradeTestBackend.py:
6
from DistUpgradeConfigParser import DistUpgradeConfig
7
8
import ConfigParser
9
import os
10
import os.path
753 by Michael Vogt
* AutoUpgradeTester/jeos/:
11
import tempfile
605 by Michael Vogt
* DistUpgrade/UpgradeTestBackend.py:
12
620 by Michael Vogt
* DistUpgrade/UpgradeTestBackend.py:
13
# refactor the code so that we have
14
# UpgradeTest - the controler object
15
# UpgradeTestImage - abstraction for chroot/qemu/xen
16
17
class UpgradeTestImage(object):
18
    def runInTarget(self, command):
19
        pass
20
    def copyToImage(self, fromFile, toFile):
21
        pass
22
    def copyFromImage(self, fromFile, toFile):
23
        pass
763 by Michael Vogt
AutoUpgradeTester/UpgradeTestBackend.py:
24
    def bootstrap(self, force=False):
620 by Michael Vogt
* DistUpgrade/UpgradeTestBackend.py:
25
        pass
26
    def start(self):
27
        pass
28
    def stop(self):
29
        pass
30
605 by Michael Vogt
* DistUpgrade/UpgradeTestBackend.py:
31
class UpgradeTestBackend(object):
32
    """ This is a abstrace interface that all backends (chroot, qemu)
33
        should implement - very basic currently :)
34
    """
611 by Michael Vogt
* DistUpgrade/UpgradeTestBackend.py:
35
36
    apt_options = ["-y","--allow-unauthenticated"]
37
38
    def __init__(self, profile, basefiledir):
605 by Michael Vogt
* DistUpgrade/UpgradeTestBackend.py:
39
        " init the backend with the given profile "
611 by Michael Vogt
* DistUpgrade/UpgradeTestBackend.py:
40
        # init the dirs
41
        assert(profile != None)
42
        self.resultdir = os.path.abspath(os.path.join(os.path.dirname(profile),"result"))
43
        self.basefilesdir = os.path.abspath(basefiledir)
44
        # init the rest
45
        if os.path.exists(profile):
46
            self.profile = os.path.abspath(profile)
47
            self.config = DistUpgradeConfig(datadir=os.path.dirname(profile),
48
                                            name=os.path.basename(profile))
49
        else:
50
            raise IOError, "Can't find profile '%s' (%s) " % (profile, os.getcwd())
51
        
52
        self.fromDist = self.config.get("Sources","From")
53
        if self.config.has_option("NonInteractive","Proxy"):
54
            proxy=self.config.get("NonInteractive","Proxy")
55
            os.putenv("http_proxy",proxy)
56
        os.putenv("DEBIAN_FRONTEND","noninteractive")
57
        self.cachedir = None
58
        try:
59
            self.cachedir = self.config.get("NonInteractive","CacheDebs")
60
        except ConfigParser.NoOptionError:
61
            pass
62
        # init a sensible environment (to ensure proper operation if
63
        # run from cron)
64
        os.environ["PATH"] = "/usr/sbin:/usr/bin:/sbin:/bin"
65
753 by Michael Vogt
* AutoUpgradeTester/jeos/:
66
941 by Michael Vogt
* AutoUpgradeTester/automatic-upgrade-testing:
67
    def installPackages(self, pkgs):
68
        """
69
        install packages in the image
70
        """
71
        pass
72
753 by Michael Vogt
* AutoUpgradeTester/jeos/:
73
    def getSourcesListFile(self):
74
        """
75
        creates a temporary sources.list file and returns it to 
76
        the caller
77
        """
78
        # write new sources.list
79
        sourceslist = tempfile.NamedTemporaryFile()
80
        comps = self.config.getlist("NonInteractive","Components")
81
        pockets = self.config.getlist("NonInteractive","Pockets")
82
        mirror = self.config.get("NonInteractive","Mirror")
83
        sourceslist.write("deb %s %s %s\n" % (mirror, self.fromDist, " ".join(comps)))
84
        for pocket in pockets:
85
            sourceslist.write("deb %s %s-%s %s\n" % (mirror, self.fromDist,pocket, " ".join(comps)))
86
        sourceslist.flush()
87
        return sourceslist
605 by Michael Vogt
* DistUpgrade/UpgradeTestBackend.py:
88
    
89
    def bootstrap(self):
90
        " bootstaps a pristine install"
91
        pass
92
93
    def upgrade(self):
94
        " upgrade a given install "
95
        pass
96
622 by Michael Vogt
* added test() method
97
    def test(self):
98
        " test if the upgrade was successful "
99
        pass