Blob Blame Raw
Name: pcs
Version: 0.9.159
Release: 1%{?dist}
License: GPLv2
URL: https://github.com/ClusterLabs/pcs
Group: System Environment/Base
Summary: Pacemaker Configuration System

#part after last slash is recognized as filename in look-aside repository
#desired name is achived by trick with hash anchor
Source0: %{url}/archive/%{version}.tar.gz#/%{name}-%{version}.tar.gz
Source1: pcsd-bundle-config-1

Source11: https://rubygems.org/downloads/orderedhash-0.0.6.gem
Source12: https://rubygems.org/downloads/rack-1.6.4.gem
Source13: https://rubygems.org/downloads/rpam-ruby19-1.2.1.gem
Source14: https://rubygems.org/downloads/sinatra-1.4.8.gem
Source15: https://rubygems.org/downloads/sinatra-contrib-1.4.7.gem
Source16: https://rubygems.org/downloads/tilt-2.0.6.gem

Patch0: fedfix.patch

# git for patches
BuildRequires: git
# python for pcs
BuildRequires: python3
BuildRequires: python3-devel
BuildRequires: python3-setuptools
# python libraries for tests
BuildRequires: python3-lxml
BuildRequires: python3-mock
BuildRequires: python3-pycurl
# gcc for compiling custom rubygems
BuildRequires: gcc
BuildRequires: gcc-c++
# ruby and gems for pcsd
BuildRequires: ruby
BuildRequires: ruby-devel
BuildRequires: rubygem-bundler
BuildRequires: rubygem-backports
BuildRequires: rubygem-ethon
BuildRequires: rubygem-ffi
BuildRequires: rubygem-io-console
BuildRequires: rubygem-json
BuildRequires: rubygem-multi_json
BuildRequires: rubygem-open4
BuildRequires: rubygem-rack-protection
BuildRequires: rubygem-rack-test
# ruby libraries for tests
BuildRequires: rubygem-test-unit
# pam devel for compiling rubygem-rpam-ruby19
BuildRequires: pam-devel
# pcsd fonts and font management tools for creating symlinks to fonts
BuildRequires: fontconfig
BuildRequires: liberation-sans-fonts
BuildRequires: overpass-fonts
# for post, preun and postun macros
BuildRequires: systemd
# for UpdateTimestamps sanitization function
BuildRequires: diffstat
# for tests
BuildRequires: corosync
BuildRequires: pacemaker
BuildRequires: pacemaker-cli
BuildRequires: fence-agents-all
BuildRequires: fence-virt
BuildRequires: booth-site

# python and libraries for pcs, setuptools for pcs entrypoint
Requires: python3
Requires: python3-lxml
Requires: python3-pycurl
Requires: python3-setuptools
# ruby and gems for pcsd
Requires: ruby
Requires: rubygem-backports
Requires: rubygem-ethon
Requires: rubygem-ffi
Requires: rubygem-json
Requires: rubygem-multi_json
Requires: rubygem-open4
Requires: rubygem-rack-protection
Requires: rubygem-rack-test
# pcsd fonts
Requires: liberation-sans-fonts
Requires: overpass-fonts
# for killall
Requires: psmisc
# for working with certificates (validation etc.)
Requires: openssl
# cluster stack and related packages
Requires: corosync
Requires: pacemaker
Requires: pacemaker-cli
Requires: python3-clufter => 0.70.0
# for post, preun and postun macros
Requires(post): systemd
Requires(preun): systemd
Requires(postun): systemd

Provides: bundled(rubygem-orderedhash) = 0.0.6
# fedora provides version 2.0.1 which is not compatible with pcsd currently
Provides: bundled(rubygem-rack) = 1.6.4
Provides: bundled(rubygem-rpam-ruby19) = 1.2.1
# fedora provides a patched verison of sinatra which works with rack 2.0.1 but
# doesn't work with rack 1.6.4
Provides: bundled(rubygem-sinatra) = 1.4.8
Provides: bundled(rubygem-sinatra-contrib) = 1.4.7
Provides: bundled(rubygem-tilt) = 2.0.6

