libsearpc: Update to 3.2.0, add Python 3 bindings package
authorJeffery To <jeffery.to@gmail.com>
Wed, 5 Feb 2020 21:34:55 +0000 (05:34 +0800)
committerJeffery To <jeffery.to@gmail.com>
Fri, 13 Mar 2020 20:49:59 +0000 (04:49 +0800)
This also moves the Python dependency from libsearpc to python3-searpc,
and adds myself as a maintainer.

Patches:
* 001-fix-memory-leak-GH-48.patch: This is (at this time) the only
  difference between the tags v3.2.0 and v3.2-latest.

* 002-no-future-import.patch: The future package is only needed for
  Python 2 compatibility; all of the functions/symbols it provides are
  available in Python 3.

Signed-off-by: Jeffery To <jeffery.to@gmail.com>
libs/libsearpc/Makefile
libs/libsearpc/patches/001-fix-memory-leak-GH-48.patch [new file with mode: 0644]
libs/libsearpc/patches/002-no-future-import.patch [new file with mode: 0644]

index c52ca822225bb08759e94f2d818fffdeb696cbc8..3134603428190e36eed9f78eb0e21aab1733f9c3 100644 (file)
@@ -8,15 +8,15 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=libsearpc
-PKG_VERSION:=3.1.0
-PKG_RELEASE=2
+PKG_VERSION:=3.2.0
+PKG_RELEASE:=1
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
 PKG_SOURCE_URL:=https://codeload.github.com/haiwen/libsearpc/tar.gz/v$(PKG_VERSION)?
-PKG_HASH:=cbd86d3c37b54ca2060ca537a07940fe3e98498abf345b2f3e1cec488230231a
-PKG_MAINTAINER:=Alexandru Ardelean <ardeleanalex@gmail.com>
+PKG_HASH:=c479d85e405674c3450eac040abe143af5a9fafe7f1b74926e2a05280ab5420e
 
-PKG_LICENSE:=GPL-3.0
+PKG_MAINTAINER:=Alexandru Ardelean <ardeleanalex@gmail.com>, Jeffery To <jeffery.to@gmail.com>
+PKG_LICENSE:=Apache-2.0
 PKG_LICENSE_FILES:=LICENSE.txt
 
 PKG_FIXUP:=autoreconf
@@ -26,41 +26,70 @@ PKG_INSTALL:=1
 include $(INCLUDE_DIR)/package.mk
 include $(INCLUDE_DIR)/nls.mk
 include ../../lang/python/python-package.mk
+include ../../lang/python/python3-package.mk
 
 define Package/libsearpc
-    SECTION:=libs
-    CATEGORY:=Libraries
-    TITLE:=Seafile RPC Library
-    URL:=https://seafile.com
-    DEPENDS:=+glib2 +jansson +python $(ICONV_DEPENDS)
+  SECTION:=libs
+  CATEGORY:=Libraries
+  TITLE:=Seafile RPC Library
+  URL:=https://seafile.com
+  DEPENDS:=+glib2 +jansson $(ICONV_DEPENDS)
 endef
 
 define Package/libsearpc/description
-    Searpc is a simple C language RPC framework based on GObject system.
-    Searpc handles the serialization/deserialization part of RPC,
-    the transport part is left to users.
+  Searpc is a simple C language RPC framework based on GObject system.
+  Searpc handles the serialization/deserialization part of RPC, the
+  transport part is left to users.
 endef
 
-CONFIGURE_ARGS += --enable-compile-demo=no \
-                   --disable-server-pkg
+define Package/python3-searpc
+  SECTION:=lang
+  CATEGORY:=Languages
+  SUBMENU:=Python
+  TITLE:=Python bindings for Searpc
+  DEPENDS:=+libsearpc +python3-light +python3-logging
+  VARIANT:=python3
+endef
+
+define Package/python3-searpc/description
+$(call Package/libsearpc/description)
+
+  This package contains the Python bindings for Searpc.
+endef
 
-TARGET_LDFLAGS += -Wl,-rpath-link=$(STAGING_DIR)/usr/lib -liconv
+CONFIGURE_ARGS += \
+       --disable-compile-demo \
+       --disable-server-pkg
 
 define Build/InstallDev
        $(INSTALL_DIR) $(1)/usr/{bin,include}
        $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
        $(CP) $(PKG_INSTALL_DIR)/usr/lib/libsearpc.so* $(1)/usr/lib/
