Index: jhbuild/modtypes/autotools.py
===================================================================
--- jhbuild/modtypes/autotools.py	(revision 1648)
+++ jhbuild/modtypes/autotools.py	(working copy)
@@ -49,7 +49,8 @@ class AutogenModule(Package):
                  supports_non_srcdir_builds=True,
                  skip_autogen=False,
                  autogen_sh='autogen.sh',
-                 makefile='Makefile'):
+                 makefile='Makefile',
+                 skip_installed=False):
         Package.__init__(self, name, dependencies, after)
         self.branch = branch
         self.autogenargs = autogenargs
@@ -59,6 +60,7 @@ class AutogenModule(Package):
         self.skip_autogen = skip_autogen
         self.autogen_sh = autogen_sh
         self.makefile = makefile
+        self.skip_installed = skip_installed
 
     def get_srcdir(self, buildscript):
         return self.branch.srcdir
@@ -75,15 +77,21 @@ class AutogenModule(Package):
         return self.branch.branchname
 
     def do_start(self, buildscript):
+        #if self.skip_installed:
+        #    print "skipping %s because it's installed from debian packages" % self.name
+        #    do_checkout.next_state = Package.STATE_DONE
+        #    return
         pass
     do_start.next_state = STATE_CHECKOUT
     do_start.error_states = []
 
     def skip_checkout(self, buildscript, last_state):
         # skip the checkout stage if the nonetwork flag is set
-        return buildscript.config.nonetwork
+        return buildscript.config.nonetwork or self.skip_installed
 
     def do_checkout(self, buildscript):
+        if self.skip_installed:
+            return
         srcdir = self.get_srcdir(buildscript)
         builddir = self.get_builddir(buildscript)
         buildscript.set_action('Checking out', self)
@@ -96,7 +104,7 @@ class AutogenModule(Package):
     do_checkout.error_states = [STATE_FORCE_CHECKOUT]
 
     def skip_force_checkout(self, buildscript, last_state):
-        return False
+        return False or self.skip_installed
 
     def do_force_checkout(self, buildscript):
         buildscript.set_action('Checking out', self)
@@ -107,11 +115,11 @@ class AutogenModule(Package):
     def skip_configure(self, buildscript, last_state):
         # skip if nobuild is set.
         if buildscript.config.nobuild:
-            return True
+            return True or self.skip_installed
 
         # skip if manually instructed to do so
         if self.skip_autogen:
-            return True
+            return True or self.skip_installed
 
         # don't skip this stage if we got here from one of the
         # following states:
@@ -119,13 +127,13 @@ class AutogenModule(Package):
                           self.STATE_CLEAN,
                           self.STATE_BUILD,
                           self.STATE_INSTALL]:
-            return False
+            return False or self.skip_installed
 
         # skip if the makefile exists and we don't have the
         # alwaysautogen flag turned on:
         builddir = self.get_builddir(buildscript)
         return (os.path.exists(os.path.join(builddir, self.makefile)) and
-                not buildscript.config.alwaysautogen)
+                not buildscript.config.alwaysautogen) or self.skip_installed
 
     def do_configure(self, buildscript):
         builddir = self.get_builddir(buildscript)
@@ -171,7 +179,7 @@ class AutogenModule(Package):
 
     def skip_clean(self, buildscript, last_state):
         return (not buildscript.config.makeclean or
-                buildscript.config.nobuild)
+                buildscript.config.nobuild) or self.skip_installed
 
     def do_clean(self, buildscript):
         buildscript.set_action('Cleaning', self)
@@ -181,7 +189,7 @@ class AutogenModule(Package):
     do_clean.error_states = [STATE_FORCE_CHECKOUT, STATE_CONFIGURE]
 
     def skip_build(self, buildscript, last_state):
-        return buildscript.config.nobuild
+        return buildscript.config.nobuild or self.skip_installed
 
     def do_build(self, buildscript):
         buildscript.set_action('Building', self)
@@ -192,7 +200,7 @@ class AutogenModule(Package):
 
     def skip_check(self, buildscript, last_state):
         return (not buildscript.config.makecheck or
-                buildscript.config.nobuild)
+                buildscript.config.nobuild) or self.skip_installed
 
     def do_check(self, buildscript):
         buildscript.set_action('Checking', self)
@@ -202,7 +210,7 @@ class AutogenModule(Package):
     do_check.error_states = [STATE_FORCE_CHECKOUT, STATE_CONFIGURE]
 
     def skip_dist(self, buildscript, last_state):
-        return not (buildscript.config.makedist or buildscript.config.makedistcheck)
+        return not (buildscript.config.makedist or buildscript.config.makedistcheck) or self.skip_installed
 
     def do_dist(self, buildscript):
         buildscript.set_action('Creating tarball for', self)
@@ -215,7 +223,7 @@ class AutogenModule(Package):
     do_dist.error_states = [STATE_FORCE_CHECKOUT, STATE_CONFIGURE]
 
     def skip_install(self, buildscript, last_state):
-        return buildscript.config.nobuild
+        return buildscript.config.nobuild or self.skip_installed
 
     def do_install(self, buildscript):
         buildscript.set_action('Installing', self)
@@ -238,6 +246,7 @@ def parse_autotools(node, config, uri, r
     supports_non_srcdir_builds = True
     autogen_sh = 'autogen.sh'
     skip_autogen = False
+    skip_installed = False
     makefile = 'Makefile'
     if node.hasAttribute('autogenargs'):
         autogenargs = node.getAttribute('autogenargs')
@@ -254,7 +263,16 @@ def parse_autotools(node, config, uri, r
         autogen_sh = node.getAttribute('autogen-sh')
     if node.hasAttribute('makefile'):
         makefile = node.getAttribute('makefile')
-
+    if node.hasAttribute('debian'):
+        debian = node.getAttribute('debian')
+        import apt
+        cache = apt.Cache()
+        skip_installed = False
+        if cache.has_key(debian):
+            skip_installed = not cache._dict[debian].isInstalled
+            print skip_installed, debian
+        
+        
     # Make some substitutions; do special handling of '${prefix}' and '${libdir}'
     p = re.compile('(\${prefix})')
     autogenargs     = p.sub(config.prefix, autogenargs)
@@ -283,7 +301,8 @@ def parse_autotools(node, config, uri, r
                          supports_non_srcdir_builds=supports_non_srcdir_builds,
                          skip_autogen=skip_autogen,
                          autogen_sh=autogen_sh,
-                         makefile=makefile)
+                         makefile=makefile,
+                         skip_installed=skip_installed)
 register_module_type('autotools', parse_autotools)
 
 
Index: jhbuild/modtypes/__init__.py
===================================================================
--- jhbuild/modtypes/__init__.py	(revision 1648)
+++ jhbuild/modtypes/__init__.py	(working copy)
@@ -37,6 +37,7 @@ def register_lazy_module_type(name, modu
     def parse_func(node, config, uri, repositories, default_repo):
         old_func = _module_types[name]
         mod = __import__(module)
+        #print old_func, name, module, _module_types
         assert _module_types[name] != old_func, (
             'module did not register new parser_func for %s' % name)
         return _module_types[name](node, config, uri, repositories, default_repo)
@@ -127,6 +128,7 @@ class Package:
             seen_states.append(state)
             if state == self.STATE_DONE:
                 return state
+            print state
             do_method = getattr(self, 'do_' + state)
             if hasattr(self, 'skip_' + state):
                 skip_method = getattr(self, 'skip_' + state)
