+# Centos 6.5 does not have collections.OrderedDict
+# This implementation provides the minimal functionality of OrderedDict that we need
+# It works here, but should not be counted on for anything else.
+class OrderedDict(dict):
+
+ def __setitem__(self,k, v):
+ if k not in self:
+ self.keylist.append(k)
+ return super(OrderedDict,self).__setitem__(k,v)
+
+ def __init__(self, *args, **kwargs):
+ super(OrderedDict,self).__init__(*args, **kwargs)
+ self.keylist = []
+
+ def values(self):
+ return map( lambda(elt): self[elt], self.keylist)
+
+builder_by_type = {
+ '.tar.gz': lambda(t): run_cmd([ 'rpmbuild', '-ta', t]),
+ '.spec':
+ lambda(s): run_cmd(['rpmbuild', '--define', '_sourcedir '+os.getcwd(),
+ '-ba', s]),
+ }
+
+
+def find_type(name):
+ match = re.match('^.*(\\.tar\\.gz|\\.spec)$', name)
+ if match:
+ return match.group(1)
+ else: return None
+
+
+# The following regexp is not quite right.
+# One place is the rpm_packages file.
+# The other is the directory listing.
+# The rpm_packages file might have entries like shibboleth/xmltooling
+# Where as the distributions directory might have xmltooling-1.5.tar.gz
+# Two requirements for correct operation:
+# trim_target produces unique results for everything in rpm_packages
+# trim_target correctly trims what's in the packages file to the same
+# thing it trims the tar file or spec file to.
+#
+def trim_target(t):