Add redhat RPM build directory
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/6d770c4f Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/6d770c4f Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/6d770c4f Branch: refs/heads/cassandra-3.0 Commit: 6d770c4ff56fbdd195bc4f89e64cb69df5b3cb7c Parents: a449e8f Author: Michael Shuler <mich...@pbandjelly.org> Authored: Fri Dec 2 18:15:33 2016 -0600 Committer: Michael Shuler <mich...@pbandjelly.org> Committed: Tue Dec 6 17:26:34 2016 -0600 ---------------------------------------------------------------------- redhat/README.md | 31 ++++++++ redhat/cassandra | 94 +++++++++++++++++++++++ redhat/cassandra.conf | 4 + redhat/cassandra.in.sh | 30 ++++++++ redhat/cassandra.spec | 176 ++++++++++++++++++++++++++++++++++++++++++++ redhat/default | 7 ++ 6 files changed, 342 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/6d770c4f/redhat/README.md ---------------------------------------------------------------------- diff --git a/redhat/README.md b/redhat/README.md new file mode 100644 index 0000000..0b2ab0d --- /dev/null +++ b/redhat/README.md @@ -0,0 +1,31 @@ +# Apache Cassandra rpmbuild + +### Requirements: +- The build system needs to have Apache Cassandra `ant artifacts` build dependencies installed. +- Since Apache Cassandra depends on Python 2.7, the earliest version supported is RHEL/CentOS 7.0. + +### Step 1: +- Build and copy sources to build tree: +``` +ant artifacts +cp build/apache-cassandra-*-src.tar.gz $RPM_BUILD_DIR/SOURCES/ +``` + +### Step 2: +- Since there is no version specified in the SPEC file, one needs to be passed at `rpmbuild` time (example with 4.0): +``` +rpmbuild --define="version 4.0" -ba redhat/cassandra.spec +``` + +- RPM files can be found in their respective build tree directories: +``` +ls -l $RPM_BUILD_DIR/{SRPMS,RPMS}/ +``` + +### Hint: +- Don't build packages as root.. +``` +# this makes your RPM_BUILD_DIR = ~/rpmbuild +mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS} +echo '%_topdir %(echo $HOME)/rpmbuild' > ~/.rpmmacros +``` http://git-wip-us.apache.org/repos/asf/cassandra/blob/6d770c4f/redhat/cassandra ---------------------------------------------------------------------- diff --git a/redhat/cassandra b/redhat/cassandra new file mode 100644 index 0000000..3e59534 --- /dev/null +++ b/redhat/cassandra @@ -0,0 +1,94 @@ +#!/bin/bash +# +# /etc/init.d/cassandra +# +# Startup script for Cassandra +# +# chkconfig: 2345 20 80 +# description: Starts and stops Cassandra + +. /etc/rc.d/init.d/functions + +export CASSANDRA_HOME=/usr/share/cassandra +export CASSANDRA_CONF=/etc/cassandra/conf +export CASSANDRA_INCLUDE=$CASSANDRA_HOME/cassandra.in.sh +export CASSANDRA_OWNR=cassandra +NAME="cassandra" +log_file=/var/log/cassandra/cassandra.log +pid_file=/var/run/cassandra/cassandra.pid +lock_file=/var/lock/subsys/$NAME +CASSANDRA_PROG=/usr/sbin/cassandra + +# The first existing directory is used for JAVA_HOME if needed. +JVM_SEARCH_DIRS="/usr/lib/jvm/jre /usr/lib/jvm/jre-1.7.* /usr/lib/jvm/java-1.7.*/jre" + +# Read configuration variable file if it is present +[ -r /etc/default/$NAME ] && . /etc/default/$NAME + +# If JAVA_HOME has not been set, try to determine it. +if [ -z "$JAVA_HOME" ]; then + # If java is in PATH, use a JAVA_HOME that corresponds to that. This is + # both consistent with how the upstream startup script works, and with + # the use of alternatives to set a system JVM (as is done on Debian and + # Red Hat derivatives). + java="`/usr/bin/which java 2>/dev/null`" + if [ -n "$java" ]; then + java=`readlink --canonicalize "$java"` + JAVA_HOME=`dirname "\`dirname \$java\`"` + else + # No JAVA_HOME set and no java found in PATH; search for a JVM. + for jdir in $JVM_SEARCH_DIRS; do + if [ -x "$jdir/bin/java" ]; then + JAVA_HOME="$jdir" + break + fi + done + # if JAVA_HOME is still empty here, punt. + fi +fi +JAVA="$JAVA_HOME/bin/java" +export JAVA_HOME JAVA + +case "$1" in + start) + # Cassandra startup + echo -n "Starting Cassandra: " + su $CASSANDRA_OWNR -c "$CASSANDRA_PROG -p $pid_file" > $log_file 2>&1 + retval=$? + [ $retval -eq 0 ] && touch $lock_file + echo "OK" + ;; + stop) + # Cassandra shutdown + echo -n "Shutdown Cassandra: " + su $CASSANDRA_OWNR -c "kill `cat $pid_file`" + retval=$? + [ $retval -eq 0 ] && rm -f $lock_file + for t in `seq 40`; do $0 status > /dev/null 2>&1 && sleep 0.5 || break; done + # Adding a sleep here to give jmx time to wind down (CASSANDRA-4483). Not ideal... + # Adam Holmberg suggests this, but that would break if the jmx port is changed + # for t in `seq 40`; do netstat -tnlp | grep "0.0.0.0:7199" > /dev/null 2>&1 && sleep 0.1 || break; done + sleep 5 + STATUS=`$0 status` + if [[ $STATUS == "$NAME is stopped" ]]; then + echo "OK" + else + echo "ERROR: could not stop $NAME: $STATUS" + exit 1 + fi + ;; + reload|restart) + $0 stop + $0 start + ;; + status) + status -p $pid_file cassandra + exit $? + ;; + *) + echo "Usage: `basename $0` start|stop|status|restart|reload" + exit 1 +esac + +exit 0 + http://git-wip-us.apache.org/repos/asf/cassandra/blob/6d770c4f/redhat/cassandra.conf ---------------------------------------------------------------------- diff --git a/redhat/cassandra.conf b/redhat/cassandra.conf new file mode 100644 index 0000000..a5aebe1 --- /dev/null +++ b/redhat/cassandra.conf @@ -0,0 +1,4 @@ +cassandra - memlock unlimited +cassandra - nofile 100000 +cassandra - nproc 32768 +cassandra - as unlimited http://git-wip-us.apache.org/repos/asf/cassandra/blob/6d770c4f/redhat/cassandra.in.sh ---------------------------------------------------------------------- diff --git a/redhat/cassandra.in.sh b/redhat/cassandra.in.sh new file mode 100644 index 0000000..ca71782 --- /dev/null +++ b/redhat/cassandra.in.sh @@ -0,0 +1,30 @@ + +# The directory where Cassandra's configs live (required) +CASSANDRA_CONF=/etc/cassandra/conf + +CASSANDRA_HOME=/usr/share/cassandra + +# The java classpath (required) +if [ -n "$CLASSPATH" ]; then + CLASSPATH=$CLASSPATH:$CASSANDRA_CONF +else + CLASSPATH=$CASSANDRA_CONF +fi + +for jar in /usr/share/cassandra/lib/*.jar; do + CLASSPATH=$CLASSPATH:$jar +done + +for jar in /usr/share/cassandra/*.jar; do + CLASSPATH=$CLASSPATH:$jar +done + +CLASSPATH="$CLASSPATH:$EXTRA_CLASSPATH" + + +# set JVM javaagent opts to avoid warnings/errors +if [ "$JVM_VENDOR" != "OpenJDK" -o "$JVM_VERSION" \> "1.6.0" ] \ + || [ "$JVM_VERSION" = "1.6.0" -a "$JVM_PATCH_VERSION" -ge 23 ] +then + JAVA_AGENT="$JAVA_AGENT -javaagent:$CASSANDRA_HOME/lib/jamm-0.3.0.jar" +fi http://git-wip-us.apache.org/repos/asf/cassandra/blob/6d770c4f/redhat/cassandra.spec ---------------------------------------------------------------------- diff --git a/redhat/cassandra.spec b/redhat/cassandra.spec new file mode 100644 index 0000000..b40a706 --- /dev/null +++ b/redhat/cassandra.spec @@ -0,0 +1,176 @@ +%define __jar_repack %{nil} +# Turn off the brp-python-bytecompile script +%global __os_install_post %(echo '%{__os_install_post}' | sed -e 's!/usr/lib[^[:space:]]*/brp-python-bytecompile[[:space:]].*$!!g') + +%global username cassandra + +%define relname apache-cassandra-%{version} +%define revision 1 + +Name: cassandra +Version: %{version} +Release: %{revision} +Summary: Cassandra is a highly scalable, eventually consistent, distributed, structured key-value store. + +Group: Development/Libraries +License: Apache Software License 2.0 +URL: http://cassandra.apache.org/ +Source0: %{relname}-src.tar.gz +BuildRoot: %{_tmppath}/%{relname}root-%(%{__id_u} -n) + +BuildRequires: ant + +Requires: jre >= 1.7.0 +Requires: python(abi) >= 2.7 +Requires(pre): user(cassandra) +Requires(pre): group(cassandra) +Requires(pre): shadow-utils +Provides: user(cassandra) +Provides: group(cassandra) + +BuildArch: noarch + +# Don't examine the .so files we bundle for dependencies +AutoReqProv: no + +%description +Cassandra is a distributed (peer-to-peer) system for the management and storage of structured data. + +%prep +%setup -q -n %{relname}-src + +%build +export LANG=en_US.UTF-8 +export JAVA_TOOL_OPTIONS="-Dfile.encoding=UTF-8" +ant clean jar -Dversion=%{version} + +%install +%{__rm} -rf %{buildroot} +mkdir -p %{buildroot}/%{_sysconfdir}/%{username} +mkdir -p %{buildroot}/usr/share/%{username} +mkdir -p %{buildroot}/usr/share/%{username}/lib +mkdir -p %{buildroot}/%{_sysconfdir}/%{username}/default.conf +mkdir -p %{buildroot}/%{_sysconfdir}/rc.d/init.d +mkdir -p %{buildroot}/%{_sysconfdir}/security/limits.d +mkdir -p %{buildroot}/%{_sysconfdir}/default +mkdir -p %{buildroot}/usr/sbin +mkdir -p %{buildroot}/usr/bin +mkdir -p %{buildroot}/var/lib/%{username}/commitlog +mkdir -p %{buildroot}/var/lib/%{username}/data +mkdir -p %{buildroot}/var/lib/%{username}/saved_caches +mkdir -p %{buildroot}/var/run/%{username} +mkdir -p %{buildroot}/var/log/%{username} +( cd pylib && python2.7 setup.py install --no-compile --root %{buildroot}; ) + +# patches for data and log paths +patch -p1 < debian/patches/001cassandra_yaml_dirs.dpatch +patch -p1 < debian/patches/002cassandra_logdir_fix.dpatch + +# remove batch, powershell, and other files not being installed +rm conf/*.ps1 +rm bin/*.bat +rm bin/*.orig +rm bin/*.ps1 +rm bin/cassandra.in.sh +rm lib/sigar-bin/*winnt* # strip segfaults on dll.. +rm tools/bin/*.bat +rm tools/bin/cassandra.in.sh + +# copy default configs +cp -pr conf/* %{buildroot}/%{_sysconfdir}/%{username}/default.conf/ + +# step on default config with our redhat one +cp -p redhat/%{username}.in.sh %{buildroot}/usr/share/%{username}/%{username}.in.sh +cp -p redhat/%{username} %{buildroot}/%{_sysconfdir}/rc.d/init.d/%{username} +cp -p redhat/%{username}.conf %{buildroot}/%{_sysconfdir}/security/limits.d/ +cp -p redhat/default %{buildroot}/%{_sysconfdir}/default/%{username} + +# copy cassandra bundled libs +cp -pr lib/* %{buildroot}/usr/share/%{username}/lib/ + +# copy stress jar +cp -p build/tools/lib/stress.jar %{buildroot}/usr/share/%{username}/ + +# copy binaries +mv bin/cassandra %{buildroot}/usr/sbin/ +cp -p bin/* %{buildroot}/usr/bin/ +cp -p tools/bin/* %{buildroot}/usr/bin/ + +# copy cassandra, thrift jars +cp build/apache-cassandra-%{version}.jar %{buildroot}/usr/share/%{username}/ +cp build/apache-cassandra-thrift-%{version}.jar %{buildroot}/usr/share/%{username}/ + +%clean +%{__rm} -rf %{buildroot} + +%pre +getent group %{username} >/dev/null || groupadd -r %{username} +getent passwd %{username} >/dev/null || \ +useradd -d /var/lib/%{username} -g %{username} -M -r %{username} +exit 0 + +%files +%defattr(0644,root,root,0755) +%doc CHANGES.txt LICENSE.txt README.asc NEWS.txt NOTICE.txt +%attr(755,root,root) %{_bindir}/cassandra-stress +%attr(755,root,root) %{_bindir}/cqlsh +%attr(755,root,root) %{_bindir}/cqlsh.py +%attr(755,root,root) %{_bindir}/debug-cql +%attr(755,root,root) %{_bindir}/nodetool +%attr(755,root,root) %{_bindir}/sstablekeys +%attr(755,root,root) %{_bindir}/sstableloader +%attr(755,root,root) %{_bindir}/sstablescrub +%attr(755,root,root) %{_bindir}/sstableupgrade +%attr(755,root,root) %{_bindir}/sstableverify +%attr(755,root,root) %{_bindir}/stop-server +%attr(755,root,root) %{_sbindir}/cassandra +%attr(755,root,root) /%{_sysconfdir}/rc.d/init.d/%{username} +%attr(755,root,root) /%{_sysconfdir}/default/%{username} +%attr(755,root,root) /%{_sysconfdir}/security/limits.d/%{username}.conf +%attr(755,%{username},%{username}) /usr/share/%{username}* +%attr(755,%{username},%{username}) %config(noreplace) /%{_sysconfdir}/%{username} +%attr(755,%{username},%{username}) %config(noreplace) /var/lib/%{username}/* +%attr(755,%{username},%{username}) /var/log/%{username}* +%attr(755,%{username},%{username}) /var/run/%{username}* +/usr/lib/python2.7/site-packages/cqlshlib/ +/usr/lib/python2.7/site-packages/cassandra_pylib*.egg-info + +%post +alternatives --install /%{_sysconfdir}/%{username}/conf %{username} /%{_sysconfdir}/%{username}/default.conf/ 0 +exit 0 + +%preun +# only delete alternative on removal, not upgrade +if [ "$1" = "0" ]; then + alternatives --remove %{username} /%{_sysconfdir}/%{username}/default.conf/ +fi +exit 0 + + +%package tools +Summary: Extra tools for Cassandra. Cassandra is a highly scalable, eventually consistent, distributed, structured key-value store. +Group: Development/Libraries +Requires: cassandra = %{version}-%{revision} + +%description tools +Cassandra is a distributed (peer-to-peer) system for the management and storage of structured data. +. +This package contains extra tools for working with Cassandra clusters. + +%files tools +%attr(755,root,root) %{_bindir}/cassandra-stressd +%attr(755,root,root) %{_bindir}/json2sstable +%attr(755,root,root) %{_bindir}/sstable2json +%attr(755,root,root) %{_bindir}/sstableexpiredblockers +%attr(755,root,root) %{_bindir}/sstablelevelreset +%attr(755,root,root) %{_bindir}/sstablemetadata +%attr(755,root,root) %{_bindir}/sstableofflinerelevel +%attr(755,root,root) %{_bindir}/sstablerepairedset +%attr(755,root,root) %{_bindir}/sstablesplit +%attr(755,root,root) %{_bindir}/token-generator + + +%changelog +* Mon Dec 05 2016 Michael Shuler <mshu...@apache.org> +- 2.1.17, 2.2.9, 3.0.11, 3.10 +- Reintroduce RPM packaging http://git-wip-us.apache.org/repos/asf/cassandra/blob/6d770c4f/redhat/default ---------------------------------------------------------------------- diff --git a/redhat/default b/redhat/default new file mode 100644 index 0000000..1b56a98 --- /dev/null +++ b/redhat/default @@ -0,0 +1,7 @@ +# NOTICE: See also /etc/cassandra/cassandra-env.sh + +# EXTRA_CLASSPATH provides the means to extend Cassandra's classpath with +# additional libraries. It is formatted as a colon-delimited list of +# class directories and/or jar files. For example, to enable the +# JMX-to-web bridge install libmx4j-java and uncomment the following. +#EXTRA_CLASSPATH="/usr/share/java/mx4j-tools.jar"