%global upstream_name ClickHouse %if 0%{?fedora} >= 17 || 0%{?rhel} >= 7 %global with_systemd 1 %else %global with_systemd 0 %endif %define clickhouse_user clickhouse %define clickhouse_uid 189 %define clickhouse_group %{clickhouse_user} %define clickhouse_gid 189 %define clickhouse_home %{_localstatedir}/lib/clickhouse Name: clickhouse Version: 1.1.54198 Release: 1%{?dist} Summary: Free analytic DBMS for big data License: ASL 2.0 Group: Applications/Databases URL: https://clickhouse.yandex/ Source0: https://github.com/yandex/%{upstream_name}/archive/v%{version}-stable.tar.gz Source1: clickhouse.service Source2: clickhouse.tmpfiles.d Patch0: clickhouse-lz4-deprecated.patch Patch1: clickhouse-libpath.patch Patch2: clickhouse-maybe-uninitialized.patch BuildRequires: gcc >= 6 BuildRequires: libicu-devel BuildRequires: readline-devel BuildRequires: unixODBC-devel BuildRequires: mariadb-devel BuildRequires: clang >= 3.8.0 BuildRequires: cmake BuildRequires: zlib-devel BuildRequires: poco-devel BuildRequires: lz4-devel BuildRequires: boost-devel BuildRequires: libzstd-devel BuildRequires: sparsehash-devel BuildRequires: zookeeper-devel BuildRequires: double-conversion-devel BuildRequires: re2-devel BuildRequires: gperftools-devel BuildRequires: libtool-ltdl-devel BuildRequires: libstdc++-static %if %{with_systemd} BuildRequires: systemd-units Requires(post): systemd Requires(preun): systemd Requires(postun): systemd # For triggerun Requires(post): systemd-sysv %else Requires: initscripts Requires: libevent Requires(post): /sbin/chkconfig Requires(preun): /sbin/chkconfig, /sbin/service Requires(postun): /sbin/service %endif %description ClickHouse manages extremely large volumes of data in a stable and sustainable manner. It currently powers Yandex.Metrica, world’s second largest web analytics platform, with over 20.3 trillion database records and over 20 billion events a day, generating customized reports on-the-fly, directly from non-aggregated data. This system was successfully implemented at CERN’s LHCb experiment to store and process metadata on 10bn events with over 1000 attributes per event registered in 2011. %package server Summary: clickhouse server and related files Group: Applications/Databases Requires: %{name} = %{version}-%{release} %description server This package contains the clickhouse server and some accompanying files and directories. %prep %setup -qn %{upstream_name}-%{version}-stable %patch0 -p1 %patch1 -p1 %patch2 -p1 %build mkdir build cd build cmake .. \ -DCMAKE_INSTALL_PREFIX=%{_prefix} \ -DCMAKE_VERBOSE_MAKEFILE=ON \ -DCMAKE_BUILD_TYPE=RelWithDebInfo \ -DUSE_STATIC_LIBRARIES=OFF \ -DUNBUNDLED=ON make %{?_smp_mflags} %install cd build make install DESTDIR=%{buildroot} %{__mkdir_p} %{buildroot}%{_localstatedir}/lib/%{name} %{__mkdir_p} %{buildroot}%{_localstatedir}/log/%{name}-server %{__mkdir_p} %{buildroot}%{_localstatedir}/run/%{name} %{__mkdir_p} %{buildroot}%{_sysconfdir}/security/limits.d %{__mkdir_p} %{buildroot}%{_sysconfdir}/cron.d %{__install} -m 644 ../tools/etc/cron.d/clickhouse-server %{buildroot}%{_sysconfdir}/cron.d/clickhouse-server %{__install} -m 644 ../tools/etc/security/limits.d/clickhouse.conf %{buildroot}%{_sysconfdir}/security/limits.d/30-clickhouse.conf for file in config users ; do cp %{buildroot}%{_sysconfdir}/%{name}-server/${file}.xml %{buildroot}%{_localstatedir}/lib/%{name}/${file}-preprocessed.xml ln -s %{_localstatedir}/lib/%{name}/${file}-preprocessed.xml %{buildroot}%{_sysconfdir}/%{name}-server/${file}-preprocessed.xml done %if %{with_systemd} # Unit file %{__mkdir_p} %{buildroot}%{_unitdir} install -Dp -m0644 %{SOURCE1} %{buildroot}%{_unitdir}/%{name}.service mkdir -p %{buildroot}%{_tmpfilesdir} install -m 0644 %{SOURCE2} %{buildroot}%{_tmpfilesdir}/%{name}.conf %else # Init script %{__mkdir_p} %{buildroot}%{_initrddir} install -Dp -m0755 tools/etc/init.d/%{name}-server %{buildroot}%{_initrddir}/%{name} %endif %pre getent group %{clickhouse_group} >/dev/null || \ groupadd -r %{clickhouse_group} -g %{clickhouse_gid} getent passwd %{clickhouse_user} >/dev/null || \ useradd -r -g %{clickhouse_group} -d %{clickhouse_home} \ -s /sbin/nologin -c "%{name} user" -u %{clickhouse_uid} %{clickhouse_user} exit 0 %post %if 0%{?systemd_post:1} %systemd_post %{name}.service %else if [ $1 = 1 ]; then # Initial installation %if %{with_systemd} /bin/systemctl daemon-reload >/dev/null 2>&1 || : %else /sbin/chkconfig --add %{name} %endif fi %endif %preun %if 0%{?systemd_preun:1} %systemd_preun %{name}.service %else if [ "$1" = 0 ] ; then # Package removal, not upgrade %if %{with_systemd} /bin/systemctl --no-reload disable %{name}.service >/dev/null 2>&1 || : /bin/systemctl stop %{name}.service >/dev/null 2>&1 || : %else /sbin/service %{name} stop > /dev/null 2>&1 /sbin/chkconfig --del %{name} %endif fi exit 0 %endif %postun %if 0%{?systemd_postun_with_restart:1} %systemd_postun_with_restart %{name}.service %else %if %{with_systemd} /bin/systemctl daemon-reload >/dev/null 2>&1 || : if [ $1 -ge 1 ]; then # Package upgrade, not uninstall /bin/systemctl try-restart %{name}.service >/dev/null 2>&1 || : fi %else if [ "$1" -ge 1 ]; then /sbin/service %{name} restart > /dev/null 2>&1 fi exit 0 %endif %endif %files %doc AUTHORS CHANGELOG.md README.md doc/* %dir %{_sysconfdir}/%{name}-client %config(noreplace) %{_sysconfdir}/%{name}-client/config.xml %{_bindir}/%{name} %{_bindir}/%{name}-benchmark %{_bindir}/%{name}-client %{_bindir}/%{name}-compressor %{_bindir}/%{name}-local %{_bindir}/config-processor %{_bindir}/corrector_utf8 %{_libdir}/lib%{name}.so* %files server %dir %{_sysconfdir}/%{name}-server %config(noreplace) %{_sysconfdir}/%{name}-server/config.xml %config(noreplace) %{_sysconfdir}/%{name}-server/users.xml %{_sysconfdir}/%{name}-server/config-preprocessed.xml %{_sysconfdir}/%{name}-server/users-preprocessed.xml %config(noreplace) %{_sysconfdir}/cron.d/clickhouse-server %{_sysconfdir}/security/limits.d/30-clickhouse.conf %{_bindir}/%{name}-server %attr(0775,%{clickhouse_user},%{clickhouse_group}) %dir %{_localstatedir}/run/%{name} %attr(0700,%{clickhouse_user},%{clickhouse_group}) %dir %{_localstatedir}/lib/%{name} %attr(0775,%{clickhouse_user},%{clickhouse_group}) %dir %{_localstatedir}/log/%{name}-server %attr(0664,%{clickhouse_user},%{clickhouse_group}) %{_localstatedir}/lib/%{name}/config-preprocessed.xml %attr(0664,%{clickhouse_user},%{clickhouse_group}) %{_localstatedir}/lib/%{name}/users-preprocessed.xml %if %{with_systemd} # Unit file %{_unitdir}/%{name}.service %{_tmpfilesdir}/%{name}.conf %else # Init script %{_initrddir}/%{name} %endif %changelog * Fri Apr 07 2017 Didier Fabert - 1.1.54198-1 - initial package