nixpkgs/pkgs/os-specific/linux/libcap/default.nix

70 lines
1.9 KiB
Nix
Raw Normal View History

{ stdenv, lib, buildPackages, fetchurl, attr, perl
, usePam ? !isStatic, pam ? null
, isStatic ? stdenv.hostPlatform.isStatic
}:
assert usePam -> pam != null;
stdenv.mkDerivation rec {
pname = "libcap";
version = "2.44";
2013-08-23 08:55:51 +01:00
src = fetchurl {
url = "mirror://kernel/linux/libs/security/linux-privs/libcap2/${pname}-${version}.tar.xz";
sha256 = "1qf80lifygbnxwvqjf8jz5j24n6fqqx4ixnkbf76xs2vrmcq664j";
};
2013-08-23 08:55:51 +01:00
patches = lib.optional isStatic ./no-shared-lib.patch;
outputs = [ "out" "dev" "lib" "man" "doc" ]
++ lib.optional usePam "pam";
2013-08-23 08:55:51 +01:00
depsBuildBuild = [ buildPackages.stdenv.cc ];
nativeBuildInputs = [ perl ];
buildInputs = lib.optional usePam pam;
propagatedBuildInputs = [ attr ];
makeFlags = [
"lib=lib"
"PAM_CAP=${if usePam then "yes" else "no"}"
"BUILD_CC=$(CC_FOR_BUILD)"
"CC:=$(CC)"
];
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
# 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"
'';
2019-11-05 01:10:31 +00:00
installFlags = [ "RAISE_SETFCAP=no" ];
2014-08-27 00:14:09 +01:00
postInstall = ''
${lib.optionalString (!isStatic) ''rm "$lib"/lib/*.a''}
mkdir -p "$doc/share/doc/${pname}-${version}"
cp License "$doc/share/doc/${pname}-${version}/"
'' + stdenv.lib.optionalString usePam ''
mkdir -p "$pam/lib/security"
mv "$lib"/lib/security "$pam/lib"
2014-08-27 00:14:09 +01:00
'';
meta = {
description = "Library for working with POSIX capabilities";
homepage = "https://sites.google.com/site/fullycapable";
platforms = stdenv.lib.platforms.linux;
2018-08-08 20:18:16 +01:00
license = stdenv.lib.licenses.bsd3;
};
}