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