Hi,

I spend the last week to build the spacewalk client tools on openSUSE and 
create a project in openSUSE build service.

 http://download.opensuse.org/repositories/systemsmanagement:/spacewalk/

It is based on current git master and I want to provide you the patches.
Mainly I modified the specfile to get the different RPM names for SUSE in it.
Additionally the services got a SUSE specific specfile which is used, if the
package compiles on a SUSE distribution. 
If you prefer a LSB specfile which run on RedHat,Fedora and SUSE, please tell 
me. I will try to create one and I hope you can help to test them on Fedora 
and RedHat.

I will write a seperate mail for every package which hopefully helps to manage 
the answers and comments easier.

rhn-client-tools:

0001-get-hostname-on-not-RedHat-systems.patch:
On SUSE /etc/sysconfig/network is a directory and not a file which contains 
the hostname. So I added a check if it is a file and use the following code to 
find the hostname. Another special thing on SUSE is, that gethostbyname return 
only the (short) hostname, not the FQDN. Therefor I added a test, if hostname 
contains a ".". If not, find the hostname using the socket class.

0002-enhance-getOSVersionAndRelease-to-find-SUSE-distribu.patch:
Add code to make _getOSVerionAndRelease work on SUSE

0003-modify-spec-file-to-build-on-SUSE.patch:
Specfile work. Use SUSE rpm names and add some directories to the filelist 
which does not exist on SUSE or does not exist during build.

0004-Check-if-system_id-has-changed.patch:
up2dateAuth.readCachedLogin() seems not to check, if the systemid has changed 
and the cache file is invalid. 

-- 
Regards,

        Michael Calmer

--------------------------------------------------------------------------
Michael Calmer
SUSE LINUX Products GmbH, Maxfeldstr. 5, D-90409 Nuernberg
T: +49 (0) 911 74053 0
F: +49 (0) 911 74053575  - e-mail: michael.cal...@suse.com
--------------------------------------------------------------------------
SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nürnberg)
From 59d44ce683dbfc933baeec4bf92a4a415c225936 Mon Sep 17 00:00:00 2001
From: Michael Calmer <m...@suse.de>
Date: Mon, 4 Apr 2011 11:10:55 +0200
Subject: [PATCH 01/17] get hostname on not RedHat systems

Other Linux distributions may not have a file named /etc/sysconfig/network.
So we should check if it is a file and use the other methods to
find the hostname.
Additionally let's check if the found hostname contains a "." .
If not, let's find the hostname by Route.
---
 .../src/up2date_client/hardware.py                 |   13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/client/rhel/rhn-client-tools/src/up2date_client/hardware.py b/client/rhel/rhn-client-tools/src/up2date_client/hardware.py
index ca80e5b..f299bc2 100644
--- a/client/rhel/rhn-client-tools/src/up2date_client/hardware.py
+++ b/client/rhel/rhn-client-tools/src/up2date_client/hardware.py
@@ -429,13 +429,13 @@ def findHostByRoute():
         except:
             s.close()
             continue
-        
-    # Override hostname with the one in /etc/sysconfig/network 
+
+    # Override hostname with the one in /etc/sysconfig/network
     # for bz# 457953
-    
-    if os.access("/etc/sysconfig/network", os.R_OK):
+
+    if  os.path.isfile("/etc/sysconfig/network") and os.access("/etc/sysconfig/network", os.R_OK):
 	networkinfo = open("/etc/sysconfig/network", "r").readlines()
-	
+
         for info in networkinfo:
             if not len(info):
                 continue
@@ -489,10 +489,11 @@ def read_network():
 
 
     if netdict['hostname'] == 'localhost.localdomain' or \
+    "." not in netdict['hostname'] or \
     netdict['ipaddr'] == "127.0.0.1":
         hostname, ipaddr = findHostByRoute()
 
-        if netdict['hostname'] == 'localhost.localdomain':
+        if netdict['hostname'] == 'localhost.localdomain' or "." not in netdict['hostname']:
             netdict['hostname'] = hostname
         if netdict['ipaddr'] == "127.0.0.1":
             netdict['ipaddr'] = ipaddr
-- 
1.7.3.4

From 39a69260d0bafc78b3bb8c6dba7dd25031821893 Mon Sep 17 00:00:00 2001
From: Michael Calmer <m...@suse.de>
Date: Mon, 4 Apr 2011 11:12:46 +0200
Subject: [PATCH 03/17] modify spec file to build on SUSE

---
 client/rhel/rhn-client-tools/rhn-client-tools.spec |   45 +++++++++++++++++++-
 1 files changed, 44 insertions(+), 1 deletions(-)

diff --git a/client/rhel/rhn-client-tools/rhn-client-tools.spec b/client/rhel/rhn-client-tools/rhn-client-tools.spec
index dfe8f5f..0a061a2 100644
--- a/client/rhel/rhn-client-tools/rhn-client-tools.spec
+++ b/client/rhel/rhn-client-tools/rhn-client-tools.spec
@@ -22,17 +22,30 @@ Requires: python-ethtool >= 0.4
 %endif
 Requires: gnupg
 Requires: sh-utils
