Hi,

Am Freitag, 8. April 2011, 14:55:50 schrieb Michael Calmer:
> Hi,
> 
> here is the patch to build and run osad on openSUSE.
> 
> 0006-build-osad-on-SUSE.patch:
> - specfile work
> - add init script for SUSE
> - osad.py missed and import of the config module

I have splitted this one into 3 seperate patches.

-- 
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 14f2ca3fba16b6f017d023d985893332d585af8e Mon Sep 17 00:00:00 2001
From: Michael Calmer <m...@suse.de>
Date: Fri, 15 Apr 2011 13:16:04 +0200
Subject: [PATCH 03/13] provide config

---
 client/tools/osad/src/osad.py |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/client/tools/osad/src/osad.py b/client/tools/osad/src/osad.py
index 60b3307..662e641 100644
--- a/client/tools/osad/src/osad.py
+++ b/client/tools/osad/src/osad.py
@@ -22,6 +22,7 @@ from rhn import rpclib
 import random
 
 from up2date_client.config import initUp2dateConfig
+from up2date_client import config
 
 from rhn_log import set_debug_level, log_debug, die, set_logfile
 
-- 
1.7.3.4

From 5d912a755e7690e96a539c7e79b72850cc78da11 Mon Sep 17 00:00:00 2001
From: Michael Calmer <m...@suse.de>
Date: Thu, 14 Apr 2011 17:53:54 +0200
Subject: [PATCH 02/13] build osad on SUSE

- some packages are named different on SUSE
- the apache group is named different on SUSE
- BuildRequire sysconfig and syslog on SUSE to make chkconfig test
  work in OBS
- add init script for SUSE
- no selinux on SUSE
- add extra dirs in filelist to make filelist check work in OBS
---
 client/tools/osad/osad.spec      |   55 +++++++++++++++++++++++++++-
 client/tools/osad/prog.init.SUSE |   75 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 128 insertions(+), 2 deletions(-)
 create mode 100644 client/tools/osad/prog.init.SUSE

diff --git a/client/tools/osad/osad.spec b/client/tools/osad/osad.spec
index 38ad533..8fa9797 100644
--- a/client/tools/osad/osad.spec
+++ b/client/tools/osad/osad.spec
@@ -2,6 +2,14 @@
 %define rhnconf /etc/sysconfig/rhn
 %define client_caps_dir /etc/sysconfig/rhn/clientCaps.d
 
+%if 0%{?suse_version}
+%define apache_group www
+%define include_selinux_package 0
+%else
+%define apache_group apache
+%define include_selinux_package 1
+%endif
+
 Name: osad
 Summary: Open Source Architecture Daemon
 Group:   System Environment/Daemons
@@ -19,14 +27,26 @@ Requires: jabberpy
 %if 0%{?rhel} <= 5
 Requires: python-hashlib
 %endif
+%if 0%{?suse_version} >= 1140
+Requires: python-xml
+%else
 # This should have been required by rhnlib
 Requires: PyXML
+%endif
 Conflicts: osa-dispatcher < %{version}-%{release}
 Conflicts: osa-dispatcher > %{version}-%{release}
+%if !0%{?suse_version}
 Requires(post): chkconfig
 Requires(preun): chkconfig
 # This is for /sbin/service
 Requires(preun): initscripts
+%else
+# provides chkconfig on SUSE
+Requires(post): aaa_base
+Requires(preun): aaa_base
+# to make chkconfig test work during build
+BuildRequires: sysconfig syslog
+%endif
 
 %description 
 OSAD agent receives commands over jabber protocol from Spacewalk Server and
@@ -43,16 +63,23 @@ Requires: jabberpy
 Requires: lsof
 Conflicts: %{name} < %{version}-%{release}
 Conflicts: %{name} > %{version}-%{release}
+%if !0%{?suse_version}
 Requires(post): chkconfig
 Requires(preun): chkconfig
 # This is for /sbin/service
 Requires(preun): initscripts
+%else
+# provides chkconfig on SUSE
+Requires(post): aaa_base
+Requires(preun): aaa_base
+%endif
 
 %description -n osa-dispatcher
 OSA dispatcher is supposed to run on the Spacewalk server. It gets information
 from the Spacewalk server that some command needs to be execute on the client;
 that message is transported via jabber protocol to OSAD agent on the clients.
 
