# Template file for 'ghidra' pkgname=ghidra version=10.1 revision=1 archs="x86_64* aarch64*" # Other 64bit archs should be easily patchable, # grep for linux_arm_64 to find all places in need of patching create_wrksrc=yes build_wrksrc="ghidra_build" hostmakedepends="gradle openjdk11 flex unzip protobuf which" depends="openjdk11" short_desc="Software reverse engineering (SRE) framework" maintainer="Andrew Benson " license="Apache-2.0" homepage="https://ghidra-sre.org/" distfiles="https://github.com/NationalSecurityAgency/ghidra/archive/Ghidra_${version}_build.tar.gz https://github.com/pxb1988/dex2jar/releases/download/2.0/dex-tools-2.0.zip https://sourceforge.net/projects/catacombae/files/HFSExplorer/0.21/hfsexplorer-0_21-bin.zip https://sourceforge.net/projects/yajsw/files/yajsw/yajsw-beta-13.01/yajsw-beta-13.01.zip https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/android4me/AXMLPrinter2.jar" checksum="6250b2c2ff56d6f7beaf29d6144ae5d52ce33ba0a132ef54e5d4f7839d950dff 7907eb4d6e9280b6e17ddce7ee0507eae2ef161ee29f70a10dbc6944fdca75bc 90c9b54798abca5b12f4a678db7d0a4c970f4702cb153c11919536d0014dedbf 430fb7901bd0fd52a5b90bd0cbd89e9d334077eb72a9b26896f465de1e593a99 00ed038eb6abaf6ddec8d202a3ed7a81b521458f4cd459948115cfd02ff59d6d" skip_extraction="AXMLPrinter2.jar" nopie=yes nostrip_files="animals createStructure dataMutability inline ldiv opaque setRegister switch compilerVsDecompiler custom globalRegVars.so jumpWithinInstruction noReturn override.so sharedReturn write" skiprdeps="/usr/libexec/ghidra/docs/GhidraClass/ExerciseFiles/Advanced/animals /usr/libexec/ghidra/docs/GhidraClass/ExerciseFiles/Advanced/compilerVsDecompiler /usr/libexec/ghidra/docs/GhidraClass/ExerciseFiles/Advanced/createStructure /usr/libexec/ghidra/docs/GhidraClass/ExerciseFiles/Advanced/custom /usr/libexec/ghidra/docs/GhidraClass/ExerciseFiles/Advanced/dataMutability /usr/libexec/ghidra/docs/GhidraClass/ExerciseFiles/Advanced/globalRegVars.so /usr/libexec/ghidra/docs/GhidraClass/ExerciseFiles/Advanced/inline /usr/libexec/ghidra/docs/GhidraClass/ExerciseFiles/Advanced/jumpWithinInstruction /usr/libexec/ghidra/docs/GhidraClass/ExerciseFiles/Advanced/ldiv /usr/libexec/ghidra/docs/GhidraClass/ExerciseFiles/Advanced/noReturn /usr/libexec/ghidra/docs/GhidraClass/ExerciseFiles/Advanced/opaque /usr/libexec/ghidra/docs/GhidraClass/ExerciseFiles/Advanced/override.so /usr/libexec/ghidra/docs/GhidraClass/ExerciseFiles/Advanced/setRegister /usr/libexec/ghidra/docs/GhidraClass/ExerciseFiles/Advanced/sharedReturn /usr/libexec/ghidra/docs/GhidraClass/ExerciseFiles/Advanced/switch /usr/libexec/ghidra/docs/GhidraClass/ExerciseFiles/Advanced/write" python_version=2 # Jython 2.7.2 stuff nocross=yes post_extract() { # makes patching easier mv ${wrksrc}/ghidra-Ghidra_${version}_build ${wrksrc}/ghidra_build } do_configure() { mkdir -p dependencies/flatRepo cp -f ${XBPS_SRCDISTDIR}/${pkgname}-${version}/AXMLPrinter2.jar dependencies/flatRepo for lib in csframework.jar hfsx_dmglib.jar hfsx.jar iharder-base64.jar; do cp -f ../lib/$lib dependencies/flatRepo done cp -f ../dex2jar-2.0/lib/dex-*.jar dependencies/flatRepo mkdir -p ${wrksrc}/ghidra.bin/Ghidra/Features/GhidraServer/ cp -f ${XBPS_SRCDISTDIR}/${pkgname}-${version}/yajsw-beta-13.01.zip ${wrksrc}/ghidra.bin/Ghidra/Features/GhidraServer/ gradle yajswDevUnpack } do_build() { gradle buildGhidra } do_install() { case "$XBPS_TARGET_MACHINE" in x86_64*) arch=x86_64;; aarch64*) arch=arm_64;; esac cd ${wrksrc}/${build_wrksrc} vmkdir usr/libexec/ghidra bsdtar --strip-components 1 -C ${DESTDIR}/usr/libexec/ghidra -xf build/dist/ghidra_${version}_DEV_$(date -u +%Y%m%d)_linux_${arch}.zip vmkdir usr/bin ln -srf /usr/libexec/$pkgname/ghidraRun ${DESTDIR}/usr/bin/ghidra }