Merge pull request #11714 from neheb/cgr

libcgroup: fix compile with newer musl
This commit is contained in:
Rosen Penev 2020-04-02 16:15:59 -07:00 committed by GitHub
commit cf44e13a5e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 262 additions and 41 deletions

View File

@ -2,17 +2,18 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=libcgroup
PKG_VERSION:=0.41
PKG_RELEASE:=1
PKG_LICENSE:=LGPL
PKG_LICENSE_FILES:=COPYING
PKG_RELEASE:=2
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
PKG_SOURCE_URL:=@SF/libcg
PKG_HASH:=e4e38bdc7ef70645ce33740ddcca051248d56b53283c0dc6d404e17706f6fb51
PKG_MAINTAINER:=Daniel Danzberger <daniel@dd-wrt.com>
PKG_MAINTAINER:=Daniel Danzberger <daniel@dd-wrt.com>
PKG_LICENSE:=LGPL-2.1-or-later
PKG_LICENSE_FILES:=COPYING
PKG_INSTALL:=1
PKG_BUILD_PARALLEL:=1
PKG_FIXUP:=autoreconf
include $(INCLUDE_DIR)/package.mk
@ -20,7 +21,7 @@ define Package/libcgroup
TITLE:=CGroup config and exec library
SECTION:=libs
CATEGORY:=Libraries
DEPENDS:=+musl-fts +@KERNEL_CGROUPS
DEPENDS:=+USE_MUSL:musl-fts +@KERNEL_CGROUPS
endef
define Package/cgroup-tools
@ -33,27 +34,31 @@ define Package/libcgroup/description
Helpers utils for working with cgroups.
endef
CONFIGURE_ARGS += --enable-tools \
--enable-shared \
--disable-daemon \
--disable-pam
CONFIGURE_ARGS += \
--enable-tools \
--enable-shared \
--disable-daemon \
--disable-pam
TARGET_LDFLAGS += $(if $(CONFIG_USE_MUSL),-lfts)
define Build/InstallDev
$(INSTALL_DIR) $(1)/usr/include $(1)/usr/lib $(1)/usr/lib/pkgconfig
$(CP) $(PKG_BUILD_DIR)/include/libcgroup.h $(1)/usr/include
$(CP) $(PKG_BUILD_DIR)/include/libcgroup $(1)/usr/include
$(CP) $(PKG_BUILD_DIR)/src/.libs/libcgroup.so* $(1)/usr/lib
$(CP) $(PKG_BUILD_DIR)/libcgroup.pc $(1)/usr/lib/pkgconfig/
$(CP) $(PKG_INSTALL_DIR)/usr/include/libcgroup.h $(1)/usr/include
$(CP) $(PKG_INSTALL_DIR)/usr/include/libcgroup $(1)/usr/include
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libcgroup.so* $(1)/usr/lib
$(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libcgroup.pc $(1)/usr/lib/pkgconfig/
endef
define Package/libcgroup/install
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_BUILD_DIR)/src/.libs/libcgroup.so* $(1)/usr/lib
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libcgroup.so* $(1)/usr/lib
endef
define Package/cgroup-tools/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/tools/.libs/* $(1)/usr/bin
$(INSTALL_DIR) $(1)/usr/bin $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/* $(1)/usr/bin
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/* $(1)/usr/sbin
endef
$(eval $(call BuildPackage,libcgroup))

View File

@ -1,24 +0,0 @@
diff --git a/configure.in b/configure.in
index 75f4a51..f70b37c 100644
--- a/configure.in
+++ b/configure.in
@@ -193,6 +193,19 @@ if test x$with_pam = xtrue; then
header files!])])
fi
+AC_CHECK_LIB(
+ [fts],
+ [fts_open],
+ [],
+ [AC_MSG_ERROR([Cannot compile without fts!])]
+)
+
+AC_CHECK_HEADERS(
+ [fts.h],
+ [],
+ [AC_MSG_ERROR([Cannot compile without fts.h])]
+)
+
AC_CONFIG_FILES([Makefile
tests/Makefile
tests/tools/testenv.sh

View File

@ -0,0 +1,240 @@
--- a/include/libcgroup/config.h
+++ b/include/libcgroup/config.h
@@ -5,12 +5,10 @@
#error "Only <libcgroup.h> should be included directly."
#endif
-#ifndef SWIG
-#include <features.h>
+#ifdef __cplusplus
+extern "C" {
#endif
-__BEGIN_DECLS
-
/**
* @defgroup group_config 5. Configuration
* @{
@@ -107,6 +105,8 @@ int cgroup_config_create_template_group(
* @}
* @}
*/
-__END_DECLS
+#ifdef __cplusplus
+}
+#endif
#endif /*_LIBCGROUP_CONFIG_H*/
--- a/include/libcgroup/error.h
+++ b/include/libcgroup/error.h
@@ -5,12 +5,10 @@
#error "Only <libcgroup.h> should be included directly."
#endif
-#ifndef SWIG
-#include <features.h>
+#ifdef __cplusplus
+extern "C" {
#endif
-__BEGIN_DECLS
-
/**
* @defgroup group_errors 6. Error handling
* @{
@@ -99,6 +97,8 @@ int cgroup_get_last_errno(void);
* @}
* @}
*/
-__END_DECLS
+#ifdef __cplusplus
+}
+#endif
#endif /* _LIBCGROUP_INIT_H */
--- a/include/libcgroup/groups.h
+++ b/include/libcgroup/groups.h
@@ -6,12 +6,13 @@
#endif
#ifndef SWIG
-#include <features.h>
#include <sys/types.h>
#include <stdbool.h>
#endif
-__BEGIN_DECLS
+#ifdef __cplusplus
+extern "C" {
+#endif
/**
* Flags for cgroup_delete_cgroup_ext().
@@ -577,6 +578,8 @@ char *cgroup_get_cgroup_name(struct cgroup *cgroup);
*/
-__END_DECLS
+#ifdef __cplusplus
+}
+#endif
#endif /* _LIBCGROUP_GROUPS_H */
--- a/include/libcgroup/init.h
+++ b/include/libcgroup/init.h
@@ -5,12 +5,10 @@
#error "Only <libcgroup.h> should be included directly."
#endif
-#ifndef SWIG
-#include <features.h>
+#ifdef __cplusplus
+extern "C" {
#endif
-__BEGIN_DECLS
-
/**
* @defgroup group_init 1. Initialization
* @{
@@ -58,6 +56,8 @@ int cgroup_get_subsys_mount_point(const char *controller, char **mount_point);
* @}
* @}
*/
-__END_DECLS
+#ifdef __cplusplus
+}
+#endif
#endif /* _LIBCGROUP_INIT_H */
--- a/include/libcgroup/iterators.h
+++ b/include/libcgroup/iterators.h
@@ -8,10 +8,11 @@
#ifndef SWIG
#include <sys/types.h>
#include <stdio.h>
-#include <features.h>
#endif
-__BEGIN_DECLS
+#ifdef __cplusplus
+extern "C" {
+#endif
/**
* @defgroup group_iterators 3. Iterators
@@ -423,6 +424,8 @@ int cgroup_get_subsys_mount_point_end(void **handle);
* @}
*/
-__END_DECLS
+#ifdef __cplusplus
+}
+#endif
#endif /* _LIBCGROUP_ITERATORS_H */
--- a/include/libcgroup/log.h
+++ b/include/libcgroup/log.h
@@ -5,13 +5,11 @@
#error "Only <libcgroup.h> should be included directly."
#endif
-#ifndef SWIG
-#include <features.h>
-#endif
-
#include <stdarg.h>
-__BEGIN_DECLS
+#ifdef __cplusplus
+extern "C" {
+#endif
/**
* @defgroup group_log 7. Logging
@@ -142,6 +140,8 @@ extern int cgroup_parse_log_level_str(const char *levelstr);
* @}
* @}
*/
-__END_DECLS
+#ifdef __cplusplus
+}
+#endif
#endif /* _LIBCGROUP_LOG_H */
--- a/include/libcgroup/tasks.h
+++ b/include/libcgroup/tasks.h
@@ -8,11 +8,12 @@
#include <libcgroup/groups.h>
#ifndef SWIG
-#include <features.h>
#include <stdbool.h>
#endif
-__BEGIN_DECLS
+#ifdef __cplusplus
+extern "C" {
+#endif
/** Flags for cgroup_change_cgroup_uid_gid(). */
enum cgflags {
@@ -204,6 +205,8 @@ int cgroup_register_unchanged_process(pid_t pid, int flags);
* @}
* @}
*/
-__END_DECLS
+#ifdef __cplusplus
+}
+#endif
#endif /* _LIBCGROUP_TASKS_H */
--- a/src/daemon/cgrulesengd.h
+++ b/src/daemon/cgrulesengd.h
@@ -15,9 +15,9 @@
#ifndef _CGRULESENGD_H
#define _CGRULESENGD_H
-#include <features.h>
-
-__BEGIN_DECLS
+#ifdef __cplusplus
+extern "C" {
+#endif
#include "config.h"
#include "libcgroup.h"
@@ -119,7 +119,9 @@ void cgre_flash_templates(int signum);
*/
void cgre_catch_term(int signum);
-__END_DECLS
+#ifdef __cplusplus
+}
+#endif
#endif /* _CGRULESENGD_H */
--- a/src/libcgroup-internal.h
+++ b/src/libcgroup-internal.h
@@ -16,7 +16,9 @@
#define __LIBCG_INTERNAL
-__BEGIN_DECLS
+#ifdef __cplusplus
+extern "C" {
+#endif
#include "config.h"
#include <fts.h>
@@ -279,6 +281,8 @@ extern void cgroup_dictionary_iterator_end(void **handle);
*/
int cg_chmod_path(const char *path, mode_t mode, int owner_is_umask);
-__END_DECLS
+#ifdef __cplusplus
+}
+#endif
#endif