From 4dee55fe523220d486b224ca5ec66c6511aae47a Mon Sep 17 00:00:00 2001 From: Guido Günther Date: Fri, 24 Sep 2010 10:28:48 +0200 Subject: Allow distros to map services to different packages --- whatmaps | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'whatmaps') diff --git a/whatmaps b/whatmaps index 45d2ab6..7a90303 100755 --- a/whatmaps +++ b/whatmaps @@ -82,6 +82,13 @@ class Distro(object): def pkg_by_file(klass, path): raise NotImplementedError + @classmethod + def pkg_services(klass, pkg): + try: + return klass._pkg_services[pkg.name] + except KeyError, AttributeError: + return [] + class Pkg(object): services = None @@ -114,6 +121,12 @@ class DebianDistro(Distro): "Debian (dpkg) based distribution""" id = 'Debian' + _pkg_services = { 'apache2-mpm-worker': [ 'apache2' ], + 'apache2-mpm-prefork': [ 'apache2' ], + 'dovecot-imapd': [ 'dovecot' ], + 'dovecot-pop3d': [ 'dovecot' ], + } + @classmethod def pkg(klass, name): return DebianPkg(name) @@ -170,7 +183,6 @@ class DebianPkg(Pkg): class RedHatDistro(Distro): - # Package contains file: rpm -q -f somefile "RPM based distribution""" _pkg_re = re.compile(r'(?P[\w\-\+]+)-(?P[\w\.]+)-(?P[\w\.]+)\.(?P.+)') @@ -223,7 +235,6 @@ class RpmPkg(Pkg): self._shared_objects.append(m.group('so')) return self._shared_objects - @property def services(self): if self._services != None: @@ -359,15 +370,18 @@ def main(argv): all_services = set() try: for pkg in pkgs.values(): - services = set(pkg.services) + services = pkg.services + distro.pkg_services(pkg) if not services: - logging.warning("No service script found in '%s' for '%s' - restart manually" - % (pkg.name, pkg.procs)) + logging.warning("No service script found in '%s' for '%s' " + "- restart manually" % (pkg.name, pkg.procs)) else: all_services = all_services.union(services) except NotImplementedError: if level > logging.INFO: - logging.error("Service listing/restarting not implemented for distribution %s - rerun with --verbose to see a list of binaries and packages to map a shared objects from %s", distro.id, args) + logging.error("Getting Service listing not implemented " + "for distribution %s - rerun with --verbose to see a list" + "of binaries and packages to map a shared objects from %s", + distro.id, args) return 1 else: return 0 -- cgit v1.2.3