summaryrefslogtreecommitdiff
blob: 0e505aba9bb8f137bc5514151b174c8743210581 (plain)
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# Copyright 1999-2015 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$

EAPI=5

MY_P="hashcat-${PV}"

inherit eutils pax-utils
DESCRIPTION="An multi-threaded multihash cracker"
HOMEPAGE="http://hashcat.net/hashcat/"

SRC_URI="http://hashcat.net/files/${MY_P}.7z"

#license applies to this version per http://hashcat.net/forum/thread-1348.html
LICENSE="hashcat"
SLOT="0"
KEYWORDS="-* ~amd64 ~amd64-linux ~x64-macos ~x86 ~x86-linux"

IUSE=""

RDEPEND=""
DEPEND="${RDEPEND}
	app-arch/p7zip"

S="${WORKDIR}/${MY_P}"

RESTRICT="strip"
QA_PREBUILT="opt/${PN}/hashcat-cli*.bin
		opt/${PN}/hashcat-cli64.app"

has_xop() {
	echo | $(tc-getCC) ${CFLAGS} -E -dM - | grep -q "#define __XOP__ 1"
}

has_avx() {
	echo | $(tc-getCC) ${CFLAGS} -E -dM - | grep -q "#define __AVX__ 1"
}

src_install() {
	dodoc docs/*
	rm -r *.exe docs || die
	use x86 || { rm hashcat-cli32.bin || die; }
	use amd64 || { rm hashcat-cli64.bin || die; }
	use x64-macos || { rm hashcat-cli64.app || die; }
	has_avx || { rm hashcat-cliAVX.bin || die; }
	has_xop || { rm hashcat-cliXOP.bin || die; }

	#I assume this is needed but I didn't check
	pax-mark m hashcat-cli*.bin

	insinto /opt/${PN}
	doins -r "${S}"/*

	dodir /opt/bin
	if [ -f "${ED}"/opt/${PN}/hashcat-cli32.bin ]
	then
		fperms +x /opt/${PN}/hashcat-cli32.bin
		cat <<-EOF > "${ED}"/opt/bin/hashcat-cli32.bin
			#! /bin/sh
			cd "${EPREFIX}"/opt/${PN}
			echo "Warning: hashcat-cli32.bin is running from ${EPREFIX}/opt/${PN} so be careful of relative paths."
			exec ./hashcat-cli32.bin \$@
		EOF
		fperms +x /opt/bin/hashcat-cli32.bin
	fi
	if [ -f "${ED}"/opt/${PN}/hashcat-cli64.bin ]
	then
		fperms +x /opt/${PN}/hashcat-cli64.bin
		cat <<-EOF > "${ED}"/opt/bin/hashcat-cli64.bin
			#! /bin/sh
			cd "${EPREFIX}"/opt/${PN}
			echo "Warning: hashcat-cli64.bin is running from ${EPREFIX}/opt/${PN} so be careful of relative paths."
			exec ./hashcat-cli64.bin \$@
		EOF
		fperms +x /opt/bin/hashcat-cli64.bin
	fi
	if [ -f "${ED}"/opt/${PN}/hashcat-cliAVX.bin ]
	then
		fperms +x /opt/${PN}/hashcat-cliAVX.bin
		cat <<-EOF > "${ED}"/opt/bin/hashcat-cliAVX.bin
			#! /bin/sh
			cd "${EPREFIX}"/opt/${PN}
			echo "Warning: hashcat-cliAVX.bin is running from ${EPREFIX}/opt/${PN} so be careful of relative paths."
			exec ./hashcat-cliAVX.bin \$@
		EOF
		fperms +x /opt/bin/hashcat-cliAVX.bin
	fi
	if [ -f "${ED}"/opt/${PN}/hashcat-cliXOP.bin ]
	then
		fperms +x /opt/${PN}/hashcat-cliXOP.bin
		cat <<-EOF > "${ED}"/opt/bin/hashcat-cliXOP.bin
			#! /bin/sh
			cd "${EPREFIX}"/opt/${PN}
			echo "Warning: hashcat-cliXOP.bin is running from ${EPREFIX}/opt/${PN} so be careful of relative paths."
			exec ./hashcat-cliXOP.bin \$@
		EOF
		fperms +x /opt/bin/hashcat-cliXOP.bin
	fi
	if [ -f "${ED}"/opt/${PN}/hashcat-cli64.app ]
	then
		fperms +x /opt/${PN}/hashcat-cli64.app
		cat <<-EOF > "${ED}"/opt/bin/hashcat-cli64.app
			#! /bin/sh
			cd "${EPREFIX}"/opt/${PN}
			echo "Warning: hashcat-cli64.app is running from ${EPREFIX}/opt/${PN} so be careful of relative paths."
			exec ./hashcat-cli64.app \$@
		EOF
		fperms +x /opt/bin/hashcat-cli64.app
	fi
}