Skip to content

Commit

Permalink
Merge pull request #2147 from blshkv/master
Browse files Browse the repository at this point in the history
ghidra-11.2.1.ebuild
  • Loading branch information
github-actions[bot] authored Nov 7, 2024
2 parents 263b115 + c08d55f commit 25d6397
Show file tree
Hide file tree
Showing 2 changed files with 182 additions and 0 deletions.
1 change: 1 addition & 0 deletions dev-util/ghidra/Manifest
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
DIST AXMLPrinter2.jar 24552 BLAKE2B 3ff09da948c2962919927ad35f8d38a13391c763a83962f8fdce90ec4720430b00be891f68fc149f62180ddf5f5e818af4e6b6a153d1a55e871f181e930d2b7b SHA512 c1168ec913f1fbb0675915d4fd865ec9a8e8573f6c8aedcb6e68166f61f11aeaececc7548d54d78134843c0102c57d6350973f6d3027d0ffdae52a5c57a7f601
DIST Ghidra_11.1.2_build.tar.gz 70080146 BLAKE2B 15427af59a06c4b9ddc14581a734b66d5d2bcb7ffab936f03b2d0dcf3af20b5c58fa6059e743c703037a2de9e1710b050d88fb60405d417a395c697f34a2dcc7 SHA512 8323cb574e33f18358091eabb9af4296cb833109d712aac4cbf5ba1a50d435fca1f450e15e96adfd1cdffc466d47c9a5e5590b631b9df39374ee05608632dd86
DIST Ghidra_11.2.1_build.tar.gz 70356567 BLAKE2B 32c4bcc7e6b4f0d124fe76895ab9326e98eccf5723ee4fc693252da4c3a1a69da3fe9ebb60806ec109b8801e34782f1d914cbaa7ccbac81062bce4b724eccca7 SHA512 27046a76f69e7d1ddaf4a958e2419798b721cf4f9f11481c9a3b284c93962af1e759ac9f336199252b6faabedf60599ef491f3bef0afdb70592db646f4bb7555
DIST Ghidra_11.2_build.tar.gz 70350959 BLAKE2B 50ebc8272ae33fb002e9b83ab8b814103f6a6974664a9fa0dcc4debd5322d66a642414d3012ba105c87f1c43502ab1a68e76eda249462771988df88ab90cbbf1 SHA512 f351dde015c065bb7d8bf5268c4d202f86523ad6135ad6a0e8a44526d0e9686ad5e547b843d23e44193d65312506b04ba4e9e4496593bbbb841565da9f5382c2
DIST PyDev-6.3.1.zip 24756333 BLAKE2B e9a942e0ff90b9eafbd1fa0df5429f2ff227ed140b7352a1003be04ffbc043e17bf19bd622d7fe9b958286a75ff4897c03088c1627ee62ea7b6e832752cb427e SHA512 411ed78d1057f5e9780e44169935fb8a0da17e97ce26e9a7a9fa9a251d4d3c1118e9b47dd9f7af03bde1f47180bde0d456039b65687f600026a148055311ecfa
DIST Pybag-2.2.10-py3-none-any.whl 297877 BLAKE2B 6563cfd657b4bed2a57217fd2fbac9a9bf4449f7dd9b3881bda7942d38b14390b2aca611d71811e98a3f1c78266cb66bcaff5229c46920935bec6a6a9642b200 SHA512 9a2582a6e7ec922b28abf2a7b5250161ef2da4ba2570b29435e626da8c98d8be17298fde7a374783599605224781feec6dc16bfca5d7eb0455bea49a51dfbeb7
Expand Down
181 changes: 181 additions & 0 deletions dev-util/ghidra/ghidra-11.2.1.ebuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
# Copyright 1999-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8
inherit java-pkg-2 desktop

GRADLE_DEP_VER="20240928"
GRADLE_VER="8.5"
RELEASE_VERSION="11.2" #${PV}

DESCRIPTION="A software reverse engineering framework"
HOMEPAGE="https://ghidra-sre.org/"

