%global _hardened_build 1 %global services hbase-master.service hbase-thrift.service hbase-rest.service hbase-zookeeper.service hbase-regionserver.service # Currently disabled because packaging the singular binary in a noarch package # is troublesome %global package_native 0 Name: hbase Version: 2.5.0 Release: 3 Summary: A database for Apache Hadoop License: Apache-2.0 and BSD and CPL-1.0 and EPL-1.0 and MIT URL: http://hbase.apache.org/ Source0: https://github.com/apache/%{name}/archive/rel/%{version}.tar.gz Source1: %{name}.logrotate Source2: %{name}-site.xml Source3: %{name}.service.template Source4: xmvn-reactor Source5: protoc-3.21.1-linux-riscv64.exe Patch0: upgrade_os-maven_plugin_to_1.7.1.patch Patch1: fix-riscv64-support.patch BuildArch: noarch BuildRequires: cmake BuildRequires: gcc-c++ BuildRequires: gradle-local xmvn xmvn-install BuildRequires: systemd BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root BuildRequires: java-1.8.0-openjdk-devel maven hostname maven-local protobuf2-devel protobuf2-compiler protobuf2 Requires: java-1.8.0-openjdk Requires(post): systemd Requires(preun): systemd Requires(postun): systemd %description Apache HBase is a database for Apache Hadoop that provides a distributed, scalable, big data store. %if %{package_native} %package native Summary: Native Apache HBase libraries Requires: %{name} = %{version}-%{release} %description native Apache HBase is a database for Apache Hadoop that provides a distributed, scalable, big data store. This package contains native libraries for Apache HBase. %endif %if %{with javadoc} %package javadoc Summary: Javadoc for Apache HBase BuildArch: noarch %description javadoc This package contains the API documentation for %{name}. %endif %prep %setup -qn %{name}-rel-%{version} %patch0 -p1 %if "%{_arch}" == "riscv64" %patch1 -p1 mvn install:install-file -DgroupId=com.google.protobuf -DartifactId=protoc -Dversion=2.5.0 -Dclassifier=linux-riscv64 -Dpackaging=exe -Dfile=/usr/bin/protoc mvn install:install-file -DgroupId=com.google.protobuf -DartifactId=protoc -Dversion=3.21.1 -Dclassifier=linux-riscv64 -Dpackaging=exe -Dfile=%{SOURCE5} %endif mvn install:install-file -DgroupId=com.google.protobuf -DartifactId=protoc -Dversion=2.5.0 -Dclassifier=linux-aarch_64 -Dpackaging=exe -Dfile=/usr/bin/protoc cp %{SOURCE4} ./.xmvn-reactor echo `pwd` > absolute_prefix.log sed -i 's/\//\\\//g' absolute_prefix.log absolute_prefix=`head -n 1 absolute_prefix.log` sed -i 's/absolute-prefix/'"$absolute_prefix"'/g' .xmvn-reactor %build %if "%{_arch}" == "riscv64" export MAVEN_OPTS="-Xms2048M -Xmx8000M" %endif mvn -Pnative clean install -DskipTests assembly:single -Prelease -Dmaven.javadoc.skip=true -Drat.skip=true %if %{with tests} %check %if %{package_native} profile="-Pnative" %endif xmvn -o -Dhadoop.profile=2.0 $profile test %endif %install %mvn_install # Extract the binary tarball tar -C %{name}-assembly/target -zxf %{name}-assembly/target/%{name}-%{version}-bin.tar.gz install -d -m 0755 %{buildroot}/%{_bindir} install -d -m 0755 %{buildroot}/%{_datadir}/%{name}/bin install -d -m 0755 %{buildroot}/%{_datadir}/%{name}/lib install -d -m 0755 %{buildroot}/%{_datadir}/%{name}/%{name}-webapps install -d -m 0755 %{buildroot}/%{_libdir}/%{name} install -d -m 0755 %{buildroot}/%{_sysconfdir}/%{name} install -d -m 0755 %{buildroot}/%{_sysconfdir}/logrotate.d install -d -m 0755 %{buildroot}/%{_tmpfilesdir} install -d -m 0755 %{buildroot}/%{_unitdir} install -d -m 0755 %{buildroot}/%{_var}/cache/%{name} install -d -m 0755 %{buildroot}/%{_sharedstatedir}/%{name}/zookeeper install -d -m 0755 %{buildroot}/%{_var}/log/%{name} install -d -m 0755 %{buildroot}/%{_var}/run/%{name} pushd %{name}-assembly/target/%{name}-%{version} # Binaries cp -arf bin/* %{buildroot}/%{_datadir}/%{name}/bin rm -f %{buildroot}/%{_datadir}/%{name}/bin/*.cmd pushd %{buildroot}/%{_datadir}/%{name}/bin # Create symlinks for commands in _bindir for f in `ls | grep -v \\.rb` do if [ -f $f ] then %{__ln_s} %{_datadir}/%{name}/bin/$f %{buildroot}/%{_bindir} fi done popd # Remove symlinks from files that aren't commands but are includes pushd %{buildroot}/%{_bindir} rm -f %{name}-common %{name}-config popd # Configuration install -m 0644 conf/* %{buildroot}/%{_sysconfdir}/%{name} rm -f %{buildroot}/%{_sysconfdir}/%{name}/*.cmd install -m 0644 %{SOURCE2} %{buildroot}/%{_sysconfdir}/%{name} # Modify hbase-env.sh to point to the correct location for JAVA_HOME sed -i "s|#\s*export JAVA_HOME.*|export JAVA_HOME=/usr/lib/jvm/jre|" %{buildroot}/%{_sysconfdir}/%{name}/%{name}-env.sh # Modify hbase-env.sh to point to the correct location for pid creation sed -i "s|#\s*export HBASE_PID_DIR.*|export HBASE_PID_DIR=/var/run/hbase|" %{buildroot}/%{_sysconfdir}/%{name}/%{name}-env.sh # Modify hbase-env.sh to point to the correct location for log files sed -i "s|#\s*export HBASE_LOG_DIR.*|export HBASE_LOG_DIR=/var/log/hbase|" %{buildroot}/%{_sysconfdir}/%{name}/%{name}-env.sh # Link the hdfs-site.xml into the config directory to pick up any HDFS # client configuration %{__ln_s} %{_sysconfdir}/hadoop/hdfs-site.xml %{buildroot}/%{_sysconfdir}/%{name} # Webapps cp -arp %{name}-webapps/* %{buildroot}/%{_datadir}/%{name}/%{name}-webapps # Dependency jars install lib/*.jar %{buildroot}/%{_datadir}/%{name}/lib # Other files cp -arf lib/ruby %{buildroot}/%{_datadir}/%{name}/lib cp -arf lib/client-facing-thirdparty %{buildroot}/%{_datadir}/%{name}/lib cp -arf lib/shaded-clients %{buildroot}/%{_datadir}/%{name}/lib %if 0 # Native libraries cp -arf lib/native/* %{buildroot}/%{_libdir}/%{name} %endif popd pushd %{buildroot}/%{_datadir}/%{name} %{__ln_s} %{_sysconfdir}/%{name} conf %{__ln_s} %{_libdir}/%{name} lib/native %{__ln_s} %{_var}/log/%{name} logs %{__ln_s} %{_var}/run/%{name} pids popd # Ensure /var/run directory is recreated on boot echo "d %{_var}/run/%{name} 0775 hbase hbase -" > %{buildroot}/%{_tmpfilesdir}/%{name}.conf # logrotate config install -m 0644 %{SOURCE1} %{buildroot}/%{_sysconfdir}/logrotate.d/%{name} # systemd configuration for service in %{services} do s=`echo $service | cut -d'-' -f 2- | cut -d'.' -f 1` sed -e "s|DAEMON|$s|g" %{SOURCE3} > %{buildroot}/%{_unitdir}/%{name}-$s.service done %pretrans -p path = "%{_datadir}/%{name}/%{name}-webapps" st = posix.stat(path) if st and st.type == "link" then os.remove(path) end %pre getent group hbase >/dev/null || /usr/sbin/groupadd -r hbase getent passwd hbase > /dev/null || /usr/sbin/useradd -c "Apache HBase" -s /sbin/nologin -g hbase -r -d %{_sharedstatedir}/%{name} hbase %preun %systemd_preun %{services} %post # Change the home directory for the hbase user if [[ `getent passwd hbase | cut -d: -f 6` != "%{_sharedstatedir}/%{name}" ]] then /usr/sbin/usermod -d %{_sharedstatedir}/%{name} hbase fi if [ $1 -gt 1 ] then if [ -d %{_var}/cache/%{name}/zookeeper ] && [ ! -L %{_var}/cache/%{name}/zookeeper ] then # Move the existing zookeeper data to the new location mv -f %{_var}/cache/%{name}/zookeeper/* %{_sharedstatedir}/%{name}/zookeeper fi if [ -d %{_var}/cache/%{name}/%{name} ] && [ ! -L %{_var}/cache/%{name}/%{name} ] then # Move the existing hbase data to the new location mv -f %{_var}/cache/%{name}/%{name}/* %{_var}/cache/%{name} fi fi %systemd_post %{services} %postun %systemd_postun_with_restart %{services} if [ $1 -lt 1 ] then # Remove compatibility symlinks rm -f %{_var}/cache/%{name}/%{name} rm -f %{_var}/cache/%{name}/zookeeper fi %posttrans # Create symlinks to the new locations for zookeeper and hbase data in case # the user changed the configuration file and the new one isn't in place to # point to the correct location if [ -d %{_var}/cache/%{name}/zookeeper ] then rm -rf %{_var}/cache/%{name}/zookeeper fi if [ ! -e %{_var}/cache/%{name}/zookeeper ] then %{__ln_s} %{_sharedstatedir}/%{name}/zookeeper %{_var}/cache/%{name} fi if [ -d %{_var}/cache/%{name}/%{name} ] then rm -rf %{_var}/cache/%{name}/%{name} fi if [ ! -e %{_var}/cache/%{name}/%{name} ] then %{__ln_s} %{_var}/cache/%{name} %{_var}/cache/%{name} fi %files -f .mfiles %doc LICENSE.txt NOTICE.txt README.txt %exclude %{_datadir}/%{name}/lib/native %{_bindir}/* %{_datadir}/%{name} %dir %{_javadir}/%{name} %attr(-,hbase,hbase) %{_sharedstatedir}/%{name} %config(noreplace) %{_sysconfdir}/%{name} %config(noreplace) %{_sysconfdir}/logrotate.d/%{name} %{_tmpfilesdir}/%{name}.conf %{_unitdir}/%{name}-*.service %attr(0755,hbase,hbase) %dir %{_var}/cache/%{name} %attr(0755,hbase,hbase) %dir %{_var}/log/%{name} %attr(0755,hbase,hbase) %dir %{_var}/run/%{name} %if %{package_native} %files native %{_datadir}/%{name}/lib/native %{_libdir}/%{name} %endif %changelog * Wed May 29 2024 Dingli Zhang - 2.5.0-3 - Fix riscv64 support - Upgrade os-maven-plugin to 1.7.1 - Remove useless settings.xml * Wed May 8 2024 xiexing - 2.5.0-2 - remove unnecessary require * Tue Sep 12 2023 Youjing Yu <2534849757@qq.com> 2.5.0-1 - Upgrade Hbase Version to 2.5.0 * Tue Mar 16 2021 Ge Wang 2.2.5-1 - Init package