merlimat closed pull request #1970: Added DEB packaging for C++ pulsar client 
lib
URL: https://github.com/apache/incubator-pulsar/pull/1970
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/pulsar-client-cpp/pkg/deb/.gitignore 
b/pulsar-client-cpp/pkg/deb/.gitignore
new file mode 100644
index 0000000000..89620f3105
--- /dev/null
+++ b/pulsar-client-cpp/pkg/deb/.gitignore
@@ -0,0 +1 @@
+BUILD
diff --git a/pulsar-client-cpp/pkg/deb/Dockerfile 
b/pulsar-client-cpp/pkg/deb/Dockerfile
new file mode 100644
index 0000000000..8f538ece39
--- /dev/null
+++ b/pulsar-client-cpp/pkg/deb/Dockerfile
@@ -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
diff --git a/pulsar-client-cpp/pkg/deb/build-deb.sh 
b/pulsar-client-cpp/pkg/deb/build-deb.sh
new file mode 100755
index 0000000000..b0b17810f0
--- /dev/null
+++ b/pulsar-client-cpp/pkg/deb/build-deb.sh
@@ -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
diff --git a/pulsar-client-cpp/pkg/deb/build-docker-image.sh 
b/pulsar-client-cpp/pkg/deb/build-docker-image.sh
new file mode 100755
index 0000000000..910aaaa591
--- /dev/null
+++ b/pulsar-client-cpp/pkg/deb/build-docker-image.sh
@@ -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 .
diff --git a/pulsar-client-cpp/pkg/deb/docker-build-deb.sh 
b/pulsar-client-cpp/pkg/deb/docker-build-deb.sh
new file mode 100755
index 0000000000..35d229e329
--- /dev/null
+++ b/pulsar-client-cpp/pkg/deb/docker-build-deb.sh
@@ -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
diff --git a/pulsar-client-cpp/pkg/rpm/docker-build-rpm.sh 
b/pulsar-client-cpp/pkg/rpm/docker-build-rpm.sh
index 11b459273f..0e386cb3aa 100755
--- a/pulsar-client-cpp/pkg/rpm/docker-build-rpm.sh
+++ b/pulsar-client-cpp/pkg/rpm/docker-build-rpm.sh
@@ -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
diff --git a/src/stage-release.sh b/src/stage-release.sh
index 4c29df5aaf..c4091e8ad4 100755
--- a/src/stage-release.sh
+++ b/src/stage-release.sh
@@ -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


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to