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