2022-04-15 01:41:22 +00:00
|
|
|
{ stdenv, lib, buildPackages, fetchurl, attr, runtimeShell
|
2021-01-05 17:05:55 +00:00
|
|
|
, 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";
|
2023-03-15 16:39:30 +00:00
|
|
|
version = "2.67";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchurl {
|
|
|
|
url = "mirror://kernel/linux/libs/security/linux-privs/libcap2/${pname}-${version}.tar.xz";
|
2023-03-15 16:39:30 +00:00
|
|
|
sha256 = "sha256-zpsi/cJxvrba51Q9pfdM8ky4LmhIz9CIpaBp3sXqUZg=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
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 ];
|
|
|
|
|
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)"
|
2022-04-27 09:35:20 +00:00
|
|
|
"CROSS_COMPILE=${stdenv.cc.targetPrefix}"
|
2021-04-08 16:26:57 +00:00
|
|
|
] ++ lib.optional isStatic "SHARED=no";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-04-15 01:41:22 +00:00
|
|
|
postPatch = ''
|
|
|
|
patchShebangs ./progs/mkcapshdoc.sh
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
# use full path to bash
|
2021-04-26 19:14:03 +00:00
|
|
|
substituteInPlace progs/capsh.c --replace "/bin/bash" "${runtimeShell}"
|
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
|
|
|
};
|
|
|
|
}
|