# ./gradle/support/fetchDependencies.gradle
FIDB_FILES="vs2012_x86.fidb vs2012_x64.fidb vs2015_x86.fidb vs2015_x64.fidb \
vs2017_x86.fidb vs2017_x64.fidb vs2019_x86.fidb vs2019_x64.fidb vsOlder_x86.fidb vsOlder_x64.fidb"

# ./gradle/support/fetchDependencies.gradle
SRC_URI="https://github.com/NationalSecurityAgency/${PN}/archive/Ghidra_${PV}_build.tar.gz
https://dev.pentoo.ch/~blshkv/distfiles/${PN}-dependencies-${GRADLE_DEP_VER}.tar.gz
https://github.com/pxb1988/dex2jar/releases/download/v2.1/dex2jar-2.1.zip
https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/android4me/AXMLPrinter2.jar
https://sourceforge.net/projects/catacombae/files/HFSExplorer/0.21/hfsexplorer-0_21-bin.zip
https://downloads.sourceforge.net/yajsw/yajsw/yajsw-stable-13.12.zip
https://ftp.postgresql.org/pub/source/v15.3/postgresql-15.3.tar.gz
https://archive.eclipse.org/tools/cdt/releases/8.6/cdt-8.6.0.zip
https://downloads.sourceforge.net/pydev/pydev/PyDev%206.3.1/PyDev%206.3.1.zip -> PyDev-6.3.1.zip
https://github.com/NationalSecurityAgency/ghidra-data/raw/Ghidra_${RELEASE_VERSION}/lib/java-sarif-2.1-modified.jar
"
for FIDB in ${FIDB_FILES}; do
SRC_URI+=" https://github.com/NationalSecurityAgency/ghidra-data/raw/Ghidra_${RELEASE_VERSION}/FunctionID/${FIDB}"
done

SRC_URI+=" https://files.pythonhosted.org/packages/8d/14/619e24a4c70df2901e1f4dbc50a6291eb63a759172558df326347dce1f0d/protobuf-3.20.3-py2.py3-none-any.whl
https://files.pythonhosted.org/packages/90/c7/6dc0a455d111f68ee43f27793971cf03fe29b6ef972042549db29eec39a2/psutil-5.9.8.tar.gz
https://files.pythonhosted.org/packages/c7/42/be1c7bbdd83e1bfb160c94b9cafd8e25efc7400346cf7ccdbdb452c467fa/setuptools-68.0.0-py3-none-any.whl
https://files.pythonhosted.org/packages/27/d6/003e593296a85fd6ed616ed962795b2f87709c3eee2bca4f6d0fe55c6d00/wheel-0.37.1-py2.py3-none-any.whl
https://files.pythonhosted.org/packages/ce/78/91db67e7fe1546dc8b02c38591b7732980373d2d252372f7358054031dd4/Pybag-2.2.12-py3-none-any.whl
https://files.pythonhosted.org/packages/d0/dd/b28df50316ca193dd1275a4c47115a720796d9e1501c1888c4bfa5dc2260/capstone-5.0.1-py3-none-win_amd64.whl
https://files.pythonhosted.org/packages/50/8f/518a37381e55a8857a638afa86143efa5508434613541402d20611a1b322/comtypes-1.4.1-py3-none-any.whl
https://files.pythonhosted.org/packages/83/1c/25b79fc3ec99b19b0a0730cc47356f7e2959863bf9f3cd314332bddb4f68/pywin32-306-cp312-cp312-win_amd64.whl"

# run: "pentoo/scripts/gradle_dependencies.py buildGhidra" from "${S}" directory to generate dependencies
# https://www.eclipse.org/downloads/download.php?r=1&protocol=https&file=/tools/cdt/releases/8.6/cdt-8.6.0.zip
# https://sourceforge.net/projects/yajsw/files/yajsw/yajsw-stable-13.05/yajsw-stable-13.05.zip/download

S="${WORKDIR}/ghidra-Ghidra_${PV}_build"
LICENSE="Apache-2.0"
SLOT="0"
KEYWORDS="amd64"

