Discussion:
[Libstoragemgmt-devel] [Draft PATCH] RPM SPEC: Add OpenSuSE support.
Gris Ge
2014-10-17 10:23:25 UTC
Permalink
* Please don't commit this patch until we got feedback from openSuSE user.

* 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)

* On openSuSE, the package name has been changed due to their share lib naming
policy[1]:
libstoragemgmt-devel
libstoragemgmt-udev
libstoragemgmt1
libstoragemgmt1-python
libstoragemgmt1-smis-plugin
libstoragemgmt1-netapp-plugin
libstoragemgmt1-targetd-plugin
libstoragemgmt1-nstor-plugin
libstoragemgmt1-rest

* Run fdupes on OpenSuSE to create soft link against duplicated
python .pyo and .pyc files.
For Fedora, it will conflict with brp-python-bytecompile.
For RHEL, fdupes is in EPEL repo.

* Move '/var/run/lsm' folder creation to %pre script as a rpm package should
not own a ghost file in /var/run which might be mounted as tmpfs.

* Add %post and %postun scripts into plugin package to 'try-restart'
the libstoragemgmt.service when new install or package removal.
This is only for systemd as RHEL 6 does not have 'try-restart' feature yet.

* On openSuSE, use 'LGPL-2.1+' string due to openSuSE requirements.

* Compile pass on OBS for Fedora 19/20, RHEL 6/7, OpenSuSE 13.1/13.2

* Manually tested via 'lsmcli lp' against simulator C and python plugin,
smispy plugin, ontap plugin and targetd plugin on these OS:
* RHEL 6.5 x86_64
* RHEL 7.0 x86_64
* Fedora 20 x86_64
* OpenSuSE 13.1 x86_64

[1] https://en.opensuse.org/openSUSE:Shared_library_packaging_policy

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

diff --git a/packaging/libstoragemgmt.spec.in b/packaging/libstoragemgmt.spec.in
index f84266c..5f59439 100644
--- a/packaging/libstoragemgmt.spec.in
+++ b/packaging/libstoragemgmt.spec.in
@@ -1,50 +1,78 @@
-%bcond_without rest_api
+%bcond_with rest_api

# Use one-line macro for OBS workaround:
# https://bugzilla.novell.com/show_bug.cgi?id=864323
%{?_with_rest_api: %global with_rest_api 1 }
%{?_without_rest_api: %global with_rest_api 0 }

+%define libsoname libstoragemgmt
+
+%if 0%{?suse_version} || 0%{?fedora} >= 15 || 0%{?rhel} >= 7
+%define with_systemd 1
+%endif
+
+%global libstoragemgmt libstoragemgmt
+
+%if 0%{?suse_version}
+%define _libexecdir %{_libdir}
+%global libstoragemgmt libstoragemgmt1
+%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
+
+%if 0%{?suse_version}
+# Use fdupes on openSuSE.
+# For Fedora, it will conflict with brp-python-bytecompile
+# For RHEL, fdupes is in EPEL repo.
+%define do_fdupes 1
+%endif
+
Name: libstoragemgmt
Version: @VERSION@
Release: 1%{?dist}
Summary: Storage array management library
Group: System Environment/Libraries
+%if 0%{?suse_version}
+License: LGPL-2.1+
+%else
License: LGPLv2+
+%endif
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
+Requires: %{libstoragemgmt}-python
+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.
-# These line is only for OBS SPEC parser, not for rpmbuild.
-%if 0%{?centos_version} == 600 || 0%{?rhel_version} == 600
-BuildRequires: python-ordereddict
-# redhat-release was not included in OBS. It provides %{rhel} macro.
-BuildRequires: redhat-release
+%if 0%{?do_fdupes}
+BuildRequires: fdupes
%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
+%if 0%{?rhel} == 6
+BuildRequires: python-ordereddict
%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
@@ -54,6 +82,20 @@ arrays. The library includes a command line interface for interactive use and
scripting (command lsmcli). The library also has a daemon that is used for
executing plug-ins in a separate process (lsmd).

+%if %{libstoragemgmt} != %{name}
+%package -n %{libstoragemgmt}
+Summary: Storage array management library
+Group: System Environment/Libraries
+Requires: %{libstoragemgmt}-python
+
+%description -n %{libstoragemgmt}
+The libStorageMgmt library will provide a vendor agnostic open source storage
+application programming interface (API) that will allow management of storage
+arrays. The library includes a command line interface for interactive use and
+scripting (command lsmcli). The library also has a daemon that is used for
+executing plug-ins in a separate process (lsmd).
+%endif
+
%package devel
Summary: Development files for %{name}
Group: Development/Libraries
@@ -63,10 +105,10 @@ Requires: %{name}%{?_isa} = %{version}-%{release}
The %{name}-devel package contains libraries and header files for
developing applications that use %{name}.

-%package python
-Summary: Python client libraries and plug-in support for %{name}
+%package -n %{libstoragemgmt}-python
+Summary: Python client libraries and plug-in support for %{libstoragemgmt}
Group: System Environment/Libraries
-Requires: %{name} = %{version}-%{release}
+Requires: %{libstoragemgmt} = %{version}-%{release}
BuildArch: noarch
Requires: python-argparse
%if 0%{?rhel} == 6
@@ -75,62 +117,70 @@ Requires: python-argparse
Requires: python-ordereddict
%endif

-%description python
-The %{name}-python package contains python client libraries as
+%description -n %{libstoragemgmt}-python
+The %{libstoragemgmt}-python package contains python client libraries as
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}
+%package -n %{libstoragemgmt}-smis-plugin
+Summary: Files for SMI-S generic array support for %{libstoragemgmt}
Group: System Environment/Libraries
+%if 0%{?suse_version}
+BuildRequires: python-pywbem
+Requires: python-pywbem
+%else
BuildRequires: pywbem
-Requires: pywbem %{name}-python
-Requires: libstoragemgmt-python = %{version}-%{release}
+Requires: pywbem
+%endif
+Requires: %{libstoragemgmt}-python = %{version}-%{release}
BuildArch: noarch

-%description smis-plugin
-The %{name}-smis-plugin package contains plug-in for generic SMI-S array
-support.
+%description -n %{libstoragemgmt}-smis-plugin
+The %{libstoragemgmt}-smis-plugin package contains plug-in for generic SMI-S
+array support.


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

-%description netapp-plugin
-The %{name}-netapp-plugin package contains plug-in for NetApp array
+%description -n %{libstoragemgmt}-netapp-plugin
+The %{libstoragemgmt}-netapp-plugin package contains plug-in for NetApp array
support.


-%package targetd-plugin
-Summary: Files for targetd array support for %{name}
+%package -n %{libstoragemgmt}-targetd-plugin
+Summary: Files for targetd array support for %{libstoragemgmt}
Group: System Environment/Libraries
-Requires: %{name}-python
-Requires: libstoragemgmt-python = %{version}-%{release}
+Requires: %{libstoragemgmt}-python = %{version}-%{release}
BuildArch: noarch

-%description targetd-plugin
-The %{name}-targetd-plugin package contains plug-in for targetd array
-support.
+%description -n %{libstoragemgmt}-targetd-plugin
+The %{libstoragemgmt}-targetd-plugin package contains plug-in for targetd
+array support.


-%package nstor-plugin
-Summary: Files for NexentaStor array support for %{name}
+%package -n %{libstoragemgmt}-nstor-plugin
+Summary: Files for NexentaStor array support for %{libstoragemgmt}
Group: System Environment/Libraries
-Requires: %{name}-python
-Requires: libstoragemgmt-python = %{version}-%{release}
+Requires: %{libstoragemgmt}-python = %{version}-%{release}
BuildArch: noarch

-%description nstor-plugin
-The %{name}-nstor-plugin package contains plug-in for NexentaStor array
-support.
+%description -n %{libstoragemgmt}-nstor-plugin
+The %{libstoragemgmt}-nstor-plugin package contains plug-in for NexentaStor
+array support.

%package udev
-Summary: udev files for %{name}
+Summary: Udev files for %{name}
Group: System Environment/Base

%description udev
@@ -138,15 +188,25 @@ The %{name}-udev package contains udev rules and helper utilities for
uevents generated by the kernel.

%if 0%{?with_rest_api}
-%package rest
-Summary: REST API daemon for %{name}
+%package -n %{libstoragemgmt}-rest
+Summary: REST API daemon for %{libstoragemgmt}
Group: System Environment/Daemons
-Requires: %{name}%{?_isa} = %{version}-%{release}
-Requires: libmicrohttpd json-c
-BuildRequires: libmicrohttpd-devel json-c-devel
+Requires: %{libstoragemgmt}%{?_isa} = %{version}-%{release}
+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.
+%description -n %{libstoragemgmt}-rest
+the %{libstoragemgmt}-rest package contains the http daemon for
+%{libstoragemgmt} rest api.
%endif

%prep
@@ -168,7 +228,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
@@ -184,9 +244,6 @@ install packaging/daemon/libstoragemgmtd \
%{buildroot}/etc/rc.d/init.d/libstoragemgmtd
%endif

-#Need these to exist at install so we can start the daemon
-mkdir -p %{buildroot}%{_localstatedir}/run/lsm/ipc
-
#Files for udev handling
mkdir -p %{buildroot}/%{udev_dir}/udev/rules.d
install -m 644 tools/udev/90-scsi-ua.rules \
@@ -194,6 +251,18 @@ 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
+
+# Deduplication
+%if 0%{?do_fdupes}
+%fdupes -s %{buildroot}/%{python_sitelib}/lsm
+%endif
+
%clean
rm -rf %{buildroot}

@@ -204,69 +273,149 @@ then
exit 1
fi

-%pre
-getent group libstoragemgmt >/dev/null || groupadd -r libstoragemgmt
-getent passwd libstoragemgmt >/dev/null || \
- useradd -r -g libstoragemgmt -d /var/run/lsm -s /sbin/nologin \
- -c "daemon account for libstoragemgmt" libstoragemgmt
+%pre -n %{libstoragemgmt}
+if [ $1 -eq 1 ]; then
+ #New install.
+ getent group libstoragemgmt >/dev/null || groupadd -r libstoragemgmt
+ getent passwd libstoragemgmt >/dev/null || \
+ useradd -r -g libstoragemgmt -d %{_localstatedir}/run/lsm \
+ -s /sbin/nologin \
+ -c "daemon account for libstoragemgmt" libstoragemgmt
+ #Need these to exist at install so we can start the daemon
+ mkdir -p %{_localstatedir}/run/lsm/ipc
+ chmod 0755 %{_localstatedir}/run/lsm
+ chmod 0755 %{_localstatedir}/run/lsm/ipc
+ chown libstoragemgmt:libstoragemgmt %{_localstatedir}/run/lsm
+ chown libstoragemgmt:libstoragemgmt %{_localstatedir}/run/lsm/ipc
+fi

-%post
+%post -n %{libstoragemgmt}
/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
+ %systemd_post libstoragemgmt.service
%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 || :
+%else
+ /sbin/chkconfig --add libstoragemgmtd
%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 || :
-%endif
-fi
+%preun -n %{libstoragemgmt}
+%if 0%{?with_systemd}
+%if 0%{?suse_version}
+ %service_del_preun libstoragemgmt.service
+%else
+ %systemd_preun libstoragemgmt.service
%endif
-
-%preun
-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.service >/dev/null 2>&1 || :
- /bin/systemctl stop libstoragemgmt.service >/dev/null 2>&1 || :
%else
/etc/rc.d/init.d/libstoragemgmtd stop > /dev/null 2>&1 || :
/sbin/chkconfig --del libstoragemgmtd
%endif
-fi

-%postun
+%postun -n %{libstoragemgmt}
/sbin/ldconfig
-/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.service >/dev/null 2>&1 || :
+%if 0%{?with_systemd}
+%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
+
+%if 0%{?with_rest_api}
+%post -n %{libstoragemgmt}-rest
+%if 0%{?with_systemd}
+%if 0%{?suse_version}
+ %service_add_post libstoragemgmt-rest.service
+%else
+ %systemd_post libstoragemgmt-rest.service
+%endif
+%endif
+
+%preun -n %{libstoragemgmt}-rest
+%if 0%{?with_systemd}
+%if 0%{?suse_version}
+ %service_del_preun libstoragemgmt-rest.service
+%else
+ %systemd_preun libstoragemgmt-rest.service
+%endif
+%endif
+
+%postun -n %{libstoragemgmt}-rest
+%if 0%{?with_systemd}
+%if 0%{?suse_version}
+ %service_del_postun libstoragemgmt-rest.service
+%else
+ %systemd_postun libstoragemgmt-rest.service
+%endif
+%endif
+%endif
+
+# Need to restart lsmd if plugin is new installed or removed.
+%post -n %{libstoragemgmt}-smis-plugin
+if [ $1 -eq 1 ]; then
+ # New install.
+ /usr/bin/systemctl try-restart libstoragemgmt.service \
+ >/dev/null 2>&1 || :
+fi
+
+%postun -n %{libstoragemgmt}-smis-plugin
+if [ $1 -eq 0 ]; then
+ # Remove
+ /usr/bin/systemctl try-restart libstoragemgmt.service \
+ >/dev/null 2>&1 || :
+fi
+
+# Need to restart lsmd if plugin is new installed or removed.
+%post -n %{libstoragemgmt}-netapp-plugin
+if [ $1 -eq 1 ]; then
+ # New install.
+ /usr/bin/systemctl try-restart libstoragemgmt.service \
+ >/dev/null 2>&1 || :
+fi
+
+%postun -n %{libstoragemgmt}-netapp-plugin
+if [ $1 -eq 0 ]; then
+ # Remove
+ /usr/bin/systemctl try-restart libstoragemgmt.service \
+ >/dev/null 2>&1 || :
fi

