about summary refs log tree commit diff
path: root/pkgs/development/python-modules/binwalk/default.nix
blob: 25365c67fbde303df5c3f68626f96056d718e78d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
{
  lib,
  buildPythonPackage,
  fetchFromGitHub,
  stdenv,
  zlib,
  xz,
  gzip,
  bzip2,
  gnutar,
  p7zip,
  cabextract,
  cramfsprogs,
  cramfsswap,
  sasquatch,
  setuptools,
  squashfsTools,
  matplotlib,
  pycrypto,
  pyqtgraph,
  pyqt5,
  pytestCheckHook,
  visualizationSupport ? false,
}:

buildPythonPackage rec {
  pname = "binwalk${lib.optionalString visualizationSupport "-full"}";
  version = "2.4.2";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "OSPG";
    repo = "binwalk";
    rev = "refs/tags/v${version}";
    hash = "sha256-IFq/XotW3bbf3obWXRK6Nw1KQDqyFHb4tcA09Twg8SQ=";
  };

  build-system = [ setuptools ];

  propagatedBuildInputs =
    [
      zlib
      xz
      gzip
      bzip2
      gnutar
      p7zip
      cabextract
      squashfsTools
      xz
      pycrypto
    ]
    ++ lib.optionals visualizationSupport [
      matplotlib
      pyqtgraph
      pyqt5
    ]
    ++ lib.optionals (!stdenv.isDarwin) [
      cramfsprogs
      cramfsswap
      sasquatch
    ];

  # setup.py only installs version.py during install, not test
  postPatch = ''
    echo '__version__ = "${version}"' > src/binwalk/core/version.py
  '';

  # binwalk wants to access ~/.config/binwalk/magic
  preCheck = ''
    HOME=$(mktemp -d)
  '';

  nativeCheckInputs = [ pytestCheckHook ];

  pythonImportsCheck = [ "binwalk" ];

  meta = with lib; {
    homepage = "https://github.com/OSPG/binwalk";
    description = "Tool for searching a given binary image for embedded files";
    mainProgram = "binwalk";
    maintainers = [ maintainers.koral ];
    license = licenses.mit;
  };
}