Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ghidra: build from source #105636

Closed
wants to merge 1 commit into from
Closed

Conversation

tadfisher
Copy link
Contributor

@tadfisher tadfisher commented Dec 2, 2020

Motivation for this change

ghidra-bin is currently a patched binary release. This change adds a ghidra derivation which builds Ghidra from source using a configuration generated by gradle2nix.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@@ -0,0 +1,70 @@
{ stdenv, fetchzip, lib, makeWrapper, autoPatchelfHook
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{ stdenv, fetchzip, lib, makeWrapper, autoPatchelfHook
{ stdenv, fetchzip, makeWrapper, autoPatchelfHook

lib can be replaced with stdenv.lib.

Comment on lines +15 to +18


in stdenv.mkDerivation rec {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
in stdenv.mkDerivation rec {
in stdenv.mkDerivation rec {


pname = "ghidra";
version = "9.2";
versiondate = "20201113";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please leave a comment here when to update which and where this can be found.

dontStrip = true;

installPhase = ''
mkdir -p "${pkg_path}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
mkdir -p "${pkg_path}"

installPhase = ''
mkdir -p "${pkg_path}"
mkdir -p "${pkg_path}" "$out/share/applications"
cp -a * "${pkg_path}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
cp -a * "${pkg_path}"
cp -a . "${pkg_path}"

Isn't this the same with the difference that yours fails if the path contains 1024 chars of files?

pkg_path = "$out/lib/ghidra";
let

# To update: Install gradle2nix from https://github.com/tadfisher/gradle2nix
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we convert this to a nix-shell comamnd?

];
envSpec = ./gradle-env.json;
nativeBuildInputs = [ bison flex icoutils libarchive makeWrapper ];
buildJdk = jdk;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This variable is not used anywhere and has no special meaning in buildGradle. Please define it in the other derviation as an default input instead of here.

Comment on lines +59 to +64
mkdir -p $sourceRoot/flatRepo
ln -s ${dex2jar}/lib/dex2jar/lib/dex-*.jar $sourceRoot/flatRepo/
ln -s ${axmlprinter2} $sourceRoot/flatRepo/AXMLPrinter2.jar
ln -s ${hfsexplorer}/lib/{csframework.jar,hfsx_dmglib.jar,hfsx.jar,iharder-base64.jar} $sourceRoot/flatRepo/

mkdir -p $sourceRoot/Ghidra/Features/GhidraServer/build/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
mkdir -p $sourceRoot/flatRepo
ln -s ${dex2jar}/lib/dex2jar/lib/dex-*.jar $sourceRoot/flatRepo/
ln -s ${axmlprinter2} $sourceRoot/flatRepo/AXMLPrinter2.jar
ln -s ${hfsexplorer}/lib/{csframework.jar,hfsx_dmglib.jar,hfsx.jar,iharder-base64.jar} $sourceRoot/flatRepo/
mkdir -p $sourceRoot/Ghidra/Features/GhidraServer/build/
mkdir -p $sourceRoot/flatRepo $sourceRoot/Ghidra/Features/GhidraServer/build/
ln -s ${dex2jar}/lib/dex2jar/lib/dex-*.jar $sourceRoot/flatRepo/
ln -s ${axmlprinter2} $sourceRoot/flatRepo/AXMLPrinter2.jar
ln -s ${hfsexplorer}/lib/{csframework.jar,hfsx_dmglib.jar,hfsx.jar,iharder-base64.jar} $sourceRoot/flatRepo/

mkdir -p "${pkg_path}"
mkdir -p "${pkg_path}" "$out/share/applications"
cp -a * "${pkg_path}"
mkdir -p $out/{bin,share/applications,share/ghidra}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
mkdir -p $out/{bin,share/applications,share/ghidra}
mkdir -p $out/bin $out/share/applications $out/share/ghidra

This is easier to read while only marginally longer.

@@ -2184,7 +2184,11 @@ in

gh-ost = callPackage ../tools/misc/gh-ost { };

ghidra-bin = callPackage ../tools/security/ghidra { };
ghidra = callPackage ../tools/security/ghidra {
jdk = jdk11;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make any difference when you overwrite this at runtime? If not this can be removed.

@stale
Copy link

stale bot commented Jul 21, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jul 21, 2021
@tadfisher tadfisher closed this Aug 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants