archrelease: copy trunk to community-any
[ArchLinux/community.git] / ghidra / trunk / PKGBUILD
blob143d5b5aae97c81902b68d6c8b8cc2c28ac93226
1 # Maintainer: Robin Broda <robin at broda dot me>
2 # Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
4 pkgname=ghidra
5 pkgver=10.3
6 _d2j=2.1
7 _yajsw=13.09
8 pkgrel=1
9 pkgdesc='Software reverse engineering framework'
10 url='https://ghidra-sre.org/'
11 arch=('x86_64')
12 license=('Apache')
13 depends=('java-environment>=17' 'bash')
14 makedepends=('git' 'gradle' 'unzip' 'java-environment=17')
15 optdepends=('pam: GhidraServer support')
16 options=('!strip')
17 source=(https://github.com/NationalSecurityAgency/ghidra/archive/Ghidra_${pkgver}_build.tar.gz
18         "git+https://github.com/NationalSecurityAgency/ghidra-data#tag=Ghidra_${pkgver}"
19         https://github.com/pxb1988/dex2jar/releases/download/v${_d2j}/dex2jar-${_d2j}.zip
20         https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/android4me/AXMLPrinter2.jar
21         https://sourceforge.net/projects/yajsw/files/yajsw/yajsw-stable-${_yajsw}/yajsw-stable-${_yajsw}.zip)
22 noextract=(AXMLPrinter2.jar
23            yajsw-beta-${_yajsw}.zip)
24 sha512sums=('79e9130df1274850fc81c9ccbc87f03103dabe992c2a5cde014c24ba9bffe6cc55a09687da91189781ebc81790bdf35828db92b9020cdb6b793462efb345666c'
25             'SKIP'
26             '44b4a51043ef608158e16f70d9a448ae0a37896da19bd9837e1124e197b7b41a7c37f074386b0cc03edd4f385066bf5ef04c553f6dec0b0cc2a11ecbf299b16f'
27             'c1168ec913f1fbb0675915d4fd865ec9a8e8573f6c8aedcb6e68166f61f11aeaececc7548d54d78134843c0102c57d6350973f6d3027d0ffdae52a5c57a7f601'
28             'd8682b57ce7577374a17113e1ace77393397e405e6450e3f7637ed1f0f42bc7170b378f775a4ba3c458b202ef35f95b35317cce45659b8a3b25aaa59e8393aa4')
30 prepare() {
31   export PATH="/usr/lib/jvm/java-17-openjdk/bin:${PATH}"
32   cd ghidra-Ghidra_${pkgver}_build
34   # Copy needed libraries into flat repo folder
35   install -Dm 644 ../dex-tools-${_d2j}/lib/dex-*.jar \
36     ../AXMLPrinter2.jar \
37     -t dependencies/flatRepo
39   # YAJSW expects this symlink
40   ln -sf ghidra-Ghidra_${pkgver}_build ../ghidra.bin
41   install -Dm 644 ../yajsw-stable-${_yajsw}.zip -t dependencies/GhidraServer
43   # Add FID datasets
44   install -Dm 644 ../ghidra-data/FunctionID/*.fidb -t Ghidra/Features/FunctionID/src/main/fidb
46   # Ignore lack of licensing for YAJSW zip, packed FID datasets, and the native binaries
47   sed -i '/FileTree tree/a\\t\texclude "yajsw-stable-**.zip"\n\t\texclude "src/main/fidb/**.fidb"\n\t\texclude "os/linux64/**"' gradle/support/ip.gradle
50 build() {
51   export GRADLE_HOME="$(pwd)/usr/share/java/gradle/"
52   export PATH="$(pwd)/usr/share/java/gradle/bin/:${PATH}"
53   cd ghidra-Ghidra_${pkgver}_build
54   gradle yajswDevUnpack
55   gradle buildNatives_linux_x86_64
56   gradle sleighCompile
57   gradle buildGhidra
60 package() {
61   cd ghidra-Ghidra_${pkgver}_build
63   # Extract built archive into destination folder
64   install -d "${pkgdir}"/{opt,usr/bin}
65   _appver=$(grep -oP '(?<=^application.version=).*$' Ghidra/application.properties)
66   _relname=$(grep -oP '(?<=^application.release.name=).*$' Ghidra/application.properties)
67   unzip -u "build/dist/ghidra_${_appver}_${_relname}"_*_linux_x86_64.zip -d "${pkgdir}"/opt
69   # Simplify some directory and binary names
70   mv "${pkgdir}"/opt/ghidra{_*,}
71   ln -s /opt/ghidra/ghidraRun "${pkgdir}"/usr/bin/ghidra
72   ln -s /opt/ghidra/support/analyzeHeadless "${pkgdir}"/usr/bin/ghidra-analyzeHeadless
75 # vim: ts=2 sw=2 et: