1{
2 lib,
3 buildPythonApplication,
4 pkgsBuildTarget,
5 python,
6 minijail,
7}:
8
9let
10 targetClang = pkgsBuildTarget.targetPackages.clangStdenv.cc;
11in
12
13buildPythonApplication {
14 format = "setuptools";
15 pname = "minijail-tools";
16 inherit (minijail) version src;
17
18 postPatch = ''
19 substituteInPlace Makefile --replace /bin/echo echo
20 '';
21
22 postConfigure = ''
23 substituteInPlace tools/compile_seccomp_policy.py \
24 --replace "'constants.json'" "'$out/share/constants.json'"
25 '';
26
27 preBuild = ''
28 make libconstants.gen.c libsyscalls.gen.c
29 ${targetClang}/bin/${targetClang.targetPrefix}cc -S -emit-llvm \
30 libconstants.gen.c libsyscalls.gen.c
31 ${python.pythonOnBuildForHost.interpreter} tools/generate_constants_json.py \
32 --output constants.json \
33 libconstants.gen.ll libsyscalls.gen.ll
34 '';
35
36 postInstall = ''
37 mkdir -p $out/share
38 cp -v constants.json $out/share/constants.json
39 '';
40
41 meta = with lib; {
42 homepage = "https://android.googlesource.com/platform/external/minijail/+/refs/heads/master/tools/";
43 description = "Set of tools for minijail";
44 license = licenses.asl20;
45 inherit (minijail.meta) maintainers platforms;
46 };
47}