Index: jhbuild/commands/base.py
===================================================================
--- jhbuild/commands/base.py	(revision 1548)
+++ jhbuild/commands/base.py	(working copy)
@@ -136,6 +136,9 @@
             make_option('-t', '--start-at', metavar='MODULE',
                         action='store', dest='startat', default=None,
                         help='start building at the given module'),
+            make_option('--tags',
+                        action='append', dest='tags', default=[],
+                        help='build only modules with the given tags'),
             make_option('-D', metavar='DATE-SPEC',
                         action='store', dest='sticky_date', default=None,
                         help='set a sticky date when checking out modules'),
@@ -161,10 +164,13 @@
             config.sticky_date = options.sticky_date
         if options.noxvfb is not None:
             config.noxvfb = options.noxvfb
+        for item in options.tags:
+            config.tags += item.split(',')
 
         module_set = jhbuild.moduleset.load(config)
         module_list = module_set.get_module_list(args or config.modules,
-                                                 config.skip)
+                                                 config.skip,
+                                                 config.tags)
         # remove modules up to startat
         if options.startat:
             while module_list and module_list[0].name != options.startat:
Index: jhbuild/modtypes/__init__.py
===================================================================
--- jhbuild/modtypes/__init__.py	(revision 1548)
+++ jhbuild/modtypes/__init__.py	(working copy)
@@ -103,6 +103,8 @@
         self.name = name
         self.dependencies = dependencies
         self.after = after
+        self.tags = []
+
     def __repr__(self):
         return "<%s '%s'>" % (self.__class__.__name__, self.name)
 
Index: jhbuild/moduleset.py
===================================================================
--- jhbuild/moduleset.py	(revision 1548)
+++ jhbuild/moduleset.py	(working copy)
@@ -43,33 +43,13 @@
         '''add a Module object to this set of modules'''
         self.modules[module.name] = module
 
-    # functions for handling dep expansion
-    def __expand_mod_list(self, modlist, skip):
-        '''expands a list of names to a list of Module objects.  Expands
-        dependencies.  Does not handle loops in deps''' #"
-        ret = [self.modules[modname]
-                   for modname in modlist
-                       if modname not in skip]
-        i = 0
-        while i < len(ret):
-            depadd = []
-            for depmod in [self.modules[modname]
-                               for modname in ret[i].dependencies]:
-                if depmod not in ret[:i+1] and depmod.name not in skip:
-                    depadd.append(depmod)
-            if depadd:
-                ret[i:i] = depadd
-            else:
-                i = i + 1
-        i = 0
-        while i < len(ret):
-            if ret[i] in ret[:i]:
-                del ret[i]
-            else:
-                i = i + 1
-        return ret
+    def __module_has_tags(self, mod, tags):
+        for tag in tags:
+            if not tag in mod.tags:
+                return False
+        return True
 
-    def get_module_list(self, seed, skip=[]):
+    def get_module_list(self, seed, skip=[], tags=[]):
         '''gets a list of module objects (in correct dependency order)
         needed to build the modules in the seed list''' #"
 
@@ -109,11 +89,14 @@
                 modules[i:i] = depadd
             else:
                 i = i + 1
-        # remove duplicates
+        # remove duplicates, check tags
         ret = []
         for module in modules:
-            if module not in ret:
-                ret.append(module)
+            if module in ret:
+                continue
+            if tags and not self.__module_has_tags(module, tags):
+                continue
+            ret.append(module)
         return ret
     
     def get_full_module_list(self, skip=[]):
@@ -210,6 +193,9 @@
 
     assert document.documentElement.nodeName == 'moduleset'
     moduleset = ModuleSet()
+    moduleset_name = document.documentElement.getAttribute('name')
+    if not moduleset_name and uri.endswith('.modules'):
+        moduleset_name = os.path.basename(uri)[:-len('.modules')]    
 
     # load up list of repositories
     repositories = {}
@@ -259,7 +245,10 @@
                                'arch-archive']:
             pass
         else:
-            moduleset.add(modtypes.parse_xml_node(node, config, uri,
-                                                  repositories, default_repo))
+            module = modtypes.parse_xml_node(node, config, uri,
+                                             repositories, default_repo)
+            if moduleset_name:
+                module.tags.append(moduleset_name)
+            moduleset.add(module)
 
     return moduleset
Index: jhbuild/config.py
===================================================================
--- jhbuild/config.py	(revision 1548)
+++ jhbuild/config.py	(working copy)
@@ -28,7 +28,7 @@
 _defaults_file = os.path.join(os.path.dirname(__file__), 'defaults.jhbuildrc')
 _default_jhbuildrc = os.path.join(os.environ['HOME'], '.jhbuildrc')
 
-_known_keys = [ 'moduleset', 'modules', 'skip', 'prefix',
+_known_keys = [ 'moduleset', 'modules', 'skip', 'tags', 'prefix',
                 'checkoutroot', 'buildroot', 'autogenargs', 'makeargs',
                 'repos', 'branches', 'noxvfb', 'xvfbargs',
                 'builddir_pattern', 'module_autogenargs', 'module_makeargs',
Index: jhbuild/defaults.jhbuildrc
===================================================================
--- jhbuild/defaults.jhbuildrc	(revision 1548)
+++ jhbuild/defaults.jhbuildrc	(working copy)
@@ -10,6 +10,8 @@
 
 # modules to skip during dependency expansion
 skip = []
+# tags used as module filters
+tags = []
 
 # directories
 prefix = '/opt/gnome2'
