On 05/13/2011 02:27 PM, Miroslav Suchý wrote:
On 05/13/2011 02:22 PM, Duncan Mac-Vicar P. wrote:
Would it make more sense for errata.py to be in the yum-rhn-plugin?
It fine with me. yum-rhn-plugin and rhn-client-tools require each other
(on rhel/fedora) anyway. So yes, it can be moved to yum-rhn-plugin.

For *SUSE I think we will have to override errata.py as zypper should
install the patch directly and not let the plugin resolve the package list.

Would it be acceptable upstream that we don't install errata.py from the
.spec file %if 0%{?suse_version} and supply it with
zypp-plugin-spacewalk (which contains package.py)?
That possible as well.

I slightly prefer the first option (move it to yum-rhn-plugin). But
choose yourself.

Can we still move errata.py to yum-rhn-plugin? We've gone with the second option until now, but this would make packaging cleaner.

-Ionuț
>From 8bfecb11e2f14b1f922bb2986693840e8dc77107 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ionu=C8=9B=20Ar=C8=9B=C4=83ri=C8=99i?= <iartar...@suse.cz>
Date: Tue, 18 Oct 2011 16:49:24 +0200
Subject: [PATCH] move errata.py action to the yum-rhn-plugin package

---
 client/rhel/rhn-client-tools/rhn-client-tools.spec |    1 -
 client/rhel/rhn-client-tools/src/actions/Makefile  |    2 +-
 client/rhel/rhn-client-tools/src/actions/errata.py |   87 --------------------
 client/rhel/yum-rhn-plugin/actions/errata.py       |   87 ++++++++++++++++++++
 4 files changed, 88 insertions(+), 89 deletions(-)
 delete mode 100644 client/rhel/rhn-client-tools/src/actions/errata.py
 create mode 100644 client/rhel/yum-rhn-plugin/actions/errata.py

diff --git a/client/rhel/rhn-client-tools/rhn-client-tools.spec b/client/rhel/rhn-client-tools/rhn-client-tools.spec
index 8d9f58b..51292fb 100644
--- a/client/rhel/rhn-client-tools/rhn-client-tools.spec
+++ b/client/rhel/rhn-client-tools/rhn-client-tools.spec
@@ -249,7 +249,6 @@ make -f Makefile.rhn-client-tools test
 # actions for rhn_check to run
 %{_datadir}/rhn/actions/__init__.*
 %{_datadir}/rhn/actions/hardware.*
-%{_datadir}/rhn/actions/errata.*
 %{_datadir}/rhn/actions/systemid.*
 %{_datadir}/rhn/actions/reboot.*
 %{_datadir}/rhn/actions/rhnsd.*
diff --git a/client/rhel/rhn-client-tools/src/actions/Makefile b/client/rhel/rhn-client-tools/src/actions/Makefile
index 2d72848..fec4eff 100644
--- a/client/rhel/rhn-client-tools/src/actions/Makefile
+++ b/client/rhel/rhn-client-tools/src/actions/Makefile
@@ -3,7 +3,7 @@
 # $Id$
 
 ACTIONS		= up2date_config hardware reboot \
-		  rhnsd systemid errata __init__
+		  rhnsd systemid __init__
 PYFILES		= $(addsuffix .py, $(ACTIONS))
 OBJECTS		= $(PYFILES) $(addsuffix .pyc, $(ACTIONS))
 
