File apache-cassandra.spec of Package apache-cassandra

%define progname cassandra

%define relname %{name}-%{version}

Name:           apache-cassandra
Version:        2.0.7
Release:        0
Summary:        Cassandra is a highly scalable, distributed, structured key-value store

Group:          Network/Other
License:        Apache-2.0
URL:            http://cassandra.apache.org/
Source0:	http://archive.apache.org/dist/cassandra/%{version}/apache-cassandra-%{version}-bin.tar.gz
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

BuildRequires: java-devel

Requires:      java >= 1.6.0
Requires(pre): /usr/sbin/useradd
Requires(pre): /usr/sbin/groupadd

BuildArch:      noarch

%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/

%prep
%setup -q -n %{relname}

%build

%install
%{__rm} -rf %{buildroot}
mkdir -p %{buildroot}%{_sysconfdir}/%{progname}/
mkdir -p %{buildroot}/usr/share/%{progname}
mkdir -p %{buildroot}/usr/sbin
mkdir -p %{buildroot}%{_bindir}
rm bin/*.bat 
rm bin/cassandra.in.sh
rm bin/stop-server
rm -r lib/licenses
rm lib/*zip
cp -r lib %{buildroot}/usr/share/%{progname}
cp -r conf/* %{buildroot}%{_sysconfdir}/%{progname}
mv bin/cassandra %{buildroot}/usr/sbin
cp bin/* %{buildroot}%{_bindir}
mkdir -p %{buildroot}%{_localstatedir}/lib/%{progname}/commitlog
mkdir -p %{buildroot}%{_localstatedir}/lib/%{progname}/data
mkdir -p %{buildroot}%{_localstatedir}/lib/%{progname}/saved_caches
mkdir -p %{buildroot}%{_localstatedir}/log/%{progname}

# generate cassandra.in.sh
echo "CASSANDRA_HOME=/usr/share/%{progname}" > %{buildroot}/usr/share/%{progname}/cassandra.in.sh
echo "CASSANDRA_CONF=%{_sysconfdir}/%{progname}" >> %{buildroot}/usr/share/%{progname}/cassandra.in.sh
echo "CLASSPATH=\"\$CLASSPATH:\$CASSANDRA_CONF\"" >> %{buildroot}/usr/share/%{progname}/cassandra.in.sh
echo "for jar in \$CASSANDRA_HOME/lib/*jar ; do"  >> %{buildroot}/usr/share/%{progname}/cassandra.in.sh
echo "  CLASSPATH=\"\$CLASSPATH:\$jar\""  >> %{buildroot}/usr/share/%{progname}/cassandra.in.sh
echo "done"  >> %{buildroot}/usr/share/%{progname}/cassandra.in.sh

%clean
%{__rm} -rf %{buildroot}

%files
%defattr(-,root,root,-)
%doc CHANGES.txt LICENSE.txt README.txt NEWS.txt NOTICE.txt
%{_sbindir}/cassandra
%{_bindir}/*
/usr/share/%{progname}*
%dir %{_sysconfdir}/%{progname}
%config(noreplace) %{_sysconfdir}/%{progname}/*
%config(noreplace) %{_localstatedir}/lib/%{progname}/*
%dir %{_localstatedir}/lib/%{progname}
%dir %{_localstatedir}/log/%{progname}


%changelog