Update version according to OSCI-883
[packages/precise/mcollective.git] / ext / redhat / mcollective.spec
index bd5d9276223aa20e7a24d0ab9ad27c84a91e2022..af93a46996a2ecfa744eaaeec19c78b9767bf25b 100644 (file)
@@ -1,32 +1,60 @@
-# Fedora 19 ships with ruby 2, which uses vendorlibdir instead
-# of sitelibdir
-%if 0%{?fedora} >= 19
-%global ruby_libdir %(ruby -rrbconfig -e 'puts RbConfig::CONFIG["vendorlibdir"]')
+# Fedora 17 and later use vendorlibdir instead of sitelibdir (see https://fedoraproject.org/wiki/Packaging:Ruby?rd=Packaging/Ruby#Pure_Ruby_packages)
+%if 0%{?fedora} >= 17 || 0%{?rhel} >= 7
+%global         ruby_libdir %(ruby -rrbconfig -e 'puts RbConfig::CONFIG["vendorlibdir"]')
 %else
-%global ruby_libdir %(ruby -rrbconfig -e "puts RbConfig::CONFIG['sitelibdir']")
+%global         ruby_libdir %(ruby -rrbconfig -e "puts RbConfig::CONFIG['sitelibdir']")
 %endif
 
-%define release %{rpm_release}%{?dist}
-
-Summary: Application Server for hosting Ruby code on any capable middleware
-Name: mcollective
-Version: %{version}
-Release: %{release}
-Group: System Environment/Daemons
-License: ASL 2.0
-URL: http://puppetlabs.com/mcollective/introduction/
-Source0: http://downloads.puppetlabs.com/mcollective/%{name}-%{version}.tgz
-BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
-Requires: mcollective-common = %{version}-%{release}
-Packager: R.I.Pienaar <rip@devco.net>
-BuildArch: noarch
+%if 0%{?fedora} >= 17 || 0%{?rhel} >= 7
+%global         _with_systemd 1
+%else
+%global         _with_systemd 0
+%endif
+
+# VERSION is subbed out during rake package:srpm process
+%global         realversion 2.3.3
+%global         rpmversion 2.3.3
+
+Summary:        Application Server for hosting Ruby code on any capable middleware
+Name:           mcollective
+Version:        %{rpmversion}
+Release:        1%{?dist}
+Group:          System Environment/Daemons
+License:        ASL 2.0
+URL:            http://puppetlabs.com/mcollective/introduction/
+Source0:        http://downloads.puppetlabs.com/mcollective/%{name}-%{realversion}.tar.gz
+BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
+BuildRequires:  ruby >= 1.8
+Requires:       mcollective-common = %{version}-%{release}
+Packager:       Puppet Labs <info@puppetlabs.com>
+BuildArch:      noarch
+
+%if 0%{?_with_systemd}
+# Required for %%post, %%preun, %%postun
+Requires:       systemd
+%if 0%{?fedora} >= 18
+BuildRequires:  systemd
+%else
+BuildRequires:  systemd-units
+%endif
+%else
+# Required for %%post and %%preun
+Requires:       chkconfig
+# Required for %%preun and %%postun
+Requires:       initscripts
+%endif
+
+%description
+The Marionette Collective:
+
+Server for the mcollective Application Server
 
 %package common
-Summary: Common libraries for the mcollective clients and servers
-Group: System Environment/Libraries
-Requires: ruby >= 1.8
-Requires: rubygems
-Requires: rubygem(stomp)
+Summary:        Common libraries for the mcollective clients and servers
+Group:          System Environment/Libraries
+Requires:       ruby >= 1.8
+Requires:       rubygems
+Requires:       rubygem-stomp
 
 %description common
 The Marionette Collective:
@@ -34,77 +62,82 @@ The Marionette Collective:
 Common libraries for the mcollective clients and servers
 
 %package client
-Summary: Client tools for the mcollective Application Server
-Requires: mcollective-common = %{version}-%{release}
-Group: Applications/System
+Summary:        Client tools for the mcollective Application Server
+Requires:       mcollective-common = %{version}-%{release}
+Group:          Applications/System
 
 %description client
 The Marionette Collective:
 
 Client tools for the mcollective Application Server
 
-%description
-The Marionette Collective:
-
-Server for the mcollective Application Server
-
 %prep
-%setup -q
+%setup -q -n %{name}-%{realversion}
 
 %build
 
 %install
 rm -rf %{buildroot}
-%{__install} -d -m0755  %{buildroot}/%{ruby_libdir}/mcollective
-%{__install} -d -m0755  %{buildroot}%{_bindir}
-%{__install} -d -m0755  %{buildroot}%{_sbindir}
+
+ruby install.rb --destdir=%{buildroot} --no-rdoc --sitelibdir=%{ruby_libdir} --plugindir=%{_libexecdir}/mcollective
+
+%if 0%{?_with_systemd}
+%{__install} -d -m0755  %{buildroot}%{_unitdir}
+%{__install} -m0644 ext/redhat/mcollective.service %{buildroot}%{_unitdir}/mcollective.service
+%else
 %{__install} -d -m0755  %{buildroot}%{_sysconfdir}/init.d