-%files
+# Need to restart lsmd if plugin is new installed or removed.
+%post -n %{libstoragemgmt}-targetd-plugin
+if [ $1 -eq 1 ]; then
+ # New install.
+ /usr/bin/systemctl try-restart libstoragemgmt.service \
+ >/dev/null 2>&1 || :
+fi
+
+%postun -n %{libstoragemgmt}-targetd-plugin
+if [ $1 -eq 0 ]; then
+ # Remove
+ /usr/bin/systemctl try-restart libstoragemgmt.service \
+ >/dev/null 2>&1 || :
+fi
+
+# Need to restart lsmd if plugin is new installed or removed.
+%post -n %{libstoragemgmt}-nstor-plugin
+if [ $1 -eq 1 ]; then
+ # New install.
+ /usr/bin/systemctl try-restart libstoragemgmt.service \
+ >/dev/null 2>&1 || :
+fi
+
+%postun -n %{libstoragemgmt}-nstor-plugin
+if [ $1 -eq 0 ]; then
+ # Remove
+ /usr/bin/systemctl try-restart libstoragemgmt.service \
+ >/dev/null 2>&1 || :
+fi
+
+%files -n %{libstoragemgmt}
%defattr(-,root,root,-)
%doc README COPYING.LIB
%{_mandir}/man1/lsmcli.1*
@@ -276,14 +425,11 @@ 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
@@ -295,10 +441,12 @@ fi
%{_libdir}/*.so
%{_libdir}/pkgconfig/libstoragemgmt.pc

-%files python
+%files -n %{libstoragemgmt}-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,17 +455,21 @@ 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.*
%{_bindir}/sim_lsmplugin

-%files smis-plugin
+%files -n %{libstoragemgmt}-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.*
@@ -329,21 +481,24 @@ fi
%{python_sitelib}/lsm/plugin/smispy/smis_disk.*
%{_bindir}/smispy_lsmplugin

-%files netapp-plugin
+%files -n %{libstoragemgmt}-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.*
%{_bindir}/ontap_lsmplugin

-%files targetd-plugin
+%files -n %{libstoragemgmt}-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
+%files -n %{libstoragemgmt}-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
@@ -354,10 +509,10 @@ fi
%{udev_dir}/udev/rules.d/90-scsi-ua.rules

%if 0%{?with_rest_api}
-%files rest
+%files -n %{libstoragemgmt}-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
Nick Wang
2014-10-18 03:26:04 UTC
Permalink
Hi Gris,

Thanks a lot for the merge.
I will have a look at is and test on openSUSE to make it suitable for redhat/suse.

Best regards,
Nick
Post by Gris Ge
在 6:23 下午 的 10/17/2014 上,在讯息
<1413541406-24698-1-git-send-email-***@redhat.com> 中,Gris Ge <***@redhat.com>
写入:
Post by Gris Ge
* Please don't commit this patch until we got feedback from openSuSE user.
* 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)
* On openSuSE, the package name has been changed due to their share lib naming
libstoragemgmt-devel
libstoragemgmt-udev
libstoragemgmt1
libstoragemgmt1-python
libstoragemgmt1-smis-plugin
libstoragemgmt1-netapp-plugin
libstoragemgmt1-targetd-plugin
libstoragemgmt1-nstor-plugin
libstoragemgmt1-rest
* Run fdupes on OpenSuSE to create soft link against duplicated
python .pyo and .pyc files.
For Fedora, it will conflict with brp-python-bytecompile.
For RHEL, fdupes is in EPEL repo.
* Move '/var/run/lsm' folder creation to %pre script as a rpm package should
not own a ghost file in /var/run which might be mounted as tmpfs.
* Add %post and %postun scripts into plugin package to 'try-restart'
the libstoragemgmt.service when new install or package removal.
This is only for systemd as RHEL 6 does not have 'try-restart' feature yet.
* On openSuSE, use 'LGPL-2.1+' string due to openSuSE requirements.
* Compile pass on OBS for Fedora 19/20, RHEL 6/7, OpenSuSE 13.1/13.2
* Manually tested via 'lsmcli lp' against simulator C and python plugin,
* RHEL 6.5 x86_64
* RHEL 7.0 x86_64
* Fedora 20 x86_64
* OpenSuSE 13.1 x86_64
[1] https://en.opensuse.org/openSUSE:Shared_library_packaging_policy
---
packaging/libstoragemgmt.spec.in | 399 +++++++++++++++++++++++++++------------
1 file changed, 277 insertions(+), 122 deletions(-)
diff --git a/packaging/libstoragemgmt.spec.in
b/packaging/libstoragemgmt.spec.in
index f84266c..5f59439 100644
--- a/packaging/libstoragemgmt.spec.in
+++ b/packaging/libstoragemgmt.spec.in
@@ -1,50 +1,78 @@
-%bcond_without rest_api
+%bcond_with rest_api
# https://bugzilla.novell.com/show_bug.cgi?id=864323
%{?_with_rest_api: %global with_rest_api 1 }
%{?_without_rest_api: %global with_rest_api 0 }
+%define libsoname libstoragemgmt
+
+%if 0%{?suse_version} || 0%{?fedora} >= 15 || 0%{?rhel} >= 7
+%define with_systemd 1
+%endif
+
+%global libstoragemgmt libstoragemgmt
+
+%if 0%{?suse_version}
+%define _libexecdir %{_libdir}
+%global libstoragemgmt libstoragemgmt1
+%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
+
+%if 0%{?suse_version}
+# Use fdupes on openSuSE.
+# For Fedora, it will conflict
with brp-python-bytecompile
Post by Gris Ge
+# For RHEL, fdupes is in EPEL repo.
+%define do_fdupes 1
+%endif
+
Name: libstoragemgmt
Release: 1%{?dist}
Summary: Storage array management library
Group: System Environment/Libraries
+%if 0%{?suse_version}
+License: LGPL-2.1+
+%else
License: LGPLv2+
+%endif
URL: http://sourceforge.net/projects/libstoragemgmt/
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
+Requires: %{libstoragemgmt}-python
+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.
-# These line is only for OBS SPEC parser, not for rpmbuild.
-%if 0%{?centos_version} == 600 || 0%{?rhel_version} == 600
-BuildRequires: python-ordereddict
-# redhat-release was not included in OBS. It provides %{rhel} macro.
-BuildRequires: redhat-release
+%if 0%{?do_fdupes}
+BuildRequires: fdupes
%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
+%if 0%{?rhel} == 6
+BuildRequires: python-ordereddict
%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
@@ -54,6 +82,20 @@ arrays. The library includes a command line interface for
interactive use and
scripting (command lsmcli). The library also has a daemon that is used for
executing plug-ins in a separate process (lsmd).
+%if %{libstoragemgmt} != %{name}
+%package -n %{libstoragemgmt}
+Summary: Storage array management library
+Group: System Environment/Libraries
+Requires: %{libstoragemgmt}-python
+
+%description -n %{libstoragemgmt}
+The libStorageMgmt library will provide a vendor agnostic open source storage
+application programming interface (API) that will allow management of storage
+arrays. The library includes a command line interface for interactive use and
+scripting (command lsmcli). The library also has a daemon that is used for
+executing plug-ins in a separate process (lsmd).
+%endif
+
%package devel
Summary: Development files for %{name}
Group: Development/Libraries
@@ -63,10 +105,10 @@ Requires: %{name}%{?_isa} = %{version}-%{release}
The %{name}-devel package contains libraries and header files for
developing applications that use %{name}.
-%package python
-Summary: Python client libraries and plug-in support for %{name}
+%package -n %{libstoragemgmt}-python
+Summary: Python client libraries and plug-in support for %{libstoragemgmt}
Group: System Environment/Libraries
-Requires: %{name} = %{version}-%{release}
+Requires: %{libstoragemgmt} = %{version}-%{release}
BuildArch: noarch
Requires: pytho
n-argparse
Post by Gris Ge
%if 0%{?rhel} == 6
@@ -75,62 +117,70 @@ Requires: python-argparse
Requires: python-ordereddict
%endif
-%description python
-The %{name}-python package contains python client libraries as
+%description -n %{libstoragemgmt}-python
+The %{libstoragemgmt}-python package contains python client libraries as
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}
+%package -n %{libstoragemgmt}-smis-plugin
+Summary: Files for SMI-S generic array support for %{libstoragemgmt}
Group: System Environment/Libraries
+%if 0%{?suse_version}
+BuildRequires: python-pywbem
+Requires: python-pywbem
+%else
BuildRequires: pywbem
-Requires: pywbem %{name}-python
-Requires: libstoragemgmt-python = %{version}-%{release}
+Requires: pywbem
+%endif
+Requires: %{libstoragemgmt}-python = %{version}-%{release}
BuildArch: noarch
-%description smis-plugin
-The %{name}-smis-plugin package contains plug-in for generic SMI-S array
-support.
+%description -n %{libstoragemgmt}-smis-plugin
+The %{libstoragemgmt}-smis-plugin package contains plug-in for generic SMI-S
+array support.
-%package netapp-plugin
-Summary: Files for NetApp array support for %{name}
+%package -n %{libstoragemgmt}-netapp-plugin
+Summary: Files for NetApp array support for %{libstoragemgmt}
Group: System Environment/Libraries
+%if 0%{?suse_version}
+BuildRequires: python-M2Crypto
+Requires: python-M2Crypto
+%else
BuildRequires: m2crypto
-Requires: m2crypto %{name}-python
-Requires: libstoragemgmt-python = %{version}-%{release}
+Requires: m2crypto
+%endif
+Requires: %{libstoragemgmt}-python = %{version}-%{release}
BuildArch: noarch
-%description netapp-plugin
-The %{name}-netapp-plugin package contains plug-in for NetApp array
+%description -n %{libstoragemgmt}-netapp-plugin
+The %{libstoragemgmt}-netapp-plugin package contains plug-in for NetApp array
support.
-%package targetd-plugin
-Summary: Files for targetd array support for %{name}
+%package -n %{libstoragemgmt}-targetd-plugin
+Summary: Files for targetd array support for %{libstoragemgmt}
Group: System Environment/Libraries
-Requires: %{name}-python
-Requires: libstoragemgmt-python = %{version}-%{release}
+Requires: %{libstoragemgmt}-python = %{version}-%{release}
BuildArch: noarch
-%description targetd-plugin
-The %{name}-targetd-plugin package contains plug-in for targetd array
-support.
+%description -n %{libstoragemgmt}-targetd-plugin
+The %{libstoragemgmt}-targetd-plugin package contains plug-in for targetd
+array support.
-%package nstor-plugin
-Summary: Files for NexentaStor array support for %{name}
+%package -n %{libstoragemgmt}-nstor-plugin
+Summary: Files for NexentaStor array support for %{libstoragemgmt}
Group: System Environment/Libraries
-Requires: %{name}-python
-Requires: libstoragemgmt-python = %{version}-%{release}
+Requires: %{libstoragemgmt}-python = %{version}-%{release}
BuildArch: noarch
-%description nstor-plugin
-The %{name}-nstor-plugin package contains plug-in for NexentaStor array
-support.
+%description -n %{libstoragemgmt}-nstor-plugin
+The %{libstoragemgmt}-nstor-plugin package contains plug-in for NexentaStor
+array support.
%package udev
-Summary: udev files for %{name}
+Summary: Udev files for %{name}
Group: System Environment/Base
%description udev
@@ -138,15 +188,25 @@ The %{name}-udev package c
ontains udev rules and helper
Post by Gris Ge
utilities for
uevents generated by the kernel.
%if 0%{?with_rest_api}
-%package rest
-Summary: REST API daemon for %{name}
+%package -n %{libstoragemgmt}-rest
+Summary: REST API daemon for %{libstoragemgmt}
Group: System Environment/Daemons
-Requires: %{name}%{?_isa} = %{version}-%{release}
-Requires: libmicrohttpd json-c
-BuildRequires: libmicrohttpd-devel json-c-devel
+Requires: %{libstoragemgmt}%{?_isa} = %{version}-%{release}
+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.
+%description -n %{libstoragemgmt}-rest
+the %{libstoragemgmt}-rest package contains the http daemon for
+%{libstoragemgmt} rest api.
%endif
%prep
@@ -168,7 +228,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
@@ -184,9 +244,6 @@ install packaging/daemon/libstoragemgmtd \
%{buildroot}/etc/rc.d/init.d/libstoragemgmtd
%endif
-#Need these to exist at install so we can start the daemon
-mkdir -p %{buildroot}%{_localstatedir}/run/lsm/ipc
-
#Files for udev handling
mkdir -p %{buildroot}/%{udev_dir}/udev/rules.d
install -m 644 tools/udev/90-scsi-ua.rules \
@@ -194,6 +251,18 @@ 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
+
+# Deduplication
+%if 0%{?do_fdupes}
+%fdupes -s %{buildroot}/%{python_sitelib}/lsm
+%endif
+
%clean
rm -rf %{buildroot}
@@ -204,69 +273,149 @@ then
exit 1
fi
-%pre
-getent group libstoragemgmt >/dev/null || groupadd -r libstoragemgmt
-getent passwd libstoragemgmt >/dev/null || \
- useradd -r -g libstoragemgmt -d /var/run/lsm -s /sbin/nologin \
- -c "daemon account for libstoragemgmt" libstoragemgmt
+%pre -n %{libstoragemgmt}
+if [ $1 -eq 1 ]; then
+ #New install.
+ getent group libstoragemgmt >/dev/null || groupadd -r libstoragemgmt
+ getent passwd libstoragemgmt >/dev/null || \
+ useradd -r -g libstoragemgmt -d %{_localstatedir}/run/lsm \
+ -s /sbin/nologin \
+ -c "daemon account for libstoragemgmt" libstoragemgmt
+ #Need these to exist at install so we can start the daemon
+ mkdir -p %{_localstatedir}/run/lsm/ipc
+ chmod 0755 %{_localstatedir}/run/lsm
+ chmod 0755 %{_localstatedir}/run/lsm/ipc
+ chown libstoragemgmt:libstoragemgmt %{_localstatedir}/run/lsm
+ chown libstoragemgmt:libstoragemgmt %{_localstatedir}/run/lsm/ipc
+fi
-%post
+%post -n %{libstoragemgmt}
/sbin/ldconfig
-if [ $1 -eq 1 ]; then
-%if 0%{?fedora} >= 15 || 0%{?rhel} >= 7
+%if 0%{?with_systemd}
+%if 0%{?suse_version}
+ %service_add_post libstoragemgmt.service
%else
- /sbin/chkconfig --add libstoragemgmtd
+ %systemd_post libstoragemgmt.service
%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
Post by Gris Ge
- /bin/systemctl --no-reload disable \
+%else
+ /sbin/chkconfig --add libstoragemgmtd
%endif
-fi
-%postun rest
-if [ $1 -ge 1 ] ; then
-%if 0%{?fedora} >= 15 || 0%{?rhel} >= 7
- # On upgrade (not uninstall), optionally, restart the daemon
-%endif
-fi
+%preun -n %{libstoragemgmt}
+%if 0%{?with_systemd}
+%if 0%{?suse_version}
+ %service_del_preun libstoragemgmt.service
+%else
+ %systemd_preun libstoragemgmt.service
%endif
-
-%preun
-if [ $1 -eq 0 ]; then
-%if 0%{?fedora} >= 15 || 0%{?rhel} >= 7
- # On uninstall (not upgrade), disable and stop the units
%else
/sbin/chkconfig --del libstoragemgmtd
%endif
-fi
-%postun
+%postun -n %{libstoragemgmt}
/sbin/ldconfig
-if [ $1 -ge 1 ] ; then
-%if 0%{?fedora} >= 15 || 0%{?rhel} >= 7
- # On upgrade (not uninstall), optionally, restart the daemon
+%if 0%{?with_systemd}
+%if 0%{?suse_version}
+ %service_del_postun libstoragemgmt.service
+%else
+ %systemd_postun libstoragemgmt.service
+%endif
%else
#Restart the daemond
%endif
+
+%if 0%{?with_rest_api}
+%post -n %{libstoragemgmt}-rest
+%if 0%{?with_systemd}
+%if 0%{?suse_version}
+ %service_add_post libstoragemgmt-rest.service
+%else
+ %systemd_post libstoragemgmt-rest.service
+%endif
+%endif
+
+%preun -n %{libstoragemgmt}-rest
+%if 0%{?with_systemd}
+%if 0%{?suse_version}
+ %service_del_preun libstoragemgmt-rest.service
+%else
+ %systemd_preun libstoragemgmt-rest.service
+%endif
+%endif
+
+%postun -n %{libstoragemgmt}-rest
+%if 0%{?with_systemd}
+%if 0%{?suse_version}
+ %service_del_postun libstoragemgmt-rest.service
+%else
+ %systemd_postun libstoragemgmt-rest.service
+%endif
+%endif
+%endif
+
+# Need to restart lsmd if plugin is new installed or removed.
+%post -n %{libstoragemgmt}-smis-plugin
+if [ $1 -eq 1 ]; then
+ # New install.
+ /usr/bin/systemctl try-restart libstoragemgmt.service \
+fi
+
+%postun -n %{libstoragemgmt}-smis-plugin
+if [ $1 -eq 0 ]; then
+ # Remove
+ /usr/bin/systemctl try-restart libstoragemgmt.service \
+fi
+
+# Need to restart lsmd if plugin is new installed or removed.
+%post -n %{libstoragemgmt}-netapp-plugin
+if [ $1 -eq 1 ]; then
+ # New install.
+ /usr/bin/systemctl try-restart libstoragemgmt.service \
+fi
+
+%postun -n %{libstoragemgmt}-netapp-plugin
+if [ $1 -eq 0 ]; then
+ # Remove
+ /usr/bin/systemctl try-restart libstoragemgmt.service \
fi
-%files
+# Need to restart lsmd if plugin is new installed or removed.
+%post -n %{libstoragemgmt}-targetd-plugin
+if [ $1 -eq 1 ]; then
+ # New install.
+ /usr/bin/systemctl try-restart libstoragemgmt.service \
+fi
+
+%postun -n %{libstoragemgmt}-targetd-plugin
+if [ $1 -eq 0 ]; then
+ # Remove
+ /usr/bin/systemctl try-restart libstoragemgmt.service \
+fi
+
+# Need to restart lsmd if plugin is new installed or remov
ed.
Post by Gris Ge
+%post -n %{libstoragemgmt}-nstor-plugin
+if [ $1 -eq 1 ]; then
+ # New install.
+ /usr/bin/systemctl try-restart libstoragemgmt.service \
+fi
+
+%postun -n %{libstoragemgmt}-nstor-plugin
+if [ $1 -eq 0 ]; then
+ # Remove
+ /usr/bin/systemctl try-restart libstoragemgmt.service \
+fi
+
+%files -n %{libstoragemgmt}
%defattr(-,root,root,-)
%doc README COPYING.LIB
%{_mandir}/man1/lsmcli.1*
@@ -276,14 +425,11 @@ 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
@@ -295,10 +441,12 @@ fi
%{_libdir}/*.so
%{_libdir}/pkgconfig/libstoragemgmt.pc
-%files python
+%files -n %{libstoragemgmt}-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,17 +455,21 @@ 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.*
%{_bindir}/sim_lsmplugin
-%files smis-plugin
+%files -n %{libstoragemgmt}-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.*
@@ -329,21 +481,24 @@ fi
%{python_sitelib}/lsm/plugin/smispy/smis_disk.*
%{_bindir}/smispy_lsmplugin
-%files netapp-plugin
+%files -n %{libstoragemgmt}-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.*
%{_bindir}/ontap_lsmplugin
-%files targetd-plugin
+%files -n %{libstoragemgmt}-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
+%files -n %{libstoragemgmt}-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
@@ -354,10 +509,10 @@ fi
%{udev_dir}/udev/rules.d/90-scsi-ua.rules
%if 0%{?with_rest_api}
-%files rest
+%files -n %{libstoragemgmt}-rest
%defattr(-,root,root,-)
%{_bindir}/lsm_restd
-%if 0%{?fedora} >= 15 || 0%{?rhel} >= 7
+%if 0%{?with_systemd}
%{_unitdir}/libstoragemgmt-rest.service
%endif
%endif
Nick Wang
2014-10-20 12:13:40 UTC
Permalink
Hi Gris,

Thanks for your help on merging the SPEC.
I rebuilt and checked on openSUSE with the latest code of your github.
Seems the rpms are working fine.

However, please help to remove the necessary suse define of _libexecdir.
I enclosed the patch for details, thanks a lot and sorry for the late reply.

Best regards,
Nick
Post by Gris Ge
圚 18:23 的 2014-10-17 䞊圚讯息
<1413541406-24698-1-git-send-email-***@redhat.com> 䞭Gris Ge <***@redhat.com>
写入
Post by Gris Ge
* Please don't commit this patch until we got feedback from openSuSE user.
* 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)
* On openSuSE, the package name has been changed due to their share lib naming
libstoragemgmt-devel
libstoragemgmt-udev
libstoragemgmt1
libstoragemgmt1-python
libstoragemgmt1-smis-plugin
libstoragemgmt1-netapp-plugin
libstoragemgmt1-targetd-plugin
libstoragemgmt1-nstor-plugin
libstoragemgmt1-rest
* Run fdupes on OpenSuSE to create soft link against duplicated
python .pyo and .pyc files.
For Fedora, it will conflict with brp-python-bytecompile.
For RHEL, fdupes is in EPEL repo.
* Move '/var/run/lsm' folder creation to %pre script as a rpm package should
not own a ghost file in /var/run which might be mounted as tmpfs.
* Add %post and %postun scripts into plugin package to 'try-restart'
the libstoragemgmt.service when new install or package removal.
This is only for systemd as RHEL 6 does not have 'try-restart' feature yet.
* On openSuSE, use 'LGPL-2.1+' string due to openSuSE requirements.
* Compile pass on OBS for Fedora 19/20, RHEL 6/7, OpenSuSE 13.1/13.2
* Manually tested via 'lsmcli lp' against simulator C and python plugin,
* RHEL 6.5 x86_64
* RHEL 7.0 x86_64
* Fedora 20 x86_64
* OpenSuSE 13.1 x86_64
[1] https://en.opensuse.org/openSUSE:Shared_library_packaging_policy
---
packaging/libstoragemgmt.spec.in | 399 +++++++++++++++++++++++++++------------
1 file changed, 277 insertions(+), 122 deletions(-)
diff --git a/packaging/libstoragemgmt.spec.in
b/packaging/libstoragemgmt.spec.in
index f84266c..5f59439 100644
--- a/packaging/libstoragemgmt.spec.in
+++ b/packaging/libstoragemgmt.spec.in
@@ -1,50 +1,78 @@
-%bcond_without rest_api
+%bcond_with rest_api
# https://bugzilla.novell.com/show_bug.cgi?id=864323
%{?_with_rest_api: %global with_rest_api 1 }
%{?_without_rest_api: %global with_rest_api 0 }
+%define libsoname libstoragemgmt
+
+%if 0%{?suse_version} || 0%{?fedora} >= 15 || 0%{?rhel} >= 7
+%define with_systemd 1
+%endif
+
+%global libstoragemgmt libstoragemgmt
+
+%if 0%{?suse_version}
+%define _libexecdir %{_libdir}
+%global libstoragemgmt libstoragemgmt1
+%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
+
+%if 0%{?suse_version}
+# Use fdupes on openSuSE.
+# For Fedora, it will conflict with brp-python-bytecompile
+# For RHEL, fdupes is in EPEL repo.
+%define do_fdupes 1
+%endif
+
Name: libstoragemgmt
Release: 1%{?dist}
Summary: Storage array management library
Group: System Environment/Libraries
+%if 0%{?suse_version}
+License: LGPL-2.1+
+%else
License: LGPLv2+
+%endif
URL: http://sourceforge.net/projects/libstoragemgmt/
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
+Requires: %{libstoragemgmt}-python
+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.
-# These line is only for OBS SPEC parser, not for rpmbuild.
-%if 0%{?centos_version} == 600 || 0%{?rhel_version} == 600
-BuildRequires: python-ordereddict
-# redhat-release was not included in OBS. It provides %{rhel} macro.
-BuildRequires: redhat-release
+%if 0%{?do_fdupes}
+BuildRequires: fdupes
%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
+%if 0%{?rhel} == 6
+BuildRequires: python-ordereddict
%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
@@ -54,6 +82,20 @@ arrays. The library includes a command line interface for
interactive use and
scripting (command lsmcli). The library also has a daemon that is used for
executing plug-ins in a separate process (lsmd).
+%if %{libstoragemgmt} != %{name}
+%package -n %{libstoragemgmt}
+Summary: Storage array management library
+Group: System Environment/Libraries
+Requires: %{libstoragemgmt}-python
+
+%description -n %{libstoragemgmt}
+The libStorageMgmt library will provide a vendor agnostic open source storage
+application programming interface (API) that will allow management of storage
+arrays. The library includes a command line interface for interactive use and
+scripting (command lsmcli). The library also has a daemon that is used for
+executing plug-ins in a separate process (lsmd).
+%endif
+
%package devel
Summary: Development files for %{name}
Group: Development/Libraries
@@ -63,10 +105,10 @@ Requires: %{name}%{?_isa} = %{version}-%{release}
The %{name}-devel package contains libraries and header files for
developing applications that use %{name}.
-%package python
-Summary: Python client libraries and plug-in support for %{name}
+%package -n %{libstoragemgmt}-python
+Summary: Python client libraries and plug-in support for %{libstoragemgmt}
Group: System Envir
onment/Libraries
Post by Gris Ge
-Requires: %{name} = %{version}-%{release}
+Requires: %{libstoragemgmt} = %{version}-%{release}
BuildArch: noarch
Requires: python-argparse
%if 0%{?rhel} == 6
@@ -75,62 +117,70 @@ Requires: python-argparse
Requires: python-ordereddict
%endif
-%description python
-The %{name}-python package contains python client libraries as
+%description -n %{libstoragemgmt}-python
+The %{libstoragemgmt}-python package contains python client libraries as
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}
+%package -n %{libstoragemgmt}-smis-plugin
+Summary: Files for SMI-S generic array support for %{libstoragemgmt}
Group: System Environment/Libraries
+%if 0%{?suse_version}
+BuildRequires: python-pywbem
+Requires: python-pywbem
+%else
BuildRequires: pywbem
-Requires: pywbem %{name}-python
-Requires: libstoragemgmt-python = %{version}-%{release}
+Requires: pywbem
+%endif
+Requires: %{libstoragemgmt}-python = %{version}-%{release}
BuildArch: noarch
-%description smis-plugin
-The %{name}-smis-plugin package contains plug-in for generic SMI-S array
-support.
+%description -n %{libstoragemgmt}-smis-plugin
+The %{libstoragemgmt}-smis-plugin package contains plug-in for generic SMI-S
+array support.
-%package netapp-plugin
-Summary: Files for NetApp array support for %{name}
+%package -n %{libstoragemgmt}-netapp-plugin
+Summary: Files for NetApp array support for %{libstoragemgmt}
Group: System Environment/Libraries
+%if 0%{?suse_version}
+BuildRequires: python-M2Crypto
+Requires: python-M2Crypto
+%else
BuildRequires: m2crypto
-Requires: m2crypto %{name}-python
-Requires: libstoragemgmt-python = %{version}-%{release}
+Requires: m2crypto
+%endif
+Requires: %{libstoragemgmt}-python = %{version}-%{release}
BuildArch: noarch
-%description netapp-plugin
-The %{name}-netapp-plugin package contains plug-in for NetApp array
+%description -n %{libstoragemgmt}-netapp-plugin
+The %{libstoragemgmt}-netapp-plugin package contains plug-in for NetApp array
support.
-%package targetd-plugin
-Summary: Files for targetd array support for %{name}
+%package -n %{libstoragemgmt}-targetd-plugin
+Summary: Files for targetd array support for %{libstoragemgmt}
Group: System Environment/Libraries
-Requires: %{name}-python
-Requires: libstoragemgmt-python = %{version}-%{release}
+Requires: %{libstoragemgmt}-python = %{version}-%{release}
BuildArch: noarch
-%description targetd-plugin
-The %{name}-targetd-plugin package contains plug-in for targetd array
-support.
+%description -n %{libstoragemgmt}-targetd-plugin
+The %{libstoragemgmt}-targetd-plugin package contains plug-in for targetd
+array support.
-%package nstor-plugin
-Summary: Files for NexentaStor array support for %{name}
+%package -n %{libstoragemgmt}-nstor-plugin
+Summary: Files for NexentaStor array support for %{libstoragemgmt}
Group: System Environment/Libraries
-Requires: %{name}-python
-Requires: libstoragemgmt-python = %{version}-%{release}
+Requires: %{libstoragemgmt}-python = %{version}-%{release}
BuildArch: noarch
-%description nstor-plugin
-The %{name}-nstor-plugin package contains plug-in for NexentaStor array
-support.
+%description -n %{libstoragemgmt}-nstor-plugin
+The %{libstoragemgmt}-nstor-plugin package contains plug-in for NexentaStor
+array support.
%package udev
-Summary: udev fil
es for %{name}
Post by Gris Ge
+Summary: Udev files for %{name}
Group: System Environment/Base
%description udev
@@ -138,15 +188,25 @@ The %{name}-udev package contains udev rules and helper utilities for
uevents generated by the kernel.
%if 0%{?with_rest_api}
-%package rest
-Summary: REST API daemon for %{name}
+%package -n %{libstoragemgmt}-rest
+Summary: REST API daemon for %{libstoragemgmt}
Group: System Environment/Daemons
-Requires: %{name}%{?_isa} = %{version}-%{release}
-Requires: libmicrohttpd json-c
-BuildRequires: libmicrohttpd-devel json-c-devel
+Requires: %{libstoragemgmt}%{?_isa} = %{version}-%{release}
+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.
+%description -n %{libstoragemgmt}-rest
+the %{libstoragemgmt}-rest package contains the http daemon for
+%{libstoragemgmt} rest api.
%endif
%prep
@@ -168,7 +228,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
@@ -184,9 +244,6 @@ install packaging/daemon/libstoragemgmtd \
%{buildroot}/etc/rc.d/init.d/libstoragemgmtd
%endif
-#Need these to exist at install so we can start the daemon
-mkdir -p %{buildroot}%{_localstatedir}/run/lsm/ipc
-
#Files for udev handling
mkdir -p %{buildroot}/%{udev_dir}/udev/rules.d
install -m 644 tools/udev/90-scsi-ua.rules \
@@ -194,6 +251,18 @@ 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
+
+# Deduplication
+%if 0%{?do_fdupes}
+%fdupes -s %{buildroot}/%{python_sitelib}/lsm
+%endif
+
%clean
rm -rf %{buildroot}
@@ -204,69 +273,149 @@ then
exit 1
fi
-%pre
-getent group libstoragemgmt >/dev/null || groupadd -r libstoragemgmt
-getent passwd libstoragemgmt >/dev/null || \
- useradd -r -g libstoragemgmt -d /var/run/lsm -s /sbin/nologin \
- -c "daemon account for libstoragemgmt" libstoragemgmt
+%pre -n %{libstoragemgmt}
+if [ $1 -eq 1 ]; then
+ #New install.
+ getent group libstoragemgmt >/dev/null || groupadd -r libstoragemgmt
+ getent passwd libstoragemgmt >/dev/null || \
+ useradd -r -g libstoragemgmt -d %{_localstatedir}/run/lsm \
+ -s /sbin/nologin \
+ -c "daemon account for libstoragemgmt" libstoragemgmt
+ #Need these to exist at install so we can start the daemon
+ mkdir -p %{_localstatedir}/run/lsm/ipc
+ chmod 0755 %{_localstatedir}/run/lsm
+ chmod 0755 %{_localstatedir}/run/lsm/ipc
+ chown libstoragemgmt:libstoragemgmt %{_localstatedir}/run/lsm
+ chown libstoragemgmt:libstoragemgmt %{_localstatedir}/run/lsm/ipc
+fi
-%post
+%post -n %{libstoragemgmt}
/sbin/ldconfig
-if [ $1 -eq 1 ]; then
-%if 0%{?fedora} >= 15 || 0%{?rhel} >= 7
+%if 0%{?with_systemd}
+%if 0%{?suse_version}
+ %service_add_post libstoragemgmt.service
%else
- /sbin/chkconfig --add libstoragemgmtd
+ %systemd_post libstoragemgmt.servic
e
Post by Gris Ge
%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 \
+%else
+ /sbin/chkconfig --add libstoragemgmtd
%endif
-fi
-%postun rest
-if [ $1 -ge 1 ] ; then
-%if 0%{?fedora} >= 15 || 0%{?rhel} >= 7
- # On upgrade (not uninstall), optionally, restart the daemon
-%endif
-fi
+%preun -n %{libstoragemgmt}
+%if 0%{?with_systemd}
+%if 0%{?suse_version}
+ %service_del_preun libstoragemgmt.service
+%else
+ %systemd_preun libstoragemgmt.service
%endif
-
-%preun
-if [ $1 -eq 0 ]; then
-%if 0%{?fedora} >= 15 || 0%{?rhel} >= 7
- # On uninstall (not upgrade), disable and stop the units
%else
/sbin/chkconfig --del libstoragemgmtd
%endif
-fi
-%postun
+%postun -n %{libstoragemgmt}
/sbin/ldconfig
-if [ $1 -ge 1 ] ; then
-%if 0%{?fedora} >= 15 || 0%{?rhel} >= 7
- # On upgrade (not uninstall), optionally, restart the daemon
+%if 0%{?with_systemd}
+%if 0%{?suse_version}
+ %service_del_postun libstoragemgmt.service
+%else
+ %systemd_postun libstoragemgmt.service
+%endif
%else
#Restart the daemond
%endif
+
+%if 0%{?with_rest_api}
+%post -n %{libstoragemgmt}-rest
+%if 0%{?with_systemd}
+%if 0%{?suse_version}
+ %service_add_post libstoragemgmt-rest.service
+%else
+ %systemd_post libstoragemgmt-rest.service
+%endif
+%endif
+
+%preun -n %{libstoragemgmt}-rest
+%if 0%{?with_systemd}
+%if 0%{?suse_version}
+ %service_del_preun libstoragemgmt-rest.service
+%else
+ %systemd_preun libstoragemgmt-rest.service
+%endif
+%endif
+
+%postun -n %{libstoragemgmt}-rest
+%if 0%{?with_systemd}
+%if 0%{?suse_version}
+ %service_del_postun libstoragemgmt-rest.service
+%else
+ %systemd_postun libstoragemgmt-rest.service
+%endif
+%endif
+%endif
+
+# Need to restart lsmd if plugin is new installed or removed.
+%post -n %{libstoragemgmt}-smis-plugin
+if [ $1 -eq 1 ]; then
+ # New install.
+ /usr/bin/systemctl try-restart libstoragemgmt.service \
+fi
+
+%postun -n %{libstoragemgmt}-smis-plugin
+if [ $1 -eq 0 ]; then
+ # Remove
+ /usr/bin/systemctl try-restart libstoragemgmt.service \
+fi
+
+# Need to restart lsmd if plugin is new installed or removed.
+%post -n %{libstoragemgmt}-netapp-plugin
+if [ $1 -eq 1 ]; then
+ # New install.
+ /usr/bin/systemctl try-restart libstoragemgmt.service \
+fi
+
+%postun -n %{libstoragemgmt}-netapp-plugin
+if [ $1 -eq 0 ]; then
+ # Remove
+ /usr/bin/systemctl try-restart libstoragemgmt.service \
fi
-%files
+# Need to restart lsmd if plugin is new installed or removed.
+%post -n %{libstoragemgmt}-targetd-plugin
+if [ $1 -eq 1 ]; then
+ # New install.
+ /usr/bin/systemctl try-restart libstoragemgmt.service \
+fi
+
+%postun -n %{libstoragemgmt}-targetd-plugin
+if [ $1 -eq 0 ]; then
+
# Remove
Post by Gris Ge
+ /usr/bin/systemctl try-restart libstoragemgmt.service \
+fi
+
+# Need to restart lsmd if plugin is new installed or removed.
+%post -n %{libstoragemgmt}-nstor-plugin
+if [ $1 -eq 1 ]; then
+ # New install.
+ /usr/bin/systemctl try-restart libstoragemgmt.service \
+fi
+
+%postun -n %{libstoragemgmt}-nstor-plugin
+if [ $1 -eq 0 ]; then
+ # Remove
+ /usr/bin/systemctl try-restart libstoragemgmt.service \
+fi
+
+%files -n %{libstoragemgmt}
%defattr(-,root,root,-)
%doc README COPYING.LIB
%{_mandir}/man1/lsmcli.1*
@@ -276,14 +425,11 @@ 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
@@ -295,10 +441,12 @@ fi
%{_libdir}/*.so
%{_libdir}/pkgconfig/libstoragemgmt.pc
-%files python
+%files -n %{libstoragemgmt}-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,17 +455,21 @@ 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.*
%{_bindir}/sim_lsmplugin
-%files smis-plugin
+%files -n %{libstoragemgmt}-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.*
@@ -329,21 +481,24 @@ fi
%{python_sitelib}/lsm/plugin/smispy/smis_disk.*
%{_bindir}/smispy_lsmplugin
-%files netapp-plugin
+%files -n %{libstoragemgmt}-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.*
%{_bindir}/ontap_lsmplugin
-%files targetd-plugin
+%files -n %{libstoragemgmt}-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
+%files -n %{libstoragemgmt}-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
@@ -354,10 +509,10 @@ fi
%{udev_dir}/udev/rules.d/90-scsi-ua.rules
%if 0%{?with_rest_api}
-%files rest
+%files -n %{libstoragemgmt}-rest
%defattr(-,root,root,-)
%{_bindir}/lsm_restd
-%if 0%{?fedora} >= 15 || 0%{?rhel} >= 7
+%if 0%{?with_systemd}
%{_unitdir}/libstoragemgmt-rest.service
%endif
%endif
Gris Ge
2014-10-22 06:32:51 UTC
Permalink
* Please don't commit this patch until we got feedback from openSuSE user.

* 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)

* On openSuSE, the package name has been changed due to their share lib naming
policy[1]:
libstoragemgmt-devel
libstoragemgmt-udev
libstoragemgmt1
libstoragemgmt1-python
libstoragemgmt1-smis-plugin
libstoragemgmt1-netapp-plugin
libstoragemgmt1-targetd-plugin
libstoragemgmt1-nstor-plugin
libstoragemgmt1-rest

* Run fdupes on OpenSuSE to create soft link against duplicated
python .pyo and .pyc files.
For Fedora, it will conflict with brp-python-bytecompile.
For RHEL, fdupes is in EPEL repo.

* Move '/var/run/lsm' folder creation to %pre script as a rpm package should
not own a ghost file in /var/run which might be mounted as tmpfs.

* Add %post and %postun scripts into plugin package to 'try-restart'
the libstoragemgmt.service when new install or package removal.
This is only for systemd as RHEL 6 does not have 'try-restart' feature yet.

* On openSuSE, use 'LGPL-2.1+' string due to openSuSE requirements.

* Compile pass on OBS for Fedora 19/20, RHEL 6/7, OpenSuSE 13.1/13.2

* Manually tested via 'lsmcli lp' against simulator C and python plugin,
smispy plugin, ontap plugin and targetd plugin on these OS:
* RHEL 6.5 x86_64
* RHEL 7.0 x86_64
* Fedora 20 x86_64
* OpenSuSE 13.1 x86_64

[1] https://en.opensuse.org/openSUSE:Shared_library_packaging_policy

Changes in V2:
* Removed unneeded _libexecdir for openSuSE as suggested by Nick Wang.

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

diff --git a/packaging/libstoragemgmt.spec.in b/packaging/libstoragemgmt.spec.in
index f84266c..0ef7c16 100644
--- a/packaging/libstoragemgmt.spec.in
+++ b/packaging/libstoragemgmt.spec.in
@@ -1,50 +1,77 @@
-%bcond_without rest_api
+%bcond_with rest_api

# Use one-line macro for OBS workaround:
# https://bugzilla.novell.com/show_bug.cgi?id=864323
%{?_with_rest_api: %global with_rest_api 1 }
%{?_without_rest_api: %global with_rest_api 0 }

+%define libsoname libstoragemgmt
+
+%if 0%{?suse_version} || 0%{?fedora} >= 15 || 0%{?rhel} >= 7
+%define with_systemd 1
+%endif
+
+%global libstoragemgmt libstoragemgmt
+
+%if 0%{?suse_version}
+%global libstoragemgmt libstoragemgmt1
+%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
+
+%if 0%{?suse_version}
+# Use fdupes on openSuSE.
+# For Fedora, it will conflict with brp-python-bytecompile
+# For RHEL, fdupes is in EPEL repo.
+%define do_fdupes 1
+%endif
+
Name: libstoragemgmt
Version: @VERSION@
Release: 1%{?dist}
Summary: Storage array management library
Group: System Environment/Libraries
+%if 0%{?suse_version}
+License: LGPL-2.1+
+%else
License: LGPLv2+
+%endif
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
+Requires: %{libstoragemgmt}-python
+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.
-# These line is only for OBS SPEC parser, not for rpmbuild.
-%if 0%{?centos_version} == 600 || 0%{?rhel_version} == 600
-BuildRequires: python-ordereddict
-# redhat-release was not included in OBS. It provides %{rhel} macro.
-BuildRequires: redhat-release
+%if 0%{?do_fdupes}
+BuildRequires: fdupes
%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
+%if 0%{?rhel} == 6
+BuildRequires: python-ordereddict
%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
@@ -54,6 +81,20 @@ arrays. The library includes a command line interface for interactive use and
scripting (command lsmcli). The library also has a daemon that is used for
executing plug-ins in a separate process (lsmd).

+%if %{libstoragemgmt} != %{name}
+%package -n %{libstoragemgmt}
+Summary: Storage array management library
+Group: System Environment/Libraries
+Requires: %{libstoragemgmt}-python
+
+%description -n %{libstoragemgmt}
+The libStorageMgmt library will provide a vendor agnostic open source storage
+application programming interface (API) that will allow management of storage
+arrays. The library includes a command line interface for interactive use and
+scripting (command lsmcli). The library also has a daemon that is used for
+executing plug-ins in a separate process (lsmd).
+%endif
+
%package devel
Summary: Development files for %{name}
Group: Development/Libraries
@@ -63,10 +104,10 @@ Requires: %{name}%{?_isa} = %{version}-%{release}
The %{name}-devel package contains libraries and header files for
developing applications that use %{name}.

-%package python
-Summary: Python client libraries and plug-in support for %{name}
+%package -n %{libstoragemgmt}-python
+Summary: Python client libraries and plug-in support for %{libstoragemgmt}
Group: System Environment/Libraries
-Requires: %{name} = %{version}-%{release}
+Requires: %{libstoragemgmt} = %{version}-%{release}
BuildArch: noarch
Requires: python-argparse
%if 0%{?rhel} == 6
@@ -75,62 +116,70 @@ Requires: python-argparse
Requires: python-ordereddict
%endif

-%description python
-The %{name}-python package contains python client libraries as
+%description -n %{libstoragemgmt}-python
+The %{libstoragemgmt}-python package contains python client libraries as
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}
+%package -n %{libstoragemgmt}-smis-plugin
+Summary: Files for SMI-S generic array support for %{libstoragemgmt}
Group: System Environment/Libraries
+%if 0%{?suse_version}
+BuildRequires: python-pywbem
+Requires: python-pywbem
+%else
BuildRequires: pywbem
-Requires: pywbem %{name}-python
-Requires: libstoragemgmt-python = %{version}-%{release}
+Requires: pywbem
+%endif
+Requires: %{libstoragemgmt}-python = %{version}-%{release}
BuildArch: noarch

-%description smis-plugin
-The %{name}-smis-plugin package contains plug-in for generic SMI-S array
-support.
+%description -n %{libstoragemgmt}-smis-plugin
+The %{libstoragemgmt}-smis-plugin package contains plug-in for generic SMI-S
+array support.


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

-%description netapp-plugin
-The %{name}-netapp-plugin package contains plug-in for NetApp array
+%description -n %{libstoragemgmt}-netapp-plugin
+The %{libstoragemgmt}-netapp-plugin package contains plug-in for NetApp array
support.


-%package targetd-plugin
-Summary: Files for targetd array support for %{name}
+%package -n %{libstoragemgmt}-targetd-plugin
+Summary: Files for targetd array support for %{libstoragemgmt}
Group: System Environment/Libraries
-Requires: %{name}-python
-Requires: libstoragemgmt-python = %{version}-%{release}
+Requires: %{libstoragemgmt}-python = %{version}-%{release}
BuildArch: noarch

-%description targetd-plugin
-The %{name}-targetd-plugin package contains plug-in for targetd array
-support.
+%description -n %{libstoragemgmt}-targetd-plugin
+The %{libstoragemgmt}-targetd-plugin package contains plug-in for targetd
+array support.


-%package nstor-plugin
-Summary: Files for NexentaStor array support for %{name}
+%package -n %{libstoragemgmt}-nstor-plugin
+Summary: Files for NexentaStor array support for %{libstoragemgmt}
Group: System Environment/Libraries
-Requires: %{name}-python
-Requires: libstoragemgmt-python = %{version}-%{release}
+Requires: %{libstoragemgmt}-python = %{version}-%{release}
BuildArch: noarch

-%description nstor-plugin
-The %{name}-nstor-plugin package contains plug-in for NexentaStor array
-support.
+%description -n %{libstoragemgmt}-nstor-plugin
+The %{libstoragemgmt}-nstor-plugin package contains plug-in for NexentaStor
+array support.

%package udev
-Summary: udev files for %{name}
+Summary: Udev files for %{name}
Group: System Environment/Base

%description udev
@@ -138,15 +187,25 @@ The %{name}-udev package contains udev rules and helper utilities for
uevents generated by the kernel.

%if 0%{?with_rest_api}
-%package rest
-Summary: REST API daemon for %{name}
+%package -n %{libstoragemgmt}-rest
+Summary: REST API daemon for %{libstoragemgmt}
Group: System Environment/Daemons
-Requires: %{name}%{?_isa} = %{version}-%{release}
-Requires: libmicrohttpd json-c
-BuildRequires: libmicrohttpd-devel json-c-devel
+Requires: %{libstoragemgmt}%{?_isa} = %{version}-%{release}
+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.
+%description -n %{libstoragemgmt}-rest
+the %{libstoragemgmt}-rest package contains the http daemon for
+%{libstoragemgmt} rest api.
%endif

%prep
@@ -168,7 +227,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
@@ -184,9 +243,6 @@ install packaging/daemon/libstoragemgmtd \
%{buildroot}/etc/rc.d/init.d/libstoragemgmtd
%endif

-#Need these to exist at install so we can start the daemon
-mkdir -p %{buildroot}%{_localstatedir}/run/lsm/ipc
-
#Files for udev handling
mkdir -p %{buildroot}/%{udev_dir}/udev/rules.d
install -m 644 tools/udev/90-scsi-ua.rules \
@@ -194,6 +250,18 @@ 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
+
+# Deduplication
+%if 0%{?do_fdupes}
+%fdupes -s %{buildroot}/%{python_sitelib}/lsm
+%endif
+
%clean
rm -rf %{buildroot}

@@ -204,69 +272,149 @@ then
exit 1
fi

-%pre
-getent group libstoragemgmt >/dev/null || groupadd -r libstoragemgmt
-getent passwd libstoragemgmt >/dev/null || \
- useradd -r -g libstoragemgmt -d /var/run/lsm -s /sbin/nologin \
- -c "daemon account for libstoragemgmt" libstoragemgmt
+%pre -n %{libstoragemgmt}
+if [ $1 -eq 1 ]; then
+ #New install.
+ getent group libstoragemgmt >/dev/null || groupadd -r libstoragemgmt
+ getent passwd libstoragemgmt >/dev/null || \
+ useradd -r -g libstoragemgmt -d %{_localstatedir}/run/lsm \
+ -s /sbin/nologin \
+ -c "daemon account for libstoragemgmt" libstoragemgmt
+ #Need these to exist at install so we can start the daemon
+ mkdir -p %{_localstatedir}/run/lsm/ipc
+ chmod 0755 %{_localstatedir}/run/lsm
+ chmod 0755 %{_localstatedir}/run/lsm/ipc
+ chown libstoragemgmt:libstoragemgmt %{_localstatedir}/run/lsm
+ chown libstoragemgmt:libstoragemgmt %{_localstatedir}/run/lsm/ipc
+fi

-%post
+%post -n %{libstoragemgmt}
/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
+ %systemd_post libstoragemgmt.service
%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 || :
+%else
+ /sbin/chkconfig --add libstoragemgmtd
%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 || :
-%endif
-fi
+%preun -n %{libstoragemgmt}
+%if 0%{?with_systemd}
+%if 0%{?suse_version}
+ %service_del_preun libstoragemgmt.service
+%else
+ %systemd_preun libstoragemgmt.service
%endif
-
-%preun
-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.service >/dev/null 2>&1 || :
- /bin/systemctl stop libstoragemgmt.service >/dev/null 2>&1 || :
%else
/etc/rc.d/init.d/libstoragemgmtd stop > /dev/null 2>&1 || :
/sbin/chkconfig --del libstoragemgmtd
%endif
-fi

-%postun
+%postun -n %{libstoragemgmt}
/sbin/ldconfig
-/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.service >/dev/null 2>&1 || :
+%if 0%{?with_systemd}
+%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
+
+%if 0%{?with_rest_api}
+%post -n %{libstoragemgmt}-rest
+%if 0%{?with_systemd}
+%if 0%{?suse_version}
+ %service_add_post libstoragemgmt-rest.service
+%else
+ %systemd_post libstoragemgmt-rest.service
+%endif
+%endif
+
+%preun -n %{libstoragemgmt}-rest
+%if 0%{?with_systemd}
+%if 0%{?suse_version}
+ %service_del_preun libstoragemgmt-rest.service
+%else
+ %systemd_preun libstoragemgmt-rest.service
+%endif
+%endif
+
+%postun -n %{libstoragemgmt}-rest
+%if 0%{?with_systemd}
+%if 0%{?suse_version}
+ %service_del_postun libstoragemgmt-rest.service
+%else
+ %systemd_postun libstoragemgmt-rest.service
+%endif
+%endif
+%endif
+
+# Need to restart lsmd if plugin is new installed or removed.
+%post -n %{libstoragemgmt}-smis-plugin
+if [ $1 -eq 1 ]; then
+ # New install.
+ /usr/bin/systemctl try-restart libstoragemgmt.service \
+ >/dev/null 2>&1 || :
+fi
+
+%postun -n %{libstoragemgmt}-smis-plugin
+if [ $1 -eq 0 ]; then
+ # Remove
+ /usr/bin/systemctl try-restart libstoragemgmt.service \
+ >/dev/null 2>&1 || :
+fi
+
+# Need to restart lsmd if plugin is new installed or removed.
+%post -n %{libstoragemgmt}-netapp-plugin
+if [ $1 -eq 1 ]; then
+ # New install.
+ /usr/bin/systemctl try-restart libstoragemgmt.service \
+ >/dev/null 2>&1 || :
+fi
+
+%postun -n %{libstoragemgmt}-netapp-plugin
+if [ $1 -eq 0 ]; then
+ # Remove
+ /usr/bin/systemctl try-restart libstoragemgmt.service \
+ >/dev/null 2>&1 || :
fi

-%files
+# Need to restart lsmd if plugin is new installed or removed.
+%post -n %{libstoragemgmt}-targetd-plugin
+if [ $1 -eq 1 ]; then
+ # New install.
+ /usr/bin/systemctl try-restart libstoragemgmt.service \
+ >/dev/null 2>&1 || :
+fi
+
+%postun -n %{libstoragemgmt}-targetd-plugin
+if [ $1 -eq 0 ]; then
+ # Remove
+ /usr/bin/systemctl try-restart libstoragemgmt.service \
+ >/dev/null 2>&1 || :
+fi
+
+# Need to restart lsmd if plugin is new installed or removed.
+%post -n %{libstoragemgmt}-nstor-plugin
+if [ $1 -eq 1 ]; then
+ # New install.
+ /usr/bin/systemctl try-restart libstoragemgmt.service \
+ >/dev/null 2>&1 || :
+fi
+
+%postun -n %{libstoragemgmt}-nstor-plugin
+if [ $1 -eq 0 ]; then
+ # Remove
+ /usr/bin/systemctl try-restart libstoragemgmt.service \
+ >/dev/null 2>&1 || :
+fi
+
+%files -n %{libstoragemgmt}
%defattr(-,root,root,-)
%doc README COPYING.LIB
%{_mandir}/man1/lsmcli.1*
@@ -276,14 +424,11 @@ 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
@@ -295,10 +440,12 @@ fi
%{_libdir}/*.so
%{_libdir}/pkgconfig/libstoragemgmt.pc

-%files python
+%files -n %{libstoragemgmt}-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,17 +454,21 @@ 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.*
%{_bindir}/sim_lsmplugin

-%files smis-plugin
+%files -n %{libstoragemgmt}-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.*
@@ -329,21 +480,24 @@ fi
%{python_sitelib}/lsm/plugin/smispy/smis_disk.*
%{_bindir}/smispy_lsmplugin

-%files netapp-plugin
+%files -n %{libstoragemgmt}-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.*
%{_bindir}/ontap_lsmplugin

-%files targetd-plugin
+%files -n %{libstoragemgmt}-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
+%files -n %{libstoragemgmt}-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
@@ -354,10 +508,10 @@ fi
%{udev_dir}/udev/rules.d/90-scsi-ua.rules

%if 0%{?with_rest_api}
-%files rest
+%files -n %{libstoragemgmt}-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-30 13:24:19 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)

* On openSuSE, the package name has been changed due to their share lib naming
policy[1]:
libstoragemgmt-devel
libstoragemgmt-udev
libstoragemgmt1
libstoragemgmt1-python
libstoragemgmt1-smis-plugin
libstoragemgmt1-netapp-plugin
libstoragemgmt1-targetd-plugin
libstoragemgmt1-nstor-plugin
libstoragemgmt1-rest

* Run fdupes on OpenSuSE to create soft link against duplicated
python .pyo and .pyc files.
For Fedora, it will conflict with brp-python-bytecompile.
For RHEL, fdupes is in EPEL repo.

* Move '/var/run/lsm' folder creation to %pre script as a rpm package should
not own a ghost file in /var/run which might be mounted as tmpfs.

* Add %post and %postun scripts into plugin package to 'try-restart'
the libstoragemgmt.service when new install or package removal.
This is only for systemd as RHEL 6 does not have 'try-restart' feature yet.

* On openSuSE, use 'LGPL-2.1+' string due to openSuSE requirements.

* Compile pass on OBS for Fedora 19/20, RHEL 6/7, OpenSuSE 13.1/13.2

* Manually tested via 'lsmcli lp' against simulator C and python plugin,
smispy plugin, ontap plugin and targetd plugin on these OS:
* RHEL 6.5 x86_64
* RHEL 7.0 x86_64
* Fedora 20 x86_64
* OpenSuSE 13.1 x86_64

[1] https://en.opensuse.org/openSUSE:Shared_library_packaging_policy

Changes in V2:
* Removed unneeded _libexecdir for openSuSE as suggested by Nick Wang.

Changes in V3:
* Removed the "don't commit" comments.

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

diff --git a/packaging/libstoragemgmt.spec.in b/packaging/libstoragemgmt.spec.in
index f84266c..0ef7c16 100644
--- a/packaging/libstoragemgmt.spec.in
+++ b/packaging/libstoragemgmt.spec.in
@@ -1,50 +1,77 @@
-%bcond_without rest_api
+%bcond_with rest_api

# Use one-line macro for OBS workaround:
# https://bugzilla.novell.com/show_bug.cgi?id=864323
%{?_with_rest_api: %global with_rest_api 1 }
%{?_without_rest_api: %global with_rest_api 0 }

+%define libsoname libstoragemgmt
+
+%if 0%{?suse_version} || 0%{?fedora} >= 15 || 0%{?rhel} >= 7
+%define with_systemd 1
+%endif
+
+%global libstoragemgmt libstoragemgmt
+
+%if 0%{?suse_version}
+%global libstoragemgmt libstoragemgmt1
+%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
+
+%if 0%{?suse_version}
+# Use fdupes on openSuSE.
+# For Fedora, it will conflict with brp-python-bytecompile
+# For RHEL, fdupes is in EPEL repo.
+%define do_fdupes 1
+%endif
+
Name: libstoragemgmt
Version: @VERSION@
Release: 1%{?dist}
Summary: Storage array management library
Group: System Environment/Libraries
+%if 0%{?suse_version}
+License: LGPL-2.1+
+%else
License: LGPLv2+
+%endif
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
+Requires: %{libstoragemgmt}-python
+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.
-# These line is only for OBS SPEC parser, not for rpmbuild.
-%if 0%{?centos_version} == 600 || 0%{?rhel_version} == 600
-BuildRequires: python-ordereddict
-# redhat-release was not included in OBS. It provides %{rhel} macro.
-BuildRequires: redhat-release
+%if 0%{?do_fdupes}
+BuildRequires: fdupes
%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
+%if 0%{?rhel} == 6
+BuildRequires: python-ordereddict
%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
@@ -54,6 +81,20 @@ arrays. The library includes a command line interface for interactive use and
scripting (command lsmcli). The library also has a daemon that is used for
executing plug-ins in a separate process (lsmd).

+%if %{libstoragemgmt} != %{name}
+%package -n %{libstoragemgmt}
+Summary: Storage array management library
+Group: System Environment/Libraries
+Requires: %{libstoragemgmt}-python
+
+%description -n %{libstoragemgmt}
+The libStorageMgmt library will provide a vendor agnostic open source storage
+application programming interface (API) that will allow management of storage
+arrays. The library includes a command line interface for interactive use and
+scripting (command lsmcli). The library also has a daemon that is used for
+executing plug-ins in a separate process (lsmd).
+%endif
+
%package devel
Summary: Development files for %{name}
Group: Development/Libraries
@@ -63,10 +104,10 @@ Requires: %{name}%{?_isa} = %{version}-%{release}
The %{name}-devel package contains libraries and header files for
developing applications that use %{name}.

-%package python
-Summary: Python client libraries and plug-in support for %{name}
+%package -n %{libstoragemgmt}-python
+Summary: Python client libraries and plug-in support for %{libstoragemgmt}
Group: System Environment/Libraries
-Requires: %{name} = %{version}-%{release}
+Requires: %{libstoragemgmt} = %{version}-%{release}
BuildArch: noarch
Requires: python-argparse
%if 0%{?rhel} == 6
@@ -75,62 +116,70 @@ Requires: python-argparse
Requires: python-ordereddict
%endif

-%description python
-The %{name}-python package contains python client libraries as
+%description -n %{libstoragemgmt}-python
+The %{libstoragemgmt}-python package contains python client libraries as
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}
+%package -n %{libstoragemgmt}-smis-plugin
+Summary: Files for SMI-S generic array support for %{libstoragemgmt}
Group: System Environment/Libraries
+%if 0%{?suse_version}
+BuildRequires: python-pywbem
+Requires: python-pywbem
+%else
BuildRequires: pywbem
-Requires: pywbem %{name}-python
-Requires: libstoragemgmt-python = %{version}-%{release}
+Requires: pywbem
+%endif
+Requires: %{libstoragemgmt}-python = %{version}-%{release}
BuildArch: noarch

-%description smis-plugin
-The %{name}-smis-plugin package contains plug-in for generic SMI-S array
-support.
+%description -n %{libstoragemgmt}-smis-plugin
+The %{libstoragemgmt}-smis-plugin package contains plug-in for generic SMI-S
+array support.


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

-%description netapp-plugin
-The %{name}-netapp-plugin package contains plug-in for NetApp array
+%description -n %{libstoragemgmt}-netapp-plugin
+The %{libstoragemgmt}-netapp-plugin package contains plug-in for NetApp array
support.


-%package targetd-plugin
-Summary: Files for targetd array support for %{name}
+%package -n %{libstoragemgmt}-targetd-plugin
+Summary: Files for targetd array support for %{libstoragemgmt}
Group: System Environment/Libraries
-Requires: %{name}-python
-Requires: libstoragemgmt-python = %{version}-%{release}
+Requires: %{libstoragemgmt}-python = %{version}-%{release}
BuildArch: noarch

-%description targetd-plugin
-The %{name}-targetd-plugin package contains plug-in for targetd array
-support.
+%description -n %{libstoragemgmt}-targetd-plugin
+The %{libstoragemgmt}-targetd-plugin package contains plug-in for targetd
+array support.


-%package nstor-plugin
-Summary: Files for NexentaStor array support for %{name}
+%package -n %{libstoragemgmt}-nstor-plugin
+Summary: Files for NexentaStor array support for %{libstoragemgmt}
Group: System Environment/Libraries
-Requires: %{name}-python
-Requires: libstoragemgmt-python = %{version}-%{release}
+Requires: %{libstoragemgmt}-python = %{version}-%{release}
BuildArch: noarch

-%description nstor-plugin
-The %{name}-nstor-plugin package contains plug-in for NexentaStor array
-support.
+%description -n %{libstoragemgmt}-nstor-plugin
+The %{libstoragemgmt}-nstor-plugin package contains plug-in for NexentaStor
+array support.

%package udev
-Summary: udev files for %{name}
+Summary: Udev files for %{name}
Group: System Environment/Base

%description udev
@@ -138,15 +187,25 @@ The %{name}-udev package contains udev rules and helper utilities for
uevents generated by the kernel.

%if 0%{?with_rest_api}
-%package rest
-Summary: REST API daemon for %{name}
+%package -n %{libstoragemgmt}-rest
+Summary: REST API daemon for %{libstoragemgmt}
Group: System Environment/Daemons
-Requires: %{name}%{?_isa} = %{version}-%{release}
-Requires: libmicrohttpd json-c
-BuildRequires: libmicrohttpd-devel json-c-devel
+Requires: %{libstoragemgmt}%{?_isa} = %{version}-%{release}
+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.
+%description -n %{libstoragemgmt}-rest
+the %{libstoragemgmt}-rest package contains the http daemon for
+%{libstoragemgmt} rest api.
%endif

%prep
@@ -168,7 +227,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
@@ -184,9 +243,6 @@ install packaging/daemon/libstoragemgmtd \
%{buildroot}/etc/rc.d/init.d/libstoragemgmtd
%endif

-#Need these to exist at install so we can start the daemon
-mkdir -p %{buildroot}%{_localstatedir}/run/lsm/ipc
-
#Files for udev handling
mkdir -p %{buildroot}/%{udev_dir}/udev/rules.d
install -m 644 tools/udev/90-scsi-ua.rules \
@@ -194,6 +250,18 @@ 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
+
+# Deduplication
+%if 0%{?do_fdupes}
+%fdupes -s %{buildroot}/%{python_sitelib}/lsm
+%endif
+
%clean
rm -rf %{buildroot}

@@ -204,69 +272,149 @@ then
exit 1
fi

-%pre
-getent group libstoragemgmt >/dev/null || groupadd -r libstoragemgmt
-getent passwd libstoragemgmt >/dev/null || \
- useradd -r -g libstoragemgmt -d /var/run/lsm -s /sbin/nologin \
- -c "daemon account for libstoragemgmt" libstoragemgmt
+%pre -n %{libstoragemgmt}
+if [ $1 -eq 1 ]; then
+ #New install.
+ getent group libstoragemgmt >/dev/null || groupadd -r libstoragemgmt
+ getent passwd libstoragemgmt >/dev/null || \
+ useradd -r -g libstoragemgmt -d %{_localstatedir}/run/lsm \
+ -s /sbin/nologin \
+ -c "daemon account for libstoragemgmt" libstoragemgmt
+ #Need these to exist at install so we can start the daemon
+ mkdir -p %{_localstatedir}/run/lsm/ipc
+ chmod 0755 %{_localstatedir}/run/lsm
+ chmod 0755 %{_localstatedir}/run/lsm/ipc
+ chown libstoragemgmt:libstoragemgmt %{_localstatedir}/run/lsm
+ chown libstoragemgmt:libstoragemgmt %{_localstatedir}/run/lsm/ipc
+fi

-%post
+%post -n %{libstoragemgmt}
/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
+ %systemd_post libstoragemgmt.service
%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 || :
+%else
+ /sbin/chkconfig --add libstoragemgmtd
%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 || :
-%endif
-fi
+%preun -n %{libstoragemgmt}
+%if 0%{?with_systemd}
+%if 0%{?suse_version}
+ %service_del_preun libstoragemgmt.service
+%else
+ %systemd_preun libstoragemgmt.service
%endif
-
-%preun
-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.service >/dev/null 2>&1 || :
- /bin/systemctl stop libstoragemgmt.service >/dev/null 2>&1 || :
%else
/etc/rc.d/init.d/libstoragemgmtd stop > /dev/null 2>&1 || :
/sbin/chkconfig --del libstoragemgmtd
%endif
-fi

-%postun
+%postun -n %{libstoragemgmt}
/sbin/ldconfig
-/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.service >/dev/null 2>&1 || :
+%if 0%{?with_systemd}
+%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
+
+%if 0%{?with_rest_api}
+%post -n %{libstoragemgmt}-rest
+%if 0%{?with_systemd}
+%if 0%{?suse_version}
+ %service_add_post libstoragemgmt-rest.service
+%else
+ %systemd_post libstoragemgmt-rest.service
+%endif
+%endif
+
+%preun -n %{libstoragemgmt}-rest
+%if 0%{?with_systemd}
+%if 0%{?suse_version}
+ %service_del_preun libstoragemgmt-rest.service
+%else
+ %systemd_preun libstoragemgmt-rest.service
+%endif
+%endif
+
+%postun -n %{libstoragemgmt}-rest
+%if 0%{?with_systemd}
+%if 0%{?suse_version}
+ %service_del_postun libstoragemgmt-rest.service
+%else
+ %systemd_postun libstoragemgmt-rest.service
+%endif
+%endif
+%endif
+
+# Need to restart lsmd if plugin is new installed or removed.
+%post -n %{libstoragemgmt}-smis-plugin
+if [ $1 -eq 1 ]; then
+ # New install.
+ /usr/bin/systemctl try-restart libstoragemgmt.service \
+ >/dev/null 2>&1 || :
+fi
+
+%postun -n %{libstoragemgmt}-smis-plugin
+if [ $1 -eq 0 ]; then
+ # Remove
+ /usr/bin/systemctl try-restart libstoragemgmt.service \
+ >/dev/null 2>&1 || :
+fi
+
+# Need to restart lsmd if plugin is new installed or removed.
+%post -n %{libstoragemgmt}-netapp-plugin
+if [ $1 -eq 1 ]; then
+ # New install.
+ /usr/bin/systemctl try-restart libstoragemgmt.service \
+ >/dev/null 2>&1 || :
+fi
+
+%postun -n %{libstoragemgmt}-netapp-plugin
+if [ $1 -eq 0 ]; then
+ # Remove
+ /usr/bin/systemctl try-restart libstoragemgmt.service \
+ >/dev/null 2>&1 || :
fi

-%files
+# Need to restart lsmd if plugin is new installed or removed.
+%post -n %{libstoragemgmt}-targetd-plugin
+if [ $1 -eq 1 ]; then
+ # New install.
+ /usr/bin/systemctl try-restart libstoragemgmt.service \
+ >/dev/null 2>&1 || :
+fi
+
+%postun -n %{libstoragemgmt}-targetd-plugin
+if [ $1 -eq 0 ]; then
+ # Remove
+ /usr/bin/systemctl try-restart libstoragemgmt.service \
+ >/dev/null 2>&1 || :
+fi
+
+# Need to restart lsmd if plugin is new installed or removed.
+%post -n %{libstoragemgmt}-nstor-plugin
+if [ $1 -eq 1 ]; then
+ # New install.
+ /usr/bin/systemctl try-restart libstoragemgmt.service \
+ >/dev/null 2>&1 || :
+fi
+
+%postun -n %{libstoragemgmt}-nstor-plugin
+if [ $1 -eq 0 ]; then
+ # Remove
+ /usr/bin/systemctl try-restart libstoragemgmt.service \
+ >/dev/null 2>&1 || :
+fi
+
+%files -n %{libstoragemgmt}
%defattr(-,root,root,-)
%doc README COPYING.LIB
%{_mandir}/man1/lsmcli.1*
@@ -276,14 +424,11 @@ 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
@@ -295,10 +440,12 @@ fi
%{_libdir}/*.so
%{_libdir}/pkgconfig/libstoragemgmt.pc

-%files python
+%files -n %{libstoragemgmt}-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,17 +454,21 @@ 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.*
%{_bindir}/sim_lsmplugin

-%files smis-plugin
+%files -n %{libstoragemgmt}-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.*
@@ -329,21 +480,24 @@ fi
%{python_sitelib}/lsm/plugin/smispy/smis_disk.*
%{_bindir}/smispy_lsmplugin

-%files netapp-plugin
+%files -n %{libstoragemgmt}-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.*
%{_bindir}/ontap_lsmplugin

-%files targetd-plugin
+%files -n %{libstoragemgmt}-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
+%files -n %{libstoragemgmt}-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
@@ -354,10 +508,10 @@ fi
%{udev_dir}/udev/rules.d/90-scsi-ua.rules

%if 0%{?with_rest_api}
-%files rest
+%files -n %{libstoragemgmt}-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


------------------------------------------------------------------------------
Tony Asleson
2014-10-31 23:23:14 UTC
Permalink
Patch committed.

Thanks,
Tony
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)
* On openSuSE, the package name has been changed due to their share lib naming
libstoragemgmt-devel
libstoragemgmt-udev
libstoragemgmt1
libstoragemgmt1-python
libstoragemgmt1-smis-plugin
libstoragemgmt1-netapp-plugin
libstoragemgmt1-targetd-plugin
libstoragemgmt1-nstor-plugin
libstoragemgmt1-rest
* Run fdupes on OpenSuSE to create soft link against duplicated
python .pyo and .pyc files.
For Fedora, it will conflict with brp-python-bytecompile.
For RHEL, fdupes is in EPEL repo.
* Move '/var/run/lsm' folder creation to %pre script as a rpm package should
not own a ghost file in /var/run which might be mounted as tmpfs.
* Add %post and %postun scripts into plugin package to 'try-restart'
the libstoragemgmt.service when new install or package removal.
This is only for systemd as RHEL 6 does not have 'try-restart' feature yet.
* On openSuSE, use 'LGPL-2.1+' string due to openSuSE requirements.
* Compile pass on OBS for Fedora 19/20, RHEL 6/7, OpenSuSE 13.1/13.2
* Manually tested via 'lsmcli lp' against simulator C and python plugin,
* RHEL 6.5 x86_64
* RHEL 7.0 x86_64
* Fedora 20 x86_64
* OpenSuSE 13.1 x86_64
[1] https://en.opensuse.org/openSUSE:Shared_library_packaging_policy
* Removed unneeded _libexecdir for openSuSE as suggested by Nick Wang.
* Removed the "don't commit" comments.
---
packaging/libstoragemgmt.spec.in | 398 +++++++++++++++++++++++++++------------
1 file changed, 276 insertions(+), 122 deletions(-)
diff --git a/packaging/libstoragemgmt.spec.in b/packaging/libstoragemgmt.spec.in
index f84266c..0ef7c16 100644
--- a/packaging/libstoragemgmt.spec.in
+++ b/packaging/libstoragemgmt.spec.in
@@ -1,50 +1,77 @@
-%bcond_without rest_api
+%bcond_with rest_api
# https://bugzilla.novell.com/show_bug.cgi?id=864323
%{?_with_rest_api: %global with_rest_api 1 }
%{?_without_rest_api: %global with_rest_api 0 }
+%define libsoname libstoragemgmt
+
+%if 0%{?suse_version} || 0%{?fedora} >= 15 || 0%{?rhel} >= 7
+%define with_systemd 1
+%endif
+
+%global libstoragemgmt libstoragemgmt
+
+%if 0%{?suse_version}
+%global libstoragemgmt libstoragemgmt1
+%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
+
+%if 0%{?suse_version}
+# Use fdupes on openSuSE.
+# For Fedora, it will conflict with brp-python-bytecompile
+# For RHEL, fdupes is in EPEL repo.
+%define do_fdupes 1
+%endif
+
Name: libstoragemgmt
Release: 1%{?dist}
Summary: Storage array management library
Group: System Environment/Libraries
+%if 0%{?suse_version}
+License: LGPL-2.1+
+%else
License: LGPLv2+
+%endif
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
+Requires: %{libstoragemgmt}-python
+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.
-# These line is only for OBS SPEC parser, not for rpmbuild.
-%if 0%{?centos_version} == 600 || 0%{?rhel_version} == 600
-BuildRequires: python-ordereddict
-# redhat-release was not included in OBS. It provides %{rhel} macro.
-BuildRequires: redhat-release
+%if 0%{?do_fdupes}
+BuildRequires: fdupes
%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
+%if 0%{?rhel} == 6
+BuildRequires: python-ordereddict
%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
@@ -54,6 +81,20 @@ arrays. The library includes a command line interface for interactive use and
scripting (command lsmcli). The library also has a daemon that is used for
executing plug-ins in a separate process (lsmd).
+%if %{libstoragemgmt} != %{name}
+%package -n %{libstoragemgmt}
+Summary: Storage array management library
+Group: System Environment/Libraries
+Requires: %{libstoragemgmt}-python
+
+%description -n %{libstoragemgmt}
+The libStorageMgmt library will provide a vendor agnostic open source storage
+application programming interface (API) that will allow management of storage
+arrays. The library includes a command line interface for interactive use and
+scripting (command lsmcli). The library also has a daemon that is used for
+executing plug-ins in a separate process (lsmd).
+%endif
+
%package devel
Summary: Development files for %{name}
Group: Development/Libraries
@@ -63,10 +104,10 @@ Requires: %{name}%{?_isa} = %{version}-%{release}
The %{name}-devel package contains libraries and header files for
developing applications that use %{name}.
-%package python
-Summary: Python client libraries and plug-in support for %{name}
+%package -n %{libstoragemgmt}-python
+Summary: Python client libraries and plug-in support for %{libstoragemgmt}
Group: System Environment/Libraries
-Requires: %{name} = %{version}-%{release}
+Requires: %{libstoragemgmt} = %{version}-%{release}
BuildArch: noarch
Requires: python-argparse
%if 0%{?rhel} == 6
@@ -75,62 +116,70 @@ Requires: python-argparse
Requires: python-ordereddict
%endif
-%description python
-The %{name}-python package contains python client libraries as
+%description -n %{libstoragemgmt}-python
+The %{libstoragemgmt}-python package contains python client libraries as
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}
+%package -n %{libstoragemgmt}-smis-plugin
+Summary: Files for SMI-S generic array support for %{libstoragemgmt}
Group: System Environment/Libraries
+%if 0%{?suse_version}
+BuildRequires: python-pywbem
+Requires: python-pywbem
+%else
BuildRequires: pywbem
-Requires: pywbem %{name}-python
-Requires: libstoragemgmt-python = %{version}-%{release}
+Requires: pywbem
+%endif
+Requires: %{libstoragemgmt}-python = %{version}-%{release}
BuildArch: noarch
-%description smis-plugin
-The %{name}-smis-plugin package contains plug-in for generic SMI-S array
-support.
+%description -n %{libstoragemgmt}-smis-plugin
+The %{libstoragemgmt}-smis-plugin package contains plug-in for generic SMI-S
+array support.
-%package netapp-plugin
-Summary: Files for NetApp array support for %{name}
+%package -n %{libstoragemgmt}-netapp-plugin
+Summary: Files for NetApp array support for %{libstoragemgmt}
Group: System Environment/Libraries
+%if 0%{?suse_version}
+BuildRequires: python-M2Crypto
+Requires: python-M2Crypto
+%else
BuildRequires: m2crypto
-Requires: m2crypto %{name}-python
-Requires: libstoragemgmt-python = %{version}-%{release}
+Requires: m2crypto
+%endif
+Requires: %{libstoragemgmt}-python = %{version}-%{release}
BuildArch: noarch
-%description netapp-plugin
-The %{name}-netapp-plugin package contains plug-in for NetApp array
+%description -n %{libstoragemgmt}-netapp-plugin
+The %{libstoragemgmt}-netapp-plugin package contains plug-in for NetApp array
support.
-%package targetd-plugin
-Summary: Files for targetd array support for %{name}
+%package -n %{libstoragemgmt}-targetd-plugin
+Summary: Files for targetd array support for %{libstoragemgmt}
Group: System Environment/Libraries
-Requires: %{name}-python
-Requires: libstoragemgmt-python = %{version}-%{release}
+Requires: %{libstoragemgmt}-python = %{version}-%{release}
BuildArch: noarch
-%description targetd-plugin
-The %{name}-targetd-plugin package contains plug-in for targetd array
-support.
+%description -n %{libstoragemgmt}-targetd-plugin
+The %{libstoragemgmt}-targetd-plugin package contains plug-in for targetd
+array support.
-%package nstor-plugin
-Summary: Files for NexentaStor array support for %{name}
+%package -n %{libstoragemgmt}-nstor-plugin
+Summary: Files for NexentaStor array support for %{libstoragemgmt}
Group: System Environment/Libraries
-Requires: %{name}-python
-Requires: libstoragemgmt-python = %{version}-%{release}
+Requires: %{libstoragemgmt}-python = %{version}-%{release}
BuildArch: noarch
-%description nstor-plugin
-The %{name}-nstor-plugin package contains plug-in for NexentaStor array
-support.
+%description -n %{libstoragemgmt}-nstor-plugin
+The %{libstoragemgmt}-nstor-plugin package contains plug-in for NexentaStor
+array support.
%package udev
-Summary: udev files for %{name}
+Summary: Udev files for %{name}
Group: System Environment/Base
%description udev
@@ -138,15 +187,25 @@ The %{name}-udev package contains udev rules and helper utilities for
uevents generated by the kernel.
%if 0%{?with_rest_api}
-%package rest
-Summary: REST API daemon for %{name}
+%package -n %{libstoragemgmt}-rest
+Summary: REST API daemon for %{libstoragemgmt}
Group: System Environment/Daemons
-Requires: %{name}%{?_isa} = %{version}-%{release}
-Requires: libmicrohttpd json-c
-BuildRequires: libmicrohttpd-devel json-c-devel
+Requires: %{libstoragemgmt}%{?_isa} = %{version}-%{release}
+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.
+%description -n %{libstoragemgmt}-rest
+the %{libstoragemgmt}-rest package contains the http daemon for
+%{libstoragemgmt} rest api.
%endif
%prep
@@ -168,7 +227,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
@@ -184,9 +243,6 @@ install packaging/daemon/libstoragemgmtd \
%{buildroot}/etc/rc.d/init.d/libstoragemgmtd
%endif
-#Need these to exist at install so we can start the daemon
-mkdir -p %{buildroot}%{_localstatedir}/run/lsm/ipc
-
#Files for udev handling
mkdir -p %{buildroot}/%{udev_dir}/udev/rules.d
install -m 644 tools/udev/90-scsi-ua.rules \
@@ -194,6 +250,18 @@ 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
+
+# Deduplication
+%if 0%{?do_fdupes}
+%fdupes -s %{buildroot}/%{python_sitelib}/lsm
+%endif
+
%clean
rm -rf %{buildroot}
@@ -204,69 +272,149 @@ then
exit 1
fi
-%pre
-getent group libstoragemgmt >/dev/null || groupadd -r libstoragemgmt
-getent passwd libstoragemgmt >/dev/null || \
- useradd -r -g libstoragemgmt -d /var/run/lsm -s /sbin/nologin \
- -c "daemon account for libstoragemgmt" libstoragemgmt
+%pre -n %{libstoragemgmt}
+if [ $1 -eq 1 ]; then
+ #New install.
+ getent group libstoragemgmt >/dev/null || groupadd -r libstoragemgmt
+ getent passwd libstoragemgmt >/dev/null || \
+ useradd -r -g libstoragemgmt -d %{_localstatedir}/run/lsm \
+ -s /sbin/nologin \
+ -c "daemon account for libstoragemgmt" libstoragemgmt
+ #Need these to exist at install so we can start the daemon
+ mkdir -p %{_localstatedir}/run/lsm/ipc
+ chmod 0755 %{_localstatedir}/run/lsm
+ chmod 0755 %{_localstatedir}/run/lsm/ipc
+ chown libstoragemgmt:libstoragemgmt %{_localstatedir}/run/lsm
+ chown libstoragemgmt:libstoragemgmt %{_localstatedir}/run/lsm/ipc
+fi
-%post
+%post -n %{libstoragemgmt}
/sbin/ldconfig
-if [ $1 -eq 1 ]; then
-%if 0%{?fedora} >= 15 || 0%{?rhel} >= 7
+%if 0%{?with_systemd}
+%if 0%{?suse_version}
+ %service_add_post libstoragemgmt.service
%else
- /sbin/chkconfig --add libstoragemgmtd
+ %systemd_post libstoragemgmt.service
%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 \
+%else
+ /sbin/chkconfig --add libstoragemgmtd
%endif
-fi
-%postun rest
-if [ $1 -ge 1 ] ; then
-%if 0%{?fedora} >= 15 || 0%{?rhel} >= 7
- # On upgrade (not uninstall), optionally, restart the daemon
-%endif
-fi
+%preun -n %{libstoragemgmt}
+%if 0%{?with_systemd}
+%if 0%{?suse_version}
+ %service_del_preun libstoragemgmt.service
+%else
+ %systemd_preun libstoragemgmt.service
%endif
-
-%preun
-if [ $1 -eq 0 ]; then
-%if 0%{?fedora} >= 15 || 0%{?rhel} >= 7
- # On uninstall (not upgrade), disable and stop the units
%else
/sbin/chkconfig --del libstoragemgmtd
%endif
-fi
-%postun
+%postun -n %{libstoragemgmt}
/sbin/ldconfig
-if [ $1 -ge 1 ] ; then
-%if 0%{?fedora} >= 15 || 0%{?rhel} >= 7
- # On upgrade (not uninstall), optionally, restart the daemon
+%if 0%{?with_systemd}
+%if 0%{?suse_version}
+ %service_del_postun libstoragemgmt.service
+%else
+ %systemd_postun libstoragemgmt.service
+%endif
%else
#Restart the daemond
%endif
+
+%if 0%{?with_rest_api}
+%post -n %{libstoragemgmt}-rest
+%if 0%{?with_systemd}
+%if 0%{?suse_version}
+ %service_add_post libstoragemgmt-rest.service
+%else
+ %systemd_post libstoragemgmt-rest.service
+%endif
+%endif
+
+%preun -n %{libstoragemgmt}-rest
+%if 0%{?with_systemd}
+%if 0%{?suse_version}
+ %service_del_preun libstoragemgmt-rest.service
+%else
+ %systemd_preun libstoragemgmt-rest.service
+%endif
+%endif
+
+%postun -n %{libstoragemgmt}-rest
+%if 0%{?with_systemd}
+%if 0%{?suse_version}
+ %service_del_postun libstoragemgmt-rest.service
+%else
+ %systemd_postun libstoragemgmt-rest.service
+%endif
+%endif
+%endif
+
+# Need to restart lsmd if plugin is new installed or removed.
+%post -n %{libstoragemgmt}-smis-plugin
+if [ $1 -eq 1 ]; then
+ # New install.
+ /usr/bin/systemctl try-restart libstoragemgmt.service \
+fi
+
+%postun -n %{libstoragemgmt}-smis-plugin
+if [ $1 -eq 0 ]; then
+ # Remove
+ /usr/bin/systemctl try-restart libstoragemgmt.service \
+fi
+
+# Need to restart lsmd if plugin is new installed or removed.
+%post -n %{libstoragemgmt}-netapp-plugin
+if [ $1 -eq 1 ]; then
+ # New install.
+ /usr/bin/systemctl try-restart libstoragemgmt.service \
+fi
+
+%postun -n %{libstoragemgmt}-netapp-plugin
+if [ $1 -eq 0 ]; then
+ # Remove
+ /usr/bin/systemctl try-restart libstoragemgmt.service \
fi
-%files
+# Need to restart lsmd if plugin is new installed or removed.
+%post -n %{libstoragemgmt}-targetd-plugin
+if [ $1 -eq 1 ]; then
+ # New install.
+ /usr/bin/systemctl try-restart libstoragemgmt.service \
+fi
+
+%postun -n %{libstoragemgmt}-targetd-plugin
+if [ $1 -eq 0 ]; then
+ # Remove
+ /usr/bin/systemctl try-restart libstoragemgmt.service \
+fi
+
+# Need to restart lsmd if plugin is new installed or removed.
+%post -n %{libstoragemgmt}-nstor-plugin
+if [ $1 -eq 1 ]; then
+ # New install.
+ /usr/bin/systemctl try-restart libstoragemgmt.service \
+fi
+
+%postun -n %{libstoragemgmt}-nstor-plugin
+if [ $1 -eq 0 ]; then
+ # Remove
+ /usr/bin/systemctl try-restart libstoragemgmt.service \
+fi
+
+%files -n %{libstoragemgmt}
%defattr(-,root,root,-)
%doc README COPYING.LIB
%{_mandir}/man1/lsmcli.1*
@@ -276,14 +424,11 @@ 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
@@ -295,10 +440,12 @@ fi
%{_libdir}/*.so
%{_libdir}/pkgconfig/libstoragemgmt.pc
-%files python
+%files -n %{libstoragemgmt}-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,17 +454,21 @@ 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.*
%{_bindir}/sim_lsmplugin
-%files smis-plugin
+%files -n %{libstoragemgmt}-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.*
@@ -329,21 +480,24 @@ fi
%{python_sitelib}/lsm/plugin/smispy/smis_disk.*
%{_bindir}/smispy_lsmplugin
-%files netapp-plugin
+%files -n %{libstoragemgmt}-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.*
%{_bindir}/ontap_lsmplugin
-%files targetd-plugin
+%files -n %{libstoragemgmt}-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
+%files -n %{libstoragemgmt}-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
@@ -354,10 +508,10 @@ fi
%{udev_dir}/udev/rules.d/90-scsi-ua.rules
%if 0%{?with_rest_api}
-%files rest
+%files -n %{libstoragemgmt}-rest
%defattr(-,root,root,-)
%{_bindir}/lsm_restd
-%if 0%{?fedora} >= 15 || 0%{?rhel} >= 7
+%if 0%{?with_systemd}
%{_unitdir}/libstoragemgmt-rest.service
%endif
%endif
------------------------------------------------------------------------------
Loading...