Skip to content

Commit

Permalink
add protobuf-c script
Browse files Browse the repository at this point in the history
  • Loading branch information
ht353245 authored and ob-robot-pre committed Dec 11, 2023
1 parent 77cdeec commit cdd4594
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 0 deletions.
22 changes: 22 additions & 0 deletions rpm/devdeps-protobuf-c-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

CUR_DIR=$(dirname $(readlink -f "$0"))
ROOT_DIR=$CUR_DIR/..
PROJECT_DIR=${1:-"$ROOT_DIR"}
PROJECT_NAME=${2:-"devdeps-protobuf-c"}
VERSION=${3:-"1.4.1"}
RELEASE=${4:-"2"}

# check source code
if [[ -z `find $ROOT_DIR -maxdepth 1 -regex ".*/protobuf-all-3.20.3.*[tar|gz|bz2|xz|zip]$"` ]]; then
echo "Download source code"
wget https://github.com/protocolbuffers/protobuf/releases/download/v3.20.3/protobuf-all-3.20.3.tar.gz -O $ROOT_DIR/protobuf-all-3.20.3.tar.gz
fi

if [[ -z `find $ROOT_DIR -maxdepth 1 -regex ".*/protobuf-c-$VERSION.*[tar|gz|bz2|xz|zip]$"` ]]; then
echo "Download source code"
wget https://github.com/protobuf-c/protobuf-c/releases/download/v${VERSION}/protobuf-c-${VERSION}.tar.gz -O $ROOT_DIR/protobuf-c-$VERSION.tar.gz
fi

cd $CUR_DIR
bash $CUR_DIR/rpmbuild.sh $PROJECT_DIR $PROJECT_NAME $VERSION $RELEASE
59 changes: 59 additions & 0 deletions rpm/devdeps-protobuf-c.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
Name: devdeps-protobuf-c
Version: 1.4.1
Release: %(echo $RELEASE)%{?dist}

Summary: This is protobuf-c, a C implementation of the Google Protocol Buffers data serialization format.

License: BSD-2-Clause
Url: https://github.com/protobuf-c/protobuf-c/tree/v1.4.1
AutoReqProv:no

%undefine _missing_build_ids_terminate_build
# disable check-buildroot
%define __arch_install_post %{nil}
%define _buliddir %{_topdir}/BUILD
%define _tmppath %{_buliddir}/_tmp
%define _prefix /usr/local/oceanbase/deps/devel
%define _protobufc protobuf-c-1.4.1
%define _proto protobuf-all-3.20.3
%define _proto_dir protobuf-3.20.3
%define debug_package %{nil}

%description
protobuf-c is a C implementation of the Google Protocol Buffers data serialization format.

%install
mkdir -p %{buildroot}/%{_prefix}/lib/protobuf-c
mkdir -p %{buildroot}/%{_prefix}/include/protobuf-c
cd $OLDPWD/../
rm -rf %{_proto_dir}
tar xf %{_proto}.tar.gz
cd %{_proto_dir}
./configure --prefix=%{_tmppath}/proto
CPU_CORES=`grep -c ^processor /proc/cpuinfo`
make -j${CPU_CORES}
make install

cd %{_topdir}/../../
rm -rf %{_protobufc}
tar xf %{_protobufc}.tar.gz
cd %{_protobufc}
export PKG_CONFIG_PATH=%{_tmppath}/proto/lib/pkgconfig
./configure --prefix=%{_tmppath} --enable-shared=yes CFLAGS="-g -O2 -fPIC" CXXFLAGS="-g -O2 -fPIC"
make -j${CPU_CORES}
make install
cp %{_tmppath}/include/protobuf-c/*.h %{buildroot}/%{_prefix}/include/protobuf-c
cp %{_tmppath}/lib/*.a %{buildroot}/%{_prefix}/lib/

%files

%defattr(-,root,root)

%{_prefix}

%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig

%changelog
* Thu Oct 19 2023 oceanbase
- protobufc 1.4.1

0 comments on commit cdd4594

Please sign in to comment.