File munge.spec of Package munge

#
# spec file for package munge
#
# Copyright (c) 2014 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} >= 1210
%define have_systemd 1
%endif
%define lversion 2

Name:           munge
Version:        0.5.12
Release:        0
Summary:        An authentication service for creating and validating credentials
License:        GPL-3.0+ and LGPL-3.0+
Group:          Productivity/Security
Url:            http://dun.github.io/munge/
Source0:        https://github.com/dun/munge/archive/%{name}-%{version}.tar.gz
Source1:	baselibs.conf
Patch0:         Make-SUSE-specific-adjustments.patch
BuildRequires:  openssl-devel
BuildRequires:  pkgconfig
BuildRequires:  zlib-devel
BuildRequires:  libbz2-devel
%if 0%{?have_systemd}
BuildRequires: systemd
BuildRequires: systemd-rpm-macros
%{?systemd_requires}
%endif
%if 0%{?suse_version} < 1310
%{!?_tmpfilesdir:%global _tmpfilesdir /usr/lib/tmpfiles.d}
%endif
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%description
MUNGE (MUNGE Uid 'N' Gid Emporium) is an authentication service for creating
and validating credentials.  It is designed to be highly scalable for use
in an HPC cluster environment.  It allows a process to authenticate the
UID and GID of another local or remote process within a group of hosts
having common users and groups.  These hosts form a security realm that is
defined by a shared cryptographic key.  Clients within this security realm
can create and validate credentials without the use of root privileges,
reserved ports, or platform-specific methods.

%package -n lib%{name}%{lversion}
Summary:        Libraries for applications using MUNGE
Group:          System/Libraries

%description -n lib%{name}%{lversion}
A shared library for applications using the MUNGE authentication service.

%package devel
Requires:       lib%{name}%{lversion} = %{version}
Summary:        Headers and Libraries for building applications using %{name}
Group:          Development/Libraries/C and C++

%description devel
A header file and libraries forbuilding applications using the %{name} 
authenication service.

%prep
%setup -n %{name}-%{name}-%{version}
%patch0 -p1

%build
%configure
make %{?_smp_mflags}

%install
%makeinstall
%{__rm} -f %{buildroot}%{_libdir}/*.la
%{__rm} -f %{buildroot}%{_libdir}/*.a
%{__install} -m 0755 -d %{buildroot}%{_localstatedir}/adm/fillup-templates
%{__mv} %{buildroot}%{_sysconfdir}/sysconfig/munge \
   %{buildroot}%{_localstatedir}/adm/fillup-templates/sysconfig.munge

# We don't want systemd file on SLE 11
%if 0%{!?have_systemd:1}
test -d %{buildroot}%{_prefix}/lib/systemd && \
   rm -rf %{buildroot}%{_prefix}/lib/systemd
test -f %{buildroot}/lib/systemd/system/munge.service && \
   rm -f %{buildroot}/lib/systemd/system/munge.service
rm -f %{buildroot}/%{_tmpfilesdir}/munge.conf
%{__ln_s} -f %{_initrddir}/%{name} %{buildroot}%{_sbindir}/rc%{name}
%else
  sed -i 's/User=munge/User=daemon/g' %{buildroot}%{_unitdir}/munge.service
  sed -i 's/Group=munge/Group=root/g' %{buildroot}%{_unitdir}/munge.service
  sed -i 's/munge \+munge/daemon root/g' %{buildroot}%{_tmpfilesdir}/munge.conf
  %{__rm} -f %{buildroot}/%{_initddir}/munge
  %{__ln_s} %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}
%endif

%post -n lib%{name}%{lversion} -p /sbin/ldconfig

%postun -n lib%{name}%{lversion} -p /sbin/ldconfig


%if 0%{?have_systemd}
%pre
%service_add_pre munge.service
%endif

%preun
%if 0%{?have_systemd}
%service_del_preun munge.service
%else
%stop_on_removal service
%endif

%postun
%if 0%{?have_systemd}
%service_del_postun munge.service
%else
%restart_on_update service
%insserv_cleanup
%endif


%post
if [ ! -e %{_sysconfdir}/munge/munge.key -a -c /dev/urandom ]; then
  /bin/dd if=/dev/urandom bs=1 count=1024 \
    >%{_sysconfdir}/munge/munge.key 2>/dev/null
  /bin/chown daemon %{_sysconfdir}/munge/munge.key
  /bin/chmod 0400 %{_sysconfdir}/munge/munge.key
fi
%if 0%{?have_systemd}
%service_add_post munge.service
systemd-tmpfiles --create %{_tmpfilesdir}/munge.conf
%else
%{fillup_and_insserv -i munge}
%endif

%files
%defattr(-,root,root,0755)
%doc AUTHORS
%doc COPYING
%doc DISCLAIMER*
%doc HISTORY
%doc JARGON
%doc NEWS
%doc PLATFORMS
%doc QUICKSTART
%doc README
%doc TODO
%doc doc/*
%dir %attr(0700,daemon,root) %config %{_sysconfdir}/munge
%dir %attr(0711,daemon,root) %config %{_localstatedir}/lib/munge
%dir %attr(0700,daemon,root) %config %{_localstatedir}/log/munge
%{_bindir}/*
%{_sbindir}/*
%{_mandir}/*[^3]/*
%{_localstatedir}/adm/fillup-templates/sysconfig.munge
%if 0%{?have_systemd}
%{_unitdir}/munge.service
%{_tmpfilesdir}/munge.conf
%else
%attr(0755,daemon,root) %dir %{_localstatedir}/run/%{name}
%{_initddir}/munge
%endif

%files devel
%defattr(-,root,root,0755)
%{_includedir}/*
%{_mandir}/*3/*
%{_libdir}/*.so
%{_libdir}/pkgconfig/*.pc

%files -n lib%{name}%{lversion}
%defattr(-,root,root,0755)
%{_libdir}/*.so.*

%changelog
openSUSE Build Service is sponsored by