File openlmi-scripts.spec of Package openlmi-scripts

#
# Copyright (C) 2013-2014 Red Hat, Inc.
#
# Licensed under the BSD-2-Clause license
#

%if 0%{?suse_version} > 1310 && 0%{?suse_version} < 1320 
%define with_storage 0
%global         commands logicalfile service software hardware
%else
%define with_storage 1
%global         commands logicalfile service software storage hardware
%endif

%global         commit bd21016ba88ba9f856e3e4bbb9b02b72fd96af3b
%global         shortcommit %(c=%{commit}; echo ${c:0:7})
%global         openlmi_scripts_version 0.4.0
%global         commands account hardware journald logicalfile networking
%global         commands %{commands} powermanagement service software storage
%global         commands %{commands} system
%global         tools_version 0.9.1

Name:		openlmi-scripts
Version:        %{openlmi_scripts_version}
Release:	1%{?dist}
Summary:	Client-side python modules and command line utilities

License:	BSD-2-Clause
URL:		http://fedorahosted.org/openlmi
Group:          System/Management
# Source0:        https://github.com/openlmi/%{name}/archive/%{commit}/%{name}-%{version}-%{shortcommit}.tar.gz
Source0:	%{name}-%{name}-%{version}.tar.gz

%if 0%{?suse_version} > 1110
BuildArch:      noarch
%endif
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%if 0%{?suse_version}
BuildRequires:	python-devel
BuildRequires:	python-setuptools
BuildRequires:  openlmi-tools
BuildRequires:  python-docopt >= 0.6.1
BuildRequires:  openlmi
BuildRequires:  openlmi-python-base
BuildRequires:  python-sphinx
BuildRequires:  python-sphinx_rtd_theme
Requires:	python
%if 0%{?suse_version} > 1010
BuildRequires: fdupes
%endif
%else
BuildRequires:	python2-devel
Requires:	python2
%endif
Requires:       openlmi-python-base >= 0.3.0
Requires:       python-docopt >= 0.6.1
%if 0%{?suse_version}
BuildRequires:  python-ipy
BuildRequires:  python-pyparsing
%else
BuildRequires:  python-IPy
%endif

Requires:       %{name}-account         = %{version}-%{release}
Requires:       %{name}-hardware        = %{version}-%{release}
Requires:       %{name}-journald        = %{version}-%{release}
Requires:       %{name}-logicalfile     = %{version}-%{release}
Requires:       %{name}-networking      = %{version}-%{release}
Requires:       %{name}-powermanagement = %{version}-%{release}
Requires:       %{name}-service         = %{version}-%{release}
Requires:       %{name}-software        = %{version}-%{release}
Requires:       %{name}-storage         = %{version}-%{release}
Requires:       %{name}-system          = %{version}-%{release}

%description
Client-side python modules and command line utilities.

%package        account
Summary:        Client scripts for OpenLMI Account provider
Requires:       openlmi-tools >= %{tools_version}

%description    account
This packages contains client side python library for OpenLMI Account
provider and command line wrapper.

%package        hardware
Summary:        Client scripts for OpenLMI Hardware provider
Requires:       openlmi-tools >= %{tools_version}

%description    hardware
This packages contains client side python library for OpenLMI Hardware
provider and command line wrapper.

%package        journald
Summary:        Client scripts for OpenLMI Journald provider
Requires:       openlmi-tools >= %{tools_version}

%description    journald
This packages contains client side python library for OpenLMI Journald
provider and command line wrapper.

%package        logicalfile
Summary:        Client scripts for OpenLMI Logical File provider
Requires:       openlmi-tools >= %{tools_version}

%description    logicalfile
This packages contains client side python library for OpenLMI Logical File
provider and command line wrapper.

%package        networking
Summary:        Client scripts for OpenLMI Networking provider
Requires:       openlmi-tools >= %{tools_version}
%if 0%{?suse_version}
Requires:       python-ipy
%else
Requires:       python-IPy
%endif

%description    networking
This packages contains client side python library for OpenLMI Networking
provider and command line wrapper.

%package        powermanagement
Summary:        Client scripts for OpenLMI Power provider
Requires:       openlmi-tools >= %{tools_version}

%description    powermanagement
This packages contains client side python library for OpenLMI PowerManagement
provider and command line wrapper.

%package        service
Summary:        Client scripts for OpenLMI Service provider
Requires:       openlmi-tools >= %{tools_version}

