summaryrefslogtreecommitdiff
path: root/portato/backend/system_interface.py
blob: c0f4e68df897e3898b2e4695a05395bddce4f96c (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
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
# -*- coding: utf-8 -*-
#
# File: portato/backend/system_interface.py
# This file is part of the Portato-Project, a graphical portage-frontend.
#
# Copyright (C) 2007 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):

	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, 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 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, search_key, masked = False, only_cpv = False):
		"""This returns a list of packages which have to fit exactly. Additionally ranges like '<,>,=,~,!' et. al. are possible.
		
		@param search_key: the key to look for
		@type search_key: string
		@param masked: if True, also look for masked packages
		@type masked: boolean
		@param only_cpv: do not return package but only the cpv
		@type only_cpv: boolean
		
		@returns: list of found packages
		@rtype: backend.Package[] or string[]
		"""

		raise NotImplementedError


	def find_installed_packages (self, search_key, masked = False, only_cpv = False):
		"""This returns a list of packages which have to fit exactly. Additionally ranges like '<,>,=,~,!' et. al. are possible.
		
		@param search_key: the key to look for
		@type search_key: string
		@param masked: if True, also look for masked packages
		@type masked: boolean
		@param only_cpv: do not return package but only the cpv
		@type only_cpv: boolean
		
		@returns: list of found packages
		@rtype: backend.Package[] or string[]
		"""

		raise NotImplementedError

	def find_system_packages (self, only_cpv = False):
		"""Looks for all packages saved as "system-packages".
		
		@param only_cpv: do not return package but only the cpv
		@type only_cpv: boolean

		@returns: a tuple of (resolved_packages, unresolved_packages).
		@rtype: (backend.Package[], backend.Package[]) or (string[], string[])
		"""

		raise NotImplementedError

	def find_world_packages (self, only_cpv = False):
		"""Looks for all packages saved in the world-file.
		
		@param only_cpv: do not return package but only the cpv
		@type only_cpv: boolean

		@returns: a tuple of (resolved_packages, unresolved_packages).
		@rtype: (backend.Package[], backend.Package[]) or (string[], string[])
		"""

		raise NotImplementedError

	def find_all_installed_packages (self, name = None, withVersion = True, only_cpv = False):
		"""Finds all installed packages 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 packages are returned
		@type name: string or None
		@param withVersion: if True version-specific packages are returned; else only the cat/package-strings a delivered
		@type withVersion: boolean
		@param only_cpv: do not return package but only the cpv
		@type only_cpv: boolean

		@returns: all packages/cp-strings found
		@rtype: backend.Package[] or string[]
		"""

		raise NotImplementedError

	def find_all_uninstalled_packages (self, name = None, only_cpv = False):
		"""Finds all uninstalled packages 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 packages are returned
		@type name: string or None
		@param only_cpv: do not return package but only the cpv
		@type only_cpv: boolean

		@returns: all packages found
		@rtype: backend.Package[] or string[]
		"""

		raise NotImplementedError

	def find_all_packages (self, name = None, withVersion = True, only_cpv = False):
		"""Finds all packages 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 packages are returned
		@type name: string or None
		@param withVersion: if True version-specific packages are returned; else only the cat/package-strings a delivered
		@type withVersion: boolean
		@param only_cpv: do not return package but only the cpv
		@type only_cpv: boolean

		@returns: all packages/cp-strings found
		@rtype: backend.Package[] or string[]
		"""

		raise NotImplementedError
		
	def find_all_world_packages (self, name = None, only_cpv = False):
		"""Finds all world packages 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 packages are returned
		@type name: string or None
		@param only_cpv: do not return package but only the cpv
		@type only_cpv: boolean

		@returns: all packages found
		@rtype: backend.Package[] or string[]
		"""

		raise NotImplementedError

	def find_all_system_packages (self, name = None, only_cpv = False):
		"""Finds all system packages 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 packages are returned
		@type name: string or None
		@param only_cpv: do not return package but only the cpv
		@type only_cpv: boolean

		@returns: all packages found
		@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_world_file_path (self):
		"""Returns the path to the world file.

		@returns: the path of the world file
		@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