summaryrefslogtreecommitdiff
path: root/portato/backend/system_interface.py
blob: 43de1ecdb52b67af7041c1e96b443e45e990c4c7 (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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
# -*- coding: utf-8 -*-
#
# File: portato/backend/system_interface.py
# This file is part of the Portato-Project, a graphical portage-frontend.
#
# Copyright (C) 2006-2009 René 'Necoro' Neumann
# This is free software.  You may redistribute copies of it under the terms of
# the GNU General Public License version 2.
# There is NO WARRANTY, to the extent permitted by law.
#
# Written by René 'Necoro' Neumann <necoro@necoro.net>

class SystemInterface (object):
    
    SET_ALL = "__portato_all__"
    SET_TREE = "__portato_tree__"
    SET_INSTALLED = "__portato_installed__"
    SET_UNINSTALLED = "__portato_uninstalled__"

    def eapi_supported (self, eapi):
        """Signals, whether the given eapi is supported.

        @rtype: boolean"""
        raise NotImplementedError

    def has_set_support (self):
        """Signals, whether this backend supports sets.

        @rtype: boolean
        """
        raise NotImplementedError

    def get_sets (self):
        """Returns all supported sets in tuples consisting of name and description.
        If sets aren't supported, at least "world" and "system" have to be returned.

        @rtype: iter(string, string)
        """
        raise NotImplementedError

    def get_version (self):
        """Returns the version of the used backend.

        @rtype: string
        """
        raise NotImplementedError

    def split_cpv (self, cpv):
        """Splits a cpv into all its parts.

        @param cpv: the cpv to split
        @type cpv: string
        @returns: the splitted cpv
        @rtype: string[]
        """

        raise NotImplementedError

    def cpv_matches (self, cpv, criterion):
        """Checks whether a cpv matches a specific criterion.

        @param cpv: cpv to check
        @type cpv: string
        @param criterion: criterion to check against
        @type criterion: string
        @returns: match result
        @rtype: boolean
        """

        raise NotImplementedError
    
    def find_best(self, list, only_cpv = False):
        """Returns the best package out of a list of packages.

        @param list: the list of packages to select from
        @type list: string[]
        @param only_cpv: do not return package but only the cpv
        @type only_cpv: boolean

        @returns: the best package
        @rtype: backend.Package or string
        """
        
        raise NotImplementedError

    def find_best_match (self, search_key, masked = False, only_installed = False, only_cpv = False):
        """Finds the best match in the portage tree. It does not find masked packages!
        
        @param search_key: the key to find in the portage tree
        @type search_key: string
        @param masked: if True, also look for masked packages
        @type masked: boolean
        @param only_installed: if True, only installed packages are searched
        @type only_installed: boolean
        @param only_cpv: do not return package but only the cpv
        @type only_cpv: boolean
        
        @returns: the package found or None
        @rtype: backend.Package or string
        """

        raise NotImplementedError

    def find_packages (self, key, pkgSet = SET_ALL, masked = False, with_version = True, only_cpv = False):
        """This returns a list of packages matching the key.
        As key, it is allowed to use basic regexps (".*") and the normal package specs. But not a combination
        of them.
        
        @param key: the key to look for
        @type key: string
        @param all: the package set to use
        @type all: string
        @param masked: if True, also look for masked packages
        @type masked: boolean
        @param with_version: if True, return CPVs - else CP
        @type with_version: boolean
        @param only_cpv: do not return package but only the cpv. if with_version is False, this is ignored
        @type only_cpv: boolean
        
        @returns: list of found packages
        @rtype: backend.Package[] or string[]
        """

        raise NotImplementedError

    def list_categories (self, name = None):
        """Finds all categories matching a name or all if no name is specified.

        @param name: the name to look for - it is expanded to .*name.* ; if None, all categories are returned
        @type name: string or None
        @returns: all categories found
        @rtype: string[]
        """

        raise NotImplementedError

    def sort_package_list(self, pkglist):
        """Sorts a package list in the same manner portage does.
        
        @param pkglist: list to sort
        @type pkglist: Packages[]
        """

        raise NotImplementedError
        
    def reload_settings (self):
        """Reloads portage."""

        raise NotImplementedError

    def update_world (self, newuse = False, deep = False):
        """Calculates the packages to get updated in an update world.

        @param newuse: Checks if a use-flag has a different state then to install time.
        @type newuse: boolean
        @param deep: Not only check world packages but also there dependencies.
        @type deep: boolean
        @returns: a list of the tuple (new_package, old_package)
        @rtype: (backend.Package, backend.Package)[]
        """

        raise NotImplementedError

    def get_updated_packages (self):
        """Returns the packages for which a newer package is available in the portage tree and installable (thus not masked).
        This differs from update_world as it takes all installed packages into account but ignores changed useflags.

        @returns: the list of new packages
        @rtype: backend.Package[]
        """

        raise NotImplementedError

    def get_use_desc (self, flag, package = None):
        """Returns the description of a specific useflag or None if no desc was found. 
        If a package is given (in the <cat>/<name> format) the local use descriptions are searched too.
        
        @param flag: flag to get the description for
        @type flag: string
        @param package: name of a package: if given local use descriptions are searched too
        @type package: cp-string
        @returns: found description
        @rtype: string
        """

        raise NotImplementedError

    def get_global_settings(self, key):
        """Returns the value of a global setting, i.e. ARCH, USE, ROOT, DISTDIR etc.
        
        @param key: the setting to return
        @type key: string
        @returns: the value of this setting
        @rtype: string
        """

        raise NotImplementedError

    def new_package (self, cpv):
        """Returns an instance of the appropriate Package-Subclass.

        @param cpv: the cpv to create the package from
        @type cpv: string
        @returns: a new Package-object.
        @rtype: Package
        """

        raise NotImplementedError

    def get_config_path (self):
        """Returns the actual path to the config files.
        
        @returns: the path, e.g. /etc/portage
        @rtype: string
        """

        raise NotImplementedError

    def get_sync_command (self):
        """Returns the command(s) to run for syncing. This can be overridden by the user.

        @returns: command to run
        @rtype: string[]
        """

        raise NotImplementedError

    def get_merge_command (self):
        """Returns the command(s) to run for the merging.

        @returns: command to run
        @rtype: string[]
        """

        raise NotImplementedError

    def get_oneshot_option (self):
        """Returns the options to append for marking a merge as "oneshot".

        @returns: option(s) to append
        @rtype: string[]
        """

        raise NotImplementedError

    def get_newuse_option (self):
        """Returns the options to append for marking a merge as "newuse".

        @returns: option(s) to append
        @rtype: string[]
        """

        raise NotImplementedError

    def get_deep_option (self):
        """Returns the options to append for marking a merge as "deep".

        @returns: option(s) to append
        @rtype: string[]
        """

        raise NotImplementedError

    def get_update_option (self):
        """Returns the options to append for marking a merge as "update".

        @returns: option(s) to append
        @rtype: string[]
        """

        raise NotImplementedError

    def get_pretend_option (self):
        """Returns the options to append for marking a merge as "pretend".

        @returns: option(s) to append
        @rtype: string[]
        """

        raise NotImplementedError

    def get_unmerge_option (self):
        """Returns the options to append for marking a merge as "unmerge".

        @returns: option(s) to append
        @rtype: string[]
        """

        raise NotImplementedError

    def get_environment (self):
        """Returns a dictionary of environment variables to set prior to do an emerge.

        @returns: environment variables
        @rtype: dict{string : string}
        """

        raise NotImplementedError