File crmsh.spec of Package crmsh

#
# spec file for package crmsh
#
# Copyright (c) 2012 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#


# crmsh requires pacemaker, which in turn requires cluster-glue, which has a
# %pre script which creates the hacluster/haclient user and group used here:
%global gname haclient
%global uname hacluster
%global crmsh_docdir %{_defaultdocdir}/%{name}

%global specversion 0
%global upstream_version tip
%global upstream_prefix crmsh

# Compatibility macros for distros (fedora) that don't provide Python macros by default
# Do this instead of trying to conditionally include {_rpmconfigdir}/macros.python
%{!?py_ver:     %{expand: %%global py_ver      %%(echo `python -c "import sys; print sys.version[:3]"`)}}
%{!?py_prefix:  %{expand: %%global py_prefix   %%(echo `python -c "import sys; print sys.prefix"`)}}
%{!?py_libdir:  %{expand: %%global py_libdir   %%{expand:%%%%{py_prefix}/%%%%{_lib}/python%%%%{py_ver}}}}
%{!?py_sitedir: %{expand: %%global py_sitedir  %%{expand:%%%%{py_libdir}/site-packages}}}

%global crmsh_release %{specversion}

Name:           crmsh
Summary:        Pacemaker/CRM shell
License:        GPL-2.0
Group:          Productivity/Clustering/HA
Version:        1.1.0
Release:        0
Url:            http://savannah.nongnu.org/projects/crmsh
Source0:        crmsh.tar.bz2
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
Requires(pre):	pacemaker-ticket-support >= 2.0
Requires(pre):	pacemaker >= 1.1.6
Requires:       pssh
Requires:       python >= 2.4
Requires:       python-dateutil

%if 0%{?suse_version}
# Suse splits this off into a separate package
Requires:       python-curses
Requires:       python-xml
BuildRequires:  python-curses
BuildRequires:  python-xml
%endif

# Required for core functionality
BuildRequires:  asciidoc
BuildRequires:  autoconf
BuildRequires:  automake
BuildRequires:  libglue-devel
BuildRequires:  libpacemaker-devel
BuildRequires:  libtool
BuildRequires:  pkgconfig
BuildRequires:  python
%if 0%{?suse_version} > 1210
# xsltproc is necessary for manpage generation; this is split out into
# libxslt-tools as of openSUSE 12.2.  Possibly strictly should be
# required by asciidoc
BuildRequires:  libxslt-tools
%endif

%if 0%{?with_regression_tests}
BuildRequires:  corosync
BuildRequires:  procps
BuildRequires:  vim-base
Requires:       pacemaker
%endif

%description
CRM shell is a Pacemaker cluster resource manager command line
interface. It supports Pacemaker configuration, management, and
troubleshooting.

%prep
%setup -q -n %{upstream_prefix}

# Force the local time
#
# 'hg archive' sets the file date to the date of the last commit.
# This can result in files having been created in the future
# when building on machines in timezones 'behind' the one the 
# commit occurred in - which seriously confuses 'make'
find . -exec touch \{\} \;

%build
./autogen.sh

# RHEL <= 5 does not support --docdir
# SLES <= 10 does not support ./configure --docdir=,
# hence, use this ugly hack
%if 0%{?suse_version} < 1020
export docdir=%{crmsh_docdir}
%{configure}			\
	--localstatedir=%{_var}				\
	--with-package-name=%{name} \
	--with-version=%{version}-%{release}
%else
%{configure}			\
	--localstatedir=%{_var}				\
	--with-package-name=%{name}		\
	--with-version=%{version}-%{release}	\
	--docdir=%{crmsh_docdir}
%endif

make %{_smp_mflags} docdir=%{crmsh_docdir}

%install
%make_install

%if 0%{?with_regression_tests}
%post
# Needed so that the shell doesn't get stuck on escape
# sequences
# NB: this is called twice by OBS, that's why we touch the file
if [ ! -e /tmp/.crmsh_regression_tests_ran ]; then
	touch /tmp/.crmsh_regression_tests_ran
	export TERM=dumb
	if ! /usr/share/crmsh/tests/regression.sh ; then
		echo "Shell tests failed."
		cat crmtestout/regression.out
		exit 1
	fi
fi
%endif

%files
###########################################################
%defattr(-,root,root)

%{_datadir}/crmsh

%{_sbindir}/crm
%{py_sitedir}/crmsh

%doc %{_mandir}/man8/crm.8*
%doc COPYING
%doc AUTHORS
%doc ChangeLog
%doc README

%dir %attr (770, %{uname}, %{gname}) %{_var}/cache/crm

%changelog