1
2 """
3
4 @author: Fabio Erculiani <lxnay@sabayonlinux.org>
5 @contact: lxnay@sabayonlinux.org
6 @copyright: Fabio Erculiani
7 @license: GPL-2
8
9 B{Entropy Source Package Manager Plugins foundation classes}.
10 @todo: define SpmPlugin API
11
12 """
13
14 from entropy.const import etpConst
15 from entropy.core import Singleton
16 from entropy.misc import LogFile
19 """Base class for Source Package Manager plugins"""
20
21 BASE_PLUGIN_API_VERSION = 0
22
23
24
25 PLUGIN_API_VERSION = -1
26
27
28
29 SUPPORTED_MATCH_TYPES = []
30
32 """
33 Source Package Manager Plugin singleton method.
34 This method must be reimplemented by subclasses.
35 At this stage, you should also consider to tweak etpConst['spm']
36 content (importing etpConst from entropy.const).
37
38 @param output_interface: Entropy output interface
39 @type output_interface: entropy.output.TextInterface based instances
40 @raise NotImplementedError(): when method is not reimplemented
41 """
42 raise NotImplementedError()
43
44 @staticmethod
46 """
47 Return package groups available metadata (Spm categories are grouped
48 into macro categories called "groups").
49 """
50 raise NotImplementedError()
51
60
62 """
63 Return a list of available and valid package build phases.
64 Default value is ["setup", "preinstall", "postinstall", "preremove",
65 "postremove"]
66
67 @return: list of available and valid package build phases
68 @rtype: list
69 """
70 return ["setup", "preinstall", "postinstall", "preremove",
71 "postremove", "configure"]
72
74 """
75 Return Source Package Manager cache directory path.
76
77 @keyword root: specify an alternative root directory "/"
78 @type root: string
79 @return: cache directory
80 @rtype: string
81 """
82 raise NotImplementedError()
83
97
99 """
100 Return ChangeLog content for given package.
101
102 @param package: package name
103 @type package: string
104 @return: changelog
105 @rtype: string or None
106 """
107 raise NotImplementedError()
108
110 """
111 Return build script path for given package looking through available
112 packages repositories.
113
114 @param package: package name
115 @type package: string
116 @return: build script path
117 @rtype: string
118 """
119 raise NotImplementedError()
120
122 """
123 Return build script path for given package looking into installed
124 packages repository.
125
126 @param package: package name
127 @type package: string
128 @keyword root: specify an alternative root directory "/"
129 @type root: string
130 @return: build script path
131 @rtype: string
132 """
133 raise NotImplementedError()
134
150
152 """
153 Return list of core (system) packages. Core packages are usually
154 consider vital for basic system operativity.
155
156 @return: list of system packages
157 @rtype: list
158 """
159 raise NotImplementedError()
160
162 """
163 Return list of package categories in available packages repositories.
164
165 @return: list of package categories
166 @rtype: list
167 """
168 raise NotImplementedError()
169
182
184 """
185 Return a list of packages affected by given security property argument.
186 Valid security_property values are: affected, new, all.
187
188 @param security_property: packages security property
189 @type security_property: string
190 @return: list of packages affected by given security property
191 @rtype: list
192 """
193 raise NotImplementedError()
194
206
208 """
209 Return Source Package Manager setting referenced by "key"
210
211 @param key: source package manager setting
212 @type key: string
213 @raise KeyError: if setting is not available
214 """
215 raise NotImplementedError()
216
218 """
219 Return path to file containing list (one per line) of packages
220 installed by user (in Portage world, this is the world file).
221
222 @keyword root: specify an alternative root directory "/"
223 @type root: string
224 @return: path to installed packages list file
225 @rtype: string
226 """
227 raise NotImplementedError()
228
230 """
231 Return a list of paths (either directories or files) whose are
232 protected from direct merge requiring user approval.
233
234 @return: list of protected paths
235 @rtype: list
236 """
237 raise NotImplementedError()
238
240 """
241 Return a list of unprotected paths (either directories or files) which
242 reside inside a protected path (see get_merge_protected_paths()).
243 """
244 raise NotImplementedError()
245
247 """
248 Return list of download mirror URLs for given mirror name
249
250 @param mirror_name: mirror name
251 @type mirror_name: string
252 @return: list of download URLs
253 @rtype: list
254 """
255 raise NotImplementedError()
256
263
265 """
266 Log message string to logfile.
267
268 @param message: message string to log
269 @type message: string
270 """
271 log = LogFile(
272 level = etpConst['spmloglevel'],
273 filename = etpConst['spmlogfile'],
274 header = "[spm]"
275 )
276 log.write(message)
277 log.flush()
278 log.close()
279
281 """
282 Match a package looking through available packages repositories using
283 the given match term argument (package) and match type (validity
284 defined by subclasses).
285
286 @param package: package string to match inside available repositories
287 @type package: string
288 @keyword match_type: match type
289 @type match_type: string
290 @return: matched package (atom) or None
291 @rtype: string or list or None
292 @raise KeyError: if match_type is not valid
293 """
294 raise NotImplementedError()
295
297 """
298 Match a package looking through installed packages repository using
299 the given match term argument (package).
300
301 @param package: package string to match inside installed packages
302 repository
303 @type package: string
304 @keyword match_all: return all the matching packages, not just the best
305 @type match_all: bool
306 @keyword root: specify an alternative root directory "/"
307 @type root: string
308 @return: matched package (atom) or None
309 @rtype: string or list or None
310 @raise KeyError: if match_type is not valid
311 """
312 raise NotImplementedError()
313
315 """
316 Generate a package tarball file for given package, from running system.
317 All the information is recomposed from system.
318
319 @param package: package name
320 @type package: string
321 @param file_save_path: exact path (including file name and extension)
322 where package file is saved
323 @type file_save_path: string
324 @return: None
325 @rtype: None
326 @raise entropy.exception.SPMError: if unable to satisfy the request
327 """
328 raise NotImplementedError()
329
341
343 """
344 WARNING: this is an Entropy Server functionality.
345 Enable compile options (also known as USE flags) for package.
346 Compile options are intended to be features that package can
347 expose to other packages or directly to user.
348
349 @param package: package name
350 @type package: string
351 @param options: list of compile options to enable
352 @type options: string
353 @return: enable status, True if enabled, False if not
354 @rtype: bool
355 """
356 raise NotImplementedError()
357
359 """
360 WARNING: this is an Entropy Server functionality.
361 Disable compile options (also known as USE flags) for package.
362 Compile options are intended to be features that package can
363 expose to other packages or directly to user.
364
365 @param package: package name
366 @type package: string
367 @param options: list of compile options to disable
368 @type options: string
369 @return: enable status, True if disabled, False if not
370 @rtype: bool
371 """
372 raise NotImplementedError()
373
375 """
376 WARNING: this is an Entropy Server functionality.
377 Return currently configured compile options (also known as USE flags)
378 for given package.
379 There can be different kinds of compile options so a dictionary should
380 be returned with compile options identifier as key and list of options
381 as value.
382 This method looks through available packages repositories.
383
384 @param package: package name
385 @type package: string
386 @return: compile options
387 @rtype: dict
388 """
389 raise NotImplementedError()
390
392 """
393 WARNING: this is an Entropy Server functionality.
394 Return currently configured compile options (also known as USE flags)
395 for given package.
396 There can be different kinds of compile options so a dictionary should
397 be returned with compile options identifier as key and list of options
398 as value.
399 This method looks into installed packages repository.
400
401 @param package: package name
402 @type package: string
403 @keyword root: specify an alternative root directory "/"
404 @type root: string
405 @return: compile options
406 @rtype: dict
407 """
408 raise NotImplementedError()
409
410 - def get_installed_package_content(self, package, root = None):
411 """
412 Return list of files/directories owned by package.
413
414 @param package: package name
415 @type package: string
416 @keyword root: specify an alternative root directory "/"
417 @type root: string
418 @return: list of files/directories owned by package
419 @rtype: list
420 """
421 raise NotImplementedError()
422
423 - def get_packages(self, categories = None, filter_reinstalls = False):
424 """
425 Return list of packages found in available repositories.
426 Extra "filtering" arguments can be passed like "categories", which
427 will make this method returning only packages found in given category
428 list and "filter_reinstalls" which will actually filter out packages
429 already installed (with no updates nor downgrades available).
430
431 @keyword categories: list of package categories to look into
432 @type categories: iterable
433 @keyword filter_reinstalls: enable reinstall packages filter
434 @type filter_reinstalls: bool
435 @return: list of available packages found
436 @rtype: list
437 @todo: improve method, move filter_reinstalls to another function?
438 """
439 raise NotImplementedError()
440
442 """
443 Return list of packages found in installed packages repository.
444 Extra "filtering" arguments can be passed like "categories", which
445 will make this method returning only packages found in given category
446 list.
447
448 @keyword categories: list of package categories to look into
449 @type categories: iterable
450 @keyword root: specify an alternative root directory "/"
451 @type root: string
452 @return: list of installed packages found
453 @rtype: list
454 """
455 raise NotImplementedError()
456
458 """
459 Package sets are groups of packages meant to ease user installation and
460 removal of large amount of applications or libraries.
461 The difference between package groups is that sets can be referenced
462 anywhere inside Entropy, while the former is just a simple way to
463 group pacakge categories, usually too hard to understand (for eg.
464 "sys-apps" or "app-misc", where user has no clue about the meaning of
465 these).
466 Third party implementations of SPM can just return empty data if
467 this feature is not wanted or implementable.
468
469 @param builtin_sets: if True, also return SPM built-in package sets
470 @type builtin_sets: bool
471 @return: dictionary featuring set name as key, list (set) of package
472 dependencies as value
473 @rtype: dict
474 """
475 raise NotImplementedError()
476
478 """
479 Assign a new Unique Identifier to installed package and return it.
480
481 @param package: package name
482 @type package: string
483 @keyword root: specify an alternative root directory "/"
484 @type root: string
485 @return: assigned Unique Identifier
486 @rtype: int
487 """
488 raise NotImplementedError()
489
491 """
492 Return list of packages owning provided list of paths.
493 A dictionary is returned containing package name as key and list of
494 matched paths as value.
495
496 @param paths: list of paths to resolve
497 @type paths: list
498 @keyword exact_match: match paths exactly
499 @type exact_match: bool
500 @return: packages owning list of paths
501 @rtype: dict
502 """
503 raise NotImplementedError()
504
505 - def execute_package_phase(self, package, build_script_path, phase_name,
506 work_dir = None, licenses_accepted = None):
507 """
508 Execute Source Package Manager package phase (postinstall, preinstall,
509 preremove, postremove, etc).
510
511 @param package: package name
512 @type package: string
513 @param build_script_path: path to Source Package Manager build script
514 to call
515 @type build_script_path: string
516 @param phase_name: name of the phase to call, must be a valid phase
517 contained in package_phases() output.
518 @type phase_name: string
519 @keyword work_dir: specify a work directory if required by your SPM
520 @type work_dir: string
521 @keyword licenses_accepted: list of license names already accepted
522 that can be given to Source Package Manager (to skip its license
523 acceptance verification stuff, for example)
524 @type licenses_accepted: list
525 @return: phase script exit status
526 @rtype: int
527 @raise KeyError: if phase is not available
528 """
529 raise NotImplementedError()
530
532 """
533 Add package installed by Entropy to SPM database too.
534 "package_metadata" is a dictionary featuring the following (relevant)
535 keys:
536 ['accept_license', 'imagedir', 'xpakpath', 'slot', 'pkgdbpath',
537 'versiontag', 'version', 'xpakstatus', 'unpackdir', 'revision',
538 'category', 'repository', 'xpakdir', 'name', 'install_source',
539 ]
540
541 @param package_metadata: Entropy package metadata
542 @type package_metadata: dict
543 @return: SPM installed package UID or -1
544 @rtype: int
545 """
546 raise NotImplementedError()
547
549 """
550 Remove installed package from SPM database.
551 "package_metadata" is a dictionary featuring the following (relevant)
552 keys:
553 ['accept_license', 'imagedir', 'xpakpath', 'slot', 'pkgdbpath',
554 'versiontag', 'version', 'xpakstatus', 'unpackdir', 'revision',
555 'category', 'repository', 'xpakdir', 'name', 'install_source',
556 'removeatom'
557 ]
558
559 @param package_metadata: Entropy package metadata
560 @type package_metadata: dict
561 @return: execution status
562 @rtype: int
563 """
564 raise NotImplementedError()
565
584
585 @staticmethod
587 """
588 This function is called by Entropy Client during package metadata setup.
589 It is intended to be used to inject additional metadata (that would be
590 used afterwards in other entropy_install_* hooks) to entropy package
591 install metadata.
592 Note: for performance reasons, this is a static method !
593
594 @param entropy_client: Entropy Client interface instance
595 @type entropy_client: entropy.client.interfaces.Client.Client
596 @param package_metadata: Entropy package metadata
597 @type package_metadata: dict
598 @return: execution status
599 @rtype: int
600 """
601 raise NotImplementedError()
602
603
604 @staticmethod
606 """
607 This function is called by Entropy Client during package installation,
608 unpack phase. It is intended to be used to extract, if required,
609 Source Package Manager metadata from Entropy packages useful for
610 installing package into Source Package Manager plugin too.
611 For example, PortagePlugin uses this hook to extract xpak metadata
612 from entropy package files and setup Portage directories.
613 Note: for performance reasons, this is a static method !
614
615 @param entropy_client: Entropy Client interface instance
616 @type entropy_client: entropy.client.interfaces.Client.Client
617 @param package_metadata: Entropy package metadata
618 @type package_metadata: dict
619 @return: execution status
620 @rtype: int
621 """
622 raise NotImplementedError()
623