+%if 0%{?suse_version}
+Requires: dbus-1-python
+%else
 Requires: dbus-python
+%endif
 %if 0%{?fedora} > 12 || 0%{?rhel} > 5
 Requires: python-gudev
 Requires: python-hwdata
 %else
 Requires: hal >= 0.5.8.1-52
 %endif
+%if 0%{?suse_version}
+Requires: python-newt
+%else
 Requires: newt
+%endif
+Requires: logrotate
 Requires: python-dmidecode
 Requires: libxml2-python
+%if 0%{?suse_version}
+Requires: zypper
+%else
 Requires: yum
+%endif
 
 Conflicts: up2date < 5.0.0
 Conflicts: yum-rhn-plugin < 1.1.4-1
@@ -68,7 +81,11 @@ system to receive software updates from Red Hat Network or Spacewalk.
 Summary: Check for RHN actions
 Group: System Environment/Base
 Requires: %{name} = %{version}-%{release}
+%if 0%{?suse_version}
+Requires: zypp-plugin-spacewalk
+%else
 Requires: yum-rhn-plugin >= 1.1.2-1
+%endif
 
 %description -n rhn-check
 rhn-check polls a Red Hat Network or Spacewalk server to find and execute 
@@ -92,7 +109,11 @@ Group: System Environment/Base
 Requires: %{name} = %{version}-%{release}
 Requires: rhn-setup = %{version}-%{release}
 Requires: pam >= 0.72
+%if 0%{?suse_version}
+Requires: python-gnome python-gtk
+%else
 Requires: pygtk2 pygtk2-libglade gnome-python2 gnome-python2-canvas
+%endif
 Requires: usermode-gtk
 %if 0%{?fedora} > 9 || 0%{?rhel} > 5
 Requires: gnome-python2-gnome gnome-python2-bonobo
@@ -135,9 +156,10 @@ rm -rf $RPM_BUILD_ROOT%{_datadir}/firstboot/modules/rhn_*_*.*
 
 desktop-file-install --dir=${RPM_BUILD_ROOT}%{_datadir}/applications --vendor=rhn rhn_register.desktop
 %if 0%{?suse_version}
-%suse_update_desktop_file rhn_register System
+%suse_update_desktop_file -r rhn_register "Settings;System;SystemSetup;"
 %endif
 
+
 %find_lang %{name}
 
 %post
@@ -260,6 +282,12 @@ make -f Makefile.rhn-client-tools test
 
 %{_datadir}/setuptool/setuptool.d/99rhn_register
 
+%if 0%{?suse_version}
+%dir %{_sysconfdir}/security/console.apps
+%dir %{_datadir}/setuptool
+%dir %{_datadir}/setuptool/setuptool.d
+%endif
+
 %files -n rhn-setup-gnome
 %defattr(-,root,root,-)
 %{_datadir}/rhn/up2date_client/messageWindow.*
@@ -296,6 +324,21 @@ make -f Makefile.rhn-client-tools test
 %{_datadir}/rhn/up2date_client/firstboot/rhn_finish_gui.*
 %endif
 
+%if 0%{?suse_version}
+%dir %{_datadir}/icons/hicolor
+%dir %{_datadir}/icons/hicolor/16x16
+%dir %{_datadir}/icons/hicolor/16x16/apps
+%dir %{_datadir}/icons/hicolor/24x24
+%dir %{_datadir}/icons/hicolor/24x24/apps
+%dir %{_datadir}/icons/hicolor/32x32
+%dir %{_datadir}/icons/hicolor/32x32/apps
+%dir %{_datadir}/icons/hicolor/48x48
+%dir %{_datadir}/icons/hicolor/48x48/apps
+%dir %{_datadir}/rhn/up2date_client/firstboot
+%dir %{_datadir}/firstboot
+%dir %{_datadir}/firstboot/modules
+%endif
+
 %changelog
 * Wed Apr 06 2011 Simon Lukasik <sluka...@redhat.com> 1.4.12-1
 - Move code for enabling yum-rhn-plugin to separate module
-- 
1.7.3.4

From f5ca2ef2db6af2da626117f602210d2c603c1772 Mon Sep 17 00:00:00 2001
From: Michael Calmer <m...@suse.de>
Date: Mon, 4 Apr 2011 11:12:04 +0200
Subject: [PATCH 02/17] enhance getOSVersionAndRelease to find SUSE distributions

---
 .../src/up2date_client/up2dateUtils.py             |   16 +++++++++++-----
 1 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/client/rhel/rhn-client-tools/src/up2date_client/up2dateUtils.py b/client/rhel/rhn-client-tools/src/up2date_client/up2dateUtils.py
index fc33ad1..c3f0d0e 100644
--- a/client/rhel/rhn-client-tools/src/up2date_client/up2dateUtils.py
+++ b/client/rhel/rhn-client-tools/src/up2date_client/up2dateUtils.py
@@ -32,11 +32,17 @@ else:
             osVersionRelease = (h['name'], h['version'], h['release'])
             return osVersionRelease
         else:
