Projects
Eulaceura:Factory
opengauss-server
_service:obs_scm:opengauss-server.spec
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File _service:obs_scm:opengauss-server.spec of Package opengauss-server
%define zlib_name zlib %define zlib_version 1.2.12 %define xgboost_name xgboost %define xgboost_version v1.4.1 %define dmlc_name dmlc-core %define dmlc_version v0.5 %define port 7654 %define datapath /var/lib/opengauss %define apppath %{_prefix}/local/opengauss %define tmppath /var/lib/opengauss/pkg_5.0.1 Name: opengauss Version: 5.0.1 Release: 15 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.gz Source2: %{zlib_name}-%{zlib_version}.tar.gz Source3: %{dmlc_name}-%{dmlc_version}.tar.gz Source4: %{xgboost_name}-%{xgboost_version}.tar.gz Source5: opengauss-bashprofile Source6: opengauss.service Source7: autostart.sh Source8: version.cfg Source9: opengauss_upgrade_start.sh Source10: opengauss_upgrade_common.sh Source11: opengauss_upgrade_config.sh Source12: opengauss_upgrade_errorcode.sh Patch0: og-edit.patch Patch1: cmake_compile.patch Patch2: compile_2309.patch Patch3: openssl3-adptor.patch Patch4: upgrade.patch Patch20: zlib.patch Patch21: zlib-CVE-2022-37434.patch BuildRequires: cmake gcc gcc-c++ openssl-devel python tar BuildRequires: cjson lz4-devel zstd-devel boost-devel cjson-devel BuildRequires: libcgroup-devel libcurl-devel unixODBC-devel jemalloc-devel krb5-devel BuildRequires: java-1.8.0-openjdk-devel libedit-devel libaio-devel BuildRequires: bison flex, DCF >= 5 BuildRequires: numactl-devel %ifarch sw_64 BuildRequires: libatomic %endif %global _privatelibs lib(cjson|ecpg|z|pg|pq)\\.so* %global __provides_exclude %{_privatelibs} %global __requires_exclude %{_privatelibs} Requires: lz4-devel zstd-devel boost-devel cjson-devel tar Requires: libcgroup-devel libcurl-devel unixODBC-devel jemalloc-devel Requires: java-1.8.0-openjdk-devel libedit-devel libaio-devel Requires: DCF >= 5, lsof Requires: numactl-devel %description openGauss kernel : openGauss is an open source relational database management system. %global debug_package %{nil} %prep %setup -q -c -n %{name}-%{version} %setup -q -D -T -a 2 %setup -q -D -T -a 3 %setup -q -D -T -a 4 pushd openGauss-server-%{version} %patch0 -p1 %patch1 -p1 %patch2 -p1 %patch3 -p1 %patch4 -p1 popd pushd %{zlib_name}-%{zlib_version} %patch20 -p1 %patch21 -p1 popd %build build_target=$(pwd)/binarylibs/kernel/dependency ########### build zlib ########### pushd %{zlib_name}-%{zlib_version} zlib_dir=${build_target}/zlib1.2.11/comm CONFIGURE_EXTRA_FLAG="--64" %ifarch aarch64 CONFIGURE_EXTRA_FLAG="" %endif %ifarch sw_64 CONFIGURE_EXTRA_FLAG="" %endif ./configure ${CONFIGURE_EXTRA_FLAG} --prefix=${zlib_dir} sed -i '21a CFLAGS += -fPIC' Makefile MAKE_EXTRA_FLAG="-m64" %ifarch aarch64 MAKE_EXTRA_FLAG="" %endif %ifarch sw_64 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 CFLAGS="-O3 -fPIC -I../.." -f Makefile %{?_smp_mflags} mv libminiz.a libminiunz.a cp ioapi.h ${zlib_dir}/include/ cp unzip.h ${zlib_dir}/include/ cp libminiunz.a ${zlib_dir}/lib/ chmod 644 ${zlib_dir}/include/ioapi.h ${zlib_dir}/include/unzip.h ${zlib_dir}/lib/libminiunz.a cp -r ${zlib_dir} ${build_target}/zlib1.2.11/llt popd ########### build xgboost ########### pushd %{xgboost_name}-1.4.1 xgboost_dir=${build_target}/xgboost/comm sed -i '9a set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,-z,now -fPIE -fPIC -fstack-protector-strong")' ./CMakeLists.txt sed -i '10a set (CMAKE_CPP_FLAGS "${CMAKE_CPP_FLAGS} -Wl,-z,now -fPIE -fPIC -fstack-protector-strong")' ./CMakeLists.txt sed -i '11a set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,-z,now -fPIE -fPIC -fstack-protector-strong")' ./CMakeLists.txt rm -rf dmlc-core cp -r ../dmlc-core-0.5/ ./dmlc-core rm -rf build_install mkdir build_install && cd build_install cmake .. -DCMAKE_INSTALL_PREFIX=${xgboost_dir} make %{?_smp_mflags} make install cp -r ${xgboost_dir} ${build_target}/xgboost/llt popd ########### build opengauss ########### pushd openGauss-server-%{version} opengauss_source_dir=$(pwd) export ENABLE_LITE_MODE=ON export DEBUG_TYPE=release export THIRD_BIN_PATH=${build_target}/../../../binarylibs export LD_LIBRARY_PATH=$THIRD_BIN_PATH/kernel/dependency/zlib1.2.11/comm/lib:$LD_LIBRARY_PATH export LD_LIBRARY_PATH=$THIRD_BIN_PATH/kernel/dependency/xgboost/comm/lib:$LD_LIBRARY_PATH export PREFIX_HOME=${opengauss_source_dir}/mppdb_temp_install mkdir -p tmp_build cd tmp_build cmake .. -DENABLE_MULTIPLE_NODES=OFF -DENABLE_PRIVATEGAUSS=OFF -DENABLE_THREAD_SAFETY=ON -DENABLE_LITE_MODE=ON -DENABLE_OPENEULER_MAJOR=ON -DWITH_OPENEULER_OS=ON make %{?_smp_mflags} make install # clean build root rm -rf %{buildroot}/* mkdir -p %{buildroot}/var/lib/opengauss/data mkdir -p %{buildroot}%{apppath}/script mkdir -p %{buildroot}%{tmppath}/script # separate_debug_symbol.sh dir cd ${opengauss_source_dir}/build/script chmod +x ./separate_debug_information.sh ./separate_debug_information.sh rm -rf ${opengauss_source_dir}/mppdb_temp_install/packages rm -rf ${opengauss_source_dir}/mppdb_temp_install/symbols function get_os_kernel() { kernel="" if [[ -f "/etc/euleros-release" ]]; then kernel=$(cat /etc/euleros-release | awk -F ' ' '{print $1}' | tr a-z A-Z) if [[ "${kernel}" = "Euleros" ]]; then kernel="Euler" fi elif [[ -f "/etc/openEuler-release" ]]; then kernel=$(cat /etc/openEuler-release | awk -F ' ' '{print $1}') elif [[ -f "/etc/centos-release" ]]; then kernel=$(cat /etc/centos-release | awk -F ' ' '{print $1}') else kernel=$(lsb_release -d | awk -F ' ' '{print $2}') fi } get_os_kernel platform_arch=$(uname -p) cd ${opengauss_source_dir}/mppdb_temp_install tar -zcf openGauss-Lite-%{version}-${kernel}-${platform_arch}.bin * sha256sum openGauss-Lite-%{version}-${kernel}-${platform_arch}.bin | awk '{print $1}' > openGauss-Lite-%{version}-${kernel}-${platform_arch}.sha256 # copy binarylibs packages to %{tmppath} cp -r ${opengauss_source_dir}/mppdb_temp_install/* %{buildroot}%{tmppath} sed -i "/wal_insert_status_entries/d" ${opengauss_source_dir}/build/script/opengauss_config_file_mini cp ${opengauss_source_dir}/build/script/opengauss_config_file_mini %{buildroot}%{tmppath}/share/postgresql/ # make package upgrade sql cd ${opengauss_source_dir}/tmp_build cp -r ${opengauss_source_dir}/src/include/catalog/upgrade_sql ./upgrade_sql tar -zcf upgrade_sql.tar.gz ./upgrade_sql rm -rf ./upgrade_sql > /dev/null 2>&1 sha256sum upgrade_sql.tar.gz | awk '{print $1}' > upgrade_sql.sha256 if [ $? -ne 0 ]; then echo "Generate upgrade_sql.sha256 failed." exit 1 fi cp -r upgrade_sql.tar.gz %{buildroot}%{tmppath} cp -r upgrade_sql.sha256 %{buildroot}%{tmppath} 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 # auto start files install -m 644 %{SOURCE6} %{buildroot}%{tmppath}/script/opengauss.service install -m 700 %{SOURCE7} %{buildroot}%{tmppath}/script/autostart.sh # upgrade script install -m 644 %{SOURCE8} %{buildroot}%{tmppath}/version.cfg install -m 644 %{SOURCE9} %{buildroot}%{tmppath}/opengauss_upgrade_start.sh install -m 644 %{SOURCE10} %{buildroot}%{tmppath}/opengauss_upgrade_common.sh install -m 644 %{SOURCE11} %{buildroot}%{tmppath}/opengauss_upgrade_config.sh install -m 644 %{SOURCE12} %{buildroot}%{tmppath}/opengauss_upgrade_errorcode.sh %pre /usr/sbin/groupadd -r opengauss >/dev/null 2>&1 || : /usr/sbin/useradd -M -N -g opengauss -r -d %{datapath} -s /bin/bash -c "openGauss Server" opengauss >/dev/null 2>&1 || : # for install step # 1:install 2:upgrade if [ $1 -gt 1 ]; then echo "upgrade pre" else portinfo=$(lsof -i:%{port}) if [ "${portinfo}" != "" ]; then echo "The port[%{port}] is occupied. Please use command 'lsof -i:%{port} to check it.'" exit 1 fi fi %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 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 } start_opengauss(){ process_id=$(ps -ef | grep /var/lib/opengauss/data | grep -v grep | awk '{print $2}') if [ "$process_id" != "" ]; then echo "A process of opengauss already exists. Use command (ps -ef | grep /var/lib/opengauss/data) to confirm." echo "Please kill the process and reinstall opengauss." return 0 fi if [ "`ls -A /var/lib/opengauss/data`" != "" ]; then echo "Datanode dir(/var/lib/opengauss/data) is not empty." echo "Please delete dir and reinstall opengauss." return 0 fi result=$(su - opengauss -c "source ~/.bash_profile; gs_initdb -D /var/lib/opengauss/data -U opengauss --nodename=single_node") if [ $? -ne 0 ]; then echo "Init openGauss database failed." exit $result else echo "Init openGauss database success." fi } add_service(){ cp %{apppath}/script/opengauss.service /usr/lib/systemd/system/ systemctl daemon-reload } # for install step # 1:install 2:upgrade if [ $1 -eq 1 ]; then echo "install" > /var/lib/opengauss/recode_install_flag if [ -d /usr/local/opengauss ]; then rm -rf /usr/local/opengauss fi mkdir -p /usr/local/opengauss cp -r /var/lib/opengauss/pkg_%{version}/* /usr/local/opengauss chmod -R 755 /usr/local/opengauss chown -R opengauss:opengauss /usr/local/opengauss set_mini_configparam start_opengauss add_service elif [ $1 -eq 2 ]; then echo "upgrade" > /var/lib/opengauss/recode_install_flag mkdir -p /var/lib/opengauss/opengauss_upgrade mkdir -p /var/lib/opengauss/opengauss_upgrade/bak mkdir -p /var/lib/opengauss/opengauss_upgrade/tmp cp -r /var/lib/opengauss/pkg_%{version} /var/lib/opengauss/opengauss_upgrade chmod -R 755 /var/lib/opengauss/opengauss_upgrade chown -R opengauss:opengauss /var/lib/opengauss/opengauss_upgrade chmod -R 755 /usr/local/opengauss chown -R opengauss:opengauss /usr/local/opengauss chmod -R 755 /var/lib/opengauss/pkg_%{version} chown -R opengauss:opengauss /var/lib/opengauss/pkg_%{version} echo "start upgrade..." echo "upgrade pre" su - opengauss -c "source ~/.bash_profile; cd /var/lib/opengauss/opengauss_upgrade/pkg_%{version}/; sh opengauss_upgrade_start.sh -t upgrade_pre" if [ $? -ne 0 ]; then echo "Upgrade pre-check failed." echo "Please cd /var/lib/opengauss_upgrade/pkg_%{version}/; sh opengauss_upgrade_start.sh -t upgrade_pre" exit 1 fi echo "upgrade bin" su - opengauss -c "source ~/.bash_profile; cd /var/lib/opengauss/opengauss_upgrade/pkg_%{version}/; sh opengauss_upgrade_start.sh -t upgrade_bin" if [ $? -ne 0 ]; then echo "Upgrade binary failed." exit 1 fi echo "upgrade post" su - opengauss -c "source ~/.bash_profile; cd /var/lib/opengauss/opengauss_upgrade/pkg_%{version}/; sh opengauss_upgrade_start.sh -t upgrade_post" if [ $? -ne 0 ]; then echo "Upgrade post-check failed." echo "Please cd /var/lib/opengauss/opengauss_upgrade/pkg_%{version}/; sh opengauss_upgrade_start.sh -t upgrade_post" exit 1 fi su - opengauss -c "source ~/.bash_profile; cd /var/lib/opengauss/opengauss_upgrade/pkg_%{version}/; sh opengauss_upgrade_start.sh -t upgrade_commit" if [ $? -ne 0 ]; then echo "Upgrade commit failed." exit 1 fi servicename=/usr/lib/systemd/system/opengauss.service if [ -f $servicename ]; then systemctl disable opengauss.service rm $servicename fi cp %{tmppath}/script/opengauss.service /usr/lib/systemd/system/ systemctl daemon-reload # upgrade backup pid=$(ps -ef | grep /var/lib/opengauss/data | grep -v grep | awk '{print $2}') if [ "$pid" != "" ]; then kill -9 $pid fi cp -rf /usr/local/opengauss /usr/local/opengauss_%{version} fi %preun remove_service(){ servicename=/usr/lib/systemd/system/opengauss.service if [ -f $servicename ]; then systemctl disable opengauss.service rm $servicename fi } # 0: uninstall 1:upgrade if [ $1 -eq 0 ]; then echo "remove opengauss service" remove_service fi %postun clear_database(){ pid=$(ps -ef | grep /var/lib/opengauss/data | grep -v grep | awk '{print $2}') if [ "$pid" != "" ]; then kill -9 $pid fi if [ -d /usr/local/opengauss ]; then rm -rf /usr/local/opengauss fi if [ -d /usr/local/opengauss_%{version} ]; then rm -rf /usr/local/opengauss_%{version} fi if [ -f /var/lib/opengauss/recode_install_flag ]; then rm -rf /var/lib/opengauss/recode_install_flag fi if [ -d /var/lib/opengauss/pkg_%{version} ]; then rm -rf /var/lib/opengauss/pkg_%{version} fi if [ -d /var/lib/opengauss/opengauss_upgrade ]; then rm -rf /var/lib/opengauss/opengauss_upgrade fi } # 0: uninstall if [ $1 -eq 0 ]; then echo "clean database" clear_database fi %posttrans flag=$(cat /var/lib/opengauss/recode_install_flag) if [ $flag = "install" ]; then echo "opengauss install successfully!" echo "Please run: systemctl start opengauss.service" else echo "upgrade posttrans" cp -rf /usr/local/opengauss_%{version}/* /usr/local/opengauss chown -R opengauss:opengauss /usr/local/opengauss chmod -R 755 /usr/local/opengauss systemctl restart opengauss.service echo "opengauss upgrade successfully" fi %files %defattr (-,root,root) %{apppath} %{tmppath} %doc %attr(700,opengauss,opengauss) %dir %{?_localstatedir}/lib/opengauss %attr(700,opengauss,opengauss) %dir %{?_localstatedir}/lib/opengauss/data %attr(755,opengauss,opengauss) %dir %{apppath} %attr(755,opengauss,opengauss) %dir %{tmppath} %attr(644,opengauss,opengauss) %config(noreplace) %{?_localstatedir}/lib/opengauss/.bash_profile %changelog * Thu Jun 20 2024 liuheng <liuheng76@huawei.com> - 5.0.1-15 - Fix bugs: Initialize Remove Password * Wed Jun 12 2024 liuheng <liuheng76@huawei.com> - 5.0.1-14 - Fix bugs: #IA4KLQ #IA4PTU * Fri May 24 2024 zhangzhihui <zhangzhihui42@huawei.com> - 5.0.1-13 - upgrade function * Mon May 6 2024 liuheng <liuheng76@huawei.com> - 5.0.1-12 - Update version to 5.0.1 * Fri Aug 18 2023 panchenbo <panchenbo@kylinsec.com.cn> - 2.1.0-11 - add sw_64 support * Mon Aug 14 2023 zhangxubo <zhangxubo1@huawei.com> - 2.1.0-10 - Fix bugs: #I7QJRO * Tue Jun 6 2023 dillon chen<dillon.chen@gmail.com> - 2.1.0-9 - Fix bugs: #I677QX; add lsof * Mon Apr 10 2023 panchenbo <panchenbo@kylinsec.com.cn> - 2.1.0-8 - add /etc/kylinsec-release support for KylinSec * Sat Feb 11 2023 zhangxubo <zhangxubo1@huawei.com> - 2.1.0-7 - Fix bugs: #I6ED94 * Wed Mar 30 2022 ouyangminxiang <ouyangminxiang@kylinsec.com.cn> - 2.1.0-6 - add kylinsec platform * Sat Mar 12 2022 zhangxubo <zhangxubo1@huawei.com> - 2.1.0-5 - Fix bugs: #I4VDYQ #I4V624 #I4UOUU #I4TCDB #I4TCB8 * Thu Jan 27 2022 zhangxubo <zhangxubo1@huawei.com> - 2.1.0-4 - Fix bugs: #I4SDWX * Sat Jan 22 2022 zhangxubo <zhangxubo1@huawei.com> - 2.1.0-3 - Fix bugs: #I4RVNX * Mon Dec 13 2021 zhangxubo <zhangxubo1@huawei.com> - 2.1.0-2 - Fix bugs: Mask dependencies acquired during installation * Wed Dec 1 2021 zhangxubo <zhangxubo1@huawei.com> - 2.1.0-1 - Package init
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.
浙ICP备2022010568号-2