On 02/25/2010 07:06 PM, Sebastian Pipping wrote:
> I agree that additional repoman checks can help to improve quality in
> Gentoo...
> 
> 
> It seems that currently neither metagen nor repoman check what I put in
> for herd (i.e. if such a herd exists or not).
> 
> Does anyone feel like getting his hands on that or like teaming up on it?
> 
> 
> 
> Sebastian
> 

I started playing with herd checks in repoman but unfortunately I didn't
finish it yet.
I'm sure we can put such checks together with my stuff.
The diff was against portage-2.2_rc61 iirc.

-- 
Regards,
Christian Ruppert
Gentoo Linux Developer and Bugzilla Admin
Fingerprint: 9B50 01DF E873 A0E4 126D  6C16 8B17 B68E 7FAE 7D38

--- portage/pym/repoman/utilities.py.orig       2010-01-03 23:00:18.703948362 
+0100
+++ portage/pym/repoman/utilities.py    2010-01-29 12:26:28.891391463 +0100
@@ -15,7 +15,8 @@ __all__ = [
        "get_commit_message_with_editor",
        "get_commit_message_with_stdin",
        "have_profile_dir",
-       "parse_metadata_use"
+       "parse_metadata_use",
+       "check_metadata"
 ]
 
 import codecs
@@ -146,6 +147,53 @@ def parse_metadata_use(mylines, uselist=
        metadatadom.unlink()
        return uselist
 
+def check_metadata(settings, metadata):
+       try:
+               metadatadom = minidom.parse(metadata)
+       except ExpatError, e:
+               raise ExpatError("%s: %s" % (metadata, e,))
+
+       _elem = metadatadom.getElementsByTagName("herd")
+
+       # If no herd tag exist
+       if not _elem:
+               print("There must be at least one herd subtag.")
+               metadatadom.unlink()
+               return True
+       else:
+               for _herd in _elem:
+                       # Check for empty herd tags
+                       if not _herd.hasChildNodes():
+                               print('The contents of the "herd" tag must be 
the name of a herd as specified in the herds.xml file or the "no-herd" herd. It 
must occur at least once.')
+                               metadatadom.unlink()
+                               return True
+       
+       _elem = metadatadom.getElementsByTagName("maintainer")
+       if _elem:
+               try:
+                       herddom = 
minidom.parse(os.path.join(settings["PORTDIR"], "metadata/herds.xml"))
+               except ExpatError, e:
+                       print(e)
+                       metadatadom.unlink()
+                       return True
+
+               _herdlist = []
+               _helem = herddom.getElementsByTagName("herd")
+               for _herd in _helem:
+                       _email = _herd.getElementsByTagName("email")
+                       # Some herds don't have a email tag
+                       if _email:
+                               _herdlist.append(_email[0].childNodes[0].data)
+               herddom.unlink()
+
+               for _mtainer in _elem:
+                       _email = _mtainer.getElementsByTagName("email")
+                       if _email[0].childNodes[0].data in _herdlist:
+                               print(_email[0].childNodes[0].data)
+                               metadatadom.unlink()
+                               return True
+
+       metadatadom.unlink()
 
 def FindPackagesToScan(settings, startdir, reposplit):
        """ Try to find packages that need to be scanned
--- portage/repoman.orig        2010-01-03 23:00:14.698949316 +0100
+++ portage/repoman     2010-01-29 12:27:06.805142940 +0100
@@ -1273,6 +1273,11 @@ for x in scanlist:
                                        print(red("!!! ")+z)
                                stats["metadata.bad"]+=1
                                fails["metadata.bad"].append(x+"/metadata.xml")
+                               metadata_bad = True
+               if not metadata_bad:
+                       if utilities.check_metadata(repoman_settings, 
os.path.join(checkdir, "metadata.xml")):
+                               stats["metadata.bad"]+=1
+                               fails["metadata.bad"].append(x+"/metadata.xml")
 
                del metadata_bad
        muselist = frozenset(muselist)

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to