-%{__install} -d -m0755  %{buildroot}%{_libexecdir}/mcollective/
-%{__install} -d -m0755  %{buildroot}%{_sysconfdir}/mcollective
-%{__install} -d -m0755  %{buildroot}%{_sysconfdir}/mcollective/plugin.d
-%{__install} -d -m0755  %{buildroot}%{_sysconfdir}/mcollective/ssl
-%{__install} -d -m0755  %{buildroot}%{_sysconfdir}/mcollective/ssl/clients
-%{__install} -m0755 bin/mcollectived %{buildroot}%{_sbindir}/mcollectived
-%{__install} -m0640 etc/server.cfg.dist %{buildroot}%{_sysconfdir}/mcollective/server.cfg
-%{__install} -m0644 etc/client.cfg.dist %{buildroot}%{_sysconfdir}/mcollective/client.cfg
-%{__install} -m0444 etc/facts.yaml.dist %{buildroot}%{_sysconfdir}/mcollective/facts.yaml
-%{__install} -m0444 etc/rpc-help.erb %{buildroot}%{_sysconfdir}/mcollective/rpc-help.erb
-%{__install} -m0444 etc/data-help.erb %{buildroot}%{_sysconfdir}/mcollective/data-help.erb
-%{__install} -m0444 etc/discovery-help.erb %{buildroot}%{_sysconfdir}/mcollective/discovery-help.erb
-%{__install} -m0444 etc/metadata-help.erb %{buildroot}%{_sysconfdir}/mcollective/metadata-help.erb
-%{__install} -m0444 etc/msg-help.erb %{buildroot}%{_sysconfdir}/mcollective/msg-help.erb
 %if 0%{?suse_version}
 %{__install} -m0755 mcollective.init %{buildroot}%{_sysconfdir}/init.d/mcollective
 %else
 %{__install} -m0755 ext/redhat/mcollective.init %{buildroot}%{_sysconfdir}/init.d/mcollective
 %endif
+%endif
 
-
-cp -R lib/* %{buildroot}/%{ruby_libdir}/
-cp -R plugins/* %{buildroot}%{_libexecdir}/mcollective/
-cp bin/mc-* %{buildroot}%{_sbindir}/
-cp bin/mco %{buildroot}%{_bindir}/
-chmod 0755 %{buildroot}%{_sbindir}/*
+%{__install} -d -m0755  %{buildroot}%{_sysconfdir}/mcollective/plugin.d
+%{__install} -d -m0755  %{buildroot}%{_sysconfdir}/mcollective/ssl/clients
 
 %clean
 rm -rf %{buildroot}
 
 %post
+%if 0%{?_with_systemd}
+if [ $1 -eq 1 ] ; then
+    /bin/systemctl daemon-reload >/dev/null 2>&1 || :
+fi
+%else
 /sbin/chkconfig --add mcollective || :
+%endif
 
 %postun
+%if 0%{?_with_systemd}
+if [ $1 -ge 1 ] ; then
+    # Package upgrade, not uninstall
+    /bin/systemctl try-restart mcollective.service >/dev/null 2>&1 || :
+fi
+%else
 if [ "$1" -ge 1 ]; then
   /sbin/service mcollective condrestart &>/dev/null || :
 fi
+%endif
 
 %preun
+%if 0%{?_with_systemd}
+if [ $1 -eq 0 ] ; then
+    # Package removal, not upgrade
+    /bin/systemctl --no-reload disable mcollective.service > /dev/null 2>&1 || :
+    /bin/systemctl stop mcollective.service > /dev/null 2>&1 || :
+fi
+%else
 if [ "$1" = 0 ] ; then
   /sbin/service mcollective stop > /dev/null 2>&1
   /sbin/chkconfig --del mcollective || :
 fi
+%endif
 
 %files common
+%defattr(-, root, root, 0755)
 %doc COPYING
+%doc doc
 %{ruby_libdir}/mcollective.rb
 %{ruby_libdir}/mcollective
 %{_libexecdir}/mcollective/mcollective
@@ -113,6 +146,7 @@ fi
 %config %{_sysconfdir}/mcollective/*.erb
 
 %files client
+%defattr(-, root, root, 0755)
 %attr(0755, root, root)%{_sbindir}/mc-call-agent
 %attr(0755, root, root)%{_bindir}/mco
 %doc COPYING
@@ -121,14 +155,22 @@ fi
 %{_libexecdir}/mcollective/mcollective/pluginpackager
 
 %files
+%defattr(-, root, root, 0755)
 %doc COPYING
-%{_sbindir}/mcollectived
+%attr(0755, root, root)%{_sbindir}/mcollectived
+%if 0%{?_with_systemd}
+%{_unitdir}/mcollective.service
+%else
 %{_sysconfdir}/init.d/mcollective
+%endif
 %config(noreplace)%{_sysconfdir}/mcollective/server.cfg
 %config(noreplace)%{_sysconfdir}/mcollective/facts.yaml
 %dir %{_sysconfdir}/mcollective/ssl/clients
 %config(noreplace)%{_sysconfdir}/mcollective/plugin.d
 
 %changelog
+* Fri Nov 15 2013 Puppet Labs Release <info@puppetlabs.com> -  2.3.3-1
+- Build for 2.3.3
+
 * Tue Nov 03 2009 R.I.Pienaar <rip@devco.net>
 - First release