summaryrefslogtreecommitdiff
path: root/portato/backend/portage/system_22.py
blob: 882232f15da5520db6423bf6f2d2e74b4f87a8b3 (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
# -*- coding: utf-8 -*-
#
# File: portato/backend/portage/system_22.py
# This file is part of the Portato-Project, a graphical portage-frontend.
#
# Copyright (C) 2006-2010 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>

import os
import portage

from collections import defaultdict

from .package_22 import PortagePackage_22
from .settings_22 import PortageSettings_22
from .system import PortageSystem
from . import sets as syssets

class PortageSystem_22 (PortageSystem):

    def __init__ (self):
        self.settings = PortageSettings_22()
        portage.WORLD_FILE = os.path.join(self.settings.global_settings["ROOT"],portage.WORLD_FILE)

        self.use_descs = {}
        self.local_use_descs = defaultdict(dict)

        self.setmap = {
                self.SET_ALL : syssets.AllSet(),
                self.SET_INSTALLED : syssets.InstalledSet(),
                self.SET_UNINSTALLED : syssets.UninstalledSet(),
                self.SET_TREE : syssets.TreeSet()
                }

    def get_update_option (self):
        return ["--update", "--oneshot"] # --oneshot to not record the used sets in world file

    def has_set_support (self):
        return True

    def get_sets (self, description = False):
        if description:
            return ((name, set.description) for name, set in self.settings.setsconfig.getSets().items())
        else:
            return tuple(self.settings.setsconfig.getSets())

    def _get_set (self, pkgSet):
        pkgSet = pkgSet.lower()
        if pkgSet == "": pkgSet = self.SET_ALL

        s = self.setmap.get(pkgSet, None)
        if s is None:
            s = syssets.PortageSet(pkgSet)
            self.setmap[pkgSet] = s

        return s

    def new_package (self, cpv):
        return PortagePackage_22(cpv)