File openais.spec of Package openais

#
# spec file for package openais
#
# Copyright (c) 2011 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/
#


%if 0%{?suse_version}
%define _libexecdir %{_libdir}
%endif

Name:           openais
Summary:        The OpenAIS Standards-Based Cluster Framework executive and APIs
Version:        1.1.4
Release:        7
License:        BSD-3-Clause
Group:          Productivity/Clustering/HA
URL:            http://www.openais.org/
Source0:        http://www.osdl.org/downloads/openais-%{version}/openais-%{version}.tar.gz
Patch1:         openais-suse-init.patch
# Runtime bits
Requires(post): /sbin/chkconfig
Requires(preun): /sbin/chkconfig
Requires:       corosync
Requires:       libopenais3 = %{version}-%{release}
# Setup/build bits
BuildRequires:  libcorosync-devel
%define buildtrunk 0
%{?_with_buildtrunk: %define buildtrunk 1}
%if %{buildtrunk}
BuildRequires:  autoconf automake
%endif
BuildRequires:  pkgconfig
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%prep
%setup -q -n openais-%{version}
%patch1 -p1

%build
%if %{buildtrunk}
./autogen.sh
%endif
%{configure}
make %{_smp_mflags}

%install
rm -rf %{buildroot}
make install DESTDIR=%{buildroot}
mkdir -p %{buildroot}%{_initrddir}
install -m 755 init/suse %{buildroot}%{_initrddir}/openais
%if 0%{?suse_version}
ln -sf ../../etc/init.d/openais %{buildroot}%{_sbindir}/rcopenais
%endif
mkdir -p %{buildroot}%{_sysconfdir}/ais
cat<<EOF > %{buildroot}%{_sysconfdir}/ais/openais.conf
# This configuration file is not used any more
# Please refer to %{_sysconfdir}/corosync/corosync.conf
EOF
## tree fixup
# drop static libs
rm -f %{buildroot}%{_libdir}/*.a
# drop docs and html docs for now
rm -rf %{buildroot}%{_docdir}/*
# the docdir is /usr/share/doc/<pkg> in the configuration
rm -rf %{buildroot}%{_datadir}/doc/*

%clean
rm -rf %{buildroot}

%description
This package contains the openais executive, openais service handlers,
default configuration files and init script.



Authors:
--------
    Steven Dake
    Mark Haverkamp
    Muni Bajpai
    Daniel McNiel
    Miyotaka Sakai
    Daniel Stodden
    Kristen Smith
    Patrick Caulfield
    Fabien Thomas
    Hans Feldt
    Lars Holm
    Anders Eriksson
    Renaud Metrich
    Frederic Hermann
    Alejandro Lopez
    David Teigland
    Robert Peterson
    Abhijith Das

%pre
ais2coroconf() {
# rules:
# consensus > 1.2 * token
	conf=$1
	filter=`mktemp`
	awk '
	BEGIN{cons=0; tok=0}
	$1=="token:"{tok=$2}
	$1=="consensus:"{cons=$2}
	$1=="timestamp:"{timestamp=$2}
	END{
		if( cons>0 && tok>0 && 1.2*cons <= tok ) {
			newcons = tok*1.2;
			printf "$1==\"consensus:\"{$2=%d}\n",newcons
			printf "WARN: consensus in corosync.conf adjusted from %d to %d\n",cons,newcons > "/dev/stderr"
		}
		if( timestamp == "on" ) {
			printf "$1==\"timestamp:\"{$2=\"off\"}\n"
			printf "WARN: timestamp in corosync.conf set to off\n" > "/dev/stderr"
		}
	}
	' $conf >> $filter
	echo '{print}' >> $filter
	awk -f $filter $conf
	rm -f $filter
}
if [ -f %{_sysconfdir}/ais/openais.conf ]; then
  mkdir -p %{_sysconfdir}/corosync
  [ -f %{_sysconfdir}/ais/authkey -a ! -f %{_sysconfdir}/corosync/authkey ] &&
	  cp -p %{_sysconfdir}/ais/authkey %{_sysconfdir}/corosync
  if [ ! -f %{_sysconfdir}/corosync/corosync.conf ]; then
	# Only replace corosync.conf if existing openais.conf has actual content,
	# i.e. at least one non-comment, non-whitespace line (bnc#611545)
	if grep -q -v '^\([[:space:]]*#\|[[:space:]]*$\)' %{_sysconfdir}/ais/openais.conf; then
	  ais2coroconf %{_sysconfdir}/ais/openais.conf > %{_sysconfdir}/corosync/corosync.conf
	fi
  fi
fi

%post
%{fillup_and_insserv -n openais}
# This code addresses bnc#549579 - a previous package version wrongly
# disabled openais in %postun, which this needs to work around:
if chkconfig -c openais; then
	touch /var/run/start_open_ais_on_boot
fi

%posttrans
if test -f /var/run/start_open_ais_on_boot; then
	chkconfig --add openais
	rm -f /var/run/start_open_ais_on_boot 
fi

%preun
%stop_on_removal openais

%postun
%restart_on_update openais
%{insserv_cleanup}

%files
%defattr(-,root,root,-)
%doc LICENSE README.amf
%dir %{_sysconfdir}/corosync
%dir %{_sysconfdir}/ais
%config(noreplace) %{_sysconfdir}/corosync/amf.conf.example
%config(missingok) %{_sysconfdir}/ais/openais.conf
%{_initrddir}/openais
%if 0%{?suse_version}
%{_sbindir}/rcopenais
%endif
%dir %{_libexecdir}/lcrso
%{_libexecdir}/lcrso/openaisserviceenable.lcrso
%{_libexecdir}/lcrso/service_amf.lcrso
%{_libexecdir}/lcrso/service_ckpt.lcrso
%{_libexecdir}/lcrso/service_clm.lcrso
%{_libexecdir}/lcrso/service_evt.lcrso
%{_libexecdir}/lcrso/service_lck.lcrso
%{_libexecdir}/lcrso/service_msg.lcrso
%{_libexecdir}/lcrso/service_tmr.lcrso
%{_mandir}/man8/openais_overview.8*
%{_mandir}/man5/openais.conf.5*
%{_mandir}/man5/amf.conf.5*
%{_sbindir}/aisexec
%{_sbindir}/openais-instantiate

%package -n libopenais3
License:        BSD-3-Clause
Summary:        The openais Standards-Based Cluster Framework libraries
Group:          Productivity/Clustering/HA
Obsoletes:      libopenais2
Conflicts:      libopenais2

%description -n libopenais3
This package contains openais libraries.



Authors:
--------
    Steven Dake
    Mark Haverkamp
    Muni Bajpai
    Daniel McNiel
    Miyotaka Sakai
    Daniel Stodden
    Kristen Smith
    Patrick Caulfield
    Fabien Thomas
    Hans Feldt
    Lars Holm
    Anders Eriksson
    Renaud Metrich
    Frederic Hermann
    Alejandro Lopez
    David Teigland
    Robert Peterson
    Abhijith Das

%files -n libopenais3
%defattr(-,root,root,-)
%doc LICENSE
%{_libdir}/libSaAmf.so.*
%{_libdir}/libSaCkpt.so.*
%{_libdir}/libSaClm.so.*
%{_libdir}/libSaEvt.so.*
%{_libdir}/libSaLck.so.*
%{_libdir}/libSaMsg.so.*
%{_libdir}/libSaTmr.so.*

%post -n libopenais3 -p /sbin/ldconfig

%postun -n libopenais3 -p /sbin/ldconfig

%package -n libopenais-devel
License:        BSD-3-Clause
Summary:        The openais Standards-Based Cluster Framework libraries
Group:          Development/Libraries/C and C++
Requires:       libopenais3 = %{version}-%{release}
Requires:       pkgconfig
Provides:       openais-devel = %{version}
Obsoletes:      openais-devel < 0.92
Conflicts:      openais-devel < 0.92

%description -n libopenais-devel
This package contains the libraries and include files used to develop
using openais APIs.



Authors:
--------
    Steven Dake
    Mark Haverkamp
    Muni Bajpai
    Daniel McNiel
    Miyotaka Sakai
    Daniel Stodden
    Kristen Smith
    Patrick Caulfield
    Fabien Thomas
    Hans Feldt
    Lars Holm
    Anders Eriksson
    Renaud Metrich
    Frederic Hermann
    Alejandro Lopez
    David Teigland
    Robert Peterson
    Abhijith Das

%files -n libopenais-devel
%defattr(-,root,root,-)
%doc LICENSE
%dir %{_includedir}/openais/
%{_includedir}/openais/saAis.h
%{_includedir}/openais/saAmf.h
%{_includedir}/openais/saCkpt.h
%{_includedir}/openais/saClm.h
%{_includedir}/openais/saEvt.h
%{_includedir}/openais/saLck.h
%{_includedir}/openais/saMsg.h
%{_includedir}/openais/saTmr.h
%{_libdir}/libSaAmf.so
%{_libdir}/libSaCkpt.so
%{_libdir}/libSaClm.so
%{_libdir}/libSaEvt.so
%{_libdir}/libSaLck.so
%{_libdir}/libSaMsg.so
%{_libdir}/libSaTmr.so
%{_libdir}/pkgconfig/*.pc

%changelog
openSUSE Build Service is sponsored by