Discussion:
[Libstoragemgmt-devel] [PATCH 1/2] Plugin Test: Fix the sha-bang line of plugin_test.py
Gris Ge
2014-10-16 13:06:35 UTC
Permalink
* Changed the sha-bang line of plugin_test.py:
Old:
#!/bin/env python2
Now:
#!/usr/bin/env python2

Signed-off-by: Gris Ge <***@redhat.com>
---
test/plugin_test.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test/plugin_test.py b/test/plugin_test.py
index a79cc8f..2aa6c37 100755
--- a/test/plugin_test.py
+++ b/test/plugin_test.py
@@ -1,4 +1,4 @@
-#!/bin/env python2
+#!/usr/bin/env python2

# Copyright (C) 2013-2014 Red Hat, Inc.
# This library is free software; you can redistribute it and/or
--
1.8.3.1
Gris Ge
2014-10-16 13:06:36 UTC
Permalink
* This is based on rpm SPEC provided by Nick Wang <***@suse.com>.

* Use %if 0%{?suse_version} to use SuSE only setting.

* Replaced '/bin/systemctl' command with %systemd_xxx macros which was
provided by /usr/lib/rpm/macros.d/macros.systemd by systemd rpm.
# For SuSE, they use %service_xxx instead.

* Removed command "systemctl enable libstoragemgmt.service".
We should use systemd.preset instead.
For RHEL 7 and Fedora, systemd.preset enabled libstoragemgmt.service.
So nothing actual changed.

* Add %post script to libstoragemgmt-rest package.

* Make sure all folder is owned by certain rpm package by add lines like:
%dir %{python_sitelib}/lsm/plugin/sim

* Move 'libstoragemgmt-rest.service' systemd file to libstoragemgmt-rest
package. (Old RPM SPEC was including it in libstoragemgmt.rpm)

* Tested on OpenSuSE 13.1 x86_64

Signed-off-by: Gris Ge <***@redhat.com>
---
packaging/libstoragemgmt.spec.in | 193 ++++++++++++++++++++++++++-------------
1 file changed, 129 insertions(+), 64 deletions(-)

diff --git a/packaging/libstoragemgmt.spec.in b/packaging/libstoragemgmt.spec.in
index f84266c..ed4e495 100644
--- a/packaging/libstoragemgmt.spec.in
+++ b/packaging/libstoragemgmt.spec.in
@@ -5,6 +5,20 @@
%{?_with_rest_api: %global with_rest_api 1 }
%{?_without_rest_api: %global with_rest_api 0 }

+%if 0%{?suse_version} || 0%{?fedora} >= 15 || 0%{?rhel} >= 7
+%define with_systemd 1
+%endif
+
+%if 0%{?suse_version}
+%define _libexecdir %{_libdir}
+%endif
+
+%define udev_dir /lib
+# Later versions moved /lib to /usr/lib
+%if 0%{?fedora} >= 18 || 0%{?rhel} >= 7 || 0%{?suse_version}
+%define udev_dir /usr/lib
+%endif
+
Name: libstoragemgmt
Version: @VERSION@
Release: 1%{?dist}
@@ -15,13 +29,20 @@ URL: http://sourceforge.net/projects/libstoragemgmt/
Source0: http://sourceforge.net/projects/libstoragemgmt/files/libstoragemgmt-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
Requires: %{name}-python
-BuildRequires: autoconf automake libtool yajl-devel libxml2-devel check-devel perl
+BuildRequires: autoconf automake libtool libxml2-devel check-devel perl
BuildRequires: openssl-devel
BuildRequires: python-argparse
BuildRequires: glib2-devel
# Explicitly require gcc-c++ is for OBS
BuildRequires: gcc-c++
+%if 0%{?suse_version}
+BuildRequires: libyajl-devel
+BuildRequires: python-PyYAML
+%else
+# Fedora RHEL
+BuildRequires: yajl-devel
BuildRequires: PyYAML
+%endif

# For OBS only. OBS is still using RHEL/Centos 6.2 which does not have
# OrderedDict from python collection. Use EPEL6 python-ordereddict.
@@ -32,19 +53,11 @@ BuildRequires: python-ordereddict
BuildRequires: redhat-release
%endif

