Skip to content

Commit

Permalink
Packaging: major refresh for 1.8
Browse files Browse the repository at this point in the history
Created separate Python 2 and 3 packages:

Use separate packages for Python 2 and Python 3 ClusterShell modules
and related command line tools. The python 2 and python 3 stacks are
intended to be fully-installable in parallel as recommended by the
Fedora/EPEL guidelines.

The "clustershell" package includes the common configuration files and
documentation and requires python2-clustershell, mainly because Python 2
is the default interpreter in EPEL 7.

The specfile template could be easily modified to set
python3-clustershell as the default, as recommended in latest Fedora
versions IF the command line tools do actually provide the SAME
functionality, which is _almost_ the case here (tree communication
protocols are not compatible).

Removed vim-clustershell subpackage:

vim-clustershell was confusing so we remove it and add the vim
extensions to the main clustershell subpackage. Another change is the
use of vim-filesystem (when available) instead of vim-common as a
requirement. This is needed for proper vim extension directory
ownership.

Improved portability and tested with:

- EPEL 6 and 7
- Fedora 26, 27 and rawhide
- openSUSE Factory, Leap 42.1, 42.3, Tumbleweed.

Change-Id: I88411e5f2518e86acd44686d14aac2e14876c08a
  • Loading branch information
thiell committed Sep 7, 2017
1 parent c26aa5f commit 059548e
Showing 1 changed file with 137 additions and 31 deletions.
168 changes: 137 additions & 31 deletions clustershell.spec.in
Original file line number Diff line number Diff line change
@@ -1,49 +1,122 @@
%{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")}
%{!?python2_sitelib: %global python2_sitelib %{python_sitelib}}
%{!?__python: %global __python2 python}
%{!?__python2: %global __python2 %{__python}}

%if 0%{?fedora} >= 22
%{!?python2_pkgversion: %global python2_pkgversion 2}
%global python2_pkgprefix python%{python2_pkgversion}
%else
%global python2_pkgprefix python
%endif

%if 0%{?rhel}
%{!?python3_pkgversion: %global python3_pkgversion 34}
%else
%{!?python3_pkgversion: %global python3_pkgversion 3}
%endif
%global python3_pkgprefix python%{python3_pkgversion}

# Undefined in SUSE
%{!?__python3: %global __python3 python3}
%{!?python3_shortver: %global python3_shortver %(%{__python3} -c 'import sys; print(str(sys.version_info.major) + "." + str(sys.version_info.minor))')}

%global srcname ClusterShell

Name: clustershell
Version: %{version}
Release: 1%{?dist}
Release: 5%{?dist}
Summary: Python framework for efficient cluster administration

%if 0%{?suse_version}
License: LGPL-2.1
%else
License: LGPLv2+
%endif
URL: http://cea-hpc.github.io/clustershell/
Source0: https://files.pythonhosted.org/packages/source/C/%{srcname}/%{srcname}-%{version}.tar.gz
BuildArch: noarch
BuildRequires: python-devel
BuildRequires: python-setuptools
Requires: python-setuptools
Requires: PyYAML
Requires: python2-%{name} = %{version}-%{release}
%if 0%{?rhel} >= 7 || 0%{?fedora}
Requires: vim-filesystem
%else if 0%{?suse_version}
BuildRequires: vim
Requires: vim
%else
Requires: vim-common
%endif
Provides: vim-clustershell = %{version}-%{release}
Obsoletes: vim-clustershell < 1.7.81-4

%description
Tools and event-based Python library to execute commands on cluster nodes in
parallel depending on selected engine and worker mechanisms. The library
provides also advanced NodeSet and NodeGroups handling methods to ease and
improve administration of large compute clusters or server farms. Three
convenient command line utilities, clush, clubak and nodeset (or cluset) allow
traditional shell scripts to benefit some useful features offered by the
library.
ClusterShell is a set of tools and a Python library to execute commands
on cluster nodes in parallel depending on selected engine and worker
mechanisms. Advanced node sets and node groups handling methods are provided
to ease and improve the daily administration of large compute clusters or
server farms. Command line utilities like clush, clubak and nodeset (or
cluset) allow traditional shell scripts to take benefit of the features
offered by the library.


%package -n python2-%{name}
Summary: ClusterShell module for Python 2
BuildRequires: %{python2_pkgprefix}-devel
BuildRequires: %{python2_pkgprefix}-setuptools
Requires: %{python2_pkgprefix}-setuptools
%if 0%{?suse_version}
Requires: %{python2_pkgprefix}-PyYAML
%else
Requires: PyYAML
%endif
%{?python_provide:%python_provide python2-%{name}}

%description -n python2-%{name}
ClusterShell Python 2 module and related command line tools.

%package -n vim-%{name}
Summary: VIM files for ClusterShell
Group: System Environment/Base
Requires: clustershell = %{version}-%{release}, vim-common

%description -n vim-%{name}
Syntax highlighting in the VIM editor for ClusterShell configuration files.
%package -n %{python3_pkgprefix}-%{name}
Summary: ClusterShell module for Python 3
BuildRequires: %{python3_pkgprefix}-devel
BuildRequires: %{python3_pkgprefix}-setuptools
Requires: %{python3_pkgprefix}-setuptools
Requires: %{python3_pkgprefix}-PyYAML
%{?python_provide:%python_provide %{python3_pkgprefix}-%{srcname}}

%description -n %{python3_pkgprefix}-%{name}
ClusterShell Python 3 module and related command line tools.


%prep
%setup -q -n %{srcname}-%{version}

%build
%{__python} setup.py build
%{__python3} setup.py build
%{__python2} setup.py build

%install
# install library (lib), scripts (bin) and config (etc)
%{__python} setup.py install -O1 --skip-build --root %{buildroot}
%if 0%{?rhel}
rm -rf %{buildroot}
%endif

%{__python3} setup.py install -O1 --skip-build --root %{buildroot}

pushd %{buildroot}%{_bindir}
for i in clubak cluset clush nodeset; do
mv $i $i-%{python3_shortver}
done
popd

%{__python2} setup.py install -O1 --skip-build --root %{buildroot}

# move config dir away from default setuptools /usr prefix (if rpm-building as user)
[ -d %{buildroot}/usr/etc ] && mv %{buildroot}/usr/etc %{buildroot}/%{_sysconfdir}

%if 0%{?rhel} && 0%{?rhel} <= 6
# old versions of rpm (el5 and el6) requires that a file/link exists in buildroot
# even when ghosted, but it is not installed at the end...
ln -s conf/groups.d/local.cfg %{buildroot}/%{_sysconfdir}/clustershell/groups
%endif

# man pages
install -d %{buildroot}/%{_mandir}/{man1,man5}
install -p -m 0644 doc/man/man1/clubak.1 %{buildroot}/%{_mandir}/man1/
Expand All @@ -54,17 +127,48 @@ install -p -m 0644 doc/man/man5/clush.conf.5 %{buildroot}/%{_mandir}/man5/
install -p -m 0644 doc/man/man5/groups.conf.5 %{buildroot}/%{_mandir}/man5/

# vim addons
%if 0%{?suse_version}
%define vimdatadir %{_datadir}/vim/site
%else
%define vimdatadir %{_datadir}/vim/vimfiles
%endif

install -d %{buildroot}/%{vimdatadir}/{ftdetect,syntax}
install -p -m 0644 doc/extras/vim/ftdetect/clustershell.vim %{buildroot}/%{vimdatadir}/ftdetect/
install -p -m 0644 doc/extras/vim/syntax/clushconf.vim %{buildroot}/%{vimdatadir}/syntax/
install -p -m 0644 doc/extras/vim/syntax/groupsconf.vim %{buildroot}/%{vimdatadir}/syntax/

%if 0%{?rhel}
%clean
rm -rf %{buildroot}
%endif

%files -n python2-%{name}
%if 0%{?rhel}
%defattr(-,root,root,-)
%endif
%{_bindir}/clubak
%{_bindir}/cluset
%{_bindir}/clush
%{_bindir}/nodeset
%{python2_sitelib}/ClusterShell/
%{python2_sitelib}/ClusterShell-*-py?.?.egg-info

%files
%files -n %{python3_pkgprefix}-%{name}
%if 0%{?rhel}
%defattr(-,root,root,-)
%endif
%{_bindir}/clubak-%{python3_shortver}
%{_bindir}/cluset-%{python3_shortver}
%{_bindir}/clush-%{python3_shortver}
%{_bindir}/nodeset-%{python3_shortver}
%{python3_sitelib}/ClusterShell/
%{python3_sitelib}/ClusterShell-*-py?.?.egg-info

%files -n %{name}
%if 0%{?rhel}
%defattr(-,root,root,-)
%endif
%doc ChangeLog COPYING.LGPLv2.1 README.md
%doc doc/examples
%doc doc/sphinx
Expand All @@ -86,20 +190,22 @@ rm -rf %{buildroot}
%doc %{_sysconfdir}/clustershell/groups.d/README
%doc %{_sysconfdir}/clustershell/groups.d/*.yaml.example
%doc %{_sysconfdir}/clustershell/topology.conf.example
%{python_sitelib}/ClusterShell/
%{python_sitelib}/ClusterShell-*-py?.?.egg-info
%{_bindir}/clubak
%{_bindir}/cluset
%{_bindir}/clush
%{_bindir}/nodeset

%files -n vim-%{name}
%defattr(-,root,root,-)
%{vimdatadir}/ftdetect/clustershell.vim
%{vimdatadir}/syntax/clushconf.vim
%{vimdatadir}/syntax/groupsconf.vim

%changelog
* Sun Sep 3 2017 Stephane Thiell <sthiell@stanford.edu> 1.7.81-4
- move vim extensions into the clustershell package
- use Requires: vim-filesystem instead of vim-common
- define upgrade path for vim-clustershell

* Sat Sep 2 2017 Stephane Thiell <sthiell@stanford.edu> 1.7.81-3
- use `python2-` prefix in *Requires if available

* Sat Sep 2 2017 Stephane Thiell <sthiell@stanford.edu> 1.7.81-2
- create separate packages for python2 and python3 modules

* Fri Sep 1 2017 Stephane Thiell <sthiell@stanford.edu> 1.7.81-1
- update to 1.7.81 (1.8 beta1)

Expand Down

0 comments on commit 059548e

Please sign in to comment.