[jhbuild/external-deps: 2/19] Add system packages helper and skip installed pkgs



commit 8f60c22ee177f0426f88a26ec68f9b6dd2b9604c
Author: John Carr <john carr unrouted co uk>
Date:   Thu May 28 11:35:45 2009 +0100

    Add system packages helper and skip installed pkgs
---
 jhbuild/commands/base.py        |   13 +++++--
 jhbuild/moduleset.py            |    2 +-
 jhbuild/utils/systempackages.py |   74 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 85 insertions(+), 4 deletions(-)

diff --git a/jhbuild/commands/base.py b/jhbuild/commands/base.py
index ffc02ab..8a7d470 100644
--- a/jhbuild/commands/base.py
+++ b/jhbuild/commands/base.py
@@ -32,6 +32,7 @@ from jhbuild.commands import Command, register_command
 
 from jhbuild.config import parse_relative_time
 
+from jhbuild.utils import systempackages
 
 class cmd_update(Command):
     doc = N_('Update all modules from version control')
@@ -60,10 +61,12 @@ class cmd_update(Command):
 
     def run(self, config, options, args):
         config.set_from_cmdline_options(options)
+        pkgs = systempackages.get_system_packages()
         module_set = jhbuild.moduleset.load(config)
         module_list = module_set.get_module_list(args or config.modules,
                 config.skip, tags=config.tags,
-                ignore_suggests=config.ignore_suggests)
+                ignore_suggests=config.ignore_suggests,
+                should_skip=pkgs.satisfied)
         # remove modules up to startat
         if options.startat:
             while module_list and module_list[0].name != options.startat:
@@ -268,12 +271,14 @@ class cmd_build(Command):
         if not config.quiet_mode:
             check_bootstrap_updateness(config)
 
+        pkgs = systempackages.get_system_packages()
         module_set = jhbuild.moduleset.load(config)
         modules = args or config.modules
         module_list = module_set.get_module_list(modules,
                 config.skip, tags = config.tags,
                 include_optional_modules=options.build_optional_modules,
-                ignore_suggests=config.ignore_suggests)
+                ignore_suggests=config.ignore_suggests,
+                should_skip=pkgs.satisfied)
         # remove modules up to startat
         if options.startat:
             while module_list and module_list[0].name != options.startat:
@@ -454,6 +459,7 @@ class cmd_list(Command):
 
     def run(self, config, options, args):
         config.set_from_cmdline_options(options)
+        pkgs = systempackages.get_system_packages()
         module_set = jhbuild.moduleset.load(config)
         if options.list_all_modules:
             module_list = module_set.modules.values()
@@ -461,7 +467,8 @@ class cmd_list(Command):
             module_list = module_set.get_module_list(args or config.modules,
                                 config.skip, tags = config.tags,
                                 include_optional_modules = options.list_optional_modules,
-                                ignore_suggests=config.ignore_suggests)
+                                ignore_suggests=config.ignore_suggests,
+                                should_skip=pkgs.satisfied)
 
         # remove modules up to startat
         if options.startat:
diff --git a/jhbuild/moduleset.py b/jhbuild/moduleset.py
index 5de9782..b9cfcab 100644
--- a/jhbuild/moduleset.py
+++ b/jhbuild/moduleset.py
@@ -119,7 +119,7 @@ class ModuleSet:
                     self._state[self.modules[modname]] = 'processed'
 
         if should_skip:
-            for name, module in self.modules:
+            for name, module in self.modules.iteritems():
                 if should_skip(name, module):
                     self._state[module] = 'processed'
 
diff --git a/jhbuild/utils/systempackages.py b/jhbuild/utils/systempackages.py
new file mode 100644
index 0000000..d6752e8
--- /dev/null
+++ b/jhbuild/utils/systempackages.py
@@ -0,0 +1,74 @@
+# jhbuild - a build script for GNOME 1.x and 2.x
+# Copyright (C) 2009  Codethink Ltd.
+#
+#   systempackage.py:  Infrastructure for interacting with installed packages
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+#
+# Authors:
+#   John Carr <john carr unrouted co uk>
+
+
+class SystemPackages(object):
+
+    def satisfiable(self, name, module):
+        """ Returns true if a module is satisfiable by installing a system package """
+        return self.is_available(name)
+
+    def satisfied(self, name, module):
+        """ Returns true if module is satisfied by an already installed system package """
+        return self.is_installed(name)
+
+    def is_installed(self, name, version=None):
+        return False
+
+    def is_available(self, name, version=None):
+        return False
+
+    def install(self, names):
+        raise UnimplementedError
+
+    def remove(self, names):
+        raise UnimplementedError
+
+    def supported(cls):
+        return False
+    supported = classmethod(supported)
+
+
+class PackageKitPackages(SystemPackages):
+    pass
+
+
+class DebianPackages(SystemPackages):
+
+    def install(self, names):
+        buildscript.execute(['apt-get', 'install', ' '.join(name)])
+
+    def remove(self, names):
+        buildscript.execute(['apt-get', 'remove', ' '.join(name)])
+
+    def supported(cls):
+        return True
+    supported = classmethod(supported)
+
+
+def get_system_packages():
+    for c in SystemPackages.__subclasses__():
+        if c.supported():
+            return c()
+    return SystemPackages()
+
+



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]