%description
pcs is a corosync and pacemaker configuration tool.  It permits users to
easily view, modify and create pacemaker based clusters.

%define PCS_PREFIX /usr
%prep
%setup -q

# -- following borrowed from python-simplejon.el5 --
# Update timestamps on the files touched by a patch, to avoid non-equal
# .pyc/.pyo files across the multilib peers within a build, where "Level"
# is the patch prefix option (e.g. -p1)
UpdateTimestamps() {
  Level=$1
  PatchFile=$2
  # Locate the affected files:
  for f in $(diffstat $Level -l $PatchFile); do
    # Set the files to have the same timestamp as that of the patch:
    touch -r $PatchFile $f
  done
}

%patch0 -p1
UpdateTimestamps -p1 %{PATCH0}

mkdir -p pcsd/.bundle
cp -f %SOURCE1 pcsd/.bundle/config
mkdir -p pcsd/vendor/cache
#copy ruby gems
cp -f %SOURCE11 pcsd/vendor/cache
cp -f %SOURCE12 pcsd/vendor/cache
cp -f %SOURCE13 pcsd/vendor/cache
cp -f %SOURCE14 pcsd/vendor/cache
cp -f %SOURCE15 pcsd/vendor/cache
cp -f %SOURCE16 pcsd/vendor/cache
#ruby gems copied

%build

%install
rm -rf $RPM_BUILD_ROOT
pwd
make install \
  DESTDIR=$RPM_BUILD_ROOT \
  PREFIX=%{PCS_PREFIX} \
  PYTHON=%{__python3} \
  PYTHON_SITELIB=%{python3_sitelib} \
  BASH_COMPLETION_DIR=$RPM_BUILD_ROOT/usr/share/bash-completion/completions
make install_pcsd \
  DESTDIR=$RPM_BUILD_ROOT \
  PREFIX=%{PCS_PREFIX} \
  PYTHON=%{__python3} \
  PYTHON_SITELIB=%{python3_sitelib} \
  hdrdir="%{_includedir}" \
  rubyhdrdir="%{_includedir}" \
  includedir="%{_includedir}"
#after the ruby gem compilation we do not need ruby gems in the cache
rm -r -v $RPM_BUILD_ROOT%{PCS_PREFIX}/lib/pcsd/vendor/cache

%check
# In the building environment LC_CTYPE is set to C which causes tests to fail
# due to python prints a warning about it to stderr. The following environment
# variable disables the warning.
# On the live system either UTF8 locale is set or the warning is emmited
# which breaks pcs. That is the correct behavior since with wrong locales it
# would be probably broken anyway.
# The main concern here is to make the tests pass.
# See https://fedoraproject.org/wiki/Changes/python3_c.utf-8_locale for details.
export PYTHONCOERCECLOCALE=0

run_all_tests(){
  #prepare environmet for tests
  sitelib=$RPM_BUILD_ROOT%{python3_sitelib}
  pcsd_dir=$RPM_BUILD_ROOT%{PCS_PREFIX}/lib/pcsd
  export PYTHONPATH="${PYTHONPATH}:${sitelib}"

  #run pcs tests and remove them, we do not distribute them in the rpm

  # disabled tests:
  #
  # pcs.test.test_cluster.ClusterTest.testUIDGID
  #   touches live cluster configuration, cannot run in mock environment
  # pcs.test.cib_resource.test_create.Success.test_base_create_with_agent_name_including_systemd_instance
  #   It requires systemd to be running so pacemaker can connect to it via dbus.
  #   This is not possible during building.
  #   AssertionError: 0 != 1 : Expected return code "0", but was "1"
  #   command: resource create R systemd:lvm2-pvscan@252:2 --no-default-ops
  #   stdout: Error: Agent 'systemd:lvm2-pvscan@252:2' is not installed or does
  #     not provide valid metadata: error: crm_abort: systemd_unit_exec:
  #     Triggered fatal assert at systemd.c:728 : systemd_init(), use --force to
  #     override
  %{__python3} ${sitelib}/pcs/test/suite.py -v --vanilla --all-but \
    pcs.test.test_cluster.ClusterTest.testUIDGID \
    pcs.test.cib_resource.test_create.Success.test_base_create_with_agent_name_including_systemd_instance \

  test_result_python=$?

  #remove pcs tests, we do not distribute them in the rpm
  find ${sitelib}/pcs -name test -type d -print0|xargs -0 rm -r -v --

  #run pcsd tests and remove them
  GEM_HOME=${pcsd_dir}/vendor/bundle/ruby ruby \
    -I${pcsd_dir} \
    -I${pcsd_dir}/test \
    ${pcsd_dir}/test/test_all_suite.rb
  test_result_ruby=$?
  #remove pcsd tests, we do not distribute them in the rpm
  rm -r -v ${pcsd_dir}/test

  if [ $test_result_python -ne 0 ]; then
    return $test_result_python
  fi
  return $test_result_ruby
}

