bodhi/config/app.cfg | 1 +
bodhi/masher.py | 1 +
bodhi/metadata.py | 34 ++++++++++++++++++++++++++++++++++
bodhi/modifyrepo.py | 8 +++++---
4 files changed, 41 insertions(+), 3 deletions(-)
New commits:
commit 8f623181e4cb04758369e631f29eca5148e60324
Author: Luke Macken <lmacken(a)redhat.com>
Date: Wed Sep 15 11:44:19 2010 -0400
Download and inject the pkgtags.sqlite into our repodata from the pkgdb (#435)
diff --git a/bodhi/config/app.cfg b/bodhi/config/app.cfg
index 49b7884..c7320d6 100644
--- a/bodhi/config/app.cfg
+++ b/bodhi/config/app.cfg
@@ -130,6 +130,7 @@ acl_system = 'dummy'
## Package DB
##
pkgdb_url = 'https://admin.fedoraproject.org/pkgdb'
+pkgtags_url = 'https://admin.fedoraproject.org/pkgdb/lists/sqlitebuildtags/'
##
## Bugzilla settings. The username/password for our bugzilla account comes
diff --git a/bodhi/masher.py b/bodhi/masher.py
index fe26b4b..59f4033 100644
--- a/bodhi/masher.py
+++ b/bodhi/masher.py
@@ -835,6 +835,7 @@ class MashTask(Thread):
log.debug("Generating updateinfo.xml.gz for %s" % repo)
uinfo = ExtendedMetadata(repo, olduinfo)
uinfo.insert_updateinfo()
+ uinfo.insert_pkgtags()
log.debug("Updateinfo generation took: %s secs" % (time.time()-t0))
self.genmd = False
diff --git a/bodhi/metadata.py b/bodhi/metadata.py
index 465ada0..9541743 100644
--- a/bodhi/metadata.py
+++ b/bodhi/metadata.py
@@ -16,6 +16,7 @@
__version__ = '1.4'
import os
+import urllib
import logging
from xml.dom import minidom
@@ -278,3 +279,36 @@ class ExtendedMetadata(object):
repomd.add(self.doc)
except RepositoryNotFound:
log.error("Cannot find repomd.xml in %s" % self.repo)
+
+ def insert_pkgtags(self):
+ """ Download and inject the pkgtags sqlite from the pkgdb
"""
+ try:
+ for arch in os.listdir(self.repo):
+ if arch == 'SRPMS':
+ continue
+ filename = ''
+ if self.repo.startswith('f'):
+ release = self.repo[1:].split('-')[0]
+ filename = 'F-%s-%s-' % (release, arch)
+ if 'testing' in self.repo:
+ filename += 'tu'
+ else:
+ filename += 'u'
+ elif self.repo.startswith('el'):
+ release = self.repo[2:].split('-')[0]
+ filename = 'E-%s-%s' % (release, arch)
+ if 'testing' in self.repo:
+ filename += '-t'
+ else:
+ log.error('Unknown repo %s' % self.repo)
+
+ tags_url = config.get('pkgtags_url') + filename
+ log.info('Downloading %s' % tags_url)
+ f = urllib.urlretrieve(tags_url, filename='/tmp/pkgtags.sqlite')
+
+ repomd = RepoMetadata(join(self.repo, arch, 'repodata'))
+ repomd.add('/tmp/pkgtags.sqlite')
+
+ except Exception, e:
+ log.exception(e)
+ log.error("There was a problem injecting pkgtags")
commit b48d79af011766da2630268f11f265babbf79581
Author: Luke Macken <lmacken(a)redhat.com>
Date: Wed Sep 15 11:43:13 2010 -0400
Use kitchen's to_bytes method when writing out our extended metadata.
Without this, our metadata.py explodes when trying to inject a binary sqlite
file
diff --git a/bodhi/modifyrepo.py b/bodhi/modifyrepo.py
index a4ef06f..eb5b5ce 100644
--- a/bodhi/modifyrepo.py
+++ b/bodhi/modifyrepo.py
@@ -30,6 +30,8 @@ import gzip
from hashlib import sha1 as sha
from xml.dom import minidom
+from kitchen.text.converters import to_bytes
+
from bodhi.exceptions import RepositoryNotFound
class RepoMetadata(object):
@@ -79,7 +81,7 @@ class RepoMetadata(object):
mdtype = mdname.split('.')[0]
destmd = os.path.join(self.repodir, mdname)
newmd = gzip.GzipFile(destmd, 'wb')
- newmd.write(md.encode('utf-8'))
+ newmd.write(to_bytes(md, errors='ignore',
non_string='passthru'))
newmd.close()
print "Wrote:", destmd
@@ -102,7 +104,7 @@ class RepoMetadata(object):
self._insert_element(data, 'timestamp',
text=str(os.stat(destmd).st_mtime))
self._insert_element(data, 'open-checksum', attrs={ 'type' :
'sha' },
- text=sha(md.encode('utf-8')).hexdigest())
+ text=sha(to_bytes(md, errors='ignore',
non_string='passthru')).hexdigest())
#print " type =", mdtype
#print " location =", 'repodata/' + mdname
commit 576a4401d330d25031504f07258cde79c16cb0e6
Author: Luke Macken <lmacken(a)redhat.com>
Date: Wed Sep 15 11:42:45 2010 -0400
Check for basestring instead of str in our metadata generator
diff --git a/bodhi/modifyrepo.py b/bodhi/modifyrepo.py
index cb39ec0..a4ef06f 100644
--- a/bodhi/modifyrepo.py
+++ b/bodhi/modifyrepo.py
@@ -63,7 +63,7 @@ class RepoMetadata(object):
if isinstance(metadata, minidom.Document):
md = metadata.toxml()
mdname = 'updateinfo.xml'
- elif isinstance(metadata, str):
+ elif isinstance(metadata, basestring):
if os.path.exists(metadata):
oldmd = file(metadata, 'r')
md = oldmd.read()
Show replies by date