aboutsummaryrefslogtreecommitdiff
blob: da9712fc9ce8c998b0e7f56429e2fd9123ab3755 (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
class MatchboxCommand(object): pass

class GetNextPackage(MatchboxCommand):
    """
    Matchbox command that will make matchbox return with GetNextPackageReply
    """
    pass

class PackageInfo(object):
    """
    Package info that will be inserted into database
    """
    def __init__(self):
        """
        name: package name (CP) e.g. dev-util/git
        version: version including revision 1.6.3.1-r1
        content: dict of contents as returned by dblink.getcontents()
        use_flags: use flags enabled for compilation of this package
        attachments: dict holding additional information (build logs, environment, etc)
        error: None if no error, else holds error code
        emerge_info: output from emerge --info
        depends: list of dependencies this package has been built with in CPV form
        """
        self.name = None
        self.version = None
        self.content = {}
        self.use_flags = []
        self.attachments = None
        self.error = None
        self.emerge_info = None
        self.depends = []
    def __str__(self):
        ret ="Name: %s\n" % self.name + \
             "Version: %s\n" % self.version + \
             "Content lenght: %d\n" % len(self.content) + \
             "Content paths: %s\n" % self.content.keys() + \
             "Emerge info: %s\n" % self.emerge_info + \
             "Use flags: %s\n" % self.use_flags + \
             "Depends: %s\n" % str(self.depends)
        for key in self.attachments.keys():
            ret = ret + "Attachment %s: \n%s\n" % (key, self.attachments[key])
        return ret

class AddPackageInfo(MatchboxCommand):
    def __init__(self, package_infos):
        """
	Command for Matchbox to add information about packages into database

        @param package_infos: List of PackageInfo objects
	@type package_infos: list
        """
        if type(package_infos) is not list:
            raise TypeError("Parameter need to be a list of PackageInfo objects")
        self.package_infos = package_infos



class MatchboxReply(object): pass

class GetNextPackageReply(MatchboxReply):
    """
    Reply for GetNextPackage command. This specifies package that should be compiled
    by tinderbox
    """

    def __init__(self, package_name, version=None, use_flags=None):
        """
        @param package_name: package name and category (CP). e.g dev-util/git
        @type package_name: string
        @param version: version of package to compile. If None all versions will be compiled
        @type version: string
        @param use_flags: extra use flags to enable/disable for this build
        @type use_flags: list of strings (e.g. ['-unicode','gtk'])

        """
        self.package_name = package_name
        self.version = version
        self.use_flags = use_flags