%define cjson_name cJSON %define cjson_version 1.7.13 %define zlib_name zlib %define zlib_version 1.2.11 %define protobuf_name protobuf %define protobuf_version 3.11.3 %define orc_name orc-rel-release %define orc_version 1.6.0 %define port 7654 %define datapath /var/lib/opengauss %define apppath %{_prefix}/local/opengauss Name: opengauss Version: 2.1.0 Release: 1 Summary: openGauss is an open source relational database management system License: MulanPSL-2.0 and MIT and BSD and zlib and TCL and Apache-2.0 and BSL-1.0 URL: https://gitee.com/opengauss/openGauss-server Source0: openGauss-server-%{version}.tar.xz Source1: %{cjson_name}-%{cjson_version}.tar.gz Source2: %{zlib_name}-%{zlib_version}.tar.gz Source3: %{protobuf_name}-%{protobuf_version}.tar.gz Source4: %{orc_name}-%{orc_version}.tar.gz Source5: opengauss-bashprofile Patch1: 0001-cJSON.patch Patch20: 0001-zlib.patch Patch21: 0002-zlib.patch Patch22: 0003-zlib.patch Patch23: makefile-miniunz.patch Patch40: 0001-orc.patch BuildRequires: cmake gcc gcc-c++ openssl-devel python BuildRequires: cjson lz4-devel protobuf-devel snappy-devel zstd-devel boost-devel BuildRequires: libcgroup-devel curl-devel unixODBC-devel jemalloc-devel BuildRequires: java-1.8.0-openjdk-devel libedit-devel libaio-devel BuildRequires: bison flex DCF %ifnarch aarch64 %{arm} BuildRequires: numactl-devel %endif Requires: lz4-devel protobuf-devel snappy-devel zstd-devel boost-devel Requires: libcgroup-devel curl-devel unixODBC-devel jemalloc-devel Requires: java-1.8.0-openjdk-devel libedit-devel libaio-devel Requires: DCF %ifnarch aarch64 %{arm} Requires: numactl-devel %endif %description openGauss kernel : openGauss is an open source relational database management system. %Provides: gaussdb %global debug_package %{nil} %prep %setup -q -c -n %{name}-%{version} %setup -q -D -T -a 1 %setup -q -D -T -a 2 %setup -q -D -T -a 3 %setup -q -D -T -a 4 pushd %{cjson_name}-%{cjson_version} %patch1 -p1 popd pushd %{zlib_name}-%{zlib_version} %patch20 -p1 %patch21 -p1 %patch22 -p1 %patch23 -p1 popd pushd %{orc_name}-%{orc_version} %patch40 -p1 popd %build ########### build cjson ########### build_target=$(pwd)/deps_binarylibs pushd %{cjson_name}-%{cjson_version} make make install PREFIX=${build_target}/cjson popd ########### build zlib ########### pushd %{zlib_name}-%{zlib_version} CONFIGURE_EXTRA_FLAG="--64" %ifarch aarch64 CONFIGURE_EXTRA_FLAG="" %endif ./configure ${CONFIGURE_EXTRA_FLAG} --prefix=${build_target}/zlib sed -i '21a CFLAGS += -fPIC' Makefile MAKE_EXTRA_FLAG="-m64" %ifarch aarch64 MAKE_EXTRA_FLAG="" %endif make CFLAGS="-fPIE -fPIC" SFLAGS="-O2 -fPIC -fstack-protector-strong -Wl,-z,noexecstack -Wl,-z,relro,-z,now ${MAKE_EXTRA_FLAG} -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN" %{?_smp_mflags} make install cd contrib/minizip/ make -f Makefile.miniunz %{?_smp_mflags} rm -rf ${build_target}/zlib/lib/pkgconfig make install -f Makefile.miniunz DESTDIR=${build_target}/zlib popd ########### build protobuf ########### pushd %{protobuf_name}-%{protobuf_version}/cmake sed -i '18a set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -fPIE -fPIC -fstack-protector-all -Wstack-protector -s -Wl,-z,relro,-z,now -D_GLIBCXX_USE_CXX11_ABI=0\")' CMakeLists.txt cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=${build_target}/protobuf/ -Dprotobuf_BUILD_TESTS=OFF; make CFLAGS="-fPIE -fPIC" %{?_smp_mflags} make install popd ########### build apache-orc ########### pushd %{orc_name}-%{orc_version} cp ${build_target}/protobuf ./c++/libs/protobuf -rp cp ${build_target}/zlib ./c++/libs/zlib -rp export PATH=${build_target}/protobuf/bin:$PATH export LD_LIBRARY_PATH=$(pwd)/c++/libs:$LD_LIBRARY_PATH export ORC_LIBS=$(pwd)/c++/libs sed -i \ -e "32a set (PROTOBUF_INCLUDE_DIRS \"$ORC_LIBS/protobuf/include\")" \ -e "32a set (PROTOBUF_LIBRARIES \"$ORC_LIBS/protobuf/lib/libprotobuf.a\")" \ -e "32a set (PROTOBUF_EXECUTABLE `which protoc`)" \ -e "32a set (SNAPPY_INCLUDE_DIRS \"/usr/include\")" \ -e "32a set (SNAPPY_LIBRARIES \"/usr/lib64/libsnappy.a\")" \ -e "32a set (ZLIB_INCLUDE_DIRS \"$ORC_LIBS/zlib/include\")" \ -e "32a set (ZLIB_LIBRARIES \"$ORC_LIBS/zlib/lib/libz.a\")" \ -e "32a set (LZ4_INCLUDE_DIRS \"/usr/include\")" \ -e "32a set (LZ4_LIBRARIES \"/usr/lib64/liblz4.a\")" CMakeLists.txt mkdir build cd build cmake .. -DCMAKE_INSTALL_PREFIX=${build_target}/liborc -DBUILD_JAVA=OFF -DBUILD_SHARED_LIBS=OFF make %{?_smp_mflags} make install cp c++/src/orc_proto.pb.h ${build_target}/liborc/include cp c++/src/Adaptor.hh ${build_target}/liborc/include/orc/ cp ../c++/src/Exceptions.hh ${build_target}/liborc/include/orc/ popd ########### build opengauss ########### pushd openGauss-server-%{version} chmod +x ./configure ./configure \ CC=g++ CFLAGS='-O2 -g3' \ --prefix=%{apppath} \ --3rd=${build_target} \ --enable-thread-safety \ --with-readline \ --without-zlib \ --without-gssapi \ --without-krb5 \ --enable-lite-mode \ --with-openeuler-os %make_build %{?_smp_mflags} popd %install pushd openGauss-server-%{version} %make_install -s %{?_smp_mflags} mkdir -p %{buildroot}/var/lib/opengauss/data cp build/script/opengauss_config_file_mini %{buildroot}/%{apppath}/share/postgresql/ popd # opengauss datanode dir. install -d -m 700 $RPM_BUILD_ROOT%{?_localstatedir}/lib/opengauss/data # opengauss .bash_profile install -m 644 %{SOURCE5} $RPM_BUILD_ROOT%{?_localstatedir}/lib/opengauss/.bash_profile %pre /usr/sbin/groupadd -g 39 -o -r opengauss >/dev/null 2>&1 || : /usr/sbin/useradd -M -N -g opengauss -o -r -d %{datapath} -s /bin/bash \ -c "openGauss Server" -u 39 opengauss >/dev/null 2>&1 || : %post # set opengauss mini config parameters set_mini_configparam(){ config_mini_file=%{apppath}/share/postgresql/opengauss_config_file_mini echo "port = %{port}" >> ${config_mini_file} config_sample_file=%{apppath}/share/postgresql/postgresql.conf.sample if [[ -f $config_mini_file ]] then if [[ ! -f "$config_sample_file" ]] then echo "postgresql.conf.sample does not exist" else echo "set opengauss lite config parameters" while IFS= read -r line; do SUBSTRING=$(echo $line | cut -d'=' -f 1)"= " if grep -q "$SUBSTRING" $config_sample_file ; then sed -i "/$SUBSTRING/c$line" $config_sample_file else echo $line >> $config_sample_file fi done < $config_mini_file fi fi } set_mini_configparam su - opengauss -c "source ~/.bash_profile; gs_initdb -D /var/lib/opengauss/data -U opengauss --nodename=single_node" su - opengauss -c "source ~/.bash_profile; gs_ctl start -D /var/lib/opengauss/data" %files %defattr (-,root,root) %{apppath} %doc %{?_localstatedir}/lib/opengauss %attr(700,opengauss,opengauss) %dir %{?_localstatedir}/lib/opengauss %attr(700,opengauss,opengauss) %dir %{?_localstatedir}/lib/opengauss/data %attr(644,opengauss,opengauss) %config(noreplace) %{?_localstatedir}/lib/opengauss/.bash_profile %changelog * Wed Dec 1 2021 zhangxubo - 2.1.0-1 - Package init