+%if 0%{?include_selinux_package}
 %package -n osa-dispatcher-selinux
 %define selinux_variants mls strict targeted
 %define selinux_policyver %(sed -e 's,.*selinux-policy-\\([^/]*\\)/.*,\\1,' /usr/share/selinux/devel/policyhelp 2> /dev/null)
@@ -79,13 +106,18 @@ Requires: osa-dispatcher
 
 %description -n osa-dispatcher-selinux
 SELinux policy module supporting osa-dispatcher.
+%endif
 
 %prep
 %setup -q
+%if 0%{?suse_version}
+cp prog.init.SUSE prog.init
+%endif
 
 %build
 make -f Makefile.osad all
 
+%if 0%{?include_selinux_package}
 %{__perl} -i -pe 'BEGIN { $VER = join ".", grep /^\d+$/, split /\./, "%{version}.%{release}"; } s!\@\@VERSION\@\@!$VER!g;' osa-dispatcher-selinux/%{modulename}.te
 for selinuxvariant in %{selinux_variants}
 do
@@ -93,12 +125,14 @@ do
     mv osa-dispatcher-selinux/%{modulename}.pp osa-dispatcher-selinux/%{modulename}.pp.${selinuxvariant}
     make -C osa-dispatcher-selinux NAME=${selinuxvariant} -f /usr/share/selinux/devel/Makefile clean
 done
+%endif
 
 %install
 rm -rf $RPM_BUILD_ROOT
 install -d $RPM_BUILD_ROOT%{rhnroot}
-make -f Makefile.osad install PREFIX=$RPM_BUILD_ROOT ROOT=%{rhnroot}
+make -f Makefile.osad install PREFIX=$RPM_BUILD_ROOT ROOT=%{rhnroot} INITDIR=%{_initrddir}
 
+%if 0%{?include_selinux_package}
 for selinuxvariant in %{selinux_variants}
   do
     install -d %{buildroot}%{_datadir}/selinux/${selinuxvariant}
@@ -117,6 +151,7 @@ install -p -m 644 osa-dispatcher-selinux/%{modulename}.if \
 # Install osa-dispatcher-selinux-enable which will be called in %post
 install -d %{buildroot}%{_sbindir}
 install -p -m 755 osa-dispatcher-selinux/osa-dispatcher-selinux-enable %{buildroot}%{_sbindir}/osa-dispatcher-selinux-enable
+%endif
 
 %clean
 rm -rf $RPM_BUILD_ROOT
@@ -143,6 +178,7 @@ if [ $1 = 0 ]; then
     /sbin/chkconfig --del osa-dispatcher
 fi
 
+%if 0%{?include_selinux_package}
 %post -n osa-dispatcher-selinux
 if /usr/sbin/selinuxenabled ; then
    %{_sbindir}/osa-dispatcher-selinux-enable
@@ -173,6 +209,7 @@ fi
 
 rpm -ql osa-dispatcher | xargs -n 1 /sbin/restorecon -rvi {}
 /sbin/restorecon -vvi /var/log/rhn/osa-dispatcher.log
+%endif
 
 %files
 %defattr(-,root,root)
@@ -191,6 +228,12 @@ rpm -ql osa-dispatcher | xargs -n 1 /sbin/restorecon -rvi {}
 %attr(755,root,root) %{_initrddir}/osad
 %doc LICENSE
 %doc PYTHON-LICENSES.txt
+%if 0%{?suse_version}
+# provide directories not owned by any package during build
+%dir %{rhnroot}
+%dir %{_sysconfdir}/sysconfig/rhn
+%dir %{_sysconfdir}/sysconfig/rhn/clientCaps.d
+%endif
 
 %files -n osa-dispatcher
 %defattr(-,root,root)
@@ -207,11 +250,18 @@ rpm -ql osa-dispatcher | xargs -n 1 /sbin/restorecon -rvi {}
 %config %{_sysconfdir}/rhn/tns_admin/osa-dispatcher
 %config(noreplace) %{_sysconfdir}/rhn/tns_admin/osa-dispatcher/sqlnet.ora
 %attr(755,root,root) %{_initrddir}/osa-dispatcher
-%attr(770,root,apache) %dir %{_var}/log/rhn/oracle
+%attr(770,root,%{apache_group}) %dir %{_var}/log/rhn/oracle
 %attr(770,root,root) %dir %{_var}/log/rhn/oracle/osa-dispatcher
 %doc LICENSE
 %doc PYTHON-LICENSES.txt
