summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: a7974c203297b4c58cb7414eaf099c6e2d045175 (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
# Maintainer: David Manouchehri
# Contributor: Alex Palaistras <alex+archlinux@deuill.org>
# Contributor: Elen Eisendle
# Contributor: Spenser Reinhardt

_pkgname="binaryninja"
_branch="stable"
_edition="-personal"
pkgname="${_pkgname}${_edition}"
[[ "${_branch}" != "stable" ]] && pkgname="${pkgname}-${_branch}"
pkgdesc="Binary Ninja is a binary multi-tool and reversing platform"
url="https://binary.ninja"
license=('custom:Binary Ninja License Agreement')
arch=('x86_64')
conflicts=("${_pkgname}")
provides=("${_pkgname}")
pkgver=1.1.989
pkgrel=1 # reset after new release, and .srcinfo
install="${_pkgname}.install"
makedeps=('curl' 'perl')
depends=(
	'python2' 'glibc' 'glib2' 'gcc-libs-multilib' 'pcre' 'zlib'
	'libssh2' 'libnghttp2' 'libpsl' 'libxcb' 'icu' 'keyutils'
	'libxext' 'libx11' 'libglvnd' 'krb5' 'e2fsprogs' 'libffi'
	'libxau' 'libxdmcp' 'libcurl-compat' 'openssl-1.0'
)
# https://binary.ninja/recover/
source=(
	"file://BinaryNinja${_edition}.zip"
	"binaryninja.png"
)
_hash=$(curl -s https://binary.ninja/js/hashes.js | perl -pe "s/.*Ninja${_edition}.zip\":\s\"([\da-f]+)\".*/\$1/g")
sha256sums=(
	"${_hash}"
	'ac2e652f617d5ef8aaa34a5113164f51f3f673c872a635d29c93878a00650bf8'
)

pkgver() {
	curl -s https://binary.ninja/js/changelog.js | perl -pe 's/.*?version":\s"(\d+\.\d+\.\d+)".*/$1/'
}

_cp_files() {
	# installs files, trims `${srcdir}/${_pkgname}` to allow outpath directly
	mode="${1}"
	inpath="${2}" # single path
	outpath="${3}"
	[[ ${argc} -gt 3 ]] && depth="${4}" # unset for no limit
	[[ ${argc} -gt 4 ]] && skip="${5}" # comma separated list
	# set $cmd based on depth's existence
	[ -z ${depth+x} ] && cmd="find ${inpath} -type f" || cmd="find ${inpath} -maxdepth ${depth} -type f"
	for file in $(${cmd}); do
		if [ -z ${skip+x} ]; then # dont bother if unset
			for s in $(echo ${skip}| sed 's/,/ /g'); do
				[[ "${file}" =~ "${s}" ]] && c=0 && break
			done
			[ ! -z ${c+x} ] && unset c && continue # is skipped ? unset+continue : move file
		fi
		outfile=$(echo ${file} | perl -pe "s|${srcdir}/${_pkgname}|${outpath}|g") # trim
		install -m "${mode}" "${file}" "${outfile}"
	done
}

prepare() {
	echo "[Desktop Entry]
Name=Binary Ninja ${_edition}
Exec=/usr/bin/${_pkgname}
Icon=${pkgname}
Type=Application
Categories=Development;Debugger;Profiling;" > "${srcdir}/binaryninja.desktop"
}

package() {
	_srcdir="${srcdir}/${_pkgname}"
	destdir="${pkgdir}/opt/${_pkgname}"
	[[ "${_branch}" != "stable" ]] && destdir="${destdir}-${_branch}"
	
	msg2 "Creating directories"
	install -dm 755 "${pkgdir}/usr/share/icons/hicolor/128x128/apps/"
	install -dm 755 "${pkgdir}/usr/share/applications/"
	for dir in $(find "${_srcdir}" -type d); do
		dir=$(echo $dir | perl -pe "s|${_srcdir}|${destdir}|g")
		install -dm 755 "${dir}"
	done
	
	msg2 "Copying non-executable files"
	install -m 644 "${srcdir}/binaryninja.png" "${pkgdir}/usr/share/icons/hicolor/128x128/apps/"
	install -m 644 "${srcdir}/binaryninja.desktop" "${pkgdir}/usr/share/applications/"
	install -m 644 "${_srcdir}/qt.conf" "${destdir}/qt.conf"
	_cp_files 644 "${_srcdir}/docs" "${destdir}"
	_cp_files 644 "${_srcdir}/api-docs" "${destdir}"
	_cp_files 644 "${_srcdir}/scc-docs" "${destdir}"
	_cp_files 644 "${_srcdir}/types" "${destdir}"
	
	msg2 "Copying executable files"
	_cp_files 755 "${_srcdir}/" "${destdir}" "0" "qt.conf"
	_cp_files 755 "${_srcdir}/python" "${destdir}"
	_cp_files 755 "${_srcdir}/scripts" "${destdir}"
	_cp_files 755 "${_srcdir}/plugins" "${destdir}"
	_cp_files 755 "${_srcdir}/qt" "${destdir}"
	_cp_files 755 "${_srcdir}/examples" "${destdir}"
}

# vim:set et sw=2 sts=2 tw=80: