lol
1{ stdenv
2, fetchFromGitHub
3, coreutils
4}:
5
6let
7 yara = fetchFromGitHub {
8 owner = "avast-tl";
9 repo = "yara";
10 rev = "ea101c5856941f39cad2db3012f2660d1d5c8b65";
11 sha256 = "033ssx2hql5k4pv9si043s3mjq2b748ymjzif8pg6rdwh260faky";
12 };
13in stdenv.mkDerivation rec {
14 # only fetches the yaracpp source patched to work with a local yara clone,
15 # does not build anything
16 pname = "yaracpp-src";
17 version = "2018-10-09";
18 rev = "b92bde0e59e3b75bc445227e04b71105771dee8b"; # as specified in retdec/deps/yaracpp/CMakeLists.txt
19
20 src = fetchFromGitHub {
21 inherit rev;
22 owner = "avast-tl";
23 repo = "yaracpp";
24 sha256 = "0fan7q79j7s3bjmhsd2nw6sqyi14xgikn7mr2p4nj87lick5l4a2";
25 };
26
27 postPatch = ''
28 # check if our version of yara is the same version that upstream expects
29 echo "Checking version of yara"
30 expected_rev="$( sed -n -e 's|.*URL https://github.com/.*/archive/\(.*\)\.zip.*|\1|p' "deps/CMakeLists.txt" )"
31 if [ "$expected_rev" != '${yara.rev}' ]; then
32 echo "The yara dependency has the wrong version: ${yara.rev} while $expected_rev is expected."
33 exit 1
34 fi
35
36 # patch the CMakeLists.txt file to use our local copy of the dependency instead of fetching it at build time
37 sed -i -e "s|URL .*|URL ${yara}|" "deps/CMakeLists.txt"
38
39 # abuse the CONFIGURE_COMMAND to make the source writeable after copying it to the build locatoin (necessary for the build)
40 sed -i -e 's|CONFIGURE_COMMAND ""|CONFIGURE_COMMAND COMMAND ${coreutils}/bin/chmod -R u+w .|' "deps/CMakeLists.txt"
41 '';
42
43 buildPhase = "# do nothing";
44 configurePhase = "# do nothing";
45 installPhase = ''
46 mkdir -p "$out"
47 cp -r * "$out"
48 '';
49}