Skip to content

Commit

Permalink
Added DEB packaging for C++ pulsar client lib (apache#1970)
Browse files Browse the repository at this point in the history
  • Loading branch information
merlimat authored Jun 15, 2018
1 parent 0b26ce7 commit 4625667
Show file tree
Hide file tree
Showing 7 changed files with 225 additions and 1 deletion.
1 change: 1 addition & 0 deletions pulsar-client-cpp/pkg/deb/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
BUILD
76 changes: 76 additions & 0 deletions pulsar-client-cpp/pkg/deb/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#

# Build pulsar client library in Centos with tools to

FROM debian:9

RUN apt-get update && \
apt-get install -y curl g++ make libcurl4-openssl-dev libssl-dev python-dev \
libxml2-utils git

# Download and compile boost
RUN curl -O -L https://dl.bintray.com/boostorg/release/1.64.0/source/boost_1_64_0.tar.gz && \
tar xvfz boost_1_64_0.tar.gz && \
cd /boost_1_64_0 && \
./bootstrap.sh --with-libraries=program_options,filesystem,regex,thread,system,python && \
./b2 address-model=64 cxxflags=-fPIC link=static threading=multi variant=release install && \
rm -rf /boost_1_64_0.tar.gz /boost_1_64_0

RUN curl -O -L https://github.com/Kitware/CMake/archive/v3.8.2.tar.gz && \
tar xvfz v3.8.2.tar.gz && \
cd CMake-3.8.2 && \
./configure && \
make && make install && \
rm -rf /v3.8.2.tar.gz /CMake-3.8.2

# Compile JSON CPP
RUN curl -O -L https://github.com/open-source-parsers/jsoncpp/archive/1.8.0.tar.gz && \
tar xvfz 1.8.0.tar.gz && \
cd jsoncpp-1.8.0 && \
cmake . -DCMAKE_POSITION_INDEPENDENT_CODE=ON && \
make && make install && \
rm -rf /1.8.0.tar.gz /jsoncpp-1.8.0

# Download and copile protoubf
RUN curl -O -L https://github.com/google/protobuf/releases/download/v3.3.0/protobuf-cpp-3.3.0.tar.gz && \
tar xvfz protobuf-cpp-3.3.0.tar.gz && \
cd protobuf-3.3.0/ && \
CXXFLAGS=-fPIC ./configure && \
make && make install && ldconfig && \
rm -rf /protobuf-cpp-3.3.0.tar.gz /protobuf-3.3.0

# ZLib
RUN curl -O -L https://github.com/madler/zlib/archive/v1.2.11.tar.gz && \
tar xvfz v1.2.11.tar.gz && \
cd zlib-1.2.11 && \
CFLAGS="-fPIC -O3" ./configure && \
make && make install && \
rm -rf /zlib-1.2.11.tar.gz /zlib-1.2.11

# LibCurl
RUN curl -O -L https://github.com/curl/curl/releases/download/curl-7_54_0/curl-7.54.0.tar.gz && \
tar xvfz curl-7.54.0.tar.gz && \
cd curl-7.54.0 && \
CFLAGS=-fPIC ./configure && \
make && make install && \
rm -rf /curl-7.54.0.tar.gz /curl-7.54.0


RUN apt-get install -y dpkg-dev
95 changes: 95 additions & 0 deletions pulsar-client-cpp/pkg/deb/build-deb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
#!/bin/bash
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#

set -e -x

cd /pulsar
SRC_ROOT_DIR=$(git rev-parse --show-toplevel)
cd $SRC_ROOT_DIR/pulsar-client-cpp/pkg/deb

POM_VERSION=`cat ../../../pom.xml | xmllint --format - | sed "s/xmlns=\".*\"//g" | xmllint --stream --pattern /project/version --debug - | grep -A 2 "matches pattern" | grep text | sed "s/.* [0-9] //g"`
# Sanitize VERSION by removing `-incubating` since it's not legal in DEB
VERSION=`echo $POM_VERSION | awk -F- '{print $1}'`

ROOT_DIR=apache-pulsar-$POM_VERSION
CPP_DIR=$ROOT_DIR/pulsar-client-cpp

rm -rf BUILD
mkdir BUILD
cd BUILD
tar xfz $SRC_ROOT_DIR/all/target/apache-pulsar-$POM_VERSION-src.tar.gz
pushd $CPP_DIR

cmake . -DBUILD_TESTS=OFF -DLINK_STATIC=ON
make pulsarShared pulsarStatic -j 3
strip lib/libpulsar.*
popd

DEST_DIR=pulsar-client
mkdir -p $DEST_DIR/DEBIAN
cat <<EOF > $DEST_DIR/DEBIAN/control
Package: pulsar-client
Version: ${VERSION}
Maintainer: Apache Pulsar <[email protected]>
Architecture: amd64
Description: The Apache Pulsar client contains a C++ and C APIs to interact with Apache Pulsar brokers.
EOF

DEVEL_DEST_DIR=pulsar-client-dev
mkdir -p $DEVEL_DEST_DIR/DEBIAN
cat <<EOF > $DEVEL_DEST_DIR/DEBIAN/control
Package: pulsar-client-dev
Version: ${VERSION}
Maintainer: Apache Pulsar <[email protected]>
Architecture: amd64
Description: The Apache Pulsar client contains a C++ and C APIs to interact with Apache Pulsar brokers.
EOF

mkdir -p $DEST_DIR/usr/lib
mkdir -p $DEVEL_DEST_DIR/usr/lib
mkdir -p $DEVEL_DEST_DIR/usr/include
mkdir -p $DEST_DIR/usr/share/doc/pulsar-client-$VERSION
mkdir -p $DEVEL_DEST_DIR/usr/share/doc/pulsar-client-dev-$VERSION

cp -ar $CPP_DIR/include/pulsar $DEVEL_DEST_DIR/usr/include/
cp $CPP_DIR/lib/libpulsar.a $DEVEL_DEST_DIR/usr/lib
cp $CPP_DIR/lib/libpulsar.so.$POM_VERSION $DEST_DIR/usr/lib
pushd $DEST_DIR/usr/lib
ln -s libpulsar.so.$POM_VERSION libpulsar.so
popd

cp $ROOT_DIR/DISCLAIMER $DEST_DIR/usr/share/doc/pulsar-client-$VERSION
cp $ROOT_DIR/NOTICE $DEST_DIR/usr/share/doc/pulsar-client-$VERSION
cp $CPP_DIR/pkg/licenses/* $DEST_DIR/usr/share/doc/pulsar-client-$VERSION
cp $CPP_DIR/pkg/licenses/LICENSE.txt $DEST_DIR/usr/share/doc/pulsar-client-$VERSION/copyright
cp $CPP_DIR/pkg/licenses/LICENSE.txt $DEST_DIR/DEBIAN/copyright
cp $CPP_DIR/pkg/licenses/LICENSE.txt $DEVEL_DEST_DIR/DEBIAN/copyright

cp $DEST_DIR/usr/share/doc/pulsar-client-$VERSION/* $DEVEL_DEST_DIR/usr/share/doc/pulsar-client-dev-$VERSION


## Build actual debian packages
dpkg-deb --build pulsar-client
dpkg-deb --build pulsar-client-dev

mkdir DEB
mv *.deb DEB
cd DEB
dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz
21 changes: 21 additions & 0 deletions pulsar-client-cpp/pkg/deb/build-docker-image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#

docker build -t apachepulsar/pulsar-build:debian-9 .
28 changes: 28 additions & 0 deletions pulsar-client-cpp/pkg/deb/docker-build-deb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#

set -e

ROOT_DIR=$(git rev-parse --show-toplevel)

docker pull apachepulsar/pulsar-build:debian-9

docker run -it -v $ROOT_DIR:/pulsar apachepulsar/pulsar-build:debian-9 \
/pulsar/pulsar-client-cpp/pkg/deb/build-deb.sh
2 changes: 1 addition & 1 deletion pulsar-client-cpp/pkg/rpm/docker-build-rpm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ ROOT_DIR=$(git rev-parse --show-toplevel)
docker pull apachepulsar/pulsar-build:centos-7

docker run -it -v $ROOT_DIR:/pulsar apachepulsar/pulsar-build:centos-7 \
/build-rpm.sh
/pulsar/pulsar-client-cpp/pkg/rpm/build-rpm.sh
3 changes: 3 additions & 0 deletions src/stage-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ cp $PULSAR_PATH/all/target/apache-pulsar-$VERSION-bin.tar.gz $DEST_PATH
mkdir $DEST_PATH/RPMS
cp -r $PULSAR_PATH/pulsar-client-cpp/pkg/rpm/RPMS/x86_64/* $DEST_PATH/RPMS

mkdir $DEST_PATH/DEB
cp -r $PULSAR_PATH/pulsar-client-cpp/pkg/deb/BUILD/DEB/* $DEST_PATH/DEB

# Sign all files
cd $DEST_PATH
find . -type f | xargs $PULSAR_PATH/src/sign-release.sh

0 comments on commit 4625667

Please sign in to comment.