2020-03-27 08:46:03 +00:00
|
|
|
{ stdenv, lib, fetchFromGitiles, glibc, libcap, qemu }:
|
|
|
|
|
|
|
|
let
|
|
|
|
dumpConstants =
|
|
|
|
if stdenv.buildPlatform == stdenv.hostPlatform then "./dump_constants"
|
|
|
|
else if stdenv.hostPlatform.isAarch32 then "qemu-arm dump_constants"
|
|
|
|
else if stdenv.hostPlatform.isAarch64 then "qemu-aarch64 dump_constants"
|
|
|
|
else if stdenv.hostPlatform.isx86_64 then "qemu-x86_64 dump_constants"
|
|
|
|
else throw "Unsupported host platform";
|
|
|
|
in
|
2017-11-24 18:07:36 +00:00
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
2019-11-02 13:03:09 +00:00
|
|
|
pname = "minijail";
|
2020-08-26 19:08:08 +01:00
|
|
|
version = "16";
|
2017-11-24 18:07:36 +00:00
|
|
|
|
2019-12-02 22:29:40 +00:00
|
|
|
src = fetchFromGitiles {
|
2017-11-24 18:07:36 +00:00
|
|
|
url = "https://android.googlesource.com/platform/external/minijail";
|
2020-03-27 08:43:04 +00:00
|
|
|
rev = "linux-v${version}";
|
2020-08-26 19:08:08 +01:00
|
|
|
sha256 = "0pxazds3w12c30msq6bxs4a9cbds0dkj6n3ca0i1wqvgz864yrgs";
|
2017-11-24 18:07:36 +00:00
|
|
|
};
|
|
|
|
|
2020-03-27 08:46:03 +00:00
|
|
|
nativeBuildInputs =
|
|
|
|
lib.optional (stdenv.buildPlatform != stdenv.hostPlatform) qemu;
|
2017-11-24 18:07:36 +00:00
|
|
|
buildInputs = [ libcap ];
|
|
|
|
|
|
|
|
makeFlags = [ "LIBDIR=$(out)/lib" ];
|
2020-03-27 08:46:03 +00:00
|
|
|
dumpConstantsFlags = lib.optional (stdenv.hostPlatform.libc == "glibc")
|
|
|
|
"LDFLAGS=-L${glibc.static}/lib";
|
2017-11-24 18:07:36 +00:00
|
|
|
|
2019-12-02 16:43:40 +00:00
|
|
|
postPatch = ''
|
2020-03-27 08:46:03 +00:00
|
|
|
substituteInPlace common.mk --replace /bin/echo echo
|
2019-12-02 16:43:40 +00:00
|
|
|
patchShebangs platform2_preinstall.sh
|
|
|
|
'';
|
|
|
|
|
|
|
|
postBuild = ''
|
2020-03-27 08:46:03 +00:00
|
|
|
make $makeFlags $buildFlags $dumpConstantsFlags dump_constants
|
|
|
|
${dumpConstants} > constants.json
|
2019-12-02 16:43:40 +00:00
|
|
|
'';
|
|
|
|
|
2017-11-24 18:07:36 +00:00
|
|
|
installPhase = ''
|
2020-03-27 08:46:03 +00:00
|
|
|
./platform2_preinstall.sh ${version} $out/include/chromeos
|
|
|
|
|
|
|
|
mkdir -p $out/lib/pkgconfig $out/include/chromeos $out/bin \
|
|
|
|
$out/share/minijail
|
|
|
|
|
2017-11-24 18:07:36 +00:00
|
|
|
cp -v *.so $out/lib
|
2019-12-02 16:43:40 +00:00
|
|
|
cp -v *.pc $out/lib/pkgconfig
|
|
|
|
cp -v libminijail.h scoped_minijail.h $out/include/chromeos
|
|
|
|
cp -v minijail0 $out/bin
|
2020-03-27 08:46:03 +00:00
|
|
|
cp -v constants.json $out/share/minijail
|
2017-11-24 18:07:36 +00:00
|
|
|
'';
|
|
|
|
|
2020-03-27 08:46:03 +00:00
|
|
|
meta = with lib; {
|
|
|
|
homepage = "https://android.googlesource.com/platform/external/minijail/";
|
2017-11-24 18:07:36 +00:00
|
|
|
description = "Sandboxing library and application using Linux namespaces and capabilities";
|
2020-03-27 08:46:03 +00:00
|
|
|
license = licenses.bsd3;
|
|
|
|
maintainers = with maintainers; [ pcarrier qyliss ];
|
|
|
|
platforms = platforms.linux;
|
2017-11-24 18:07:36 +00:00
|
|
|
};
|
|
|
|
}
|