lol

john: Make package work out of the box.

So far it was only possible to run john if you've either copied over the
default configuration over to ~/.john and substitute $JOHN with the
right path or set $JOHN to the store path directly.

Both methods are not really a very good user experience, so we're now
patching in the resulting paths into the default rules/configurations.

This also splits off configuration files into $out/etc/john instead of
putting everything into $out/share/john and now also properly installs
the auxiliary programs into $out/bin.

Closes #8792.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
Reported-by: devhell <"^"@regexmail.net>
Cc: @offlinehacker

aszlig 902bcf14 cf4e2c42

+26 -8
+26 -8
pkgs/tools/security/john/default.nix
··· 1 - { stdenv, fetchurl, openssl, nss, nspr, kerberos, gmp, zlib, libpcap, re2 }: 1 + { stdenv, fetchurl, openssl, nss, nspr, kerberos, gmp, zlib, libpcap, re2 2 + , writeText 3 + }: 2 4 3 5 with stdenv.lib; 4 6 ··· 11 13 sha256 = "08q92sfdvkz47rx6qjn7qv57cmlpy7i7rgddapq5384mb413vjds"; 12 14 }; 13 15 14 - buildInputs = [ openssl nss nspr kerberos gmp zlib libpcap re2 ]; 15 - 16 - NIX_CFLAGS_COMPILE = "-DJOHN_SYSTEMWIDE=1"; 16 + postPatch = '' 17 + sed -ri -e ' 18 + s!^(#define\s+CFG_[A-Z]+_NAME\s+).*/!\1"'"$out"'/etc/john/! 19 + /^#define\s+JOHN_SYSTEMWIDE/s!/usr!'"$out"'! 20 + ' src/params.h 21 + sed -ri -e '/^\.include/ { 22 + s!\$JOHN!'"$out"'/etc/john! 23 + s!^(\.include\s*)<([^./]+\.conf)>!\1"'"$out"'/etc/john/\2"! 24 + }' run/*.conf 25 + ''; 17 26 18 27 preConfigure = "cd src"; 19 28 configureFlags = [ "--disable-native-macro" ]; 20 29 30 + buildInputs = [ openssl nss nspr kerberos gmp zlib libpcap re2 ]; 31 + 32 + NIX_CFLAGS_COMPILE = [ "-DJOHN_SYSTEMWIDE=1" ]; 33 + 21 34 installPhase = '' 22 - mkdir -p "$out/share/john" 23 - mkdir -p "$out/bin" 24 - cp -R ../run/* "$out/share/john" 25 - ln -s "$out/share/john/john" "$out/bin/john" 35 + mkdir -p "$out/etc/john" "$out/share/john" "$out/share/doc/john" 36 + find ../run -mindepth 1 -maxdepth 1 -type f -executable \ 37 + -exec "${stdenv.shell}" "${writeText "john-binary-install.sh" '' 38 + filename="$(basename "$1")" 39 + install -vD "$1" "$out/bin/''${filename%.*}" 40 + ''}" {} \; 41 + cp -vt "$out/etc/john" ../run/*.conf 42 + cp -vt "$out/share/john" ../run/*.chr ../run/password.lst 43 + cp -vrt "$out/share/doc/john" ../doc/* 26 44 ''; 27 45 28 46 meta = {