+%if 0%{?suse_version}
+%dir %{_sysconfdir}/rhn
+%dir %{_sysconfdir}/rhn/default
+%dir %{_sysconfdir}/rhn/tns_admin
+%dir %{_var}/log/rhn
+%endif
 
+%if 0%{?include_selinux_package}
 %files -n osa-dispatcher-selinux
 %defattr(-,root,root,0755)
 %doc osa-dispatcher-selinux/%{modulename}.fc
@@ -222,6 +272,7 @@ rpm -ql osa-dispatcher | xargs -n 1 /sbin/restorecon -rvi {}
 %doc LICENSE
 %doc PYTHON-LICENSES.txt
 %attr(0755,root,root) %{_sbindir}/osa-dispatcher-selinux-enable
+%endif
 
 %changelog
 * Wed Apr 13 2011 Jan Pazdziora 5.10.10-1
diff --git a/client/tools/osad/prog.init.SUSE b/client/tools/osad/prog.init.SUSE
new file mode 100644
index 0000000..c1662a3
--- /dev/null
+++ b/client/tools/osad/prog.init.SUSE
@@ -0,0 +1,75 @@
+#!/bin/sh
+#
+# @@PROG@@     This shell script starts the @@PROG@@ daemon
+#
+# chkconfig: - 81 04
+# description: @@PROG@@ is a daemon used by the Spacewalk
+#
+### BEGIN INIT INFO
+# Provides: @@PROG@@
+# Required-Start: $syslog $local_fs $network $remote_fs
+# Required-Stop: $syslog $local_fs $network $remote_fs
+# Should-Start: oracle-xe jabberd
+# Should-Stop:  oracle-xe jabberd
+# Default-Start:  3 5
+# Default-Stop: 0 1 6
+# Short-Description: This shell script starts the @@PROG@@ daemon
+# Description:       @@PROG@@ is a daemon used by the Spacewalk
+### END INIT INFO
+
+# Source function library.
+. /etc/rc.status
+
+prog="@@PROG@@"
+script="/usr/sbin/@@PROG@@"
+PIDFILE="/var/run/@@PROG@@.pid"
+
+[ -f $script ] || exit 0
+
+start() {
+    # Start daemon
+    echo -n "Starting $prog: "
+    startproc -p $PIDFILE $script --pid-file="$PIDFILE"
+    rc_status
+    touch /var/lock/subsys/$prog
+    rc_status -v
+}
+
+
+stop() {
+    # Stop daemon
+    echo -n "Shutting down $prog: "
+    rm -f /var/lock/subsys/$prog
+    killproc -p $PIDFILE $script
+    rc_status -v
+}
+
+# See how we were called.
+case "$1" in
+    start)
+        start
+        ;;
+    stop)
+        stop
+        ;;
+    restart|reload)
+        stop
+        start
+        ;;
+    status)
+        echo -n "Checking for service $prog: "
+        checkproc -p $PIDFILE $script
+        rc_status -v
+        ;;
+    condrestart|try-restart)
+        if [ -f /var/lock/subsys/$prog ]; then
+            stop
+            start
+        fi
+        ;;
+    *)
+        echo $"Usage: $0 {start|stop|restart|reload|status|condrestart}"
+        exit 1
+esac
+
+rc_exit
-- 
1.7.3.4

From 444d8944a20adff2a690a0158ea5940b52b70b6e Mon Sep 17 00:00:00 2001
From: Michael Calmer <m...@suse.de>
Date: Thu, 14 Apr 2011 17:56:07 +0200
Subject: [PATCH 04/13] require python-hashlib only on rhel and rhel <= 5

+ whitespace fix
---
 client/tools/osad/osad.spec |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/client/tools/osad/osad.spec b/client/tools/osad/osad.spec
index 8fa9797..6fa6aec 100644
--- a/client/tools/osad/osad.spec
+++ b/client/tools/osad/osad.spec
@@ -24,7 +24,7 @@ BuildRequires: python-devel
 Requires: python
 Requires: rhnlib >= 2.5.38
 Requires: jabberpy
-%if 0%{?rhel} <= 5
+%if 0%{?rhel} && 0%{?rhel} <= 5
 Requires: python-hashlib
 %endif
 %if 0%{?suse_version} >= 1140
@@ -48,7 +48,7 @@ Requires(preun): aaa_base
 BuildRequires: sysconfig syslog
 %endif
 
-%description 
+%description
 OSAD agent receives commands over jabber protocol from Spacewalk Server and
 commands are instantly executed.
 
-- 
1.7.3.4

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

Reply via email to