-       $(CP) $(PKG_INSTALL_DIR)/usr/include/searpc* $(1)/usr/include/
-       $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libsearpc.pc $(1)/usr/lib/pkgconfig/
-       $(CP) $(PKG_INSTALL_DIR)/usr/bin/searpc-codegen.py $(1)/usr/bin/
+       $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/include/*.h $(1)/usr/include/
+       $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libsearpc.pc $(1)/usr/lib/pkgconfig/
+       $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/searpc-codegen.py $(1)/usr/bin/
 endef
 
+# Include Python 2 bindings in this package to maintain compatibility with previous versions
 define Package/libsearpc/install
        $(INSTALL_DIR) $(1)/usr/lib
-       $(INSTALL_DIR) $(1)$(PYTHON_PKG_DIR)
+       $(INSTALL_DIR) $(1)$(PYTHON_PKG_DIR)/pysearpc
        $(CP) $(PKG_INSTALL_DIR)/usr/lib/libsearpc.so* $(1)/usr/lib/
-       $(CP) $(PKG_INSTALL_DIR)$(PYTHON_PKG_DIR)/pysearpc $(1)$(PYTHON_PKG_DIR)
-       find $(1) -name "*\.pyc" -o -name "*\.pyo" | xargs rm -f
+       $(INSTALL_DATA) $(PKG_BUILD_DIR)/pysearpc/*.py $(1)$(PYTHON_PKG_DIR)/pysearpc/
+       rm -f $(1)$(PYTHON_PKG_DIR)/pysearpc/{pygencode,test_pysearpc}.py
 endef
 
+define Py3Build/Compile
+       rm -rf $(PKG_INSTALL_DIR)$(PYTHON3_PKG_DIR)/pysearpc
+       $(INSTALL_DIR) $(PKG_INSTALL_DIR)$(PYTHON3_PKG_DIR)/pysearpc
+       $(INSTALL_DATA) $(PKG_BUILD_DIR)/pysearpc/*.py $(PKG_INSTALL_DIR)$(PYTHON3_PKG_DIR)/pysearpc/
+       rm -f $(PKG_INSTALL_DIR)$(PYTHON3_PKG_DIR)/pysearpc/{pygencode,test_pysearpc}.py
+endef
+
+Py3Package/python3-searpc/install:=:
+
 $(eval $(call BuildPackage,libsearpc))
+
+$(eval $(call Py3Package,python3-searpc))
+$(eval $(call BuildPackage,python3-searpc))
+$(eval $(call BuildPackage,python3-searpc-src))
diff --git a/libs/libsearpc/patches/001-fix-memory-leak-GH-48.patch b/libs/libsearpc/patches/001-fix-memory-leak-GH-48.patch
new file mode 100644 (file)
index 0000000..a0ae81f
--- /dev/null
@@ -0,0 +1,19 @@
+From 9b2e2dc65213fb22ed400dc54e4c2279564df62b Mon Sep 17 00:00:00 2001
+From: ly1217 <yu.liu@seafile.com>
+Date: Thu, 31 Oct 2019 00:31:38 -0700
+Subject: [PATCH] Fix memory leak.
+
+---
+ lib/searpc-named-pipe-transport.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/lib/searpc-named-pipe-transport.c
++++ b/lib/searpc-named-pipe-transport.c
+@@ -377,6 +377,7 @@ void searpc_free_client_with_pipe_transp
+     close(pipe_client->pipe_fd);
+ #endif
+     g_free (pipe_client);
++    g_free (data->service);
+     g_free (data);
+     searpc_client_free (client);
+ }
diff --git a/libs/libsearpc/patches/002-no-future-import.patch b/libs/libsearpc/patches/002-no-future-import.patch
new file mode 100644 (file)
index 0000000..b69c021
--- /dev/null
@@ -0,0 +1,11 @@
+--- a/pysearpc/named_pipe.py
++++ b/pysearpc/named_pipe.py
+@@ -2,8 +2,6 @@
+ RPC client/server implementation based on named pipe transport.
+ """
+-from future import standard_library
+-standard_library.install_aliases()
+ from builtins import object
+ import json
+ import logging