File cassandra.spec of Package cassandra
#
# spec file for cassandra
#
# Copyright (c) 2017 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 ! %{defined _fillupdir}
%define _fillupdir /var/adm/fillup-templates
%endif
%define _pkgvendor apache
%define _pkg cassandra
%define _pkgname %{_pkgvendor}-%{_pkg}
# only needed for < 1310
%{!?_tmpfilesdir:%global _tmpfilesdir /usr/lib/tmpfiles.d}
%define _fwdefdir /etc/sysconfig/SuSEfirewall2.d/services
Name: cassandra
Version: 3.11.2
Release: 0
License: Apache-2.0
Summary: A scalable, eventually consistent, distributed, structured key-value store
Url: http://cassandra.apache.org/
Group: Development/Libraries
Source: http://www.us.apache.org/dist/%{_pkg}/%{version}/%{_pkgvendor}-%{_pkg}-%{version}-src.tar.gz
Source2: cassandra.limits
Source3: cassandra.sysconfig
Source4: cassandra.fw
Source5: cassandra.service.suse
Source6: build.sh
BuildRequires: fdupes
BuildRequires: python-devel
BuildRequires: python-Sphinx
BuildRequires: python-Cython
# This package is required to provide the various jars the build would
# otherwise would attempt to download from the Internet (which will fail in the
# OBS environment). If you update the Cassandra package itself you will
# probably need to regenerate this kit package (at a minimum you will have to
# bump its version). You will find instructions on updating it in its
# README.building file.
BuildRequires: %{_pkg}-kit = %{version}
BuildRequires: java-1_8_0-openjdk-devel
BuildRequires: java-1_8_0-openjdk
%if 0%{?suse_version} >= 1210
BuildRequires: systemd
%{?systemd_requires}
%define has_systemd 1
%endif
Requires: java-1_8_0-openjdk
Requires: jpackage-utils
Provides: apache-cassandra
BuildRoot: %{_tmppath}/%{name}-%{version}-build
#BuildArch: noarch
PreReq: %fillup_prereq
PreReq: %insserv_prereq
%description
Cassandra brings together the distributed systems technologies from
Dynamo and the data model from Google's BigTable. Like Dynamo,
Cassandra is eventually consistent. Like BigTable, Cassandra provides
a ColumnFamily-based data model richer than typical key/value systems.
For more information see http://cassandra.apache.org/
%package javadoc
Summary: Javadoc for %{_pkg}
Requires: %{name} = %{version}
%description javadoc
Java documentation for %{name}
%package tools
Summary: Extra tools for Cassandra
Requires: %{name} = %{version}
%description tools
This package contains extra tools for working with Cassandra clusters.
%prep
%setup -q -n %{_pkgname}-%{version}-src
cp -Rf %{_datadir}/tetra ../kit
# remove windows scripts
find . -name \*.ps1 -delete
find . -name \*.bat -delete
%build
sh %{SOURCE6}
# build python library
pushd pylib
python setup.py build
popd
%install
# https://en.opensuse.org/openSUSE:Packaging_Java#bytecode_version_error
%if 0%{?suse_version} == 1110
export NO_BRP_CHECK_BYTECODE_VERSION=true
%endif
install -d -m 0755 %{buildroot}%{_sysconfdir}/default
install -d -m 0755 %{buildroot}%{_sysconfdir}/%{_pkg}/conf
install -d -m 0755 %{buildroot}%{_sysconfdir}/security/limits.d
install -d -m 0755 %{buildroot}%{_bindir}
install -d -m 0755 %{buildroot}%{_unitdir}
install -d -m 0755 %{buildroot}%{_sbindir}
install -d -m 0755 %{buildroot}%{_datarootdir}/%{_pkg}
install -d -m 0755 %{buildroot}%{_datarootdir}/%{_pkg}/lib
install -d -m 0755 %{buildroot}%{_localstatedir}/log/%{_pkg}
install -d -m 0755 %{buildroot}%{_localstatedir}/lib/%{_pkg}
install -d -m 0755 %{buildroot}%{_localstatedir}/lib/%{_pkg}/{commitlog,data,saved_caches}
%if 0%{?suse_version} == 1315
install -d -m 0755 %{buildroot}%{_localstatedir}/run/%{_pkg}
%else
install -d -m 0755 %{buildroot}/run/%{_pkg}
%endif
install -d -m 0755 %{buildroot}%{_fillupdir}
install -m 0755 bin/cassandra %{buildroot}%{_sbindir}
install -m 0755 bin/cqlsh %{buildroot}%{_bindir}
install -m 0755 bin/cqlsh.py %{buildroot}%{_bindir}
install -m 0755 bin/debug-cql %{buildroot}%{_bindir}
install -m 0755 bin/nodetool %{buildroot}%{_bindir}
install -m 0755 bin/sstableloader %{buildroot}%{_bindir}
install -m 0755 bin/sstablescrub %{buildroot}%{_bindir}
install -m 0755 bin/sstableupgrade %{buildroot}%{_bindir}
install -m 0755 bin/sstableutil %{buildroot}%{_bindir}
install -m 0755 bin/sstableverify %{buildroot}%{_bindir}
install -m 0755 bin/stop-server %{buildroot}%{_bindir}
install -m 0755 tools/bin/sstablesplit %{buildroot}%{_bindir}
install -m 0755 tools/bin/cassandra-stress %{buildroot}%{_bindir}
install -m 0755 tools/bin/cassandra-stressd %{buildroot}%{_bindir}
install -m 0755 tools/bin/compaction-stress %{buildroot}%{_bindir}
install -m 0755 tools/bin/sstabledump %{buildroot}%{_bindir}
install -m 0755 tools/bin/sstableexpiredblockers %{buildroot}%{_bindir}
install -m 0755 tools/bin/sstablelevelreset %{buildroot}%{_bindir}
install -m 0755 tools/bin/sstablemetadata %{buildroot}%{_bindir}
install -m 0755 tools/bin/sstableofflinerelevel %{buildroot}%{_bindir}
install -m 0755 tools/bin/sstablerepairedset %{buildroot}%{_bindir}
install -m 0755 tools/bin/sstablesplit %{buildroot}%{_bindir}
# This is not part of the binary release tarball, so remove it here as well:
rm lib/maven-ant-tasks-*.jar
mv build/tools/lib/* %{buildroot}%{_datarootdir}/%{_pkg}/lib/
# set home and conf
sed -i -e '/x$CASSANDRA_HOME/i CASSANDRA_HOME=/usr/share/cassandra' \
-e '/x$CASSANDRA_CONF/i CASSANDRA_CONF=/etc/cassandra/conf' \
bin/cassandra.in.sh
install -m 0644 bin/cassandra.in.sh %{buildroot}%{_datarootdir}/%{_pkg}
mv conf/* %{buildroot}%{_sysconfdir}/%{_pkg}/conf
cp lib/*.jar lib/*.zip %{buildroot}%{_datarootdir}/%{_pkg}/lib/
cp build/%{_pkgname}-%{version}-SNAPSHOT.jar %{buildroot}%{_datarootdir}/%{_pkg}/lib/
cp build/%{_pkgname}-thrift-%{version}-SNAPSHOT.jar %{buildroot}%{_datarootdir}/%{_pkg}/lib/
install -m 0644 %{SOURCE2} %{buildroot}%{_sysconfdir}/security/limits.d/%{_pkg}.conf
install -m 0644 %{SOURCE3} %{buildroot}%{_fillupdir}/sysconfig.%{_pkg}
install -m 0644 %{SOURCE5} %{buildroot}%{_unitdir}/%{_pkg}.service
# create symlinks
pushd %{buildroot}%{_datarootdir}/%{_pkg}
ln -s %{_localstatedir}/lib/%{_pkg} data
ln -s %{_localstatedir}/log/%{_pkg} logs
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}
popd
install -d -m 0755 %{buildroot}%{_fwdefdir}
install -m 0644 %{SOURCE4} %{buildroot}%{_fwdefdir}/%{_pkg}
%fdupes %{buildroot}
# install python library
pushd pylib
python setup.py install --prefix=%{_prefix} --root=%{buildroot}
popd
%pre
groupadd -r %{_pkg} 2>/dev/null || :
useradd -r -g %{_pkg} -s /bin/bash -c "Cassandra User" \
-d %{_datarootdir}/%{_pkg} %{_pkg} 2>/dev/null || :
%service_add_pre %{_pkg}.service
%post
%fillup_only -n %{_pkg}
%service_add_post %{_pkg}.service
%preun
%service_del_preun %{_pkg}.service
%stop_on_removal %{_pkg}
%postun
%service_del_postun unbound-keygen.service unbound.service
%files
%defattr(-,root,root)
%doc CHANGES.txt LICENSE.txt NEWS.txt NOTICE.txt interface lib/licenses
%dir %attr(0755 cassandra,cassandra) %{_sysconfdir}/%{_pkg}
%dir %attr(0755 cassandra,cassandra) %{_sysconfdir}/%{_pkg}/conf
%config(noreplace) %attr(0644 cassandra,cassandra) %{_sysconfdir}/%{_pkg}/conf/*
%dir %{_sysconfdir}/security/limits.d
%config(noreplace) %attr(0644 root,root) %{_sysconfdir}/security/limits.d/%{_pkg}.conf
%{_fwdefdir}/%{_pkg}
%{_bindir}/cqlsh
%{_bindir}/cqlsh.py
%{_bindir}/debug-cql
%{_bindir}/nodetool
%{_bindir}/sstableloader
%{_bindir}/sstablescrub
%{_bindir}/sstableupgrade
%{_bindir}/sstableutil
%{_bindir}/sstableverify
%{_bindir}/stop-server
%{_sbindir}/cassandra
%{_datarootdir}/%{_pkg}
%attr(0755 cassandra,cassandra) %{_localstatedir}/log/%{_pkg}
%attr(0755 cassandra,cassandra) %{_localstatedir}/lib/%{_pkg}
%if 0%{?suse_version} == 1315
%ghost %{_localstatedir}/run/%{_pkg}
%else
%ghost /run/%{_pkg}
%endif
%{_fillupdir}/sysconfig.%{_pkg}
%{_unitdir}/%{_pkg}.service
%{_sbindir}/rc%{name}
# python library
%{python_sitearch}/*
%files tools
%defattr(-,root,root)
%{_bindir}/cassandra-stress
%{_bindir}/cassandra-stressd
%{_bindir}/compaction-stress
%{_bindir}/sstabledump
%{_bindir}/sstablelevelreset
%{_bindir}/sstablemetadata
%{_bindir}/sstableofflinerelevel
%{_bindir}/sstablesplit
%{_bindir}/sstablerepairedset
%{_bindir}/sstableexpiredblockers
%files javadoc
%defattr(-,root,root)
%doc javadoc
%changelog