%description    service
This packages contains client side python library for OpenLMI Service
provider and command line wrapper.

%package        software
Summary:        Client scripts for OpenLMI Software provider
Requires:       openlmi-tools >= %{tools_version}

%description    software
This packages contains client side python library for OpenLMI Software
provider and command line wrapper.

%package        storage
Summary:        Client scripts for OpenLMI Storage provider
Requires:       openlmi-tools >= %{tools_version}

%description    storage
This packages contains client side python library for OpenLMI Storage
provider and command line wrapper.

%package        system
Summary:        Client scripts providing general system informations
Requires:       openlmi-tools >= %{tools_version}
Requires:       %{name}-service >= %{version}

%description    system
This package contains client side python library for few OpenLMI providers and
command line wrapper. It's aimed to provide some general information about
system.


%prep
%setup -q -n %{name}-%{name}-%{version}

%build
COMMANDS="%{commands}" make setup-all
for cmd in %{commands}; do
    pushd commands/$cmd
    %{__python} setup.py build
    cd doc
    make html
    [ -e _build/html/.buildinfo ] && rm _build/html/.buildinfo
    popd
done

%install
for cmd in %{commands}; do
    pushd commands/$cmd
    %{__python} setup.py install -O1 --skip-build --root $RPM_BUILD_ROOT
    install -m 0755 -d $RPM_BUILD_ROOT/%{_docdir}/%{name}-$cmd
    cp -rp doc/_build/html $RPM_BUILD_ROOT/%{_docdir}/%{name}-$cmd
    install -m 0644 README.md ../../COPYING \
            $RPM_BUILD_ROOT/%{_docdir}/%{name}-$cmd
    popd
done

# install documentation
install -m 755 -d $RPM_BUILD_ROOT%{_docdir}/%{name}
install -m 644 README.md COPYING $RPM_BUILD_ROOT/%{_docdir}/%{name}

%if 0%{?suse_version} > 1010
%fdupes -s $RPM_BUILD_ROOT
%endif

%files
%defattr(-,root,root) 
%doc README.md COPYING

%files account
%defattr(-,root,root) 
%doc %{_docdir}/%{name}-account/
%{python_sitelib}/lmi/scripts/account/
%{python_sitelib}/openlmi_scripts_account-*

%files hardware
%defattr(-,root,root) 
%doc %{_docdir}/%{name}-hardware/
%{python_sitelib}/lmi/scripts/hardware/
%{python_sitelib}/openlmi_scripts_hardware-*

%files journald
%defattr(-,root,root) 
%doc %{_docdir}/%{name}-journald/
%{python_sitelib}/lmi/scripts/journald/
%{python_sitelib}/openlmi_scripts_journald-*

%files logicalfile
%defattr(-,root,root) 
%doc %{_docdir}/%{name}-logicalfile/
%{python_sitelib}/lmi/scripts/logicalfile/
%{python_sitelib}/openlmi_scripts_logicalfile-*

%files networking
%defattr(-,root,root) 
%doc %{_docdir}/%{name}-networking/
%{python_sitelib}/lmi/scripts/networking/
%{python_sitelib}/openlmi_scripts_networking-*

%files powermanagement
%defattr(-,root,root) 
%doc %{_docdir}/%{name}-powermanagement/
%{python_sitelib}/lmi/scripts/powermanagement/
%{python_sitelib}/openlmi_scripts_powermanagement-*

%files service
%defattr(-,root,root) 
%doc %{_docdir}/%{name}-service/
%{python_sitelib}/lmi/scripts/service/
%{python_sitelib}/openlmi_scripts_service-*

%files software
%defattr(-,root,root) 
%doc %{_docdir}/%{name}-software/
%{python_sitelib}/lmi/scripts/software/
%{python_sitelib}/openlmi_scripts_software-*

%if %{with_storage}
%files storage
%defattr(-,root,root) 
%doc %{_docdir}/%{name}-storage/
%{python_sitelib}/lmi/scripts/storage/
%{python_sitelib}/openlmi_scripts_storage-*
%endif

%files system
%defattr(-,root,root) 
%doc %{_docdir}/%{name}-system/
%{python_sitelib}/lmi/scripts/system/
%{python_sitelib}/openlmi_scripts_system-*

%changelog
openSUSE Build Service is sponsored by