parlay

yet another gentoo overlay
git clone https://git.parazyd.org/parlay
Log | Files | Refs | README

ghidra-9.1.2.ebuild (4036B)


      1 # Copyright 1999-2019 Gentoo Authors
      2 # Distributed under the terms of the GNU General Public License v2
      3 
      4 EAPI=7
      5 
      6 GRADLE_DEP_VER="20191226"
      7 
      8 DESCRIPTION="A software reverse engineering framework"
      9 HOMEPAGE="https://www.nsa.gov/ghidra"
     10 SRC_URI="https://github.com/NationalSecurityAgency/${PN}/archive/Ghidra_${PV}_build.tar.gz
     11 	https://github.com/pxb1988/dex2jar/releases/download/2.0/dex-tools-2.0.zip
     12 	https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/android4me/AXMLPrinter2.jar
     13 	https://sourceforge.net/projects/catacombae/files/HFSExplorer/0.21/hfsexplorer-0_21-bin.zip
     14 	mirror://sourceforge/yajsw/yajsw/yajsw-stable-12.12.zip
     15 	http://www.eclipse.org/downloads/download.php?r=1&protocol=https&file=/tools/cdt/releases/8.6/cdt-8.6.0.zip
     16 	mirror://sourceforge/project/pydev/pydev/PyDev%206.3.1/PyDev%206.3.1.zip -> PyDev-6.3.1.zip
     17 	https://dev.pentoo.ch/~blshkv/distfiles/${PN}-dependencies-${GRADLE_DEP_VER}.tar.gz"
     18 # run: pentoo/scripts/gradle_dependencies.py from "${S}" directory to generate dependencies
     19 
     20 LICENSE="Apache-2.0"
     21 SLOT="0"
     22 KEYWORDS="~amd64"
     23 IUSE=""
     24 
     25 RDEPEND=">=virtual/jre-1.8:*"
     26 DEPEND="${RDEPEND}
     27 	>=virtual/jdk-11:*
     28 	dev-java/gradle-bin:5.2.1
     29 	sys-devel/bison
     30 	dev-java/jflex
     31 	app-arch/unzip"
     32 
     33 S="${WORKDIR}/ghidra-Ghidra_${PV}_build"
     34 
     35 src_unpack() {
     36 	# https://github.com/NationalSecurityAgency/ghidra/blob/master/DevGuide.md
     37 	unpack ${A}
     38 	mkdir -p "${S}/.gradle/flatRepo" || die "(1) mkdir failed"
     39 	cd "${S}/.gradle"
     40 
     41 	unpack dex-tools-2.0.zip
     42 	cp dex2jar-2.0/lib/dex-*.jar ./flatRepo || die "(3) cp failed"
     43 
     44 	cp "${DISTDIR}/AXMLPrinter2.jar" ./flatRepo  || die "(4) cp failed"
     45 
     46 	unpack hfsexplorer-0_21-bin.zip
     47 	cp lib/*.jar ./flatRepo            || die "(5) cp failed"
     48 
     49 	mkdir -p "${WORKDIR}"/ghidra.bin/Ghidra/Features/GhidraServer/ || die "(6) mkdir failed"
     50 	cp "${DISTDIR}"/yajsw-stable-12.12.zip "${WORKDIR}"/ghidra.bin/Ghidra/Features/GhidraServer/ || die "(7) cp failed"
     51 
     52 	mkdir -p "${WORKDIR}"/ghidra.bin/GhidraBuild/EclipsePlugins/GhidraDev/buildDependencies/ || die "(8) mkdir failed"
     53 	cp "${DISTDIR}"/PyDev-6.3.1.zip "${WORKDIR}/ghidra.bin/GhidraBuild/EclipsePlugins/GhidraDev/buildDependencies/PyDev 6.3.1.zip" || die "(9) cp failed"
     54 	cp "${DISTDIR}"/cdt-8.6.0.zip "${WORKDIR}"/ghidra.bin/GhidraBuild/EclipsePlugins/GhidraDev/buildDependencies/ || die "(10) cp failed"
     55 
     56 	cd "${S}"
     57 	mv ../dependencies .
     58 }
     59 
     60 src_prepare() {
     61 	sed -i 's|gradle.gradleVersion != "5.0"|gradle.gradleVersion <= "5.0"|g' build.gradle || die "(9) sed failed"
     62 	mkdir -p ".gradle/init.d"                       || die "(10) mkdir failed"
     63 	cp "${FILESDIR}"/repos.gradle .gradle/init.d    || die "(11) cp failed"
     64 	sed -i "s|S_DIR|${S}|g" .gradle/init.d/repos.gradle || die "(12) sed failed"
     65 	#remove build date so we can unpack dist.zip later
     66 	sed -i "s|_\${rootProject.BUILD_DATE_SHORT}||g" gradle/root/distribution.gradle || die "(13) sed failed"
     67 
     68 	if [[ -z "$(eselect java-vm show system | grep '11')"  ]]; then
     69 		eerror "JDK 11 is not installed or not selected. Please run the following:"
     70 		eerror "eselect java-vm set system <jdk-11>"
     71 		die
     72 	fi
     73 
     74 	#9.1 workaround
     75 	ln -s ./.gradle/flatRepo ./flatRepo
     76 
     77 	eapply_user
     78 }
     79 
     80 src_compile() {
     81 	export _JAVA_OPTIONS="$_JAVA_OPTIONS -Duser.home=$HOME"
     82 
     83 	GRADLE="gradle-5.2.1 --gradle-user-home .gradle --console rich --no-daemon"
     84 	GRADLE="${GRADLE} --offline"
     85 
     86 	unset TERM
     87 	${GRADLE} prepDev -x check -x test || die
     88 	${GRADLE} buildGhidra -x check -x test || die
     89 #build without eclipse plugin
     90 #	${GRADLE} yajswDevUnpack -x check -x test || die
     91 #	${GRADLE} buildNatives_linux64 -x check -x test || die
     92 #	${GRADLE} sleighCompile -x check -x test || die
     93 }
     94 
     95 src_install() {
     96 	#it is easier to unpack existing archive
     97 	dodir /usr/share
     98 	unzip build/dist/ghidra_9.1_DEV_linux64.zip -d "${ED}"/usr/share/ || die "unable to unpack dist zip"
     99 	mv "${ED}"/usr/share/ghidra_9.1_DEV "${ED}"/usr/share/ghidra || die "mv failed"
    100 
    101 	#fixme: add doc flag
    102 	rm -r  "${ED}"/usr/share/ghidra/docs/ || die "rm failed"
    103 	dosym "${EPREFIX}"/usr/share/ghidra/ghidraRun /usr/bin/ghidra
    104 }