Skip to content

Commit

Permalink
feat(package): add rpm build and dpkg build script (#238)
Browse files Browse the repository at this point in the history
* feat(package): add dpkg package script
  • Loading branch information
ShannonDing authored Feb 12, 2020
1 parent 8a6b3bd commit 0648508
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 0 deletions.
15 changes: 15 additions & 0 deletions dep/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
BASEDIR=$(dirname "$0")
if [[ ! -d ${BASEDIR}/rocketmq_amd64/usr/local/include/ ]]; then
mkdir -p ${BASEDIR}/rocketmq_amd64/usr/local/include/
fi

if [[ ! -d ${BASEDIR}/rocketmq_amd64/usr/local/lib ]]; then
mkdir -p ${BASEDIR}/rocketmq_amd64/usr/local/lib
fi

cp -R ${BASEDIR}/../include/* ${BASEDIR}/rocketmq_amd64/usr/local/include/
cp ${BASEDIR}/../bin/librocketmq.so ${BASEDIR}/rocketmq_amd64/usr/local/lib/
cp ${BASEDIR}/../bin/librocketmq.a ${BASEDIR}/rocketmq_amd64/usr/local/lib/

VERSION=`cat ${BASEDIR}/rocketmq_amd64/DEBIAN/control | grep Version | awk -F ':' '{print $2}'| sed 's/^ *//'`
dpkg-deb --build ${BASEDIR}/rocketmq_amd64 rocketmq_${VERSION}_amd64.deb
8 changes: 8 additions & 0 deletions dep/rocketmq_amd64/DEBIAN/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Package: RocketMQ
Version: 1.2.5
Architecture: amd64
Essential: no
Priority: optional
Depends:
Maintainer: "Apache RocketMQ" <[email protected]>
Description: This package is C++ client of Apache RocketMQ for debian and its derivertives like Ubuntu.
1 change: 1 addition & 0 deletions dep/rocketmq_amd64/DEBIAN/postinst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ldconfig
18 changes: 18 additions & 0 deletions rpm/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
BASEDIR=$(dirname "$0")
if [[ ! -d ${BASEDIR}/rocketmq_x64/CENTOS/ ]]; then
echo "Can not find SPEC FILE"
exit 1
fi
if [[ ! -d /root/rpmbuild/SOURCES/rocketmq/include ]]; then
mkdir -p /root/rpmbuild/SOURCES/rocketmq
mkdir -p /root/rpmbuild/SOURCES/rocketmq/include
mkdir -p /root/rpmbuild/SOURCES/rocketmq/bin
fi
cp -R ${BASEDIR}/../include/* /root/rpmbuild/SOURCES/rocketmq/include
cp ${BASEDIR}/../bin/librocketmq.so /root/rpmbuild/SOURCES/rocketmq/bin
cp ${BASEDIR}/../bin/librocketmq.a /root/rpmbuild/SOURCES/rocketmq/bin
cp ${BASEDIR}/rocketmq_x64/CENTOS/rocketmq-client-cpp.spec /root/rpmbuild/SPECS

rpmbuild -bb /root/rpmbuild/SPECS/rocketmq-client-cpp.spec

cp /root/rpmbuild/RPMS/*.rpm ${BASEDIR}/rocketmq_x64
54 changes: 54 additions & 0 deletions rpm/rocketmq_x64/CENTOS/rocketmq-client-cpp.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@

Summary: A C++ Client of Apache RocketMQ

Name: rocketmq-client-cpp
Version: 1.2.5
Release: centos
Group: Apache
License: APLv2
Source: https://github.com/apache/rocketmq-client-cpp
URL: http://rocketmq.apache.org/
Distribution: Linux

%define _prefix /usr/local

AutoReqProv: no

%description
A C++ Client of Apache RocketMQ

%prep

pwd

cat /etc/redhat-release|sed -r 's/.* ([0-9]+)\..*/\1/'

OS_VERSION=`cat /etc/redhat-release|sed -r 's/.* ([0-9]+)\..*/\1/'`

echo "OS_VERSION=${OS_VERSION}"


%build

%install
# create dirs
mkdir -p $RPM_BUILD_ROOT%{_prefix}

# create dirs
mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib
mkdir -p $RPM_BUILD_ROOT%{_prefix}/include/rocketmq

# copy files
cp -f ${RPM_SOURCE_DIR}/rocketmq/bin/librocketmq.so $RPM_BUILD_ROOT%{_prefix}/lib
cp -f ${RPM_SOURCE_DIR}/rocketmq/bin/librocketmq.a $RPM_BUILD_ROOT%{_prefix}/lib
cp -rf ${RPM_SOURCE_DIR}/rocketmq/include/* $RPM_BUILD_ROOT%{_prefix}/include/rocketmq

# package information
%files
# set file attribute here
%defattr(-, root, root, 0755)
%{_prefix}/lib
%{_prefix}/include

%define debug_package %{nil}
%define __os_install_post %{nil}

0 comments on commit 0648508

Please sign in to comment.