at 24.11-pre 1.9 kB view raw
1{ 2 lib, 3 buildPythonPackage, 4 fetchFromGitHub, 5 fetchpatch, 6 stdenv, 7 zlib, 8 xz, 9 gzip, 10 bzip2, 11 gnutar, 12 p7zip, 13 cabextract, 14 cramfsprogs, 15 cramfsswap, 16 sasquatch, 17 squashfsTools, 18 matplotlib, 19 nose, 20 pycrypto, 21 pyqtgraph, 22 visualizationSupport ? false, 23}: 24 25buildPythonPackage rec { 26 pname = "binwalk${lib.optionalString visualizationSupport "-full"}"; 27 version = "2.3.4"; 28 format = "setuptools"; 29 30 src = fetchFromGitHub { 31 owner = "ReFirmLabs"; 32 repo = "binwalk"; 33 rev = "v${version}"; 34 hash = "sha256-hlPbzqGRSXcIqlI+SNKq37CnnHd1IoMBNSjhyeAM1TE="; 35 }; 36 37 patches = [ 38 # test_firmware_zip fails with 2.3.3 upgrade 39 # https://github.com/ReFirmLabs/binwalk/issues/566 40 (fetchpatch { 41 url = "https://github.com/ReFirmLabs/binwalk/commit/dd4f2efd275c9dd1001130e82e0f985110cd2754.patch"; 42 sha256 = "1707n4nf1d1ay1yn4i8qlrvj2c1120g88hjwyklpsc2s2dcnqj9r"; 43 includes = [ "testing/tests/test_firmware_zip.py" ]; 44 revert = true; 45 }) 46 ]; 47 48 propagatedBuildInputs = 49 [ 50 zlib 51 xz 52 gzip 53 bzip2 54 gnutar 55 p7zip 56 cabextract 57 squashfsTools 58 xz 59 pycrypto 60 ] 61 ++ lib.optionals visualizationSupport [ 62 matplotlib 63 pyqtgraph 64 ] 65 ++ lib.optionals (!stdenv.isDarwin) [ 66 cramfsprogs 67 cramfsswap 68 sasquatch 69 ]; 70 71 # setup.py only installs version.py during install, not test 72 postPatch = '' 73 echo '__version__ = "${version}"' > src/binwalk/core/version.py 74 ''; 75 76 # binwalk wants to access ~/.config/binwalk/magic 77 preCheck = '' 78 HOME=$(mktemp -d) 79 ''; 80 81 nativeCheckInputs = [ nose ]; 82 83 pythonImportsCheck = [ "binwalk" ]; 84 85 meta = with lib; { 86 homepage = "https://github.com/ReFirmLabs/binwalk"; 87 description = "A tool for searching a given binary image for embedded files"; 88 mainProgram = "binwalk"; 89 maintainers = [ maintainers.koral ]; 90 license = licenses.mit; 91 }; 92}