- Update to 11.4 * See https://github.com/NationalSecurityAgency/ghidra/blob/Ghidra_11.4_build/Ghidra/Configurations/Public_Release/src/global/docs/ChangeHistory.md - fix aarch64 build - install correct desktop icons - revert last change, java-devel _is_ a runtime dep. OBS-URL: https://build.opensuse.org/request/show/1289006 OBS-URL: https://build.opensuse.org/package/show/security:forensics/ghidra?expand=0&rev=34
264 lines
8.6 KiB
RPMSpec
264 lines
8.6 KiB
RPMSpec
#
|
|
# spec file for package ghidra
|
|
#
|
|
# Copyright (c) 2020 SUSE LINUX GmbH, Nuernberg, Germany.
|
|
#
|
|
# All modifications and additions to the file contributed by third parties
|
|
# remain the property of their copyright owners, unless otherwise agreed
|
|
# upon. The license for this file, and modifications and additions to the
|
|
# file, is the same license as for the pristine package itself (unless the
|
|
# license for the pristine package is not an Open Source License, in which
|
|
# case the license is the MIT License). An "Open Source License" is a
|
|
# license that conforms to the Open Source Definition (Version 1.9)
|
|
# published by the Open Source Initiative.
|
|
|
|
# Please submit bugfixes or comments via http://bugs.opensuse.org/
|
|
#
|
|
|
|
%define java_version 21
|
|
|
|
Name: ghidra
|
|
Version: 11.4
|
|
Release: 0
|
|
Summary: Software Reverse Engineering Framework
|
|
License: Apache-2.0
|
|
Group: Development/Libraries/Java
|
|
Url: https://ghidra-sre.org
|
|
Source0: https://github.com/NationalSecurityAgency/%{name}/archive/refs/tags/%{name}-Ghidra_%{version}_build.tar.gz
|
|
Source1: %{name}-rpmlintrc
|
|
Source2: %{name}.desktop
|
|
# from https://github.com/kkaempf/ghidra-vax
|
|
Source3: ghidra-vax-main.zip
|
|
# from https://github.com/kkaempf/ghidra-nmos
|
|
Source4: ghidra-nmos-ii-main.zip
|
|
Source5: ghidra-alpha-main.zip
|
|
Source6: %{name}-kit.tar
|
|
|
|
Patch1: 0003-Introduce-operand_offset.patch
|
|
Patch2: 0004-Add-offset-to-sleigh-Java.patch
|
|
Patch3: 0006-exclude-generated-sleigh-files-from-IP-scan.patch
|
|
|
|
ExclusiveArch: x86_64 aarch64
|
|
|
|
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
|
BuildRequires: bison
|
|
BuildRequires: cabextract
|
|
BuildRequires: docbook5-xsl-stylesheets
|
|
BuildRequires: fdupes
|
|
BuildRequires: flex
|
|
BuildRequires: findutils
|
|
BuildRequires: gcc-c++
|
|
BuildRequires: gradle
|
|
BuildRequires: java-devel = %{java_version}
|
|
BuildRequires: python3 >= 3.9
|
|
BuildRequires: python3-pip
|
|
BuildRequires: sed
|
|
BuildRequires: unzip
|
|
BuildRequires: zip
|
|
|
|
Requires: cabextract >= 1.6
|
|
# yes, Ghidra requires a Java compiler at runtime :-/
|
|
Requires: java-devel >= %{java_version}
|
|
|
|
%description
|
|
Ghidra is a software reverse engineering (SRE) framework created and
|
|
maintained by the National Security Agency Research Directorate. This
|
|
framework includes a suite of full-featured, high-end software
|
|
analysis tools that enable users to analyze compiled code on a variety
|
|
of platforms including Windows, macOS, and Linux.
|
|
|
|
%package apidocs
|
|
Summary: Ghidra API documentation
|
|
BuildArch: noarch
|
|
|
|
%description apidocs
|
|
Ghidra API documentation in HTML or JSON format.
|
|
|
|
%package javadocs
|
|
Summary: Ghidra JAVA documentation
|
|
BuildArch: noarch
|
|
|
|
%description javadocs
|
|
Ghidra JAVA documentation in HTML format.
|
|
|
|
%package doc
|
|
Summary: Ghidra generic documentation
|
|
|
|
%description doc
|
|
Ghidra documentation in HTML.
|
|
|
|
%prep
|
|
%setup -q -n %{name}-Ghidra_%{version}_build
|
|
%patch -P1 -p1
|
|
%patch -P2 -p1
|
|
%patch -P3 -p1
|
|
tar xf %{S:6}
|
|
|
|
%build
|
|
find . -name .gitignore_disabled_by_tetra -exec rm '{}' \;
|
|
rm -rf GPL/CabExtract
|
|
|
|
export GRADLE_USER_HOME=/tmp/gradle
|
|
export GRADLE_CACHE=/tmp/gradle-cache
|
|
export BUILD_VCS_NUMBER=%{version}
|
|
export M2_HOME=`pwd`/dependencies/m2
|
|
export GRADLE_OPTS="-Xmx1024m"
|
|
export LANG=en_US.UTF-8
|
|
export JAVA_HOME=%{_libdir}/jvm/java-%{java_version}-openjdk-%{java_version}/
|
|
|
|
mkdir build
|
|
mkdir -p ~/.m2
|
|
rm -rf ~/.m2/repository
|
|
ln -sf $M2_HOME ~/.m2/repository
|
|
|
|
(cd Ghidra/Processors;
|
|
unzip %{S:3};
|
|
mv ghidra-vax-main VAX)
|
|
|
|
(cd Ghidra/Processors;
|
|
unzip %{S:4};
|
|
mv ghidra-nmos-ii-main NMOS-II)
|
|
|
|
(cd Ghidra/Processors;
|
|
unzip %{S:5};
|
|
mv ghidra-alpha-main Alpha)
|
|
|
|
# --stacktrace --info --debug \
|
|
# --no-parallel \
|
|
# --no-daemon \
|
|
|
|
gradle \
|
|
--gradle-user-home $GRADLE_USER_HOME \
|
|
--project-cache-dir $GRADLE_CACHE \
|
|
-Dfile.encoding=UTF-8 \
|
|
-Djava.home=$JAVA_HOME \
|
|
--project-prop finalRelease=true \
|
|
--offline \
|
|
buildGhidra
|
|
|
|
gradle --stop
|
|
|
|
(cd Ghidra/Features/FunctionID/src/main/doc;
|
|
sed -i 's|http://docbook.sourceforge.net/release/xsl/current/html/chunk.xsl|/usr/share/xml/docbook/stylesheet/nwalsh5/1.79.2/html/chunk.xsl|' fid_html.xsl;
|
|
xsltproc fid_html.xsl fid.xml)
|
|
|
|
%install
|
|
|
|
mkdir -p %{buildroot}%{_libdir}
|
|
|
|
unzip build/dist/ghidra*linux*.zip -d %{buildroot}%{_libdir}
|
|
mv %{buildroot}%{_libdir}/%{name}* %{buildroot}%{_libdir}/%{name}
|
|
|
|
mkdir -p %{buildroot}%{_datadir}/applications
|
|
install -m 644 %{S:2} %{buildroot}%{_datadir}/applications
|
|
|
|
for i in 16 24 32 40 48 64 128 256
|
|
do
|
|
mkdir -p %{buildroot}%{_iconsdir}/hicolor/${i}x${i}
|
|
cp Ghidra/Framework/Gui/src/main/resources/images/GhidraIcon$i.png %{buildroot}%{_iconsdir}/hicolor/${i}x${i}/GhidraIcon.png
|
|
done
|
|
|
|
mkdir -p %{buildroot}%{_docdir}/%{name}
|
|
mv %{buildroot}%{_libdir}/%{name}/docs/* %{buildroot}%{_docdir}/%{name}
|
|
# creates 'api' subdir
|
|
unzip build/tmp/GhidraAPI_javadoc.zip -d %{buildroot}%{_docdir}/%{name}
|
|
|
|
# please rpmlint:
|
|
%fdupes %{buildroot}%{_libdir}/%{name}
|
|
|
|
# This script uses 'env' as an interpreter.
|
|
%if 0%{?suse_version} > 1500
|
|
sed -i 's|#!/usr/bin/env bash|#!/usr/bin/bash|' %{buildroot}%{_libdir}/%{name}/ghidraRun
|
|
find %{buildroot}%{_libdir}/%{name}/server/* -exec sed -i 's|#!/usr/bin/env bash|#!/usr/bin/bash|' "{}" \;
|
|
find %{buildroot}%{_libdir}/%{name}/support/* -exec sed -i 's|#!/usr/bin/env bash|#!/usr/bin/bash|' "{}" \;
|
|
%else
|
|
sed -i 's|#!/usr/bin/env bash|#!/bin/bash|' %{buildroot}%{_libdir}/%{name}/ghidraRun
|
|
find %{buildroot}%{_libdir}/%{name}/server/* -exec sed -i 's|#!/usr/bin/env bash|#!/bin/bash|' "{}" \;
|
|
find %{buildroot}%{_libdir}/%{name}/support/* -exec sed -i 's|#!/usr/bin/env bash|#!/bin/bash|' "{}" \;
|
|
%endif
|
|
find %{buildroot}%{_libdir}/%{name} -name \*.py -exec sed -i 's|#!/usr/bin/env python|#!/usr/bin/python|' "{}" \;
|
|
|
|
# jar is packaged with world writable permissions (0100777)
|
|
chmod 644 %{buildroot}%{_libdir}/%{name}/Ghidra/Features/FileFormats/lib/*.jar
|
|
|
|
mkdir %{buildroot}%{_bindir}
|
|
ln -s %{_libdir}/%{name}/ghidraRun %{buildroot}%{_bindir}/%{name}
|
|
ln -s %{_libdir}/%{name}/support/analyzeHeadless %{buildroot}%{_bindir}
|
|
%ifarch aarch64
|
|
ln -s %{_libdir}/%{name}/Ghidra/Features/Decompiler/os/linux_arm_64/decompile %{buildroot}%{_bindir}
|
|
ln -s %{_libdir}/%{name}/Ghidra/Features/Decompiler/os/linux_arm_64/sleigh %{buildroot}%{_bindir}
|
|
%else
|
|
ln -s %{_libdir}/%{name}/Ghidra/Features/Decompiler/os/linux_x86_64/decompile %{buildroot}%{_bindir}
|
|
ln -s %{_libdir}/%{name}/Ghidra/Features/Decompiler/os/linux_x86_64/sleigh %{buildroot}%{_bindir}
|
|
%endif
|
|
|
|
# cspec docs
|
|
(cd Ghidra/Features/Decompiler/src/main/doc;
|
|
sed -i 's|http://docbook.sourceforge.net/release/xsl/current/html/chunk.xsl|/usr/share/xml/docbook/stylesheet/nwalsh5/1.79.2/html/chunk.xsl|' cspec_html.xsl;
|
|
xsltproc cspec_html.xsl cspec.xml;
|
|
mkdir -p %{buildroot}%{_docdir}/%{name}/cspec;
|
|
mv index.html cspec*.html %{buildroot}%{_docdir}/%{name}/cspec)
|
|
|
|
# Decompiler docs
|
|
cp -a Ghidra/Features/Decompiler/build/resources/main/help/topics/DecompilePlugin %{buildroot}%{_docdir}/%{name}
|
|
cp Ghidra/Features/Decompiler/build/resources/main/images/decompileFunction.gif %{buildroot}%{_docdir}/%{name}/DecompilePlugin/images
|
|
cp Ghidra/Framework/Project/build/resources/main/images/* %{buildroot}%{_docdir}/%{name}/DecompilePlugin/images
|
|
cp Ghidra/Features/Base/build/resources/main/images/* %{buildroot}%{_docdir}/%{name}/DecompilePlugin/images || true
|
|
cp Ghidra/Framework/Gui/build/resources/main/images/* %{buildroot}%{_docdir}/%{name}/DecompilePlugin/images
|
|
|
|
# (Windows) FunctionId docs
|
|
(cd Ghidra/Features/FunctionID/src/main/doc;
|
|
mkdir -p %{buildroot}%{_docdir}/%{name}/functionid;
|
|
cp *.html %{buildroot}%{_docdir}/%{name}/functionid)
|
|
|
|
cp DevGuide.md %{buildroot}%{_docdir}/%{name}
|
|
cp Ghidra/RuntimeScripts/Common/support/analyzeHeadlessREADME.md %{buildroot}%{_docdir}/%{name}
|
|
|
|
# executable-docs (Badness: 900)
|
|
chmod -x GhidraDocs/GhidraClass/BSim/*.*
|
|
cp -a GhidraDocs/* %{buildroot}%{_docdir}/%{name}
|
|
rm -f %{buildroot}%{_docdir}/%{name}/*.zip
|
|
|
|
cp -a build/tmp/javadoc %{buildroot}%{_docdir}/%{name}
|
|
|
|
%fdupes %{buildroot}%{_docdir}/%{name}
|
|
|
|
%files
|
|
%defattr(-,root,root)
|
|
%license LICENSE
|
|
%doc README.md
|
|
%doc NOTICE
|
|
%doc DISCLAIMER.md
|
|
%dir %{_libdir}/%{name}
|
|
%{_libdir}/%{name}
|
|
%{_bindir}/*
|
|
%{_datadir}/applications/%{name}.desktop
|
|
%dir %{_iconsdir}/hicolor
|
|
%dir %{_iconsdir}/hicolor/*
|
|
%{_iconsdir}/hicolor/*/GhidraIcon.png
|
|
|
|
%files apidocs
|
|
%defattr(-,root,root)
|
|
%license LICENSE
|
|
%dir %{_docdir}/%{name}
|
|
%{_docdir}/%{name}/api
|
|
|
|
%files javadocs
|
|
%defattr(-,root,root)
|
|
%license LICENSE
|
|
%dir %{_docdir}/%{name}
|
|
%{_docdir}/%{name}/javadoc
|
|
|
|
%files doc
|
|
%defattr(-,root,root)
|
|
%license LICENSE
|
|
%dir %{_docdir}/ghidra
|
|
%exclude %{_docdir}/ghidra/DISCLAIMER.md
|
|
%exclude %{_docdir}/ghidra/NOTICE
|
|
%exclude %{_docdir}/ghidra/README.md
|
|
%exclude %{_docdir}/ghidra/api
|
|
%exclude %{_docdir}/ghidra/javadoc
|
|
%{_docdir}/ghidra/*
|
|
|
|
%changelog
|