-%if 0%{?fedora} >= 15 || 0%{?rhel} >= 7
-BuildRequires: systemd-units
-Requires: initscripts
-Requires(post): systemd-units
-Requires(preun): systemd-units
-Requires(postun): systemd-units
-%endif
-
-# Later versions moved /lib to /usr/lib
-%if 0%{?fedora} >= 18 || 0%{?rhel} >= 7
-%define udev_dir /usr/lib
-%else
-%define udev_dir /lib
+%if 0%{?with_systemd}
+BuildRequires: systemd
+Requires(post): systemd
+Requires(preun): systemd
+Requires(postun): systemd
%endif

%description
@@ -83,8 +96,14 @@ well as python framework support and open source plug-ins written in python.
%package smis-plugin
Summary: Files for SMI-S generic array support for %{name}
Group: System Environment/Libraries
+%if 0%{?suse_version}
+BuildRequires: python-pywbem
+Requires: python-pywbem
+%else
BuildRequires: pywbem
-Requires: pywbem %{name}-python
+Requires: pywbem
+%endif
+Requires: %{name}-python
Requires: libstoragemgmt-python = %{version}-%{release}
BuildArch: noarch

@@ -96,8 +115,14 @@ support.
%package netapp-plugin
Summary: Files for NetApp array support for %{name}
Group: System Environment/Libraries
+%if 0%{?suse_version}
+BuildRequires: python-M2Crypto
+Requires: python-M2Crypto
+%else
BuildRequires: m2crypto
-Requires: m2crypto %{name}-python
+Requires: m2crypto
+%endif
+Requires: %{name}-python
Requires: libstoragemgmt-python = %{version}-%{release}
BuildArch: noarch

@@ -142,8 +167,17 @@ uevents generated by the kernel.
Summary: REST API daemon for %{name}
Group: System Environment/Daemons
Requires: %{name}%{?_isa} = %{version}-%{release}
-Requires: libmicrohttpd json-c
-BuildRequires: libmicrohttpd-devel json-c-devel
+BuildRequires: libmicrohttpd-devel
+%if 0%{?suse_version}
+BuildRequires: libjson-devel procps
+Requires: libjson0
+Requires: libmicrohttpd10
+%else
+# Fedora RHEL
+BuildRequires: json-c-devel
+Requires: json-c
+Requires: libmicrohttpd
+%endif

%description rest
the %{name}-rest package contains the http daemon for %{name} rest api.
@@ -168,7 +202,7 @@ rm -rf %{buildroot}
make install DESTDIR=%{buildroot}
find %{buildroot} -name '*.la' -exec rm -f {} ';'

-%if 0%{?fedora} >= 15 || 0%{?rhel} >= 7
+%if 0%{?with_systemd}
install -d -m755 %{buildroot}/%{_unitdir}
install -m644 packaging/daemon/libstoragemgmt.service \
%{buildroot}/%{_unitdir}/libstoragemgmt.service
@@ -194,15 +228,22 @@ install -m 644 tools/udev/90-scsi-ua.rules \
install -m 755 tools/udev/scan-scsi-target \
%{buildroot}/%{udev_dir}/udev/scan-scsi-target

+%if 0%{?with_rest_api}
+%if 0%{?with_systemd}
+%{__install} -m 0644 packaging/daemon/libstoragemgmt-rest.service \
+ %{buildroot}/%{_unitdir}/libstoragemgmt-rest.service
+%endif
+%endif
+
%clean
rm -rf %{buildroot}

-%check
-if ! make check
-then
- cat test/test-suite.log || true
- exit 1
-fi
+#%check
+#if ! make check
+#then
+# cat test/test-suite.log || true
+# exit 1
+#fi

%pre
getent group libstoragemgmt >/dev/null || groupadd -r libstoragemgmt
@@ -212,59 +253,74 @@ getent passwd libstoragemgmt >/dev/null || \

