libcap: upgraded package to upstream

Upgraded sys-libs/libcap to version 2.24-r2 on amd64

BUG=None
TEST=pre cq tests

Change-Id: I9dbd451bb533c6774366fa7ba39d79f84b73844f
Reviewed-on: https://chromium-review.googlesource.com/344341
Commit-Ready: Ricky Zhou <rickyz@chromium.org>
Tested-by: Ricky Zhou <rickyz@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
diff --git a/metadata/md5-cache/sys-libs/libcap-2.22-r2 b/metadata/md5-cache/sys-libs/libcap-2.24-r2
similarity index 79%
rename from metadata/md5-cache/sys-libs/libcap-2.22-r2
rename to metadata/md5-cache/sys-libs/libcap-2.24-r2
index cc69ea1..3c3b270 100644
--- a/metadata/md5-cache/sys-libs/libcap-2.22-r2
+++ b/metadata/md5-cache/sys-libs/libcap-2.24-r2
@@ -3,11 +3,11 @@
 DESCRIPTION=POSIX 1003.1e capabilities
 EAPI=4
 HOMEPAGE=http://www.friedhoff.org/posixfilecaps.html
-IUSE=pam abi_x86_32 abi_x86_64 abi_x86_x32 abi_mips_n32 abi_mips_n64 abi_mips_o32 abi_ppc_32 abi_ppc_64 abi_s390_32 abi_s390_64
+IUSE=pam static-libs abi_x86_32 abi_x86_64 abi_x86_x32 abi_mips_n32 abi_mips_n64 abi_mips_o32 abi_ppc_32 abi_ppc_64 abi_s390_32 abi_s390_64
 KEYWORDS=*
 LICENSE=|| ( GPL-2 BSD )
 RDEPEND=>=sys-apps/attr-2.4.47-r1[abi_x86_32(-)?,abi_x86_64(-)?,abi_x86_x32(-)?,abi_mips_n32(-)?,abi_mips_n64(-)?,abi_mips_o32(-)?,abi_ppc_32(-)?,abi_ppc_64(-)?,abi_s390_32(-)?,abi_s390_64(-)?] pam? ( virtual/pam )
 SLOT=0
-SRC_URI=mirror://gentoo/libcap-2.22.tar.bz2
+SRC_URI=mirror://kernel/linux/libs/security/linux-privs/libcap2/libcap-2.24.tar.xz
 _eclasses_=eutils	06133990e861be0fe60c2b428fd025d9	flag-o-matic	5d5921a298e95441da2f85be419894c0	multibuild	6d4858dc00f8bc51caf3f957f8430eb0	multilib	3bf24e6abb9b76d9f6c20600f0b716bf	multilib-build	0983c7893df461213a05f791cc7dea6d	multilib-minimal	13dd976916c35a1e2c8d170e840c7018	pam	3f746974e1cc47cabe3bd488c08cdc8e	toolchain-funcs	48b38a216afb92db6314d6c3187abea3
