Skip to content

Commit

Permalink
Make the yumconfig configurable.
Browse files Browse the repository at this point in the history
  • Loading branch information
ralphbean committed Nov 20, 2014
1 parent d953d31 commit b8a25f5
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 9 deletions.
1 change: 1 addition & 0 deletions MANIFEST.in
@@ -1,3 +1,4 @@
graft fedmsg.d
include *.rst
include LICENSE
include yum-config
2 changes: 2 additions & 0 deletions fedmsg.d/hotness-example.py
Expand Up @@ -50,6 +50,8 @@

'hotness.pkgdb_url': 'https://admin.fedoraproject.org/pkgdb/api',

'hotness.yumconfig': './yum-config',

"hotness.cache": {
"backend": "dogpile.cache.dbm",
"expiration_time": 300,
Expand Down
7 changes: 4 additions & 3 deletions hotness/consumers.py
Expand Up @@ -82,8 +82,8 @@ def __init__(self, hub):
if not hasattr(hotness.cache.cache, 'backend'):
hotness.cache.cache.configure(**self.config['hotness.cache'])

self.repoid = self.config.get('hotness.repoid')
self.log.info("Using hotness.repoid=%r" % self.repoid)
self.yumconfig = self.config.get('hotness.yumconfig')
self.log.info("Using hotness.yumconfig=%r" % self.yumconfig)
self.distro = self.config.get('hotness.distro', 'Fedora')
self.log.info("Using hotness.distro=%r" % self.distro)

Expand Down Expand Up @@ -132,7 +132,8 @@ def handle_anitya(self, msg):
return

# Is it new to us?
version, release = hotness.repository.get_version(package, self.repoid)
fname = self.yumconfig
version, release = hotness.repository.get_version(package, fname)
upstream = msg['msg']['upstream_version']
self.log.info("Comparing upstream %s against repo %s-%s" % (
upstream, version, release))
Expand Down
10 changes: 4 additions & 6 deletions hotness/repository.py
Expand Up @@ -5,23 +5,21 @@

log = logging.getLogger('fedmsg')

def get_version(package_name, repoid):
nvr_dict = build_nvr_dict(repoid)
def get_version(package_name, yumconfig):
nvr_dict = build_nvr_dict(yumconfig)
return nvr_dict[package_name]


@cache.cache_on_arguments()
def build_nvr_dict(repoid):
def build_nvr_dict(yumconfig):
cmdline = ["/usr/bin/repoquery",
"--config", yumconfig,
"--quiet",
"--archlist=src",
"--all",
"--qf",
"%{name}\t%{version}\t%{release}"]

if repoid:
cmdline.append('--repoid=%s' % repoid)

log.info("Running %r" % ' '.join(cmdline))
repoquery = subprocess.Popen(cmdline, stdout=subprocess.PIPE)
(stdout, stderr) = repoquery.communicate()
Expand Down
22 changes: 22 additions & 0 deletions yum-config
@@ -0,0 +1,22 @@
[main]
# These are values for development. store the cache in cwd.
cachedir=./yumcache/$basearch/$releasever
keepcache=0
debuglevel=2
logfile=./yum.log
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
installonly_limit=3

# It is usually 90m. We'll expire often..
metadata_expire=10m

# We have only one repo to query...
[rawhide-source]
name=Rawhide Source
failovermethod=priority
baseurl=http://dl.fedoraproject.org/pub/fedora/linux/development/rawhide/source/SRPMS/
enabled=1
gpgcheck=0

0 comments on commit b8a25f5

Please sign in to comment.