%post
/sbin/ldconfig
-if [ $1 -eq 1 ]; then
-%if 0%{?fedora} >= 15 || 0%{?rhel} >= 7
- /bin/systemctl enable libstoragemgmt.service >/dev/null 2>&1 || :
+%if 0%{?with_systemd}
+%if 0%{?suse_version}
+ %service_add_post libstoragemgmt.service
%else
- /sbin/chkconfig --add libstoragemgmtd
-%endif
-fi
-
-%if 0%{?with_rest_api}
-%preun rest
-if [ $1 -eq 0 ]; then
-%if 0%{?fedora} >= 15 || 0%{?rhel} >= 7
- # On uninstall (not upgrade), disable and stop the units
- /bin/systemctl --no-reload disable \
- libstoragemgmt-rest.service >/dev/null 2>&1 || :
- /bin/systemctl stop libstoragemgmt-rest.service >/dev/null 2>&1 || :
-%endif
-fi
-
-%postun rest
-/bin/systemctl daemon-reload >/dev/null 2>&1 || :
-if [ $1 -ge 1 ] ; then
-%if 0%{?fedora} >= 15 || 0%{?rhel} >= 7
- # On upgrade (not uninstall), optionally, restart the daemon
- /bin/systemctl try-restart libstoragemgmt-rest.service >/dev/null 2>&1 || :
+ %systemd_post libstoragemgmt.service
%endif
-fi
+%else
+ /sbin/chkconfig --add libstoragemgmtd
%endif

%preun
-if [ $1 -eq 0 ]; then
-%if 0%{?fedora} >= 15 || 0%{?rhel} >= 7
+%if 0%{?with_systemd}
# On uninstall (not upgrade), disable and stop the units
- /bin/systemctl --no-reload disable libstoragemgmt.service >/dev/null 2>&1 || :
- /bin/systemctl stop libstoragemgmt.service >/dev/null 2>&1 || :
+%if 0%{?suse_version}
+ %service_del_preun libstoragemgmt.service
+%else
+ %systemd_preun libstoragemgmt.service
+%endif
%else
/etc/rc.d/init.d/libstoragemgmtd stop > /dev/null 2>&1 || :
/sbin/chkconfig --del libstoragemgmtd
%endif
-fi

%postun
/sbin/ldconfig
-/bin/systemctl daemon-reload >/dev/null 2>&1 || :
-if [ $1 -ge 1 ] ; then
-%if 0%{?fedora} >= 15 || 0%{?rhel} >= 7
+%if 0%{?with_systemd}
# On upgrade (not uninstall), optionally, restart the daemon
- /bin/systemctl try-restart libstoragemgmt.service >/dev/null 2>&1 || :
+%if 0%{?suse_version}
+ %service_del_postun libstoragemgmt.service
+%else
+ %systemd_postun libstoragemgmt.service
+%endif
%else
#Restart the daemond
/etc/rc.d/init.d/libstoragemgmtd restart >/dev/null 2>&1 || :
%endif
-fi
+
+%if 0%{?with_rest_api}
+%post rest
+%if 0%{?with_systemd}
+%if 0%{?suse_version}
+ %service_add_post libstoragemgmt-rest.service
+%else
+ %systemd_post libstoragemgmt-rest.service
+%endif
+%endif
+
+%preun rest
+%if 0%{?with_systemd}
+ # On uninstall (not upgrade), disable and stop the units
+%if 0%{?suse_version}
+ %service_del_preun libstoragemgmt-rest.service
+%else
+ %systemd_preun libstoragemgmt-rest.service
+%endif
+%endif
+
+%postun rest
+%if 0%{?with_systemd}
+ # On upgrade (not uninstall), optionally, restart the daemon
+%if 0%{?suse_version}
+ %service_del_postun libstoragemgmt-rest.service
+%else
+ %systemd_postun libstoragemgmt-rest.service
+%endif
+%endif
+%endif
+

%files
%defattr(-,root,root,-)
@@ -276,14 +332,14 @@ fi
%{_bindir}/lsmd
%{_bindir}/simc_lsmplugin