-_md5_=104ef60dfa1bf0c74b5f005c38f4c8e0
+_md5_=5a34c59ad1837540f8a01948765d0d32
diff --git a/sys-libs/libcap/Manifest b/sys-libs/libcap/Manifest
index 90b48d8..4c7e2b3 100644
--- a/sys-libs/libcap/Manifest
+++ b/sys-libs/libcap/Manifest
@@ -1 +1 @@
-DIST libcap-2.22.tar.bz2 60051 SHA256 73ebbd4877b5f69dd28b72098e510c5b318bc480f8201c4061ac98b78c04050f SHA512 d4e070cfed7dbf416c949e79fbfbfcde2da4705d4f55527b18482c9959b80fea2841bf70f317fa5e620e13a75a8e5da69f94304b8e54195f2d0492f14d342339 WHIRLPOOL 000e3c76e83366423efc0e935c6191496c0e9bf1cc559babdbeea74c8c81009e883985c5f1c739b4fb1744522e09bda253f6012b7e52284f291eabeaf20f6a88
+DIST libcap-2.24.tar.xz 63412 SHA256 cee4568f78dc851d726fc93f25f4ed91cc223b1fe8259daa4a77158d174e6c65 SHA512 c062bab936d651a50efa66dcfa51ab3ce4b0881195d23bb32142b5c8044d30e0e2152f3497844ce90c04f909aeffe2d41203efff41972e38758dcca7b653884b WHIRLPOOL bb7a9d8d3b999ad289962ebdc8b9eff87e25bd744a86ee4717e999738cb5a556a51826d0f0cbfc628629948fa8355d5d972208910d6c1c99bdf66a673b6f1cc8
diff --git a/sys-libs/libcap/files/2.16/0001-build-system-fixes.patch b/sys-libs/libcap/files/2.16/0001-build-system-fixes.patch
deleted file mode 100644
index e82975b..0000000
--- a/sys-libs/libcap/files/2.16/0001-build-system-fixes.patch
+++ /dev/null
@@ -1,154 +0,0 @@
-From 7ee197885e113878aedab58bdda80302e42aff4c Mon Sep 17 00:00:00 2001
-From: Mike Frysinger <vapier@gentoo.org>
-Date: Sun, 16 Nov 2008 09:10:31 -0500
-Subject: [PATCH] build system fixes
-
-This touches up the homebrewed build system to work much better "out of the
-box" for people.  Specifically:
-	- allow toolchain vars to be set via environment
-		- CC / BUILD_CC / AR / RANLIB
-		- CFLAGS / CPPFLAGS / LDFLAGS
-	- split CPPFLAGS out of CFLAGS
-	- break -fPIC out of global CFLAGS and only use where needed
-	- use LDLIBS for libraries, not LDFLAGS
-
-Signed-off-by: Mike Frysinger <vapier@gentoo.org>
----
- Make.Rules       |   28 ++++++++++++++--------------
- libcap/Makefile  |   11 ++++++-----
- pam_cap/Makefile |    6 +++---
- progs/Makefile   |    2 +-
- 4 files changed, 24 insertions(+), 23 deletions(-)
-
-diff --git a/Make.Rules b/Make.Rules
-index 6e63a5b..32cb5ea 100644
---- a/Make.Rules
-+++ b/Make.Rules
-@@ -42,27 +42,27 @@ MINOR=16
- 
- # Compilation specifics
- 
--KERNEL_HEADERS := $(topdir)/libcap/include
--IPATH += -I$(topdir)/libcap/include -I$(KERNEL_HEADERS)
--
--CC := gcc
--CFLAGS := -O2
--BUILD_CC := $(CC)
--BUILD_CFLAGS := $(CFLAGS) $(IPATH)
--AR := ar
--RANLIB := ranlib
--DEBUG = -g #-DDEBUG
--WARNINGS=-fPIC -Wall -Wwrite-strings \
-+CC ?= gcc
-+BUILD_CC ?= $(CC)
-+AR ?= ar
-+RANLIB ?= ranlib
-+CFLAGS ?= -O2
-+BUILD_CFLAGS ?= -O2 -pipe
-+WARNINGS=-Wall -Wwrite-strings \
-         -Wpointer-arith -Wcast-qual -Wcast-align \
-         -Wstrict-prototypes -Wmissing-prototypes \
-         -Wnested-externs -Winline -Wshadow
- LD=$(CC) -Wl,-x -shared
--LDFLAGS := #-g
-+LDFLAGS ?= #-g
- 
--SYSTEM_HEADERS = /usr/include
-+KERNEL_HEADERS = $(topdir)/libcap/include
-+LIBCAP_CPPFLAGS = -I$(topdir)/libcap/include -I$(KERNEL_HEADERS)
-+CPPFLAGS += $(LIBCAP_CPPFLAGS)
-+BUILD_CPPFLAGS += $(LIBCAP_CPPFLAGS)
- INCS=$(topdir)/libcap/include/sys/capability.h
- LDFLAGS += -L$(topdir)/libcap
--CFLAGS += -Dlinux $(WARNINGS) $(DEBUG) $(IPATH)
-+CPPFLAGS += -Dlinux
-+CFLAGS += $(WARNINGS)
- PAM_CAP := $(shell if [ -f /usr/include/security/pam_modules.h ]; then echo yes ; else echo no ; fi)
- INDENT := $(shell if [ -n "$(which indent 2>/dev/null)" ]; then echo "| indent -kr" ; fi)
- DYNAMIC := $(shell if [ ! -d "$(topdir)/.git" ]; then echo yes; fi)
-diff --git a/libcap/Makefile b/libcap/Makefile
-index 8a61752..cf99523 100644
---- a/libcap/Makefile
-+++ b/libcap/Makefile
-@@ -16,7 +16,7 @@ FILES=cap_alloc cap_proc cap_extint cap_flag cap_text
- # no support).
- ifeq ($(LIBATTR),yes)
- FILES += cap_file
--LDFLAGS += -lattr
-+LDLIBS += -lattr
- endif
- 
- INCLS=libcap.h cap_names.h $(INCS)
-@@ -24,6 +24,7 @@ OBJS=$(addsuffix .o, $(FILES))
- MAJLIBNAME=$(LIBNAME).$(VERSION)
- MINLIBNAME=$(MAJLIBNAME).$(MINOR)
- GPERF_OUTPUT = _caps_output.gperf
-+CFLAGS += -fPIC
- 
- all: $(MINLIBNAME) $(STALIBNAME)
- 
-@@ -33,7 +34,7 @@ INCLUDE_GPERF_OUTPUT = -include $(GPERF_OUTPUT)
- endif
- 
- _makenames: _makenames.c cap_names.list.h
--	$(BUILD_CC) $(BUILD_CFLAGS) $< -o $@
-+	$(BUILD_CC) $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $< -o $@
- 
- cap_names.h: _makenames
- 	./_makenames > cap_names.h
-@@ -50,15 +51,15 @@ $(STALIBNAME): $(OBJS)
- 	$(RANLIB) $@
- 
- $(MINLIBNAME): $(OBJS)
--	$(LD) $(CFLAGS) $(LDFLAGS) -Wl,-soname,$(MAJLIBNAME) -o $@ $^
-+	$(LD) $(CFLAGS) $(LDFLAGS) -Wl,-soname,$(MAJLIBNAME) -o $@ $^ $(LDLIBS)
- 	ln -sf $(MINLIBNAME) $(MAJLIBNAME)
- 	ln -sf $(MAJLIBNAME) $(LIBNAME)
- 
- %.o: %.c $(INCLS)
--	$(CC) $(CFLAGS) -c $< -o $@
-+	$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
- 
- cap_text.o: cap_text.c $(USE_GPERF_OUTPUT) $(INCLS)
--	$(CC) $(CFLAGS) $(INCLUDE_GPERF_OUTPUT) -c $< -o $@
-+	$(CC) $(CFLAGS) $(CPPFLAGS) $(INCLUDE_GPERF_OUTPUT) -c $< -o $@
- 
- install: all
- 	mkdir -p -m 0755 $(INCDIR)/sys
-diff --git a/pam_cap/Makefile b/pam_cap/Makefile
-index eae88ed..bef59d2 100644
---- a/pam_cap/Makefile
-+++ b/pam_cap/Makefile
-@@ -14,13 +14,13 @@ install: all
- 	install -m 0755 pam_cap.so $(LIBDIR)/security
- 
- pam_cap.so: pam_cap.o
--	$(LD) $(LDFLAGS) -o pam_cap.so $< $(LDLIBS)
-+	$(LD) $(CFLAGS) $(LDFLAGS) -o pam_cap.so $< $(LDLIBS) -lpam
- 
- pam_cap.o: pam_cap.c
--	$(CC) $(CFLAGS) -c $< -o $@
-+	$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
- 
- testcompile: test.c pam_cap.o
--	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $+ -lpam -ldl $(LDLIBS)
-+	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ $+ -lpam -ldl $(LDLIBS)
- 
- clean:
- 	rm -f *.o *.so testcompile *~
-diff --git a/progs/Makefile b/progs/Makefile
-index a1542dc..612cf86 100644
---- a/progs/Makefile
-+++ b/progs/Makefile
-@@ -22,7 +22,7 @@ $(BUILD): %: %.o
- 	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LDLIBS)
- 
- %.o: %.c $(INCS)
--	$(CC) $(CFLAGS) -c $< -o $@
-+	$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
- 
- install: all
- 	mkdir -p -m 0755 $(SBINDIR)
--- 
-1.6.0.4
-
diff --git a/sys-libs/libcap/files/libcap-2.22-build-system-fixes.patch b/sys-libs/libcap/files/libcap-2.24-build-system-fixes.patch
similarity index 70%
rename from sys-libs/libcap/files/libcap-2.22-build-system-fixes.patch
rename to sys-libs/libcap/files/libcap-2.24-build-system-fixes.patch
index 888c089..6439327 100644
--- a/sys-libs/libcap/files/libcap-2.22-build-system-fixes.patch
+++ b/sys-libs/libcap/files/libcap-2.24-build-system-fixes.patch
@@ -1,4 +1,4 @@
-From 5540f3c2a3bd70ebc8140b74ac5a0aecdbc53234 Mon Sep 17 00:00:00 2001
+From 0485ff3e7f62a331aa4f1e8ec4c2fdcee400e324 Mon Sep 17 00:00:00 2001
 From: Mike Frysinger <vapier@gentoo.org>
 Date: Sun, 16 Nov 2008 09:10:31 -0500
 Subject: [PATCH] build system fixes
