diff options
author | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2010-07-12 01:15:18 -0300 |
---|---|---|
committer | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2010-07-12 01:15:18 -0300 |
commit | 92b68ae53f847990526da9006b4986b800d9b945 (patch) | |
tree | b79c1a5eb7d05171f358d697bac3c1b05ce9c33e /g_octave | |
parent | fixed a test case (diff) | |
download | g-octave-92b68ae53f847990526da9006b4986b800d9b945.tar.gz g-octave-92b68ae53f847990526da9006b4986b800d9b945.tar.bz2 g-octave-92b68ae53f847990526da9006b4986b800d9b945.zip |
bunch of fixes. added support to paludis
Diffstat (limited to 'g_octave')
-rw-r--r-- | g_octave/config.py | 2 | ||||
-rw-r--r-- | g_octave/ebuild.py | 22 | ||||
-rw-r--r-- | g_octave/package_manager.py | 83 |
3 files changed, 88 insertions, 19 deletions
diff --git a/g_octave/config.py b/g_octave/config.py index c2683a5..9dd91f3 100644 --- a/g_octave/config.py +++ b/g_octave/config.py @@ -31,7 +31,7 @@ class Config(object): 'pkg_cache': '', 'log_level': '', 'log_file': '/var/log/g-octave.log', - 'package_manager': 'emerge', + 'package_manager': 'portage', } _section_name = 'main' diff --git a/g_octave/ebuild.py b/g_octave/ebuild.py index 2ccb927..3eca54a 100644 --- a/g_octave/ebuild.py +++ b/g_octave/ebuild.py @@ -45,6 +45,7 @@ class Ebuild: def __init__(self, pkg_atom, force=False, conf=None, pkg_manager=None): self.__force = force + self.__conf = conf self.__pkg_manager = pkg_manager if conf is None: @@ -98,7 +99,7 @@ class Ebuild: out.einfo('Creating ebuild: g-octave/%s-%s.ebuild' % (self.pkgname, self.version)) try: - my_atom = self.__create(accept_keywords, manifest) + my_atom, my_catpkg = self.__create(accept_keywords, manifest) except Exception, error: if display_info: out.eerror('Failed to create: g-octave/%s-%s.ebuild' % (self.pkgname, self.version)) @@ -106,10 +107,13 @@ class Ebuild: else: if not nodeps: self.__resolve_dependencies() - return my_atom + return my_atom, my_catpkg else: - return '=g-octave/%s-%s' % (self.pkgname, self.version) + return ( + '=g-octave/%s-%s' % (self.pkgname, self.version), + 'g-octave/%s' % self.pkgname, + ) def __create(self, accept_keywords=None, manifest=True): @@ -203,7 +207,10 @@ RDEPEND="${DEPEND} if proc != os.EX_OK: raise EbuildException('Failed to create Manifest file!') - return '=g-octave/%s-%s' % (self.pkgname, self.version) + return ( + '=g-octave/%s-%s' % (self.pkgname, self.version), + 'g-octave/%s' % self.pkgname, + ) def __keywords(self, accept_keywords): @@ -285,4 +292,9 @@ RDEPEND="${DEPEND} # creating the ebuilds for the dependencies, recursivelly for ebuild in to_install: - Ebuild(ebuild).create() + Ebuild( + ebuild, + force = self.__force, + conf = self.__conf, + pkg_manager = self.__pkg_manager + ).create() diff --git a/g_octave/package_manager.py b/g_octave/package_manager.py index 2435d27..73ffbc7 100644 --- a/g_octave/package_manager.py +++ b/g_octave/package_manager.py @@ -14,6 +14,7 @@ __all__ = [ 'Portage', 'Pkgcore', + 'Paludis', ] import os @@ -27,9 +28,9 @@ class Base: post_install = [] post_uninstall = [] - def check_overlay(self, overlay, out): - return True - + check_overlay = lambda a,b,c: True + create_manifest = lambda a,b: os.EX_OK + class Portage(Base): @@ -50,13 +51,13 @@ class Portage(Base): def run_command(self, command): return subprocess.call(self._fullcommand + command) - def install_package(self, pkgatom): + def install_package(self, pkgatom, catpkg): return self.run_command([pkgatom]) - def uninstall_package(self, pkgatom): + def uninstall_package(self, pkgatom, catpkg): return self.run_command(['--unmerge', pkgatom]) - def update_package(self, pkgatom=None): + def update_package(self, pkgatom=None, catpkg=None): if pkgatom is None: pkgatom = self.installed_packages() else: @@ -101,16 +102,15 @@ class Pkgcore(Base): nocolor and self._fullcommand.append('--nocolor') def run_command(self, command): - print command return subprocess.call(self._fullcommand + command) - def install_package(self, pkgatom): + def install_package(self, pkgatom, catpkg): return self.run_command([pkgatom]) - def uninstall_package(self, pkgatom): + def uninstall_package(self, pkgatom, catpkg): return self.run_command(['--unmerge', pkgatom]) - def update_package(self, pkgatom=None): + def update_package(self, pkgatom=None, catpkg=None): if pkgatom is None: pkgatom = self.installed_packages() else: @@ -130,7 +130,64 @@ class Pkgcore(Base): for line in p.stdout: packages.append(line.strip()) return packages + + +class Paludis(Base): - def create_manifest(self, ebuild): - # from portage :S - return subprocess.call(['ebuild', ebuild, 'manifest']) + _client = 'paludis' + + post_uninstall = [ + 'You may want to remove the dependencies too, using:', + '# paludis --pretend --uninstall-unused', + ] + + def __init__(self, ask=False, verbose=False, pretend=False, nocolor=False): + self._fullcommand = [self._client] + # paludis doesn't supports '--ask' + if verbose: + self._fullcommand += [ + '--show-reasons', 'full', + '--show-use-descriptions', 'all', + '--show-package-descriptions', 'all', + ] + pretend and self._fullcommand.append('--pretend') + nocolor and self._fullcommand.append('--no-color') + + def run_command(self, command): + return subprocess.call(self._fullcommand + command) + + def install_package(self, pkgatom, catpkg): + return self.run_command([ + '--install', + '--dl-upgrade', 'as-needed', + '--add-to-world-spec', catpkg, + pkgatom + ]) + + def uninstall_package(self, pkgatom, catpkg): + return self.run_command(['--uninstall', pkgatom]) + + def update_package(self, pkgatom=None, catpkg=None): + if pkgatom is None: + pkgatom = self.installed_packages() + else: + pkgatom = [pkgatom] + return self.run_command([ + '--install', + '--dl-upgrade', 'as-needed', + '--dl-reinstall-targets', 'never', + ] + pkgatom) + + def installed_packages(self): + packages = [] + p = subprocess.Popen([ + 'cave', + 'print-ids', + '--matching', 'g-octave/*::installed', + '--format', '%c/%p\n', + ], stdout=subprocess.PIPE) + if p.wait() == os.EX_OK: + for line in p.stdout: + packages.append(line.strip()) + return packages + |