From 16ecc549f1fc5adda4b84a627557f71c95a203db Mon Sep 17 00:00:00 2001 From: Lucian Cristian Date: Sat, 16 May 2020 15:28:52 +0300 Subject: [PATCH] libcap-ng: add package libcap-ng Signed-off-by: Lucian Cristian --- libs/libcap-ng/Makefile | 90 +++++++++++++++++++ .../patches/add_library_if_header_found.patch | 30 +++++++ libs/libcap-ng/patches/fix-includes.patch | 11 +++ .../patches/fix_build_without_threads.patch | 26 ++++++ 4 files changed, 157 insertions(+) create mode 100644 libs/libcap-ng/Makefile create mode 100644 libs/libcap-ng/patches/add_library_if_header_found.patch create mode 100644 libs/libcap-ng/patches/fix-includes.patch create mode 100644 libs/libcap-ng/patches/fix_build_without_threads.patch diff --git a/libs/libcap-ng/Makefile b/libs/libcap-ng/Makefile new file mode 100644 index 000000000..04d480f2b --- /dev/null +++ b/libs/libcap-ng/Makefile @@ -0,0 +1,90 @@ +# +# Copyright (C) 2020 Lucian Cristian +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=libcap-ng +PKG_VERSION:=0.7.10 +PKG_RELEASE:=1 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz +PKG_SOURCE_URL:=https://people.redhat.com/sgrubb/libcap-ng +PKG_HASH:=a84ca7b4e0444283ed269b7a29f5b6187f647c82e2b876636b49b9a744f0ffbf + +PKG_MAINTAINER:=Lucian CRISTIAN +PKG_LICENSE:=GPL-2.0-or-later LGPL-2.1-or-later +PKG_LICENSE_FILES:=License + +PKG_INSTALL:=1 +PKG_BUILD_PARALLEL:=1 +PKG_FIXUP:=autoreconf + +include $(INCLUDE_DIR)/package.mk + +define Package/libcap-ng/Default + TITLE:=POSIX capabilities library + SECTION:=libs + CATEGORY:=Libraries + URL:=https://people.redhat.com/sgrubb/libcap-ng/index.html +endef + +define Package/libcap-ng/description/Default + POSIX capabilities library +endef + +define Package/libcap-ng + $(call Package/libcap-ng/Default) + TITLE += library +endef + +define Package/libcap-ng-bin + $(call Package/libcap-ng/Default) + TITLE += binaries + DEPENDS += libcap-ng +endef + +define Package/libcap-ng-bin/description + $(call Package/libcap-ng/description/Default) + . + This package contains the libcap-ng utilities. +endef + +TARGET_LDFLAGS += -Wl,--gc-sections,--as-needed $(FPIC) +TARGET_CFLAGS += -flto + +CONFIGURE_VARS += \ + ac_cv_prog_swig_found=no + +CONFIGURE_ARGS += \ + --prefix=/usr \ + --without-python \ + --without-python3 + +define Build/InstallDev + $(INSTALL_DIR) $(1)/usr/include + $(CP) $(PKG_INSTALL_DIR)/usr/include/*.h $(1)/usr/include/ + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libcap-ng.{so*,a} $(1)/usr/lib/ + $(INSTALL_DIR) $(1)/usr/lib/pkgconfig + $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libcap-ng.pc $(1)/usr/lib/pkgconfig/ + $(INSTALL_DIR) $(1)/usr/share/aclocal + $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/share/aclocal/cap-ng.m4\ + $(1)/usr/share/aclocal +endef + +define Package/libcap-ng/install + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libcap-ng.so* $(1)/usr/lib/ +endef + +define Package/libcap-ng-bin/install + $(INSTALL_DIR) $(1)/usr/sbin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/* $(1)/usr/sbin/ +endef + +$(eval $(call BuildPackage,libcap-ng)) +$(eval $(call BuildPackage,libcap-ng-bin)) diff --git a/libs/libcap-ng/patches/add_library_if_header_found.patch b/libs/libcap-ng/patches/add_library_if_header_found.patch new file mode 100644 index 000000000..fbeee1cde --- /dev/null +++ b/libs/libcap-ng/patches/add_library_if_header_found.patch @@ -0,0 +1,30 @@ +From 2c855b76362d1027abea967ac253cae8a7c160c3 Mon Sep 17 00:00:00 2001 +From: Trevor Woerner +Date: Wed, 6 May 2020 17:38:05 -0400 +Subject: [PATCH] configure.ac: add library if header found (#10) + +If the pthread.h header is found, make sure library containing +"pthread_atfork" is added to the list of libraries against which to link. +On some hosts (e.g. openSUSE 15.1) "-lpthread" needs to be explicitly added +in order for the code to compile correctly. + +Signed-off-by: Trevor Woerner +--- + configure.ac | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/configure.ac b/configure.ac +index 9d6aca3..4fbe4d3 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -56,7 +56,9 @@ AC_CHECK_HEADERS(sys/xattr.h, [], [ + AC_CHECK_HEADERS(attr/xattr.h, [], [AC_MSG_WARN(attr/xattr.h not found, disabling file system capabilities.)]) + ]) + AC_CHECK_HEADERS(linux/securebits.h, [], []) +-AC_CHECK_HEADERS(pthread.h, [], [AC_MSG_WARN(pthread.h not found, disabling pthread_atfork.)]) ++AC_CHECK_HEADERS(pthread.h, ++ [AC_SEARCH_LIBS(pthread_atfork, pthread)], ++ [AC_MSG_WARN(pthread.h not found, disabling pthread_atfork.)]) + + AC_C_CONST + AC_C_INLINE diff --git a/libs/libcap-ng/patches/fix-includes.patch b/libs/libcap-ng/patches/fix-includes.patch new file mode 100644 index 000000000..8fbd984b8 --- /dev/null +++ b/libs/libcap-ng/patches/fix-includes.patch @@ -0,0 +1,11 @@ +diff -ru libcap-ng-0.7.4.orig/src/cap-ng.c libcap-ng-0.7.4/src/cap-ng.c +--- libcap-ng-0.7.4.orig/src/cap-ng.c 2014-04-24 15:41:43.000000000 -0300 ++++ libcap-ng-0.7.4/src/cap-ng.c 2015-04-15 08:45:10.783335463 -0300 +@@ -34,6 +34,7 @@ + #include + #include + #include ++#include + #include + #ifdef HAVE_SYSCALL_H + #include diff --git a/libs/libcap-ng/patches/fix_build_without_threads.patch b/libs/libcap-ng/patches/fix_build_without_threads.patch new file mode 100644 index 000000000..39a2555d1 --- /dev/null +++ b/libs/libcap-ng/patches/fix_build_without_threads.patch @@ -0,0 +1,26 @@ +From 9b5597dc780a9da292f9142899a992cfc6ca081d Mon Sep 17 00:00:00 2001 +From: Fabrice Fontaine +Date: Thu, 7 May 2020 00:19:18 +0200 +Subject: [PATCH] src/cap-ng.c: fix build without threads (#13) + +Put pthread_atfork under #ifdef HAVE_PTHREAD_H block + +Signed-off-by: Fabrice Fontaine +--- + src/cap-ng.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/src/cap-ng.c b/src/cap-ng.c +index 35fcd7a..97a3dbd 100644 +--- a/src/cap-ng.c ++++ b/src/cap-ng.c +@@ -166,7 +166,9 @@ static void deinit(void) + static void init_lib(void) __attribute__ ((constructor)); + static void init_lib(void) + { ++#ifdef HAVE_PTHREAD_H + pthread_atfork(NULL, NULL, deinit); ++#endif + } + + static void init(void)