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