google / binexport

Export disassemblies into Protocol Buffers
Apache License 2.0
1.05k stars 206 forks source link

Add support for building in container #80

Open qrkyckling opened 3 years ago

qrkyckling commented 3 years ago

I was trying to build this on a few years old Debian machine and discovered the Gradle version was too old. Rather than reinstall the machine I came up with this one liner to build inside a Docker container and leave the result in same directory.

From the binexport/java directory run: docker run -it --rm -v $PWD:/home/gradle -v $GHIDRA_INSTALL_DIR:/mnt -e GHIDRA_INSTALL_DIR=/mnt gradle:jdk11

Feel free to mention it in the README.md or add a separate Makefile/build.sh if you think it might help someone.

cblichmann commented 3 years ago

Neat, thanks! This is especially useful as I a) didn't know that there are official Gradle Docker containers (kinda obvious in hindsight, duh :-)) and b) we'll have to move to Gradle 7.0+ eventually, which is not in Debian 10.

qrkyckling commented 3 years ago

No problems :-)

I have not tried. But it should also work in a Win10 / WSL2 environment :-) Unless the resulting build contain Linux specific items(due to container) the built item should be installable from Ghidra in Windows as well.

Mostly I find it useful because Debian is usually far behind on versions.

cblichmann commented 7 months ago

I was thinking about something like this Dockerfile:

# Use Gradle Ubuntu 22.04.4 LTS with OpenJDK17 as a base
FROM gradle:8.7-jdk17-jammy

ENV TZ=Europe/Zurich\
    DEBIAN_FRONTEND=noninteractive\
    GHIDRA_INSTALL_DIR=/opt/ghidra

RUN \
    apt-get update && \
    apt-get install -qy --no-install-recommends \
        gnupg \
    && \
    # Clean up to save space
    apt-get clean && \
    rm -rf /var/lib/apt/lists/* && \
    # Install Ghidra
    [ "$(wget -qO - \
            https://github.com/NationalSecurityAgency/ghidra/releases/download/Ghidra_11.0.3_build/ghidra_11.0.3_PUBLIC_20240410.zip | \
            tee ghidra.zip | sha256sum | cut '-d ' -f1)" = \
        "2462a2d0ab11e30f9e907cd3b4aa6b48dd2642f325617e3d922c28e752be6761" ] && \
    unzip -q -d /opt ghidra.zip && \
    mv /opt/ghidra_*_PUBLIC /opt/ghidra && \
    rm ghidra.zip

Enhancement ideas:

cblichmann commented 7 months ago

d45f445 added release artifacts via GitHub Actions (see #127).