blob: c85e029c3547a0bb453cb38d14979c91eaf85807 (
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
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
mangler.py
~~~~~~~~~~
package manager interaction
:copyright: (c) 2013 by Jauhien Piatlicki
:license: GPL-2, see LICENSE for more details.
"""
import os
from .logger import Logger
class PackageManager(object):
"""
Base class for package manager abstraction
"""
executable = ""
logger = Logger()
def __init__(self):
pass
def run_command(self, *args):
command = self.executable + " " + " ".join(args)
self.logger.info("running a package mangler: " + command)
return os.system(self.executable + " " + " ".join(args))
def install(self, pkgname, *args):
"""
It supports intallation by package name currently,
will add support of atoms with version specified later
"""
raise NotImplementedError
class Portage(PackageManager):
"""
Portage package manager abstraction.
"""
def __init__(self):
super(Portage, self).__init__()
self.executable = "/usr/bin/emerge"
def install(self, pkgname, *args):
return self.run_command("-va", pkgname, *args)
#list of supported package managers.
package_managers = {'portage' : Portage}
|