Hi. In an attempt to make collectd-mod-ping work instead of just having a bunch of Permission denied errors in the log and no data in collectd, I'm extending the libcap package to compile the utilities setcap and getcap so I can run this to enable the creation of raw packets from liboping (used by collectd-mod-ping):

# setcap cap_net_raw=ep `which collectd`

This is my new libcap Makefile:

#
# Copyright (C) 2011 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#

include $(TOPDIR)/rules.mk

PKG_NAME:=libcap
PKG_VERSION:=2.24
PKG_RELEASE:=1

PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
PKG_SOURCE_URL:=http://www.kernel.org/pub/linux/libs/security/linux-privs/libcap2/
PKG_MD5SUM:=d43ab9f680435a7fff35b4ace8d45b80
PKG_MAINTAINER:=Steven Barth <cyrus@openwrt.org>

PKG_INSTALL:=1

include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/kernel.mk

define Package/libcap/Default
  TITLE:=Linux capabilities 
  URL:=http://www.kernel.org/pub/linux/libs/security/linux-privs/libcap2/
  DEPENDS:=+libattr
endef

define Package/setcap
$(call Package/libcap/Default)
  SECTION:=utils
  CATEGORY:=Utilities
  TITLE+=utils (setcap)
endef

define Package/getcap
$(call Package/libcap/Default)
  SECTION:=utils
  CATEGORY:=Utilities
  TITLE+=utils (getcap)
endef

define Package/libcap
$(call Package/libcap/Default)
  SECTION:=libs
  CATEGORY:=Libraries
  TITLE+=library
endef

MAKE_FLAGS += \
    CFLAGS="$(TARGET_CFLAGS)" \
    BUILD_CC="$(CC)" \
    BUILD_CFLAGS="$(FPIC) -I$(PKG_BUILD_DIR)/libcap/include" \
    LD="$(TARGET_CC)" \
    LDFLAGS="$(TARGET_LDFLAGS) -shared" \
    INDENT="| true" \
    PAM_CAP="no" \
    LIBATTR="yes" \
    DYNAMIC="yes" \
    lib="lib"

define Build/InstallDev
        $(INSTALL_DIR) $(1)/usr/include/sys
        $(CP) $(PKG_INSTALL_DIR)/usr/include/* $(1)/usr/include/
        $(INSTALL_DIR) $(1)/usr/lib/
        $(CP) $(PKG_INSTALL_DIR)/lib/* $(1)/usr/lib/
        $(INSTALL_DIR) $(1)/usr/bin
        $(CP) $(PKG_INSTALL_DIR)/sbin/* $(1)/sbin/
endef

define Package/libcap/install
        $(INSTALL_DIR) $(1)/usr/lib
        $(CP) $(PKG_INSTALL_DIR)/lib/libcap.so* $(1)/usr/lib/
endef

define Package/setcap/install
        $(INSTALL_DIR) $(1)/sbin
        $(CP) $(PKG_INSTALL_DIR)/sbin/setcap $(1)/sbin/
endef

define Package/getcap/install
        $(INSTALL_DIR) $(1)/sbin
        $(CP) $(PKG_INSTALL_DIR)/sbin/getcap $(1)/sbin/
endef

$(eval $(call BuildPackage,libcap))
$(eval $(call BuildPackage,setcap))
$(eval $(call BUildPackage,getcap))

but when I compile it I get this error:

cap_file.c:8:23: fatal error: sys/xattr.h: No such file or directory
 #include <sys/xattr.h>
                       ^
compilation terminated.

I've checked other packages that use attr, but they don't seem to do anything special in the Makefile that makes me think of this file.

What am I doing wrong?

Thanks! smile