-            raise up2dateErrors.RpmError(
-                "Could not determine what version of Red Hat Linux you "\
-                "are running.\nIf you get this error, try running \n\n"\
-                "\t\trpm --rebuilddb\n\n")
-
+            for h in ts.dbMatch('Providename', "distribution-release"):
+                osVersionRelease = (h['name'], version, h['release'])
+                # zypper requires a exclusive lock on the rpmdb. So we need
+                # to close it here.
+                ts.ts.closeDB()
+                return osVersionRelease
+            else:
+                raise up2dateErrors.RpmError(
+                    "Could not determine what version of Red Hat Linux you "\
+                    "are running.\nIf you get this error, try running \n\n"\
+                    "\t\trpm --rebuilddb\n\n")
 
 def getVersion():
     '''
-- 
1.7.3.4

From e17fd9d755d7da6c95780ee0f217df96ba065d1a Mon Sep 17 00:00:00 2001
From: Michael Calmer <m...@suse.de>
Date: Mon, 4 Apr 2011 11:14:46 +0200
Subject: [PATCH 04/17] Check if system_id has changed

---
 .../src/up2date_client/up2dateAuth.py              |   30 +++++++++++++------
 1 files changed, 20 insertions(+), 10 deletions(-)

diff --git a/client/rhel/rhn-client-tools/src/up2date_client/up2dateAuth.py b/client/rhel/rhn-client-tools/src/up2date_client/up2dateAuth.py
index d0d02f4..1725b72 100644
--- a/client/rhel/rhn-client-tools/src/up2date_client/up2dateAuth.py
+++ b/client/rhel/rhn-client-tools/src/up2date_client/up2dateAuth.py
@@ -24,10 +24,10 @@ def getSystemId():
     path = cfg["systemIdPath"]
     if not os.access(path, os.R_OK):
         return None
-    
+
     f = open(path, "r")
     ret = f.read()
-        
+
     f.close()
     return ret
 
@@ -43,10 +43,10 @@ def maybeUpdateVersion():
         return 0
 
     systemVer = up2dateUtils.getVersion()
-    
+
     if idVer != systemVer:
       s = rhnserver.RhnServer()
-    
+
       newSystemId = s.registration.upgrade_version(getSystemId(), systemVer)
 
       path = cfg["systemIdPath"]
@@ -90,7 +90,7 @@ def writeCachedLogin():
         return False
     data = {'time': time.time(),
             'loginInfo': loginInfo}
-    
+
     pcklDir = os.path.dirname(pcklAuthFileName)
     if not os.access(pcklDir, os.W_OK):
         try:
@@ -104,7 +104,7 @@ def writeCachedLogin():
     pickle.dump(data, pcklAuth)
     pcklAuth.close()
     expireTime = data['time'] + float(loginInfo['X-RHN-Auth-Expire-Offset'])
-    log.log_debug("Wrote pickled loginInfo at ", data['time'], " with expiration of ", 
+    log.log_debug("Wrote pickled loginInfo at ", data['time'], " with expiration of ",
             expireTime, " seconds.")
     return True
 
@@ -127,13 +127,23 @@ def readCachedLogin():
         pcklAuth.close()
         return False
     pcklAuth.close()
+    # Check if system_id has changed
+    try:
+        idVer = rpclib.xmlrpclib.loads(getSystemId())[0][0]['system_id']
+        cidVer = "ID-%s" % data['loginInfo']['X-RHN-Server-Id']
+        if idVer != cidVer:
+	    log.log_me("1 %s" % idVer)
+	    log.log_me("2 %s" % cidVer)
+	    return False
+    except:
+	pass
     createdTime = data['time']
     li = data['loginInfo']
     currentTime = time.time()
     expireTime = createdTime + float(li['X-RHN-Auth-Expire-Offset'])
-    #Check if expired, offset is stored in "X-RHN-Auth-Expire-Offset" 
+    #Check if expired, offset is stored in "X-RHN-Auth-Expire-Offset"
     log.log_debug("Checking pickled loginInfo, currentTime=", currentTime,
-            ", createTime=", createdTime, ", expire-offset=", 
+            ", createTime=", createdTime, ", expire-offset=",
             float(li['X-RHN-Auth-Expire-Offset']))
     if (currentTime > expireTime):
         log.log_debug("Pickled loginInfo has expired, created = %s, expire = %s." \
@@ -179,12 +189,12 @@ def login(systemId=None, forceUpdate=False):
 
     if not systemId:
         return None
-        
+
     maybeUpdateVersion()
     log.log_me("logging into up2date server")
 
     li = server.up2date.login(systemId)
-    
+
     # figure out if were missing any needed caps
     server.capabilities.validate()
     _updateLoginInfo(li) #update global var, loginInfo
-- 
1.7.3.4

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

Reply via email to