nixpkgs/pkgs/os-specific/linux/libcap/default.nix
Vladimír Čunát 89023c38fc
Recover the complicated situation after my bad merge
I made a mistake merge.  Reverting it in c778945806 undid the state
on master, but now I realize it crippled the git merge mechanism.
As the merge contained a mix of commits from `master..staging-next`
and other commits from `staging-next..staging`, it got the
`staging-next` branch into a state that was difficult to recover.

I reconstructed the "desired" state of staging-next tree by:
 - checking out the last commit of the problematic range: 4effe769e2
 - `git rebase -i --preserve-merges a8a018ddc0` - dropping the mistaken
   merge commit and its revert from that range (while keeping
   reapplication from 4effe769e2)
 - merging the last unaffected staging-next commit (803ca85c20)
 - fortunately no other commits have been pushed to staging-next yet
 - applying a diff on staging-next to get it into that state
2020-10-26 09:01:04 +01:00

62 lines
1.7 KiB
Nix

{ stdenv, buildPackages, fetchurl, attr, perl, pam }:
stdenv.mkDerivation rec {
pname = "libcap";
version = "2.44";
src = fetchurl {
url = "mirror://kernel/linux/libs/security/linux-privs/libcap2/${pname}-${version}.tar.xz";
sha256 = "1qf80lifygbnxwvqjf8jz5j24n6fqqx4ixnkbf76xs2vrmcq664j";
};
outputs = [ "out" "dev" "lib" "man" "doc" "pam" ];
depsBuildBuild = [ buildPackages.stdenv.cc ];
nativeBuildInputs = [ perl ];
buildInputs = [ pam ];
propagatedBuildInputs = [ attr ];
makeFlags = [
"lib=lib"
"PAM_CAP=yes"
"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"
'';
installFlags = [ "RAISE_SETFCAP=no" ];
postInstall = ''
rm "$lib"/lib/*.a
mkdir -p "$doc/share/doc/${pname}-${version}"
cp License "$doc/share/doc/${pname}-${version}/"
'' + stdenv.lib.optionalString (pam != null) ''
mkdir -p "$pam/lib/security"
mv "$lib"/lib/security "$pam/lib"
'';
meta = {
description = "Library for working with POSIX capabilities";
homepage = "https://sites.google.com/site/fullycapable";
platforms = stdenv.lib.platforms.linux;
license = stdenv.lib.licenses.bsd3;
};
}