Skip to contentSkip to conversation

libcap: add menu entry to install tools.

PATCH New Eric Le Bihan 2 participants 2 messages Apr 20, 2014 – Apr 21, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libcap: add menu entry to install tools.

libcap provides a set of tools to manipulate capabilities, among which setcap(8) and getcap(8). A new menu entry has been added to install them.

---
 package/libcap/Config.in | 14 ++++++++++++++
 package/libcap/libcap.mk | 13 +++++++++++--
 2 files changed, 25 insertions(+), 2 deletions(-)
package/libcap/Config.in +14 -0
index 7bf6c58..596da26 100644
@@ -7,3 +7,17 @@ config BR2_PACKAGE_LIBCAP
 	  privilege into a set of distinct privileges.
 
 	  http://sites.google.com/site/fullycapable/
+
+if BR2_PACKAGE_LIBCAP
+
+config BR2_PACKAGE_LIBCAP_TOOLS
+	bool "install tools"
+	help
+	  Install setcap, getcap, getpcaps and capsh tools.
+
+	  For these tools to run properly, you should enable, in your
+	  kernel configuration, extended file attributes/security labels
+	  support for the file system type used on target system (e.g.
+	  CONFIG_EXT2_FS_XATTR and CONFIG_EXT2_FS_SECURITY for ext2).
+
+endif
package/libcap/libcap.mk +11 -2
index 17e2eb5..4570a62 100644
@@ -14,6 +14,7 @@ LIBCAP_LICENSE_FILES = License
 
 LIBCAP_DEPENDENCIES = host-libcap
 LIBCAP_INSTALL_STAGING = YES
+LIBCAP_BINARIES = setcap getcap getpcaps capsh
 
 ifeq ($(BR2_PACKAGE_ATTR),y)
 	LIBCAP_DEPENDENCIES += attr
@@ -34,7 +35,7 @@ LIBCAP_MAKE_INSTALL_TARGET = install
 endif
 
 define LIBCAP_BUILD_CMDS
-	$(TARGET_MAKE_ENV) $(TARGET_CONFIGURE_OPTS) $(MAKE) -C $(@D)/libcap \
+	$(TARGET_MAKE_ENV) $(TARGET_CONFIGURE_OPTS) $(MAKE) -C $(@D) \
 		LIBATTR=$(LIBCAP_HAVE_LIBATTR) BUILD_CC="$(HOSTCC)" \
 		BUILD_CFLAGS="$(HOST_CFLAGS)" $(LIBCAP_MAKE_TARGET)
 endef
@@ -45,10 +46,18 @@ define LIBCAP_INSTALL_STAGING_CMDS
 endef
 
 define LIBCAP_INSTALL_TARGET_CMDS
-	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D)/libcap LIBATTR=$(LIBCAP_HAVE_LIBATTR) \
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) LIBATTR=$(LIBCAP_HAVE_LIBATTR) \
+		RAISE_SETFCAP=no \
 		DESTDIR=$(TARGET_DIR) prefix=/usr lib=lib $(LIBCAP_MAKE_INSTALL_TARGET)
 endef
 
+ifeq ($(BR2_PACKAGE_LIBCAP_TOOLS),)
+define LIBCAP_REMOVE_TOOLS
+	rm -f $(addprefix $(TARGET_DIR)/usr/sbin/, $(LIBCAP_BINARIES))
+endef
+LIBCAP_POST_INSTALL_TARGET_HOOKS += LIBCAP_REMOVE_TOOLS
+endif
+
 define HOST_LIBCAP_BUILD_CMDS
 	$(HOST_MAKE_ENV) $(HOST_CONFIGURE_OPTS) $(MAKE) -C $(@D) LIBATTR=no
 endef
Signature · 1 line
1.9.0
#1 lore raw

PATCH 1/1 libcap: add menu entry to install tools.

Dear Eric Le Bihan,

Quoted 8 lines · Eric Le Bihan

libcap provides a set of tools to manipulate capabilities, among which setcap(8) and getcap(8). A new menu entry has been added to install them.

---
 package/libcap/Config.in | 14 ++++++++++++++
 package/libcap/libcap.mk | 13 +++++++++++--
 2 files changed, 25 insertions(+), 2 deletions(-)

I applied this patch, but I had to make heavy changes to it: you didn't take into account the !MMU case, and the BR2_PREFER_STATIC_LIB case. The first was easy to solve: programs cannot be built in a !MMU configuration. The second one required more work, as your original patch changes to run 'make' at the root of the libcap sources, which doesn't work to build only the libcap.a library in a static library context. So I had to revert your solution, and instead to a 'make' in the libcap/ directory, and another 'make' in the progs/ directory.

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com