2020-12-20 06:11:26 +00:00
|
|
|
{ stdenv, lib, buildPackages, fetchurl, attr, perl
|
|
|
|
, usePam ? !isStatic, pam ? null
|
|
|
|
, isStatic ? stdenv.hostPlatform.isStatic
|
|
|
|
}:
|
|
|
|
|
|
|
|
assert usePam -> pam != null;
|
2006-12-22 19:22:57 +00:00
|
|
|
|
2010-09-27 13:49:13 +00:00
|
|
|
stdenv.mkDerivation rec {
|
2019-08-15 12:41:18 +00:00
|
|
|
pname = "libcap";
|
2021-01-29 07:02:26 +00:00
|
|
|
version = "2.47";
|
2013-08-23 07:55:51 +00:00
|
|
|
|
2006-12-22 19:22:57 +00:00
|
|
|
src = fetchurl {
|
2019-08-15 12:41:18 +00:00
|
|
|
url = "mirror://kernel/linux/libs/security/linux-privs/libcap2/${pname}-${version}.tar.xz";
|
2021-01-29 07:02:26 +00:00
|
|
|
sha256 = "0jx0vjlfg1nzdjdrkrnbdkrqjx4l80vi9isf2qav7s4zbzs5s5mg";
|
2006-12-22 19:22:57 +00:00
|
|
|
};
|
2013-08-23 07:55:51 +00:00
|
|
|
|
2020-12-20 06:11:26 +00:00
|
|
|
patches = lib.optional isStatic ./no-shared-lib.patch;
|
2020-11-10 07:54:52 +00:00
|
|
|
|
|
|
|
outputs = [ "out" "dev" "lib" "man" "doc" ]
|
2020-12-20 06:11:26 +00:00
|
|
|
++ lib.optional usePam "pam";
|
2013-08-23 07:55:51 +00:00
|
|
|
|
2018-02-06 13:30:52 +00:00
|
|
|
depsBuildBuild = [ buildPackages.stdenv.cc ];
|
|
|
|
nativeBuildInputs = [ perl ];
|
2016-04-19 21:12:45 +00:00
|
|
|
|
2020-12-20 06:11:26 +00:00
|
|
|
buildInputs = lib.optional usePam pam;
|
2016-04-19 21:12:45 +00:00
|
|
|
|
2012-07-19 14:25:56 +00:00
|
|
|
propagatedBuildInputs = [ attr ];
|
2006-12-22 19:22:57 +00:00
|
|
|
|
2016-04-19 21:12:45 +00:00
|
|
|
makeFlags = [
|
|
|
|
"lib=lib"
|
2020-12-20 06:11:26 +00:00
|
|
|
"PAM_CAP=${if usePam then "yes" else "no"}"
|
2018-02-06 13:30:52 +00:00
|
|
|
"BUILD_CC=$(CC_FOR_BUILD)"
|
|
|
|
"CC:=$(CC)"
|
2016-04-19 21:12:45 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
prePatch = ''
|
2021-01-12 08:23:32 +00:00
|
|
|
# use full path to bash
|
|
|
|
substituteInPlace progs/capsh.c --replace "/bin/bash" "${stdenv.shell}"
|
2016-04-19 21:12:45 +00:00
|
|
|
|
2017-10-22 11:58:28 +00:00
|
|
|
# set prefixes
|
2016-04-19 21:12:45 +00:00
|
|
|
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 13:49:13 +00:00
|
|
|
|
2019-11-05 01:10:31 +00:00
|
|
|
installFlags = [ "RAISE_SETFCAP=no" ];
|
2010-09-27 13:49:13 +00:00
|
|
|
|
2014-08-26 23:14:09 +00:00
|
|
|
postInstall = ''
|
2020-12-20 06:11:26 +00:00
|
|
|
${lib.optionalString (!isStatic) ''rm "$lib"/lib/*.a''}
|
2019-08-15 12:41:18 +00:00
|
|
|
mkdir -p "$doc/share/doc/${pname}-${version}"
|
|
|
|
cp License "$doc/share/doc/${pname}-${version}/"
|
2021-01-15 14:45:37 +00:00
|
|
|
'' + lib.optionalString usePam ''
|
2016-04-19 21:12:45 +00:00
|
|
|
mkdir -p "$pam/lib/security"
|
|
|
|
mv "$lib"/lib/security "$pam/lib"
|
2014-08-26 23:14:09 +00:00
|
|
|
'';
|
2012-07-19 14:25:56 +00:00
|
|
|
|
|
|
|
meta = {
|
|
|
|
description = "Library for working with POSIX capabilities";
|
2020-10-26 07:17:14 +00:00
|
|
|
homepage = "https://sites.google.com/site/fullycapable";
|
2021-01-15 14:45:37 +00:00
|
|
|
platforms = lib.platforms.linux;
|
|
|
|
license = lib.licenses.bsd3;
|
2012-07-19 14:25:56 +00:00
|
|
|
};
|
2006-12-22 19:22:57 +00:00
|
|
|
}
|