2016-04-19 22:12:45 +01:00
|
|
|
{ stdenv, fetchurl, attr, perl, pam ? null }:
|
|
|
|
assert pam != null -> stdenv.isLinux;
|
2006-12-22 19:22:57 +00:00
|
|
|
|
2010-09-27 14:49:13 +01:00
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
name = "libcap-${version}";
|
2016-04-19 22:12:09 +01:00
|
|
|
version = "2.25";
|
2013-08-23 08:55:51 +01:00
|
|
|
|
2006-12-22 19:22:57 +00:00
|
|
|
src = fetchurl {
|
2015-03-26 07:53:45 +00:00
|
|
|
url = "mirror://kernel/linux/libs/security/linux-privs/libcap2/${name}.tar.xz";
|
2016-04-19 22:12:09 +01:00
|
|
|
sha256 = "0qjiqc5pknaal57453nxcbz3mn1r4hkyywam41wfcglq3v2qlg39";
|
2006-12-22 19:22:57 +00:00
|
|
|
};
|
2013-08-23 08:55:51 +01:00
|
|
|
|
2017-07-11 10:14:14 +01:00
|
|
|
outputs = [ "out" "dev" "lib" "man" "doc" ]
|
2016-04-19 22:12:45 +01:00
|
|
|
++ stdenv.lib.optional (pam != null) "pam";
|
2013-08-23 08:55:51 +01:00
|
|
|
|
2012-12-28 18:20:09 +00:00
|
|
|
nativeBuildInputs = [ perl ];
|
2016-04-19 22:12:45 +01:00
|
|
|
|
|
|
|
buildInputs = [ pam ];
|
|
|
|
|
2012-07-19 15:25:56 +01:00
|
|
|
propagatedBuildInputs = [ attr ];
|
2006-12-22 19:22:57 +00:00
|
|
|
|
2016-04-19 22:12:45 +01:00
|
|
|
makeFlags = [
|
|
|
|
"lib=lib"
|
|
|
|
(stdenv.lib.optional (pam != null) "PAM_CAP=yes")
|
|
|
|
];
|
|
|
|
|
|
|
|
prePatch = ''
|
|
|
|
# use relative bash path
|
|
|
|
substituteInPlace progs/capsh.c --replace "/bin/bash" "bash"
|
|
|
|
|
|
|
|
# ensure capsh can find bash in $PATH
|
|
|
|
substituteInPlace progs/capsh.c --replace execve execvpe
|
|
|
|
'';
|
|
|
|
|
|
|
|
preInstall = ''
|
|
|
|
substituteInPlace Make.Rules \
|
|
|
|
--replace 'prefix=/usr' "prefix=$lib" \
|
|
|
|
--replace 'exec_prefix=' "exec_prefix=$out" \
|
|
|
|
--replace 'lib_prefix=$(exec_prefix)' "lib_prefix=$lib" \
|
|
|
|
--replace 'inc_prefix=$(prefix)' "inc_prefix=$dev" \
|
|
|
|
--replace 'man_prefix=$(prefix)' "man_prefix=$doc"
|
|
|
|
'';
|
2010-09-27 14:49:13 +01:00
|
|
|
|
2016-04-19 22:12:45 +01:00
|
|
|
installFlags = "RAISE_SETFCAP=no";
|
2010-09-27 14:49:13 +01:00
|
|
|
|
2014-08-27 00:14:09 +01:00
|
|
|
postInstall = ''
|
2016-04-19 22:12:45 +01:00
|
|
|
rm "$lib"/lib/*.a
|
|
|
|
mkdir -p "$doc/share/doc/${name}"
|
|
|
|
cp License "$doc/share/doc/${name}/"
|
|
|
|
'' + stdenv.lib.optionalString (pam != null) ''
|
|
|
|
mkdir -p "$pam/lib/security"
|
|
|
|
mv "$lib"/lib/security "$pam/lib"
|
2014-08-27 00:14:09 +01:00
|
|
|
'';
|
2012-07-19 15:25:56 +01:00
|
|
|
|
|
|
|
meta = {
|
|
|
|
description = "Library for working with POSIX capabilities";
|
|
|
|
platforms = stdenv.lib.platforms.linux;
|
|
|
|
};
|
2006-12-22 19:22:57 +00:00
|
|
|
}
|