@@ -14,22 +14,22 @@
 
 Signed-off-by: Mike Frysinger <vapier@gentoo.org>
 ---
- Make.Rules       |   25 +++++++++++++------------
- libcap/Makefile  |   11 ++++++-----
- pam_cap/Makefile |    8 +++++---
- progs/Makefile   |    2 +-
- 4 files changed, 25 insertions(+), 21 deletions(-)
+ Make.Rules       | 26 ++++++++++++++------------
+ libcap/Makefile  | 11 ++++++-----
+ pam_cap/Makefile |  8 +++++---
+ progs/Makefile   |  2 +-
+ 4 files changed, 26 insertions(+), 21 deletions(-)
 
 diff --git a/Make.Rules b/Make.Rules
-index 011aa14..6e432a6 100644
+index 18b7cf7..5364c46 100644
 --- a/Make.Rules
 +++ b/Make.Rules
-@@ -44,27 +44,28 @@ MINOR=19
+@@ -45,27 +45,29 @@ MINOR=24
  
  # Compilation specifics
  
--KERNEL_HEADERS := $(topdir)/libcap/include
--IPATH += -fPIC -I$(topdir)/libcap/include -I$(KERNEL_HEADERS)
+-KERNEL_HEADERS := $(topdir)/libcap/include/uapi
+-IPATH += -fPIC -I$(KERNEL_HEADERS) -I$(topdir)/libcap/include
 -
 -CC := gcc
 -CFLAGS := -O2 -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
