Subject: [alpine-aports] [PATCH] testing/libcouchbase: new aport

From: Nathan Johnson <[email-masked]>
Date: Sun, 28 Feb 2016 07:31:20 -0600

http://developer.couchbase.com/community
C client library for Couchbase NoSQL database
---
 testing/libcouchbase/APKBUILD                      | 96 ++++++++++++++++++++++
 .../libcouchbase/disable_git_version_check.patch   | 37 +++++++++
 testing/libcouchbase/fix_ioserver_tests.patch      | 54 ++++++++++++
 testing/libcouchbase/fix_snappy.patch              | 12 +++
 4 files changed, 199 insertions(+)
 create mode 100644 testing/libcouchbase/APKBUILD
 create mode 100644 testing/libcouchbase/disable_git_version_check.patch
 create mode 100644 testing/libcouchbase/fix_ioserver_tests.patch
 create mode 100644 testing/libcouchbase/fix_snappy.patch

diff --git a/testing/libcouchbase/APKBUILD b/testing/libcouchbase/APKBUILD
new file mode 100644
index 0000000..b9358dc
--- /dev/null
+++ b/testing/libcouchbase/APKBUILD
@@ -0,0 +1,96 @@
+# Contributor: Nathan Johnson <[email-masked]>
+# Maintainer: Nathan Johnson <[email-masked]>
+pkgname=libcouchbase
+pkgver=2.5.6
+pkgrel=0
+pkgdesc="C client library for Couchbase"
+url="http://developer.couchbase.com/community"
+arch="all"
+license="ASL 2.0"
+depends=""
+depends_dev="musl-dev openssl-dev snappy-dev"
+makedepends="$depends_dev cmake perl openjdk8-jre-base libtool libev-dev libevent-dev libuv-dev"
+install=""
+subpackages="$pkgname-dev $pkgname-bin $pkgname-doc $pkgname-libevent $pkgname-libev $pkgname-libuv"
+source="$pkgname-$pkgver.tar.gz::https://github.com/couchbase/libcouchbase/archive/${pkgver}.tar.gz
+    disable_git_version_check.patch
+    fix_ioserver_tests.patch
+    fix_snappy.patch"
+
+_builddir="$srcdir/libcouchbase-${pkgver}"
+prepare() {
+	local i
+	cd "$_builddir"
+	for i in $source; do
+		case $i in
+		*.patch) msg $i; patch -p1 -i "$srcdir"/$i || return 1;;
+		esac
+	done
+}
+
+build() {
+    cd "$_builddir"
+    rm -rf build && mkdir build && cd build
+    ../cmake/configure --prefix=/usr || return 1
+    make || return 1
+    ctest || return 1
+}
+
+package() {
+	cd "$_builddir"/build
+    cd build
+    make install DESTDIR="$pkgdir" || return 1
+}
+
+dev() {
+    pkgdesc="$pkgdesc (development files)"
+    depends="$pkgname"
+    # can't use default_dev because it grabs /usr/bin/cbc-write-config
+    mkdir -p "$subpkgdir"/usr
+    mv "$pkgdir"/usr/include "$subpkgdir"/usr/
+}
+
+doc() {
+    default_doc
+}
+
+libevent() {
+    pkgdesc="libevent backend for libcouchbase"
+    depends="$pkgname libevent"
+    mkdir -p "$subpkgdir"/usr/lib
+    mv "$pkgdir"/usr/lib/libcouchbase_libevent.so "$subpkgdir"/usr/lib
+}
+
+libev() {
+    pkgdesc="libev backend for libcouchbase"
+    depends="$pkgname libev"
+    mkdir -p "$subpkgdir"/usr/lib
+    mv "$pkgdir"/usr/lib/libcouchbase_libev.so "$subpkgdir"/usr/lib
+}
+
+libuv() {
+    pkgdesc="libuv backend for libcouchbase"
+    depends="$pkgname libuv"
+    mkdir -p "$subpkgdir"/usr/lib
+    mv "$pkgdir"/usr/lib/libcouchbase_libuv.so "$subpkgdir"/usr/lib
+
+}
+bin() {
+      pkgdesc="command line utilities for couchbase"
+      depends="$pkgname"
+      mkdir -p "$subpkgdir"/usr/bin
+      mv "$pkgdir"/usr/bin "$subpkgdir"/usr/
+}
+
+md5sums="309944c436b1eb4d90e8c90581d7504b  libcouchbase-2.5.6.tar.gz
+99f6fd7df5b3ccf4be9bc3363a96efea  disable_git_version_check.patch
+2b1192fba9fc460db50963caddef608a  fix_ioserver_tests.patch
+e207d547e3de14e22eecef04edf97a6b  fix_snappy.patch"
+sha256sums="35690d39c51c00b2656911389068e9bc099a791872fadd6bb8d75684984cf10f  libcouchbase-2.5.6.tar.gz
+c323477ab7d2dddad9decf85b00e64a9b13e4e0c9eb78890e8c2ff99cee9ed3b  disable_git_version_check.patch
+cae791e2ed78cf570118cf9c50686aac62fd5a48b4050e9862cf0893af017a05  fix_ioserver_tests.patch
+30066934200e21c1b912600bc5dd72ec033aa9c580f1d2456a167ba91b4e624f  fix_snappy.patch"
+sha512sums="32c87c323d3336a7aec612f56751c8788494860c6223449ddeca1577ac586d11d3c267b554aece1916c866b5a9d957a80a4b9d62f790b2501ed65a9ee8724246  libcouchbase-2.5.6.tar.gz
+987b76b9c8a38a1f144bcada3c24192b30b352c993c433f4a2a1e381b765ae6bb845ebc6393c794da1b4efbb68fd1d34b027104fecf5c9bcc29b0f58c7f6a474  disable_git_version_check.patch
+40992e442a2e9376ae6d4313fde801769ad4b43d8697e47f6183c8fbb05f30b160cd099c4ca7e893cfa2e665026cb0802abc22ade6d2da2bcf1b56e199b2528a  fix_ioserver_tests.patch
+36b483883f8cc2785a1b323cb67ebb9fb7e6e3af767fdcaca88205b3bbc32c02a375a88ce3749df750770ebd62d99c4bf5a19ef496e5f7f160e4b74fbd928e45  fix_snappy.patch"
diff --git a/testing/libcouchbase/disable_git_version_check.patch b/testing/libcouchbase/disable_git_version_check.patch
new file mode 100644
index 0000000..438e37b
--- /dev/null
+++ b/testing/libcouchbase/disable_git_version_check.patch
@@ -0,0 +1,37 @@
+--- a/cmake/Modules/GetVersionInfo.cmake
++++ b/cmake/Modules/GetVersionInfo.cmake
+@@ -7,34 +7,6 @@
+ #  LCB_VERSION_MINOR
+ #  LCB_VERSION_PATCH
+ 
+-## Try git first ##
+-FIND_PROGRAM(GIT_EXECUTABLE NAMES git git.exe)
+-MACRO(RUNGIT outvar)
+-    EXECUTE_PROCESS(COMMAND git ${ARGN}
+-        OUTPUT_VARIABLE ${outvar}
+-        WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
+-        OUTPUT_STRIP_TRAILING_WHITESPACE)
+-ENDMACRO()
+-
+-if (GIT_EXECUTABLE)
+-    RUNGIT(LCB_REVDESCRIBE describe --long)
+-    RUNGIT(LCB_VERSION describe)
+-    STRING(REPLACE "-" "_" LCB_VERSION "${LCB_VERSION}")
+-    MESSAGE(STATUS "Sanitized VERSION=${LCB_VERSION}")
+-    RUNGIT(LCB_VERSION_CHANGESET rev-parse HEAD)
+-
+-    EXECUTE_PROCESS(
+-        COMMAND echo ${LCB_VERSION}
+-        COMMAND awk -F. "{printf \"0x%0.2d%0.2d%0.2d\", $1, $2, $3}"
+-        WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
+-        OUTPUT_VARIABLE LCB_VERSION_HEX)
+-ENDIF()
+-
+-IF(LCB_VERSION)
+-    # Have the version information
+-    CONFIGURE_FILE(${LCB_GENINFODIR}/distinfo.cmake.in ${LCB_GENINFODIR}/distinfo.cmake)
+-ENDIF()
+-
+ # library version
+ IF(NOT LCB_VERSION AND EXISTS ${LCB_GENINFODIR}/distinfo.cmake)
+     INCLUDE(${LCB_GENINFODIR}/distinfo.cmake)
diff --git a/testing/libcouchbase/fix_ioserver_tests.patch b/testing/libcouchbase/fix_ioserver_tests.patch
new file mode 100644
index 0000000..5e35567
--- /dev/null
+++ b/testing/libcouchbase/fix_ioserver_tests.patch
@@ -0,0 +1,54 @@
+From c941e4f79748937b117aebc0ee961325b666053d Mon Sep 17 00:00:00 2001
+From: Nathan Johnson <[email-masked]>
+Date: Sun, 28 Feb 2016 12:04:45 -0600
+Subject: [PATCH] CCBC-683 Remove double calls to pthread_join in ioserver tests.
+
+Call join() from threads-win32 close() to be consistent with pthreads.
+
+Change-Id: I62566a588eb7036205e75945305cf2277db0e00a
+---
+
+diff --git a/tests/ioserver/connection.cc b/tests/ioserver/connection.cc
+index 23712d8..7e423eb 100644
+--- a/tests/ioserver/connection.cc
++++ b/tests/ioserver/connection.cc
+@@ -152,7 +152,10 @@
+     ctlfd_user->close();
+     ctlfd_lsn->close();
+     datasock->close();
+-    thr->join();
++    // We don't want to explicitly call join() here since that
++    // gets called in the destructor.  This is unncessary
++    // and broken on musl.
++    // thr->join();
+     delete thr;
+     mutex.close();
+     initcond.close();
+diff --git a/tests/ioserver/ioserver.cc b/tests/ioserver/ioserver.cc
+index a9bce67..c5f5b14 100644
+--- a/tests/ioserver/ioserver.cc
++++ b/tests/ioserver/ioserver.cc
+@@ -63,7 +63,10 @@
+         delete *iter;
+     }
+     mutex.unlock();
+-    thr->join();
++    // We don't want to explicitly call join() here since that
++    // gets called in the destructor.  This is unncessary
++    // and broken on musl.
++    // thr->join();
+     delete thr;
+     mutex.close();
+     delete lsn;
+diff --git a/tests/ioserver/threads-win32.cc b/tests/ioserver/threads-win32.cc
+index 9ed9614..1e5710a 100644
+--- a/tests/ioserver/threads-win32.cc
++++ b/tests/ioserver/threads-win32.cc
+@@ -36,6 +36,7 @@
+ Thread::close()
+ {
+     if (initialized) {
++        join();
+         CloseHandle(hThread);
+         initialized = false;
+     }
diff --git a/testing/libcouchbase/fix_snappy.patch b/testing/libcouchbase/fix_snappy.patch
new file mode 100644
index 0000000..7756296
--- /dev/null
+++ b/testing/libcouchbase/fix_snappy.patch
@@ -0,0 +1,12 @@
+--- a/cmake/configure
++++ b/cmake/configure
+@@ -285,6 +285,9 @@
+ }
+ if ($NO_SNAPPY) {
+     push @CM_OPTIONS, "-DLCB_NO_SNAPPY=1";
++} else {
++    # the cmake options default NO_SNAPPY to ON, so this is necessary
++    push @CM_OPTIONS, "-DLCB_NO_SNAPPY=0";
+ }
+ if ($STATIC_SNAPPY) {
+     push @CM_OPTIONS, "-DLCB_STATIC_SNAPPY";
-- 
2.6.4

---
Unsubscribe:  [email-masked]
Help:         [email-masked]
---