diff --git a/client/rhel/rhn-client-tools/src/actions/errata.py b/client/rhel/rhn-client-tools/src/actions/errata.py
deleted file mode 100644
index 49f1c65..0000000
--- a/client/rhel/rhn-client-tools/src/actions/errata.py
+++ /dev/null
@@ -1,87 +0,0 @@
-#!/usr/bin/python
-
-# Client code for Update Agent
-# Copyright (c) 1999-2002 Red Hat, Inc.  Distributed under GPL.
-#
-# Author: Adrian Likins <alik...@redhat.com
-#
-
-import sys
-sys.path.append("/usr/share/rhn/")
-from up2date_client import rhnserver
-from up2date_client import up2dateAuth
-from up2date_client import pkgUtils
-from actions import packages
-
-__rhnexport__ = [
-    'update']
-
-# action version we understand
-ACTION_VERSION = 2 
-
-def __getErrataInfo(errata_id):
-    s = rhnserver.RhnServer()
-    return s.errata.getErrataInfo(up2dateAuth.getSystemId(), errata_id)
-
-def update(errataidlist, cache_only=None):
-    packagelist = []
-
-    if type(errataidlist) not in [type([]), type(())]:
-        errataidlist = [ errataidlist ]
-        
-    for errataid in errataidlist:
-        tmpList = __getErrataInfo(errataid)
-        packagelist = packagelist + tmpList
-
-    current_packages_with_arch = {}
-    current_packages ={}
-    for p in pkgUtils.getInstalledPackageList(getArch=1):
-        current_packages_with_arch[p['name']+p['arch']] = p
-        current_packages[p['name']] = p
-
-    u = {}   
-    # only update packages that are currently installed
-    # since an "applicable errata" may only contain some packages
-    # that actually apply. aka kernel. Fun fun fun. 
-
-    if len(packagelist[0]) > 4:
-        # Newer sats send down arch, filter using name+arch
-        for p in packagelist:
-	    if current_packages_with_arch.has_key(p[0]+p[4]):
-	        u[p[0]+p[4]] = p
-	    elif current_packages_with_arch.has_key(p[0]+"noarch"):
-	        u[p[0]+p[4]] = p
-	    elif p[4] == "noarch" and current_packages.has_key(p[0]):
-	        u[p[0]] = p
-    else:
-        # 5.2 and older sats + hosted dont send arch
-        for p in packagelist:
-            if current_packages.has_key(p[0]):
-                u[p[0]] = p
-
-
-    # XXX: Fix me - once we keep all errata packages around,
-    # this is the WRONG thing to do - we want to keep the specific versions
-    # that the user has asked for.
-    packagelist = map(lambda a: u[a], u.keys())
-   
-    if packagelist == []:
-	data = {}
-	data['version'] = "0"
-	data['name'] = "errata.update.no_packages"
-	data['erratas'] = errataidlist
-	
-	return (39, 
-		"No packages from that errata are available", 
-		data)
- 
-    return packages.update(packagelist, cache_only)
-   
-
-def main():
-	print update([23423423])
-
-
-if __name__ == "__main__":
-	main()
- 
diff --git a/client/rhel/yum-rhn-plugin/actions/errata.py b/client/rhel/yum-rhn-plugin/actions/errata.py
new file mode 100644
index 0000000..49f1c65
--- /dev/null
+++ b/client/rhel/yum-rhn-plugin/actions/errata.py
@@ -0,0 +1,87 @@
+#!/usr/bin/python
+
+# Client code for Update Agent
+# Copyright (c) 1999-2002 Red Hat, Inc.  Distributed under GPL.
+#
+# Author: Adrian Likins <alik...@redhat.com
+#
+
+import sys
+sys.path.append("/usr/share/rhn/")
+from up2date_client import rhnserver
+from up2date_client import up2dateAuth
+from up2date_client import pkgUtils
+from actions import packages
+
+__rhnexport__ = [
+    'update']
+
+# action version we understand
+ACTION_VERSION = 2 
+
+def __getErrataInfo(errata_id):
+    s = rhnserver.RhnServer()
+    return s.errata.getErrataInfo(up2dateAuth.getSystemId(), errata_id)
+
+def update(errataidlist, cache_only=None):
+    packagelist = []
+
+    if type(errataidlist) not in [type([]), type(())]:
+        errataidlist = [ errataidlist ]
+        
+    for errataid in errataidlist:
+        tmpList = __getErrataInfo(errataid)
+        packagelist = packagelist + tmpList
+
+    current_packages_with_arch = {}
+    current_packages ={}
+    for p in pkgUtils.getInstalledPackageList(getArch=1):
+        current_packages_with_arch[p['name']+p['arch']] = p
+        current_packages[p['name']] = p
+
+    u = {}   
+    # only update packages that are currently installed
+    # since an "applicable errata" may only contain some packages
+    # that actually apply. aka kernel. Fun fun fun. 
+
+    if len(packagelist[0]) > 4:
+        # Newer sats send down arch, filter using name+arch
+        for p in packagelist:
+	    if current_packages_with_arch.has_key(p[0]+p[4]):
+	        u[p[0]+p[4]] = p
+	    elif current_packages_with_arch.has_key(p[0]+"noarch"):
+	        u[p[0]+p[4]] = p
+	    elif p[4] == "noarch" and current_packages.has_key(p[0]):
+	        u[p[0]] = p
+    else:
+        # 5.2 and older sats + hosted dont send arch
+        for p in packagelist:
+            if current_packages.has_key(p[0]):
+                u[p[0]] = p
+
+
+    # XXX: Fix me - once we keep all errata packages around,
+    # this is the WRONG thing to do - we want to keep the specific versions
+    # that the user has asked for.
+    packagelist = map(lambda a: u[a], u.keys())
+   
+    if packagelist == []:
+	data = {}
+	data['version'] = "0"
+	data['name'] = "errata.update.no_packages"
+	data['erratas'] = errataidlist
+	
+	return (39, 
+		"No packages from that errata are available", 
+		data)
+ 
+    return packages.update(packagelist, cache_only)
+   
+
+def main():
+	print update([23423423])
+
+
+if __name__ == "__main__":
+	main()
+ 
-- 
1.7.3.4

_______________________________________________
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel

Reply via email to