@@ -53,9 +53,10 @@
 +LDFLAGS ?= #-g
  
 -SYSTEM_HEADERS = /usr/include
-+KERNEL_HEADERS = $(topdir)/libcap/include
-+LIBCAP_CPPFLAGS = -I$(topdir)/libcap/include -I$(KERNEL_HEADERS)
-+CPPFLAGS += $(LIBCAP_CPPFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
++KERNEL_HEADERS = $(topdir)/libcap/include/uapi
++LIBCAP_CPPFLAGS = -I$(KERNEL_HEADERS) -I$(topdir)/libcap/include
++LIBCAP_CPPFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
++CPPFLAGS += $(LIBCAP_CPPFLAGS)
 +BUILD_CPPFLAGS += $(LIBCAP_CPPFLAGS)
  INCS=$(topdir)/libcap/include/sys/capability.h
  LDFLAGS += -L$(topdir)/libcap
@@ -63,10 +64,10 @@
 +CPPFLAGS += -Dlinux
 +CFLAGS += $(WARNINGS) $(DEBUG)
  PAM_CAP := $(shell if [ -f /usr/include/security/pam_modules.h ]; then echo yes ; else echo no ; fi)
- INDENT := $(shell if [ -n "$(which indent 2>/dev/null)" ]; then echo "| indent -kr" ; fi)
+ INDENT := $(shell if [ -n "$$(which indent 2>/dev/null)" ]; then echo "| indent -kr" ; fi)
  DYNAMIC := $(shell if [ ! -d "$(topdir)/.git" ]; then echo yes; fi)
 diff --git a/libcap/Makefile b/libcap/Makefile
-index 4762c60..cf99523 100644
+index 0ccd2e7..6b446ea 100644
 --- a/libcap/Makefile
 +++ b/libcap/Makefile
 @@ -16,7 +16,7 @@ FILES=cap_alloc cap_proc cap_extint cap_flag cap_text
@@ -75,19 +76,19 @@
  FILES += cap_file
 -LDFLAGS += -lattr
 +LDLIBS += -lattr
+ DEPS = -lattr
  endif
  
- INCLS=libcap.h cap_names.h $(INCS)
-@@ -24,6 +24,7 @@ OBJS=$(addsuffix .o, $(FILES))
+@@ -25,6 +25,7 @@ OBJS=$(addsuffix .o, $(FILES))
  MAJLIBNAME=$(LIBNAME).$(VERSION)
  MINLIBNAME=$(MAJLIBNAME).$(MINOR)
  GPERF_OUTPUT = _caps_output.gperf
 +CFLAGS += -fPIC
  
- all: $(MINLIBNAME) $(STALIBNAME)
+ all: $(MINLIBNAME) $(STALIBNAME) libcap.pc
  
-@@ -33,7 +34,7 @@ INCLUDE_GPERF_OUTPUT = -include $(GPERF_OUTPUT)
- endif
+@@ -43,7 +44,7 @@ libcap.pc: libcap.pc.in
+ 		$< >$@
  
  _makenames: _makenames.c cap_names.list.h
 -	$(BUILD_CC) $(BUILD_CFLAGS) $< -o $@
@@ -95,7 +96,7 @@
  
  cap_names.h: _makenames
  	./_makenames > cap_names.h
-@@ -50,15 +51,15 @@ $(STALIBNAME): $(OBJS)
+@@ -60,15 +61,15 @@ $(STALIBNAME): $(OBJS)
  	$(RANLIB) $@
  
  $(MINLIBNAME): $(OBJS)
@@ -113,18 +114,9 @@
 +	$(CC) $(CFLAGS) $(CPPFLAGS) $(INCLUDE_GPERF_OUTPUT) -c $< -o $@
  
  install: all
- 	mkdir -p -m 0755 $(INCDIR)/sys
-@@ -77,7 +77,7 @@ install: all
- 	install -m 0644 include/sys/capability.h $(INCDIR)/sys
- 	mkdir -p -m 0755 $(LIBDIR)
- 	install -m 0644 $(STALIBNAME) $(LIBDIR)/$(STALIBNAME)
--	install -m 0644 $(MINLIBNAME) $(LIBDIR)/$(MINLIBNAME)
-+	install -m 0755 $(MINLIBNAME) $(LIBDIR)/$(MINLIBNAME)
- 	ln -sf $(MINLIBNAME) $(LIBDIR)/$(MAJLIBNAME)
- 	ln -sf $(MAJLIBNAME) $(LIBDIR)/$(LIBNAME)
- ifeq ($(FAKEROOT),)
+ 	mkdir -p -m 0755 $(FAKEROOT)$(INCDIR)/sys
 diff --git a/pam_cap/Makefile b/pam_cap/Makefile
-index 9ca5bef..bdae933 100644
+index cc32fb6..6f07b6b 100644
 --- a/pam_cap/Makefile
 +++ b/pam_cap/Makefile
 @@ -9,6 +9,8 @@ include ../Make.Rules
@@ -137,7 +129,7 @@
  	$(MAKE) testcompile
  
 @@ -17,13 +19,13 @@ install: all
- 	install -m 0755 pam_cap.so $(LIBDIR)/security
+ 	install -m 0755 pam_cap.so $(FAKEROOT)$(LIBDIR)/security
  
  pam_cap.so: pam_cap.o
 -	$(LD) $(LDFLAGS) -o pam_cap.so $< $(LDLIBS)
@@ -154,7 +146,7 @@
  clean:
  	rm -f *.o *.so testcompile *~
 diff --git a/progs/Makefile b/progs/Makefile
-index ef51dc6..c261f57 100644
+index 778149e..8f4e2e6 100644
 --- a/progs/Makefile
 +++ b/progs/Makefile
 @@ -22,7 +22,7 @@ $(BUILD): %: %.o
@@ -165,7 +157,7 @@
 +	$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
  
  install: all
- 	mkdir -p -m 0755 $(SBINDIR)
+ 	mkdir -p -m 0755 $(FAKEROOT)$(SBINDIR)
 -- 
-1.7.4.rc2
+2.4.1
 
diff --git a/sys-libs/libcap/files/libcap-2.24-setcap-errno.patch b/sys-libs/libcap/files/libcap-2.24-setcap-errno.patch
new file mode 100644
index 0000000..08513f6
--- /dev/null
+++ b/sys-libs/libcap/files/libcap-2.24-setcap-errno.patch
@@ -0,0 +1,45 @@
+From 62b190c09d5652c58679dffd7f09e4aceb4c7daa Mon Sep 17 00:00:00 2001
+From: Mike Frysinger <vapier@gentoo.org>
+Date: Mon, 13 Jul 2015 01:59:14 -0400
+Subject: [PATCH] setcap: fix errno display
+
+The commit 056ffb0bd25d91ffbcb83c521fc4d3d9904ec4d4 broke the display of
+the final error message because it would do more operations that would
+clobber errno.  Example:
+(libcap-2.22) sudo setcap cap_ipc_lock=ep /proc/filesystems | head -1
+Failed to set capabilities on file `/proc/filesystems' (Operation not supported)
+(libcap-2.23) sudo setcap cap_ipc_lock=ep /proc/filesystems | head -1
+Failed to set capabilities on file `/proc/filesystems' (Invalid argument)
+
+Save the original errno value and use that for the final display instead.
+
+URL: https://bugs.gentoo.org/551672
+Signed-off-by: Mike Frysinger <vapier@gentoo.org>
+---
+ progs/setcap.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/progs/setcap.c b/progs/setcap.c
+index 83090ae..7304343 100644
+--- a/progs/setcap.c
++++ b/progs/setcap.c
+@@ -171,6 +171,7 @@ int main(int argc, char **argv)
+ 	    retval = cap_set_file(*++argv, cap_d);
+ 	    if (retval != 0) {
+ 		int explained = 0;
++		int oerrno = errno;
+ #ifdef linux
+ 		cap_value_t cap;
+ 		cap_flag_value_t per_state;
+@@ -193,7 +194,7 @@ int main(int argc, char **argv)
+ 		
+ 		fprintf(stderr,
+ 			"Failed to set capabilities on file `%s' (%s)\n",
+-			argv[0], strerror(errno));
++			argv[0], strerror(oerrno));
+ 		if (!explained) {
+ 		    usage();
+ 		}
+-- 
+2.4.4
+
diff --git a/sys-libs/libcap/files/libcap-2.22-build-system-fixes.patch b/sys-libs/libcap/files/libcap-2.25-build-system-fixes.patch
similarity index 61%
copy from sys-libs/libcap/files/libcap-2.22-build-system-fixes.patch
copy to sys-libs/libcap/files/libcap-2.25-build-system-fixes.patch
index 888c089..c33fffd 100644
--- a/sys-libs/libcap/files/libcap-2.22-build-system-fixes.patch
+++ b/sys-libs/libcap/files/libcap-2.25-build-system-fixes.patch
@@ -1,35 +1,39 @@
-From 5540f3c2a3bd70ebc8140b74ac5a0aecdbc53234 Mon Sep 17 00:00:00 2001
+From d5a0c023a7f3deefd471d7b97ef4fa40ed374645 Mon Sep 17 00:00:00 2001
 From: Mike Frysinger <vapier@gentoo.org>
-Date: Sun, 16 Nov 2008 09:10:31 -0500
+Date: Wed, 10 Feb 2016 09:47:27 +0100
 Subject: [PATCH] build system fixes
 
 This touches up the homebrewed build system to work much better "out of the
 box" for people.  Specifically:
 	- allow toolchain vars to be set via environment
-		- CC / BUILD_CC / AR / RANLIB
-		- CFLAGS / CPPFLAGS / LDFLAGS
+	- CC / BUILD_CC / AR / RANLIB
+	- CFLAGS / CPPFLAGS / LDFLAGS
 	- split CPPFLAGS out of CFLAGS
 	- break -fPIC out of global CFLAGS and only use where needed
 	- use LDLIBS for libraries, not LDFLAGS
 
 Signed-off-by: Mike Frysinger <vapier@gentoo.org>
+
+Forward ported from libcap-2.24 to libcap-2.25
+
+Signed-off-by: Lars Wendler <polynomial-c@gentoo.org>
 ---
- Make.Rules       |   25 +++++++++++++------------
- libcap/Makefile  |   11 ++++++-----
- pam_cap/Makefile |    8 +++++---
- progs/Makefile   |    2 +-
- 4 files changed, 25 insertions(+), 21 deletions(-)
+ Make.Rules       | 26 ++++++++++++++------------
+ libcap/Makefile  |  7 ++++---
+ pam_cap/Makefile |  8 +++++---
+ progs/Makefile   |  2 +-
+ 4 files changed, 24 insertions(+), 19 deletions(-)
 
 diff --git a/Make.Rules b/Make.Rules
-index 011aa14..6e432a6 100644
+index 8347b26..d7196ef 100644
 --- a/Make.Rules
 +++ b/Make.Rules
-@@ -44,27 +44,28 @@ MINOR=19
+@@ -45,28 +45,30 @@ MINOR=25
  
  # Compilation specifics
  
--KERNEL_HEADERS := $(topdir)/libcap/include
--IPATH += -fPIC -I$(topdir)/libcap/include -I$(KERNEL_HEADERS)
+-KERNEL_HEADERS := $(topdir)/libcap/include/uapi
+-IPATH += -fPIC -I$(KERNEL_HEADERS) -I$(topdir)/libcap/include
 -
 -CC := gcc
 -CFLAGS := -O2 -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
@@ -51,11 +55,13 @@
  LD=$(CC) -Wl,-x -shared
 -LDFLAGS := #-g
 +LDFLAGS ?= #-g
+ BUILD_GPERF := $(shell which gperf >/dev/null 2>/dev/null && echo yes)
  
 -SYSTEM_HEADERS = /usr/include
-+KERNEL_HEADERS = $(topdir)/libcap/include
-+LIBCAP_CPPFLAGS = -I$(topdir)/libcap/include -I$(KERNEL_HEADERS)
-+CPPFLAGS += $(LIBCAP_CPPFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
++KERNEL_HEADERS = $(topdir)/libcap/include/uapi
++LIBCAP_CPPFLAGS = -I$(KERNEL_HEADERS) -I$(topdir)/libcap/include
++LIBCAP_CPPFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
++CPPFLAGS += $(LIBCAP_CPPFLAGS)
 +BUILD_CPPFLAGS += $(LIBCAP_CPPFLAGS)
  INCS=$(topdir)/libcap/include/sys/capability.h
  LDFLAGS += -L$(topdir)/libcap
@@ -63,31 +69,22 @@
 +CPPFLAGS += -Dlinux
 +CFLAGS += $(WARNINGS) $(DEBUG)
  PAM_CAP := $(shell if [ -f /usr/include/security/pam_modules.h ]; then echo yes ; else echo no ; fi)
- INDENT := $(shell if [ -n "$(which indent 2>/dev/null)" ]; then echo "| indent -kr" ; fi)
+ INDENT := $(shell if [ -n "$$(which indent 2>/dev/null)" ]; then echo "| indent -kr" ; fi)
  DYNAMIC := $(shell if [ ! -d "$(topdir)/.git" ]; then echo yes; fi)
 diff --git a/libcap/Makefile b/libcap/Makefile
-index 4762c60..cf99523 100644
+index d189777..b99740f 100644
 --- a/libcap/Makefile
 +++ b/libcap/Makefile
-@@ -16,7 +16,7 @@ FILES=cap_alloc cap_proc cap_extint cap_flag cap_text
- # no support).
- ifeq ($(LIBATTR),yes)
- FILES += cap_file
--LDFLAGS += -lattr
-+LDLIBS += -lattr
- endif
- 
- INCLS=libcap.h cap_names.h $(INCS)
-@@ -24,6 +24,7 @@ OBJS=$(addsuffix .o, $(FILES))
+@@ -17,6 +17,7 @@ OBJS=$(addsuffix .o, $(FILES))
  MAJLIBNAME=$(LIBNAME).$(VERSION)
  MINLIBNAME=$(MAJLIBNAME).$(MINOR)
  GPERF_OUTPUT = _caps_output.gperf
 +CFLAGS += -fPIC
  
- all: $(MINLIBNAME) $(STALIBNAME)
+ all: $(MINLIBNAME) $(STALIBNAME) libcap.pc
  
-@@ -33,7 +34,7 @@ INCLUDE_GPERF_OUTPUT = -include $(GPERF_OUTPUT)
- endif
+@@ -35,7 +36,7 @@ libcap.pc: libcap.pc.in
+ 		$< >$@
  
  _makenames: _makenames.c cap_names.list.h
 -	$(BUILD_CC) $(BUILD_CFLAGS) $< -o $@
@@ -95,13 +92,7 @@
  
  cap_names.h: _makenames
  	./_makenames > cap_names.h
-@@ -50,15 +51,15 @@ $(STALIBNAME): $(OBJS)
- 	$(RANLIB) $@
- 
- $(MINLIBNAME): $(OBJS)
--	$(LD) $(CFLAGS) $(LDFLAGS) -Wl,-soname,$(MAJLIBNAME) -o $@ $^
-+	$(LD) $(CFLAGS) $(LDFLAGS) -Wl,-soname,$(MAJLIBNAME) -o $@ $^ $(LDLIBS)
- 	ln -sf $(MINLIBNAME) $(MAJLIBNAME)
+@@ -57,10 +58,10 @@ $(MINLIBNAME): $(OBJS)
  	ln -sf $(MAJLIBNAME) $(LIBNAME)
  
  %.o: %.c $(INCLS)
@@ -113,18 +104,9 @@
 +	$(CC) $(CFLAGS) $(CPPFLAGS) $(INCLUDE_GPERF_OUTPUT) -c $< -o $@
  
  install: all
- 	mkdir -p -m 0755 $(INCDIR)/sys
-@@ -77,7 +77,7 @@ install: all
- 	install -m 0644 include/sys/capability.h $(INCDIR)/sys
- 	mkdir -p -m 0755 $(LIBDIR)
- 	install -m 0644 $(STALIBNAME) $(LIBDIR)/$(STALIBNAME)
--	install -m 0644 $(MINLIBNAME) $(LIBDIR)/$(MINLIBNAME)
-+	install -m 0755 $(MINLIBNAME) $(LIBDIR)/$(MINLIBNAME)
- 	ln -sf $(MINLIBNAME) $(LIBDIR)/$(MAJLIBNAME)
- 	ln -sf $(MAJLIBNAME) $(LIBDIR)/$(LIBNAME)
- ifeq ($(FAKEROOT),)
+ 	mkdir -p -m 0755 $(FAKEROOT)$(INCDIR)/sys
 diff --git a/pam_cap/Makefile b/pam_cap/Makefile
-index 9ca5bef..bdae933 100644
+index cc32fb6..6f07b6b 100644
 --- a/pam_cap/Makefile
 +++ b/pam_cap/Makefile
 @@ -9,6 +9,8 @@ include ../Make.Rules
@@ -137,7 +119,7 @@
  	$(MAKE) testcompile
  
 @@ -17,13 +19,13 @@ install: all
- 	install -m 0755 pam_cap.so $(LIBDIR)/security
+ 	install -m 0755 pam_cap.so $(FAKEROOT)$(LIBDIR)/security
  
  pam_cap.so: pam_cap.o
 -	$(LD) $(LDFLAGS) -o pam_cap.so $< $(LDLIBS)
@@ -154,10 +136,10 @@
  clean:
  	rm -f *.o *.so testcompile *~
 diff --git a/progs/Makefile b/progs/Makefile
-index ef51dc6..c261f57 100644
+index c094a24..b9f0d3f 100644
 --- a/progs/Makefile
 +++ b/progs/Makefile
-@@ -22,7 +22,7 @@ $(BUILD): %: %.o
+@@ -19,7 +19,7 @@ $(BUILD): %: %.o
  	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LDLIBS)
  
  %.o: %.c $(INCS)
@@ -165,7 +147,7 @@
 +	$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
  
  install: all
- 	mkdir -p -m 0755 $(SBINDIR)
+ 	mkdir -p -m 0755 $(FAKEROOT)$(SBINDIR)
 -- 
-1.7.4.rc2
+2.7.1
 
diff --git a/sys-libs/libcap/files/libcap-2.25-ignore-RAISE_SETFCAP-install-failures.patch b/sys-libs/libcap/files/libcap-2.25-ignore-RAISE_SETFCAP-install-failures.patch
new file mode 100644
index 0000000..0f73736
--- /dev/null
+++ b/sys-libs/libcap/files/libcap-2.25-ignore-RAISE_SETFCAP-install-failures.patch
@@ -0,0 +1,33 @@
+From 8dfcdcfdcb9c462a05566aa8d3c6eca871f0ddbf Mon Sep 17 00:00:00 2001
+From: Mike Frysinger <vapier@gentoo.org>
+Date: Wed, 10 Feb 2016 09:52:45 +0100
+Subject: [PATCH] ignore RAISE_SETFCAP install failures
+
+While the new RAISE_SETFCAP feature is nifty, its failure to run (often
+due to the fs not supporting it) shouldn't impair the default install.
+
+Signed-off-by: Mike Frysinger <vapier@gentoo.org>
+
+Forward ported from libcap-2.20 to libcap-2.25
+
+Signed-off-by: Lars Wendler <polynomial-c@gentoo.org>
+---
+ progs/Makefile | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/progs/Makefile b/progs/Makefile
+index c094a24..4a6db38 100644
+--- a/progs/Makefile
++++ b/progs/Makefile
+@@ -27,7 +27,7 @@ install: all
+ 		install -m 0755 $$p $(FAKEROOT)$(SBINDIR) ; \
+ 	done
+ ifeq ($(RAISE_SETFCAP),yes)
+-	$(FAKEROOT)$(SBINDIR)/setcap cap_setfcap=i $(FAKEROOT)$(SBINDIR)/setcap
++	-$(FAKEROOT)$(SBINDIR)/setcap cap_setfcap=i $(FAKEROOT)$(SBINDIR)/setcap
+ endif
+ 
+ clean:
+-- 
+2.7.1
+
diff --git a/sys-libs/libcap/libcap-2.22-r2.ebuild b/sys-libs/libcap/libcap-2.24-r2.ebuild
similarity index 74%
rename from sys-libs/libcap/libcap-2.22-r2.ebuild
rename to sys-libs/libcap/libcap-2.24-r2.ebuild
index a74ba36..47364c4 100644
--- a/sys-libs/libcap/libcap-2.22-r2.ebuild
+++ b/sys-libs/libcap/libcap-2.24-r2.ebuild
@@ -1,6 +1,6 @@
-# Copyright 1999-2014 Gentoo Foundation
+# Copyright 1999-2016 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/sys-libs/libcap/libcap-2.22-r2.ebuild,v 1.15 2014/09/15 08:24:08 ago Exp $
+# $Id$
 
 EAPI="4"
 
@@ -8,13 +8,13 @@
 
 DESCRIPTION="POSIX 1003.1e capabilities"
 HOMEPAGE="http://www.friedhoff.org/posixfilecaps.html"
-SRC_URI="mirror://gentoo/${P}.tar.bz2"
+SRC_URI="mirror://kernel/linux/libs/security/linux-privs/libcap2/${P}.tar.xz"
 
 # it's available under either of the licenses
 LICENSE="|| ( GPL-2 BSD )"
 SLOT="0"
 KEYWORDS="*"
-IUSE="pam"
+IUSE="pam static-libs"
 
 RDEPEND=">=sys-apps/attr-2.4.47-r1[${MULTILIB_USEDEP}]
 	pam? ( virtual/pam )"
@@ -22,15 +22,17 @@
 	sys-kernel/linux-headers"
 
 src_prepare() {
-	epatch "${FILESDIR}"/${PN}-2.22-build-system-fixes.patch
+	epatch "${FILESDIR}"/${PN}-2.24-build-system-fixes.patch
 	epatch "${FILESDIR}"/${PN}-2.22-no-perl.patch
 	epatch "${FILESDIR}"/${PN}-2.20-ignore-RAISE_SETFCAP-install-failures.patch
 	epatch "${FILESDIR}"/${PN}-2.21-include.patch
+	epatch "${FILESDIR}"/${PN}-2.24-setcap-errno.patch #551672
 
 	multilib_copy_sources
 }
 
 multilib_src_configure() {
+	local pam
 	if multilib_is_native_abi && use pam; then
 		pam=yes
 	else
@@ -40,7 +42,8 @@
 	sed -i \
 		-e "/^PAM_CAP/s:=.*:=${pam}:" \
 		-e '/^DYNAMIC/s:=.*:=yes:' \
-		-e "/^lib=/s:=.*:=/usr/$(get_libdir):" \
+		-e '/^lib_prefix=/s:=.*:=$(prefix):' \
+		-e "/^lib=/s:=.*:=$(get_libdir):" \
 		Make.Rules
 }
 
@@ -55,7 +58,8 @@
 	# no configure, needs explicit install line #444724#c3
 	emake install DESTDIR="${ED}"
 
-	multilib_is_native_abi && gen_usr_ldscript -a cap
+	gen_usr_ldscript -a cap
+	use static-libs || rm "${ED}"/usr/$(get_libdir)/libcap.a
 
 	rm -rf "${ED}"/usr/$(get_libdir)/security
 	if multilib_is_native_abi && use pam; then
diff --git a/sys-libs/libcap/metadata.xml b/sys-libs/libcap/metadata.xml
index 96a2d58..56c1244 100644
--- a/sys-libs/libcap/metadata.xml
+++ b/sys-libs/libcap/metadata.xml
@@ -1,5 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
 <pkgmetadata>
-<herd>base-system</herd>
+<maintainer type="project">
+	<email>base-system@gentoo.org</email>
+	<name>Gentoo Base System</name>
+</maintainer>
 </pkgmetadata>