Attached is a patch I wrote that allows the check_update() command to
take an optional filter.
I originally wrote this because we build packages with a specific prefix
and I only wanted those packages to be returned from the func command.
---------------
Regards,
Alex Wood
--
Software Engineer
Red Hat
919.754.4445
>From 6531c593484575163877e9f287458b538e2909ae Mon Sep 17 00:00:00 2001
From: Alex Wood <awood@xxxxxxxxxx>
Date: Tue, 22 Jul 2008 19:10:33 -0400
Subject: [PATCH] Adding the ability to search for yum updates to specific packages
---
func/minion/modules/yumcmd.py | 24 +++++++++++++++++++++---
1 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/func/minion/modules/yumcmd.py b/func/minion/modules/yumcmd.py
index f952372..3a91baa 100644
--- a/func/minion/modules/yumcmd.py
+++ b/func/minion/modules/yumcmd.py
@@ -1,5 +1,6 @@
# Copyright 2007, Red Hat, Inc
# James Bowes <jbowes@xxxxxxxxxx>
+# Alex Wood <awood@xxxxxxxxxx>
#
# This software may be freely redistributed under the terms of the GNU
# general public license.
@@ -40,11 +41,28 @@ class Yum(func_module.FuncModule):
ayum.doUnlock()
return True
- def check_update(self, repo=None):
- """Returns a list of packages due to be updated"""
+ def check_update(self, filter=[], repo=None):
+ """Returns a list of packages due to be updated
+ You can specify a filter using the standard yum wildcards
+ """
+ # parsePackages expects a list and doesn't react well if you send in a plain string with a wildcard in it
+ # (the string is broken into a list and one of the list elements is "*" which matches every package)
+ if type(filter) not in [list, tuple]:
+ filter = [filter]
+
ayum = yum.YumBase()
ayum.doConfigSetup()
ayum.doTsSetup()
if repo is not None:
ayum.repos.enableRepo(repo)
- return map(str, ayum.doPackageLists('updates').updates)
+
+ pkg_list = ayum.doPackageLists('updates').updates
+
+ if filter:
+ # exactmatch are all the packages with exactly the same name as one in the filter list
+ # matched are all the packages that matched under any wildcards
+ # unmatched are all the items in the filter list that didn't match anything
+ exactmatch, matched, unmatched = yum.packages.parsePackages(pkg_list, filter)
+ pkg_list = exactmatch + matched
+
+ return map(str, pkg_list)
--
1.5.4.1
_______________________________________________
Func-list mailing list
Func-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/func-list