From 1c05ac137980e7a2f7e639c10a62c5c5b2f3df36 Mon Sep 17 00:00:00 2001 From: "wangzelin.wzl" Date: Mon, 7 Mar 2022 11:30:42 +0800 Subject: [PATCH] add build rpm logic --- build.sh | 17 +++++++++-------- deps/3rd/obproxy.spec | 4 +++- rpm/obproxy-ce-VER.txt | 1 + rpm/obproxy-ce-build.sh | 18 ++++++++++++++++++ 4 files changed, 31 insertions(+), 9 deletions(-) create mode 100644 rpm/obproxy-ce-VER.txt create mode 100644 rpm/obproxy-ce-build.sh diff --git a/build.sh b/build.sh index c93bc75..39a56da 100755 --- a/build.sh +++ b/build.sh @@ -4,7 +4,13 @@ DEP_DIR=${TOPDIR}/deps/3rd/usr/local/oceanbase/deps/devel TOOLS_DIR=${TOPDIR}/deps/3rd/usr/local/oceanbase/devtools RUNTIME_DIR=${TOPDIR}/deps/3rd/usr CPU_CORES=`grep -c ^processor /proc/cpuinfo` -MAKE_ARGS=(-j $CPU_CORES) +MAKE_ARGS="-j $CPU_CORES" + +PACKAGE=${2:-obproxy-ce} +VERSION=${3:-`cat rpm/${PACKAGE}-VER.txt`} +RELEASE=${4:-1} +PREFIX=/home/admin/obproxy +SPEC_FILE=obproxy.spec function sw() { @@ -35,7 +41,7 @@ function do_init() function do_dep_init() { - (cd $TOPDIR/deps/3rd && bash dep_create.sh) + cd $TOPDIR/deps/3rd && bash dep_create.sh cd $TOPDIR do_init } @@ -83,18 +89,13 @@ function do_make() { set -x sw - make "${MAKE_ARGS[@]}" + make $MAKE_ARGS } function do_rpm() { set -x sw - PACKAGE=obproxy-ce - VERSION=3.2.0 - RELEASE=1 - PREFIX=/home/admin/obproxy - SPEC_FILE=obproxy.spec echo "[BUILD] make dist..." make dist-gzip || exit 1 diff --git a/deps/3rd/obproxy.spec b/deps/3rd/obproxy.spec index 9c39676..2d88e8d 100644 --- a/deps/3rd/obproxy.spec +++ b/deps/3rd/obproxy.spec @@ -36,7 +36,9 @@ OceanBase Database Proxy %build ./configure CXX=${CXX} CC=${CC} --with-gcc-version=5.2.0 RELEASEID=%{RELEASE} --prefix=%{_prefix} --with-test-case=no --with-release=yes --with-tblib-root=/opt/csr/common --with-easy-root=/usr --with-easy-lib-path=/usr/lib64 --with-svnfile --enable-shared=default --enable-silent-rules mkdir -p unittest -make %{?_smp_mflags} +CPU_CORES=`grep -c ^processor /proc/cpuinfo` +MAKE_ARGS="-j $CPU_CORES" +make $MAKE_ARGS %install make DESTDIR=$RPM_BUILD_ROOT install diff --git a/rpm/obproxy-ce-VER.txt b/rpm/obproxy-ce-VER.txt new file mode 100644 index 0000000..a4f52a5 --- /dev/null +++ b/rpm/obproxy-ce-VER.txt @@ -0,0 +1 @@ +3.2.0 \ No newline at end of file diff --git a/rpm/obproxy-ce-build.sh b/rpm/obproxy-ce-build.sh new file mode 100644 index 0000000..68a7010 --- /dev/null +++ b/rpm/obproxy-ce-build.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# use by rpm build platform + +SCRIPT_DIR=$(cd "$(dirname "$0")";pwd) +TOP_DIR=${1:-${SCRIPT_DIR}/../} +PACKAGE=$2 +VERSION=$3 +RELEASE=$4 + +# prepare rpm build dirs +cd $TOP_DIR +sh build.sh clean + +# build rpm +cd $TOP_DIR +sh build.sh rpm $PACKAGE $VERSION $RELEASE + +find $TOP_DIR/ -name "*.rpm" -maxdepth 1 -exec mv {} $SCRIPT_DIR 2>/dev/null \; \ No newline at end of file -- GitLab