#FIXME:
# * QA Notice: Files built without respecting CFLAGS have been detected
# * QA Notice: Files built without respecting LDFLAGS have been detected
# * Please include the following list of files in your report:
# * /usr/share/ghidra/GPL/DemanglerGnu/os/linux_x86_64/demangler_gnu_v2_24
# * /usr/share/ghidra/GPL/DemanglerGnu/os/linux_x86_64/demangler_gnu_v2_41
# * /usr/share/ghidra/Ghidra/Features/Decompiler/os/linux_x86_64/decompile
# * /usr/share/ghidra/Ghidra/Features/Decompiler/os/linux_x86_64/sleigh
# * /usr/share/ghidra/Ghidra/Features/FileFormats/data/sevenzipnativelibs/Linux-amd64/lib7-Zip-JBinding.so
# * /usr/share/ghidra/Ghidra/Features/FileFormats/os/linux_x86_64/lzfse

#java-pkg-2 sets java based on RDEPEND so the java slot in rdepend is used to build
RDEPEND=">=virtual/jre-21:*"
DEPEND="${RDEPEND}
>=virtual/jdk-21:*
sys-devel/bison
dev-java/jflex
app-arch/unzip
dev-python/pip"
BDEPEND=">=dev-java/gradle-bin-${GRADLE_VER}:*"

check_gradle_binary() {
gradle_link_target=$(readlink -n /usr/bin/gradle)
currentver="${gradle_link_target/gradle-bin-/}"
requiredver="${GRADLE_VER}"
einfo "Gradle version ${currentver} currently set."
if [ "$(printf '%s\n' "$requiredver" "$currentver" | sort -V | head -n1)" = "$requiredver" ]; then
einfo "Gradle version ${currentver} is >= ${requiredver}, proceeding with build..."
else
eerror "Gradle version ${requiredver} or higher must be eselected before building ${PN}."
die "Please run 'eselect gradle set gradle-bin-XX' when XX is a version of gradle higher than ${requiredver}"
fi
}

