2021-01-05 17:05:55 +00:00
|
|
|
{ stdenv, lib, buildPackages, fetchurl, attr, perl
|
|
|
|
, usePam ? !isStatic, pam ? null
|
|
|
|
, isStatic ? stdenv.hostPlatform.isStatic
|
|
|
|
}:
|
|
|
|
|
|
|
|
assert usePam -> pam != null;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "libcap";
|
2021-04-05 15:23:46 +00:00
|
|
|
version = "2.48";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchurl {
|
|
|
|
url = "mirror://kernel/linux/libs/security/linux-privs/libcap2/${pname}-${version}.tar.xz";
|
2021-04-05 15:23:46 +00:00
|
|
|
sha256 = "sha256-TelZDuCah8KC1Vhzf/tbYXXMv9JtWArdEN9E0PBH9sI=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2021-01-05 17:05:55 +00:00
|
|
|
patches = lib.optional isStatic ./no-shared-lib.patch;
|
2020-12-25 13:55:36 +00:00
|
|
|
|
|
|
|
outputs = [ "out" "dev" "lib" "man" "doc" ]
|
2021-01-05 17:05:55 +00:00
|
|
|
++ lib.optional usePam "pam";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
depsBuildBuild = [ buildPackages.stdenv.cc ];
|
|
|
|
nativeBuildInputs = [ perl ];
|
|
|
|
|
2021-01-05 17:05:55 +00:00
|
|
|
buildInputs = lib.optional usePam pam;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
propagatedBuildInputs = [ attr ];
|
|
|
|
|
|
|
|
makeFlags = [
|
|
|
|
"lib=lib"
|
2021-01-05 17:05:55 +00:00
|
|
|
"PAM_CAP=${if usePam then "yes" else "no"}"
|
2020-04-24 23:36:52 +00:00
|
|
|
"BUILD_CC=$(CC_FOR_BUILD)"
|
|
|
|
"CC:=$(CC)"
|
|
|
|
];
|
|
|
|
|
|
|
|
prePatch = ''
|
2021-02-05 17:12:51 +00:00
|
|
|
# use full path to bash
|
|
|
|
substituteInPlace progs/capsh.c --replace "/bin/bash" "${stdenv.shell}"
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
# set prefixes
|
|
|
|
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"
|
|
|
|
'';
|
|
|
|
|
|
|
|
installFlags = [ "RAISE_SETFCAP=no" ];
|
|
|
|
|
|
|
|
postInstall = ''
|
2021-01-05 17:05:55 +00:00
|
|
|
${lib.optionalString (!isStatic) ''rm "$lib"/lib/*.a''}
|
2020-04-24 23:36:52 +00:00
|
|
|
mkdir -p "$doc/share/doc/${pname}-${version}"
|
|
|
|
cp License "$doc/share/doc/${pname}-${version}/"
|
2021-02-05 17:12:51 +00:00
|
|
|
'' + lib.optionalString usePam ''
|
2020-04-24 23:36:52 +00:00
|
|
|
mkdir -p "$pam/lib/security"
|
|
|
|
mv "$lib"/lib/security "$pam/lib"
|
|
|
|
'';
|
|
|
|
|
|
|
|
meta = {
|
|
|
|
description = "Library for working with POSIX capabilities";
|
2020-11-06 00:33:48 +00:00
|
|
|
homepage = "https://sites.google.com/site/fullycapable";
|
2021-02-05 17:12:51 +00:00
|
|
|
platforms = lib.platforms.linux;
|
|
|
|
license = lib.licenses.bsd3;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|