aboutsummaryrefslogtreecommitdiffstats
path: root/testing/ghidra/APKBUILD
blob: abc12f231b8afbe9683876f24d41ff9e0a298836 (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
# Maintainer: Marian Buschsieweke <marian.buschsieweke@ovgu.de>
# Contributor: Marian Buschsieweke <marian.buschsieweke@ovgu.de>
pkgname=ghidra
pkgver=10.2.3
pkgrel=0
pkgdesc="A Cross Platform and Open Source Electronics Design Automation Suite"
url="https://ghidra-sre.org/"
# only x86_64 and aarch64 support provided by upstream
# aarch64: jdk segfaults
arch="x86_64"
license="Apache-2.0"
makedepends="
	bash
	gradle
	protoc
	unzip
	"
# Note: Ghidra refuses to launch with only JRE installed, so
#       please do not move JDK to makedepends
depends="
	openjdk17-jdk
	wmname
	"
subpackages="
	$pkgname-tutorials
	$pkgname-doc
	"
source="
	https://github.com/NationalSecurityAgency/ghidra/archive/refs/tags/Ghidra_${pkgver}_build.tar.gz
	use-system-protoc.patch
	ghidra.sh
	"
# This contains binary executables in the exercises section of the
# documentation. We don't want to spoil the fun by stripping them.
options="net !check !strip"
builddir="$srcdir/ghidra-Ghidra_${pkgver}_build"

prepare() {
	default_prepare

	local protoc_ver
	protoc_ver="$(protoc --version | grep -o '[0-9][.0-9]*')"

	# protoc version needs to match protobuf runtime version
	sed \
		-e "s/com.google.protobuf:protobuf-java:3.17.3/com.google.protobuf:protobuf-java:$protoc_ver/g" \
		-i Ghidra/Debug/Debugger-gadp/build.gradle
	sed \
		-e "s!lib/protobuf-java-3.17.3.jar!lib/protobuf-java-$protoc_ver.jar!g" \
		-i Ghidra/Debug/Debugger-gadp/Module.manifest
}

build() {
	export GRADLE_USER_HOME="$srcdir"/.gradle
	gradle --parallel -I gradle/support/fetchDependencies.gradle init
	gradle --parallel buildGhidra
}

package() {
	# impedance matching between different arch naming conventions:
	local arch
	case "$CARCH" in
		aarch64)
			arch="arm_64"
			;;
		*)
			arch="$CARCH"
			;;
	esac

	install -d "$pkgdir"/usr/share "$pkgdir"/usr/bin
	unzip \
		-u "build/dist/ghidra_${pkgver}_DEV_$(date +"%Y%m%d")_linux_$arch.zip" \
		-d "$pkgdir"/usr/share
	mv "$pkgdir"/usr/share/ghidra_${pkgver}_DEV "$pkgdir"/usr/share/ghidra

	install -Dm755 "$srcdir"/ghidra.sh "$pkgdir"/usr/bin/ghidra
	ln -s /usr/share/ghidra/support/analyzeHeadless "$pkgdir"/usr/bin/ghidra-headless
	install -Dm644 \
		Ghidra/Framework/Generic/src/main/resources/images/GhidraIcon64.png \
		"$pkgdir"/usr/share/icons/hicolor/64x64/apps/$pkgname.png
}

tutorials() {
	pkgdesc="Ghidra tutorial files"

	amove usr/share/ghidra/docs/GhidraClass
}

doc() {
	default_doc

	amove usr/share/ghidra/docs
}

sha512sums="
f5dbc828e43acabe8e30f293726b7afa7f96aa29eb2d0ea1ccd4688012e9fdf2950fab2cfa7b8a2b94feaa8ec5ffba5d39017c8ec152e592818d6e3b67df3fc7  Ghidra_10.2.3_build.tar.gz
89de3009dd0b8a26f730235ac1cce057f4c7363b0a0e7fc10cb0a52e2becd5fdf8913ec2afc8c85f3b7147e1120f8354f3f0108cb1583e3ab1157e6740148bff  use-system-protoc.patch
b075d5ac821bf4ed052acada45b882876a5493ab03cfa4d0537c4c5f27b666aa2b37de9ff561313b025f9d16b06b9ad17d59287ecf205c02798dbca2bc04925f  ghidra.sh
"