src_unpack() {
# https://github.com/NationalSecurityAgency/ghidra/blob/master/DevGuide.md
# alternative:
# gradle -I gradle/support/fetchDependencies.gradle init
# gradle -g dependencies/gradle prepdev
# build: gradle -g dependencies/gradle buildGhidra
unpack ${A}
mkdir -p "${S}/.gradle/flatRepo" || die "(1) mkdir failed"
cd "${S}/.gradle"

unpack dex2jar-2.1.zip
cp dex-tools-2.1/lib/dex-*.jar ./flatRepo || die "(2) cp failed"

cp "${DISTDIR}/AXMLPrinter2.jar" ./flatRepo || die "(3) cp failed"
cp "${DISTDIR}/java-sarif-2.1-modified.jar" ./flatRepo || die "(4) cp failed"

unpack hfsexplorer-0_21-bin.zip
cp lib/*.jar ./flatRepo || die "(5) cp failed"

mkdir -p "${WORKDIR}"/ghidra.bin/Ghidra/Features/GhidraServer/ || die "(6) mkdir failed"
cp "${DISTDIR}"/yajsw-stable-13.12.zip "${WORKDIR}"/ghidra.bin/Ghidra/Features/GhidraServer/ || die "(7) cp failed"

PLUGIN_DEP_PATH="ghidra.bin/GhidraBuild/EclipsePlugins/GhidraDev/buildDependencies"
mkdir -p "${WORKDIR}/${PLUGIN_DEP_PATH}/" || die "(8) mkdir failed"
cp "${DISTDIR}"/PyDev-6.3.1.zip "${WORKDIR}/${PLUGIN_DEP_PATH}/PyDev 6.3.1.zip" || die "(9) cp failed"
cp "${DISTDIR}"/cdt-8.6.0.zip "${WORKDIR}/${PLUGIN_DEP_PATH}/" || die "(10) cp failed"
cp "${DISTDIR}"/postgresql-15.3.tar.gz "${WORKDIR}/${PLUGIN_DEP_PATH}/" || die "(10) cp failed"

cd "${S}"
mv ../dependencies .

mkdir ./dependencies/fidb || die "failed to create fidb dir"
cp "${DISTDIR}/${FIDB_FILES}" ./dependencies/fidb/

#copy whl
mkdir -p ./dependencies/{Debugger-rmi-trace,Debugger-agent-dbgeng} || die "failed to create Debugger dir"
cp "${DISTDIR}"/protobuf-3.20.3-py2.py3-none-any.whl ./dependencies/Debugger-rmi-trace/
cp "${DISTDIR}"/psutil-5.9.8.tar.gz ./dependencies/Debugger-rmi-trace/
cp "${DISTDIR}"/setuptools-68.0.0-py3-none-any.whl ./dependencies/Debugger-rmi-trace/
cp "${DISTDIR}"/wheel-0.37.1-py2.py3-none-any.whl ./dependencies/Debugger-rmi-trace/

cp "${DISTDIR}"/Pybag-2.2.12-py3-none-any.whl ./dependencies/Debugger-agent-dbgeng/
cp "${DISTDIR}"/capstone-5.0.1-py3-none-win_amd64.whl ./dependencies/Debugger-agent-dbgeng/
cp "${DISTDIR}"/comtypes-1.4.1-py3-none-any.whl ./dependencies/Debugger-agent-dbgeng/
cp "${DISTDIR}"/pywin32-306-cp312-cp312-win_amd64.whl ./dependencies/Debugger-agent-dbgeng/

}

src_prepare() {
mkdir -p ".gradle/init.d" || die "(10) mkdir failed"
cp "${FILESDIR}"/repos.gradle .gradle/init.d || die "(11) cp failed"
sed -i "s|S_DIR|${S}|g" .gradle/init.d/repos.gradle || die "(12) sed failed"
#remove build date so we can unpack dist.zip later
sed -i "s|_\${rootProject.BUILD_DATE_SHORT}||g" gradle/root/distribution.gradle || die "(13) sed failed"
#10.0 workaround
ln -s ../.gradle/flatRepo ./dependencies/flatRepo

eapply_user
}

src_compile() {
check_gradle_binary
export _JAVA_OPTIONS="$_JAVA_OPTIONS -Duser.home=$HOME -Djava.io.tmpdir=${T}"

GRADLE="gradle --gradle-user-home .gradle --console rich --no-daemon"
GRADLE="${GRADLE} --offline --parallel --max-workers $(nproc)"
unset TERM
${GRADLE} prepDev -x check -x test || die
${GRADLE} assembleAll -x check -x test --parallel || die

#build without eclipse plugin
# ${GRADLE} yajswDevUnpack -x check -x test || die
# ${GRADLE} buildNatives_linux64 -x check -x test || die
# ${GRADLE} sleighCompile -x check -x test || die
}

src_install() {
# remove zip files which aren't needed at runtime
find build/dist/ghidra_${PV}_DEV/ -type f -name '*.zip' -exec rm -f {} +
#FIXME: add doc flag
rm -r build/dist/ghidra_${PV}_DEV/docs/ || die "rm failed"

insinto /usr/share/ghidra
doins -r build/dist/ghidra_${PV}_DEV/*
fperms +x /usr/share/ghidra/ghidraRun
fperms +x /usr/share/ghidra/support/launch.sh
fperms +x /usr/share/ghidra/GPL/DemanglerGnu/os/linux_x86_64/demangler_gnu_v2_41
fperms +x /usr/share/ghidra/Ghidra/Features/Decompiler/os/linux_x86_64/decompile

dosym -r /usr/share/ghidra/ghidraRun /usr/bin/ghidra

# icon
doicon GhidraDocs/GhidraClass/Beginner/Images/GhidraLogo64.png
# desktop entry
make_desktop_entry ${PN} "Ghidra" /usr/share/pixmaps/GhidraLogo64.png "Utility"
}

0 comments on commit 25d6397

Please sign in to comment.