run_all_tests

%pretrans -p <lua>
-- workaround for upgrading from a broken package pcs-0.9.150-1.fc24
-- taken from https://fedoraproject.org/wiki/Packaging:Directory_Replacement
-- see https://bugzilla.redhat.com/show_bug.cgi?id=1370095 for details
for i, path in pairs({
  "/usr/lib/pcsd/vendor/bundle/ruby/extensions",
  "/usr/lib/pcsd/vendor/bundle/ruby/gems",
  "/usr/lib/pcsd/vendor/bundle/ruby/specifications"
}) do
  st = posix.stat(path)
  if st and st.type == "link" then
    os.remove(path)
  end
end

%post
%systemd_post pcsd.service

%preun
%systemd_preun pcsd.service

%postun
%systemd_postun_with_restart pcsd.service

%files
%doc CHANGELOG.md
%doc README
%license COPYING
%{python3_sitelib}/pcs
%{python3_sitelib}/pcs-%{version}-py3.*.egg-info
/usr/sbin/pcs
/usr/lib/pcsd/*
/usr/lib/pcsd/.bundle/config
/usr/lib/systemd/system/pcsd.service
/usr/share/bash-completion/completions/pcs
/var/lib/pcsd
/etc/pam.d/pcsd
/etc/logrotate.d/pcsd
%dir /var/log/pcsd
%config(noreplace) /etc/sysconfig/pcsd
%ghost %config(noreplace) /var/lib/pcsd/cfgsync_ctl
%ghost %config(noreplace) /var/lib/pcsd/pcsd.cookiesecret
%ghost %config(noreplace) /var/lib/pcsd/pcsd.crt
%ghost %config(noreplace) /var/lib/pcsd/pcsd.key
%ghost %config(noreplace) /var/lib/pcsd/pcs_settings.conf
%ghost %config(noreplace) /var/lib/pcsd/pcs_users.conf
%ghost %config(noreplace) /var/lib/pcsd/tokens
%{_mandir}/man8/pcs.*
%{_mandir}/man8/pcsd.*
%exclude /usr/lib/pcsd/*.debian
%exclude /usr/lib/pcsd/pcsd.service
%exclude /usr/lib/pcsd/pcsd.conf
%exclude /usr/lib/pcsd/pcsd.8
%exclude %{python3_sitelib}/pcs/bash_completion
%exclude %{python3_sitelib}/pcs/pcs.8
%exclude %{python3_sitelib}/pcs/pcs

%changelog
* Wed Jul 12 2017 Ondrej Mular <omular@redhat.com> - 0.9.159-1
- Rebased to latest upstream sources (see CHANGELOG.md)

* Tue May 23 2017 Tomas Jelinek <tojeline@redhat.com> - 0.9.156-3
- Fixed python locales issue preventing build-time tests to pass
- Bundle rubygem-tilt which is being retired from Fedora

* Thu Mar 23 2017 Tomas Jelinek <tojeline@redhat.com> - 0.9.156-2
- Fixed Cross-site scripting (XSS) vulnerability in web UI CVE-2017-2661
- Re-added support for clufter as it is now available for Python 3

* Wed Feb 22 2017 Tomas Jelinek <tojeline@redhat.com> - 0.9.156-1
- Rebased to latest upstream sources (see CHANGELOG.md)

* Sat Feb 11 2017 Fedora Release Engineering <releng@fedoraproject.org> - 0.9.155-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild

* Thu Jan 12 2017 Vít Ondruch <vondruch@redhat.com> - 0.9.155-2
- Rebuilt for https://fedoraproject.org/wiki/Changes/Ruby_2.4

* Wed Jan 04 2017 Adam Williamson <awilliam@redhat.com> - 0.9.155-1
- Latest release 0.9.155
- Fix tests with Python 3.6 and lxml 3.7
- Package the license as license, not doc
- Use -f param for rm when wiping test directories as they are nested now

* Mon Dec 19 2016 Miro Hrončok <mhroncok@redhat.com>
- Rebuild for Python 3.6

* Tue Oct 18 2016 Tomas Jelinek <tojeline@redhat.com> - 0.9.154-2
- Fixed upgrading from pcs-0.9.150

* Thu Sep 22 2016 Tomas Jelinek <tojeline@redhat.com> - 0.9.154-1
- Re-synced to upstream sources
- Spec file cleanup and fixes

* Tue Jul 19 2016 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.9.150-2
- https://fedoraproject.org/wiki/Changes/Automatic_Provides_for_Python_RPM_Packages

* Mon Apr 11 2016 Tomas Jelinek <tojeline@redhat.com> - 0.9.150-1
- Re-synced to upstream sources
- Make pcs depend on python3
- Spec file cleanup

* Tue Feb 23 2016 Tomas Jelinek <tojeline@redhat.com> - 0.9.149-2
- Fixed rubygems issues which prevented pcsd from starting
- Added missing python-lxml dependency

* Thu Feb 18 2016 Tomas Jelinek <tojeline@redhat.com> - 0.9.149-1
- Re-synced to upstream sources
- Security fix for CVE-2016-0720, CVE-2016-0721
- Fixed rubygems issues which prevented pcsd from starting
- Rubygems built with RELRO
- Spec file cleanup
- Fixed multilib .pyc/.pyo issue

* Thu Feb 04 2016 Fedora Release Engineering <releng@fedoraproject.org> - 0.9.144-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild

* Tue Jan 12 2016 Vít Ondruch <vondruch@redhat.com> - 0.9.144-2
- Rebuilt for https://fedoraproject.org/wiki/Changes/Ruby_2.3

* Fri Sep 18 2015 Tomas Jelinek <tojeline@redhat.com> - 0.9.144-1
- Re-synced to upstream sources

* Tue Jun 23 2015 Tomas Jelinek <tojeline@redhat.com> - 0.9.141-2
- Added requirement for psmisc for killall

* Tue Jun 23 2015 Tomas Jelinek <tojeline@redhat.com> - 0.9.141-1
- Re-synced to upstream sources

* Thu Jun 18 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.9.140-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild

* Fri Jun 05 2015 Tomas Jelinek <tojeline@redhat.com> - 0.9.140-1
- Re-synced to upstream sources

* Fri May 22 2015 Tomas Jelinek <tojeline@redhat.com> - 0.9.139-4
- Fix for CVE-2015-1848, CVE-2015-3983 (sessions not signed)

* Thu Mar 26 2015 Tomas Jelinek <tojeline@redhat.com> - 0.9.139-3
- Add BuildRequires: systemd (rhbz#1206253)

* Fri Feb 27 2015 Tomas Jelinek <tojeline@redhat.com> - 0.9.139-2
- Reflect clufter inclusion (rhbz#1180723)

* Thu Feb 19 2015 Tomas Jelinek <tojeline@redhat.com> - 0.9.139-1
- Re-synced to upstream sources

* Sat Jan 17 2015 Mamoru TASAKA <mtasaka@fedoraproject.org> - 0.9.115-5
- Rebuild for https://fedoraproject.org/wiki/Changes/Ruby_2.2

* Sun Aug 17 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.9.115-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild

* Fri Jun 06 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.9.115-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild

* Tue May 06 2014 Tomas Jelinek <tojeline@redhat.com> - 0.9.115-2
- Rebuild to fix ruby dependencies

* Mon Apr 21 2014 Chris Feist <cfeist@redhat.com> - 0.9.115-1
- Re-synced to upstream sources

* Fri Dec 13 2013 Chris Feist <cfeist@redhat.com> - 0.9.102-1
- Re-synced to upstream sources

* Wed Jun 19 2013 Chris Feist <cfeist@redhat.com> - 0.9.48-1
- Rebuild with upstream sources

* Thu Jun 13 2013 Chris Feist <cfeist@redhat.com> - 0.9.44-5
- Added fixes for building rpam with ruby-2.0.0

* Mon Jun 03 2013 Chris Feist <cfeist@redhat.com> - 0.9.44-4
- Rebuild with upstream sources

* Tue May 07 2013 Chris Feist <cfeist@redhat.com> - 0.9.41-2
- Resynced to upstream sources

* Fri Apr 19 2013 Chris Feist <cfeist@redhat.com> - 0.9.39-1
- Fixed gem building
- Re-synced to upstream sources

* Mon Mar 25 2013 Chris Feist <cfeist@rehdat.com> - 0.9.36-4
- Don't try to build gems at all

* Mon Mar 25 2013 Chris Feist <cfeist@rehdat.com> - 0.9.36-3
- Removed all gems from build, will need to find pam package in the future

* Mon Mar 25 2013 Chris Feist <cfeist@redhat.com> - 0.9.36-2
- Removed duplicate libraries already present in fedora

* Mon Mar 18 2013 Chris Feist <cfeist@redhat.com> - 0.9.36-1
- Resynced to latest upstream

* Mon Mar 11 2013 Chris Feist <cfeist@redhat.com> - 0.9.33-1
- Resynched to latest upstream
- pcsd has been moved to /usr/lib to fix /usr/local packaging issues

* Thu Feb 21 2013 Chris Feist <cfeist@redhat.com> - 0.9.32-1
- Resynced to latest version of pcs/pcsd

* Mon Nov 05 2012 Chris Feist <cfeist@redhat.com> - 0.9.27-3
- Build on all archs

* Thu Oct 25 2012 Chris Feist <cfeist@redhat.com> - 0.9.27-2
- Resync to latest version of pcs
- Added pcsd daemon

* Mon Oct 08 2012 Chris Feist <cfeist@redhat.cmo> - 0.9.26-1
- Resync to latest version of pcs

* Thu Sep 20 2012 Chris Feist <cfeist@redhat.cmo> - 0.9.24-1
- Resync to latest version of pcs

* Thu Sep 20 2012 Chris Feist <cfeist@redhat.cmo> - 0.9.23-1
- Resync to latest version of pcs

* Wed Sep 12 2012 Chris Feist <cfeist@redhat.cmo> - 0.9.22-1
- Resync to latest version of pcs

* Thu Sep 06 2012 Chris Feist <cfeist@redhat.cmo> - 0.9.19-1
- Resync to latest version of pcs

* Tue Aug 07 2012 Chris Feist <cfeist@redhat.com> - 0.9.12-1
- Resync to latest version of pcs

* Fri Jul 20 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.9.3.1-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild

* Thu May 24 2012 Chris Feist <cfeist@redhat.com> - 0.9.4-1
- Resync to latest version of pcs
- Move cluster creation options to cluster sub command.

* Mon May 07 2012 Chris Feist <cfeist@redhat.com> - 0.9.3.1-1
- Resync to latest version of pcs which includes fixes to work with F17.

* Mon Mar 19 2012 Chris Feist <cfeist@redhat.com> - 0.9.2.4-1
- Resynced to latest version of pcs

* Mon Jan 23 2012 Chris Feist <cfeist@redhat.com> - 0.9.1-1
- Updated BuildRequires and %doc section for fedora

* Fri Jan 20 2012 Chris Feist <cfeist@redhat.com> - 0.9.0-2
- Updated spec file for fedora specific changes

* Mon Jan 16 2012 Chris Feist <cfeist@redhat.com> - 0.9.0-1
- Initial Build