-%if 0%{?fedora} >= 15 || 0%{?rhel} >= 7
-%{_unitdir}/*
+%if 0%{?with_systemd}
+%{_unitdir}/libstoragemgmt.service
%endif

%dir %attr(0755, libstoragemgmt, libstoragemgmt) %{_localstatedir}/run/lsm/
%dir %attr(0755, libstoragemgmt, libstoragemgmt) %{_localstatedir}/run/lsm/ipc

-%if 0%{?fedora} >= 15 || 0%{?rhel} >= 7
+%if 0%{?with_systemd}
%attr(0644, root, root) %{_tmpfilesdir}/%{name}.conf
%else
%attr(0755, root, root) /etc/rc.d/init.d/libstoragemgmtd
@@ -298,7 +354,9 @@ fi
%files python
%defattr(-,root,root,-)
#Python library files
+%dir %{python_sitelib}/lsm
%{python_sitelib}/lsm/__init__.*
+%dir %{python_sitelib}/lsm/external
%{python_sitelib}/lsm/external/*
%{python_sitelib}/lsm/_client.*
%{python_sitelib}/lsm/_common.*
@@ -307,10 +365,13 @@ fi
%{python_sitelib}/lsm/_pluginrunner.*
%{python_sitelib}/lsm/_transport.*
%{python_sitelib}/lsm/version.*
+%dir %{python_sitelib}/lsm/plugin
%{python_sitelib}/lsm/plugin/__init__.*
+%dir %{python_sitelib}/lsm/plugin/sim
%{python_sitelib}/lsm/plugin/sim/__init__.*
%{python_sitelib}/lsm/plugin/sim/simulator.*
%{python_sitelib}/lsm/plugin/sim/simarray.*
+%dir %{python_sitelib}/lsm/lsmcli
%{python_sitelib}/lsm/lsmcli/__init__.*
%{python_sitelib}/lsm/lsmcli/data_display.*
%{python_sitelib}/lsm/lsmcli/cmdline.*
@@ -318,6 +379,7 @@ fi

%files smis-plugin
%defattr(-,root,root,-)
+%dir %{python_sitelib}/lsm/plugin/smispy
%{python_sitelib}/lsm/plugin/smispy/__init__.*
%{python_sitelib}/lsm/plugin/smispy/smis.*
%{python_sitelib}/lsm/plugin/smispy/dmtf.*
@@ -331,6 +393,7 @@ fi

%files netapp-plugin
%defattr(-,root,root,-)
+%dir %{python_sitelib}/lsm/plugin/ontap
%{python_sitelib}/lsm/plugin/ontap/__init__.*
%{python_sitelib}/lsm/plugin/ontap/na.*
%{python_sitelib}/lsm/plugin/ontap/ontap.*
@@ -338,12 +401,14 @@ fi

%files targetd-plugin
%defattr(-,root,root,-)
+%dir %{python_sitelib}/lsm/plugin/targetd
%{python_sitelib}/lsm/plugin/targetd/__init__.*
%{python_sitelib}/lsm/plugin/targetd/targetd.*
%{_bindir}/targetd_lsmplugin

%files nstor-plugin
%defattr(-,root,root,-)
+%dir %{python_sitelib}/lsm/plugin/nstor
%{python_sitelib}/lsm/plugin/nstor/__init__.*
%{python_sitelib}/lsm/plugin/nstor/nstor.*
%{_bindir}/nstor_lsmplugin
@@ -357,7 +422,7 @@ fi
%files rest
%defattr(-,root,root,-)
%{_bindir}/lsm_restd
-%if 0%{?fedora} >= 15 || 0%{?rhel} >= 7
+%if 0%{?with_systemd}
%{_unitdir}/libstoragemgmt-rest.service
%endif
%endif
--
1.8.3.1
Gris Ge
2014-10-16 13:14:15 UTC
Permalink
Post by Gris Ge
* Use %if 0%{?suse_version} to use SuSE only setting.
* Replaced '/bin/systemctl' command with %systemd_xxx macros which was
provided by /usr/lib/rpm/macros.d/macros.systemd by systemd rpm.
# For SuSE, they use %service_xxx instead.
* Removed command "systemctl enable libstoragemgmt.service".
We should use systemd.preset instead.
For RHEL 7 and Fedora, systemd.preset enabled libstoragemgmt.service.
So nothing actual changed.
* Add %post script to libstoragemgmt-rest package.
%dir %{python_sitelib}/lsm/plugin/sim
* Move 'libstoragemgmt-rest.service' systemd file to libstoragemgmt-rest
package. (Old RPM SPEC was including it in libstoragemgmt.rpm)
* Tested on OpenSuSE 13.1 x86_64
Sorry. Please ignore this patch:
1. I forgot to enable 'make check'
2. It has many RPMLINT error and warning when building on openSUSE
in OBS.

I will work on V2.
--
Gris Ge
Loading...