File storm.spec of Package storm
#
# spec file for package storm
#
# Copyright (c) 2017 SUSE LINUX 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/
#
%define username storm
%define groupname storm
Name: storm
Version: 1.2.3
Release: 0
Summary: Apache Storm realtime computation system
License: Apache-2.0
Group: Productivity/Networking/Other
Url: http://storm.apache.org
Source0: http://www-eu.apache.org/dist/%{name}/apache-%{name}-%{version}/apache-%{name}-%{version}-src.tar.gz
Source2: %{name}.conf
Source3: %{name}-nimbus.service
Source4: %{name}-pacemaker.service
Source5: %{name}-supervisor.service
Source6: %{name}-ui.service
Source7: %{name}-logviewer.service
Source8: %{name}-zookeeper.service
Source9: README.SUSE
Source10: %{name}.logrotate
Source11: build.sh
Requires: java-1_8_0-openjdk
Requires: logrotate
Requires: python
BuildRequires: %{name}-kit == %{version}
BuildRequires: dos2unix
# This is a RPM that contains all dependencies used by Storm's Maven based
# build. It needs to be rebuilt from the new Storm version's source tarball.
# See the README.updating file in storm-kit for details.
BuildRequires: %{name}-kit == %{version}
BuildRequires: java-1_8_0-openjdk-devel
BuildRequires: openstack-suse-macros
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%{?systemd_requires}
Requires(pre): pwdutils
%description
Apache Storm is a free and open source distributed realtime computation system.
Storm makes it easy to reliably process unbounded streams of data, doing for
realtime processing what Hadoop did for batch processing.
%package doc
Summary: Apache Storm Documentation
Group: Productivity/Networking/Other
Requires: %{name} = %{version}
%description doc
This package contains documentation for Apache Storm.
%package zookeeper
Summary: Zookeeper server for testing Storm
Group: Productivity/Networking/Other
Requires: %{name} = %{version}
%description zookeeper
This package contains a single node Zookeeper cluster for testing Storm. This
is not meant for production use, only for testing.
%package nimbus
Summary: Storm Nimbus service
Group: Productivity/Networking/Other
Requires: %{name} = %{version}
%description nimbus
This package contains the Nimbus Master service for Apache Storm. This service
runs on Storm master nodes.
%package pacemaker
Summary: Storm Pacemaker service
Group: Productivity/Networking/Other
Requires: %{name} = %{version}
%description pacemaker
This package contains the Pacemaker service for Apache Storm.
%package supervisor
Summary: Storm Supervisor service
Group: Productivity/Networking/Other
Requires: %{name} = %{version}
%description supervisor
This package contains the Supervisor service for Apache storm. This service
manages runs on Storm worker nodes and delegates tasks to worker processes.
%package ui
Summary: Storm UI service
Group: Productivity/Networking/Other
Requires: %{name} = %{version}
%description ui
This package contains the UI service for Apache storm. This service provides a
web based user interface for Storm.
%package logviewer
Summary: Storm Logviewer service
Group: Productivity/Networking/Other
Requires: %{name} = %{version}
%description logviewer
This package contains the log viewer service for Apache storm. This service
provides a web based interface for displaying Storm logs.
%prep
%setup -q -n apache-%{name}-%{version}
cp -Rf %{_datadir}/tetra ../kit
cp -Rf %{SOURCE11} ../
%build
sh ../build.sh
# Replace source directory's with the contents of the binary tarball resulting
# from build.
mv storm-dist/binary/target/apache-storm-%{version}.tar.gz ../
pushd ..
rm -rf apache-%{name}-%{version}
tar xvf apache-storm-%{version}.tar.gz
popd
chmod -x LICENSE NOTICE README.markdown
# Remove nonsensical shebang
sed -i '/^#!\/bin\/bash$/ d' conf/%{name}-env.sh
chmod -R -x+X examples/
# Adjust some default paths to be FHS compliant
pushd lib
jar -xf %{name}-core-%{version}.jar defaults.yaml
sed -i -e 's#^storm.local.dir:.*#storm.local.dir: "%{_localstatedir}/lib/%{name}"#' \
-e 's#^dev.zookeeper.path:.*#dev.zookeeper.path: "%{_localstatedir}/run/%{name}-zookeeper/cluster"#' \
defaults.yaml
echo 'storm.log.dir: "%{_localstatedir}/log/%{name}"' >> defaults.yaml
jar -uf %{name}-core-%{version}.jar defaults.yaml
rm defaults.yaml
popd
%install
# systemd units
install -p -D -m 444 %{SOURCE3} %{buildroot}%{_unitdir}/%{name}-nimbus.service
install -p -D -m 444 %{SOURCE4} %{buildroot}%{_unitdir}/%{name}-pacemaker.service
install -p -D -m 444 %{SOURCE5} %{buildroot}%{_unitdir}/%{name}-supervisor.service
install -p -D -m 444 %{SOURCE6} %{buildroot}%{_unitdir}/%{name}-ui.service
install -p -D -m 444 %{SOURCE7} %{buildroot}%{_unitdir}/%{name}-logviewer.service
install -p -D -m 444 %{SOURCE8} %{buildroot}%{_unitdir}/%{name}-zookeeper.service
mkdir -p %{buildroot}%{_sbindir}
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}-logviewer
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}-nimbus
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}-pacemaker
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}-supervisor
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}-ui
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}-zookeeper
# Directories
install -D -m 644 %{SOURCE2} %{buildroot}/%_tmpfilesdir/%name.conf
install -d -m 755 %{buildroot}%{_libdir}/%{name}
install -d -m 755 %{buildroot}%{_libdir}/%{name}/bin
install -d -m 755 %{buildroot}%{_sysconfdir}/%{name}
install -d -m 755 %{buildroot}%{_docdir}/%{name}
install -d -m 755 %{buildroot}%{_bindir}
install -d -m 755 %{buildroot}%{_localstatedir}/lib/%{name}
install -d -m 755 %{buildroot}%{_localstatedir}/log/%{name}
install -p -D -m 644 %{SOURCE10} %{buildroot}%{_sysconfdir}/logrotate.d/%{name}
sed -e 's#__CONFDIR__#%{_sysconfdir}/%{name}#g' \
-e 's#__LIBDIR__#%{_libdir}#g' \
-e 's#__BINDIR__#%{_bindir}#g' \
-e 's#__LOCALDIR__#%{_localstatedir}/lib/%{name}#g' \
-e 's#__LOGDIR__#%{_localstatedir}/log/%{name}#g' \
-e 's#__ZKDIR__#%{_localstatedir}/run/%{name}-zookeeper/cluster#g' \
%{SOURCE9} > README.SUSE
# Executables
install -m 755 bin/flight.bash %{buildroot}%{_libdir}/%{name}/bin
install -m 755 bin/%{name} %{buildroot}%{_libdir}/%{name}/bin
install -m 755 bin/%{name}.py %{buildroot}%{_libdir}/%{name}/bin
ln -sr %{buildroot}%{_libdir}/%{name}/bin/%{name} %{buildroot}%{_bindir}
ln -sr %{buildroot}%{_libdir}/%{name}/bin/flight.bash %{buildroot}%{_bindir}
# Libraries
find external -type f -exec chmod 644 \{\} \;
cp -a external/ %{buildroot}%{_libdir}/%{name}
cp -a extlib/ %{buildroot}%{_libdir}/%{name}
cp -a extlib-daemon/ %{buildroot}%{_libdir}/%{name}
cp -a lib/ %{buildroot}%{_libdir}/%{name}
cp -a log4j2/ %{buildroot}%{_libdir}/%{name}
# Web UI
find public -type f -exec chmod 644 \{\} \;
cp -a public/ %{buildroot}%{_libdir}/%{name}
# Configuration
install -m 640 conf/{storm-env.sh,storm.yaml,storm_env.ini} %{buildroot}%{_sysconfdir}/%{name}
ln -sr %{buildroot}%{_sysconfdir}/%{name} %{buildroot}%{_libdir}/%{name}/conf
%pre
%openstack_pre_user_group_create %{username} %{groupname}
%post
%tmpfiles_create %{_tmpfilesdir}/%{name}.conf
# add/remove systemd units for services
%pre logviewer
%service_add_pre %{name}-logviewer.service
%post logviewer
%service_add_post %{name}-logviewer.service
%preun logviewer
%service_del_preun %{name}-logviewer.service
%postun logviewer
%service_del_postun %{name}-logviewer.service
%pre nimbus
%service_add_pre %{name}-nimbus.service
%post nimbus
%service_add_post %{name}-nimbus.service
%preun nimbus
%service_del_preun %{name}-nimbus.service
%postun nimbus
%service_del_postun %{name}-nimbus.service
%pre pacemaker
%service_add_pre %{name}-pacemaker.service
%post pacemaker
%service_add_post %{name}-pacemaker.service
%preun pacemaker
%service_del_preun %{name}-pacemaker.service
%postun pacemaker
%service_del_postun %{name}-pacemaker.service
%pre supervisor
%service_add_pre %{name}-supervisor.service
%post supervisor
%service_add_post %{name}-supervisor.service
%preun supervisor
%service_del_preun %{name}-supervisor.service
%postun supervisor
%service_del_postun %{name}-supervisor.service
%pre ui
%service_add_pre %{name}-ui.service
%post ui
%service_add_post %{name}-ui.service
%preun ui
%service_del_preun %{name}-ui.service
%postun ui
%service_del_postun %{name}-ui.service
%pre zookeeper
%service_add_pre %{name}-zookeeper.service
%post zookeeper
%service_add_post %{name}-zookeeper.service
%preun zookeeper
%service_del_preun %{name}-zookeeper.service
%postun zookeeper
%service_del_postun %{name}-zookeeper.service
%files
%defattr(-,root,root)
%dir %{_sysconfdir}/%{name}
%dir %attr(770, storm, storm) %{_localstatedir}/lib/%{name}
%dir %attr(770, storm, storm) %{_localstatedir}/log/%{name}
%attr(0640, root, storm) %config %{_sysconfdir}/%{name}/%{name}_env.ini
%attr(0640, root, storm) %config %{_sysconfdir}/%{name}/%{name}-env.sh
%attr(0640, root, storm) %config %{_sysconfdir}/%{name}/%{name}.yaml
%dir %_tmpfilesdir
%config %{_sysconfdir}/logrotate.d/%{name}
%_tmpfilesdir/%name.conf
%{_libdir}/%{name}
%{_bindir}/%{name}
%{_bindir}/flight.bash
%doc NOTICE README.SUSE
%license LICENSE
%files doc
%defattr(-,root,root)
%docdir %{_docdir}/%{name}/examples
%doc NOTICE README.markdown examples
%license LICENSE
%files logviewer
%defattr(-,root,root)
%doc NOTICE
%license LICENSE
%{_unitdir}/%{name}-logviewer.service
%{_sbindir}/rc%{name}-logviewer
%files nimbus
%defattr(-,root,root)
%doc NOTICE
%license LICENSE
%{_unitdir}/%{name}-nimbus.service
%{_sbindir}/rc%{name}-nimbus
%files pacemaker
%defattr(-,root,root)
%doc NOTICE
%license LICENSE
%{_unitdir}/%{name}-pacemaker.service
%{_sbindir}/rc%{name}-pacemaker
%files supervisor
%defattr(-,root,root)
%doc NOTICE
%license LICENSE
%{_unitdir}/%{name}-supervisor.service
%{_sbindir}/rc%{name}-supervisor
%files ui
%defattr(-,root,root)
%doc NOTICE
%license LICENSE
%{_unitdir}/%{name}-ui.service
%{_sbindir}/rc%{name}-ui
%files zookeeper
%defattr(-,root,root)
%doc NOTICE
%license LICENSE
%{_unitdir}/%{name}-zookeeper.service
%{_sbindir}/rc%{name}-zookeeper
%changelog