On Sat, Jun 15, 2019 at 09:26:18PM +0200, Remi Pointel wrote:
> On 6/15/19 4:56 PM, Lawrence Teo wrote:
> > On Tue, May 14, 2019 at 07:59:57PM +0200, Remi Pointel wrote:
> > > On 5/14/19 7:48 PM, Jeremy O'Brien wrote:
> > > > On Tue, May 14, 2019, at 12:43, Anthony J. Bentley wrote:
> > > > > Jeremy O'Brien writes:
> > > > > > I noticed this port was committed today. I have to
> > > > > > ask, did you actually try to use it? In its current
> > > > > > state, (sans my above changes), there is no decompiler
> > > > > > nor symbol demangler. This might have been OK to omit,
> > > > > > except for the fact that you will get a "Could not
> > > > > > find decompiler executable decompile" popup every
> > > > > > single time you click anywhere in the disassembly pane,
> > > > > > which makes this port unusable.
> > > > > 
> > > > > Indeed they are very annoying. I agree the port is not
> > > > > "finished." But I've used Ghidra to do some minor work despite that, 
> > > > > so
> > > > > I'm happy to see it in. Revising the port to add the native tools 
> > > > > would
> > > > > be very welcome though.
> > > > > 
> > > > > 
> > > > 
> > > > If you're willing to compile it yourself, my MR here: 
> > > > https://github.com/NationalSecurityAgency/ghidra/pull/490 makes the 
> > > > native components build perfectly in OpenBSD. Just follow the ghidra 
> > > > DevGuide.md instructions after applying the patch. I also have my 
> > > > personal build here (but that of course requires that you trust a 
> > > > stranger on the internet): 
> > > > https://pintobyte.com/tmp/ghidra_9.1-DEV_PUBLIC_20190513_openbsd64.zip 
> > > > if you don't feel like compiling but want the "full" ghidra experience. 
> > > > I do like that the current ghidra port requires no compilation, as the 
> > > > compilation process is a bit heavy-handed and takes some time to 
> > > > complete, but I personally would prefer to see a fully-working port 
> > > > over a fast-installing one.
> > > > 
> > > 
> > > Thank you for feedback, I will try your patch to build ghidra and I will 
> > > let
> > > you know.
> > > If you are motivated, you can send a diff that applies on the ghidra port 
> > > to
> > > integrate your work.
> > > 
> > > Cheers,
> > > 
> > > Remi.
> > > 
> > 
> > Here's my attempt to update Ghidra to add a native decompiler for
> > OpenBSD.  I created the patches based on Jeremy's pull request and used
> > https://github.com/NationalSecurityAgency/ghidra/blob/master/DevGuide.md
> > to figure out the build steps.
> > 
> > I also did the following to make it build and conform to OpenBSD port
> > conventions:
> > 
> > 1. Ghidra is built using Gradle so I have attached a new port for
> >     devel/gradle 5.4.1.
> > 
> > 2. DevGuide.md says they built Ghidra with Gradle 5.0 but I was able to
> >     build it successfully with Gradle 5.4.1.
> > 
> > 3. To prevent the build process from touching $HOME, I made gradle use
> >     ${WRKDIR}/gradle as its home and also modified GHelpBuilder.java
> >     (the program that builds help files during build) to log to ${WRKDIR}
> >     instead of $HOME/.ghidra.
> > 
> > 4. One of the Gradle scripts (ip.gradle) scans the Ghidra source tree so
> >     I had to explicitly tell it to exclude *.orig and *.beforesubst.
> > 
> > 5. The port has to be built with a high `ulimit -d` (I set it to
> >     `ulimit -Hd` which on my system is 33554432).
> > 
> > Using the resulting package I was able to decompile programs without
> > encountering the "Could not find decompiler executable decompile" popup.
> > 
> > Tests/reviews/feedback welcome! :)
> 
> Hi,
> 
> quickly tested and sounds good to me, thanks a lot for your work.
> 
> Cheers,
> 
> Remi.

Remi, thank you for testing!

Here is an updated diff now that Gradle has been imported.

The only change is the BUILD_DEPENDS for Gradle which I've changed from
devel/gradle to java/gradle.

ok?
Index: Makefile
===================================================================
RCS file: /cvs/ports/security/ghidra/Makefile,v
retrieving revision 1.3
diff -u -p -r1.3 Makefile
--- Makefile    11 Jun 2019 00:38:36 -0000      1.3
+++ Makefile    17 Jun 2019 00:58:58 -0000
@@ -6,9 +6,14 @@ ONLY_FOR_ARCHS =       amd64
 COMMENT =      software reverse engineering (SRE) framework
 
 VERSION =      9.0.4
-REVISION =     0
-DISTNAME =     ghidra_9.0.4_PUBLIC_20190516
-PKGNAME =      ghidra-${VERSION}
+GHIDRA_DATE =  20190516
+YAJSW_VER =    12.12
+REVISION =     1
+
+GH_ACCOUNT =   NationalSecurityAgency
+GH_PROJECT =   ghidra
+GH_TAGNAME =   Ghidra_${VERSION}_build
+DISTNAME =     ghidra-${VERSION}
 
 CATEGORIES =   security
 
@@ -17,32 +22,85 @@ HOMEPAGE =  https://www.ghidra-sre.org/
 MAINTAINER =   Remi Pointel <rpoin...@openbsd.org>
 
 # Apache v2
-PERMIT_PACKAGE_CDROM = Yes
+PERMIT_PACKAGE =       Yes
 
-MASTER_SITES =         ${HOMEPAGE}
+WANTLIB +=     c m stdc++
+
+MASTER_SITES0 =                ${HOMEPAGE}
+MASTER_SITES1 =                
https://sourceforge.net/projects/yajsw/files/yajsw/yajsw-stable-${YAJSW_VER}/
 
 EXTRACT_SUFX =         .zip
 
+DISTFILES =            ${DISTNAME}.tar.gz
+DISTFILES +=           ghidra_${VERSION}_PUBLIC_${GHIDRA_DATE}${EXTRACT_SUFX}:0
+DISTFILES +=           yajsw-stable-${YAJSW_VER}${EXTRACT_SUFX}:1
+
+EXTRACT_ONLY =         ${DISTNAME}.tar.gz
+
 MODULES =              java
 MODJAVA_VER =          11+
 
+BUILD_DEPENDS =                devel/bison \
+                       java/gradle \
+                       shells/bash
+
 RUN_DEPENDS =          shells/bash \
                        java/javaPathHelper
 
-NO_BUILD =             Yes
 NO_TEST =              Yes
 
-WRKDIST =      ${WRKDIR}/${PKGNAME:S/-/_/}
+SUBST_VARS +=          GHIDRA_DATE VERSION WRKDIR
 
 post-extract:
        @perl -pi -e 's,#!/bin/bash,#!${LOCALBASE}/bin/bash,' \
-               ${WRKSRC}/ghidraRun
+               ${WRKSRC}/Ghidra/RuntimeScripts/Linux/ghidraRun
+       @perl -pi -e 's,#!/bin/bash,#!${LOCALBASE}/bin/bash,' \
+               ${WRKSRC}/Ghidra/RuntimeScripts/Linux/support/launch.sh
        @perl -pi -e 's,#!/bin/bash,#!${LOCALBASE}/bin/bash,' \
-               ${WRKSRC}/support/launch.sh
+               ${WRKSRC}/Ghidra/RuntimeScripts/Linux/support/launch.sh
+       @perl -pi -e 's,(application.version)=.*,\1=${VERSION},' \
+               ${WRKSRC}/Ghidra/application.properties
+
+# Steps derived from:
+# https://github.com/NationalSecurityAgency/ghidra/blob/master/DevGuide.md
+pre-build:
+       cp ${FILESDIR}/repos.gradle ${WRKDIR}
+       ${SUBST_CMD} ${WRKDIR}/repos.gradle \
+               
${WRKSRC}/Ghidra/Framework/Help/src/main/java/help/GHelpBuilder.java
+       mkdir ${WRKDIR}/flatRepo
+.for name in dex-ir-2.0 dex-reader-2.0 dex-reader-api-2.0 dex-translator-2.0 
AXMLPrinter2
+       unzip -j ${DISTDIR}/ghidra_${VERSION}_PUBLIC_${GHIDRA_DATE}.zip \
+               -d ${WRKDIR}/flatRepo \
+               ghidra_${VERSION}/Ghidra/Features/FileFormats/lib/${name}.jar
+.endfor
+.for name in csframework hfsx_dmglib hfsx iharder-base64
+       cp ${WRKSRC}/GPL/DMG/data/lib/catacombae_${name}.jar \
+               ${WRKDIR}/flatRepo/${name}.jar
+.endfor
+       mkdir -p ${WRKDIR}/ghidra.bin/Ghidra/Features/GhidraServer
+       cp ${DISTDIR}/yajsw-stable-${YAJSW_VER}.zip \
+               ${WRKDIR}/ghidra.bin/Ghidra/Features/GhidraServer
+       mkdir ${WRKDIR}/gradle ${WRKDIR}/home
+       cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} gradle -g ${WRKDIR}/gradle \
+               --no-daemon -I ${WRKDIR}/repos.gradle yajswDevUnpack
+
+do-build:
+       cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} gradle -g ${WRKDIR}/gradle \
+               --no-daemon -I ${WRKDIR}/repos.gradle buildGhidra
 
 do-install:
-       ${INSTALL_DATA_DIR} ${PREFIX}/share/java/ghidra
-       cp -r ${WRKSRC}/*  ${PREFIX}/share/java/ghidra/
+       ${INSTALL_DATA_DIR} ${PREFIX}/share/java
+       unzip -d ${PREFIX}/share/java \
+               ${WRKSRC}/build/dist/ghidra_${VERSION}_PUBLIC_*_openbsd64.zip
+       mv ${PREFIX}/share/java/ghidra_${VERSION} ${PREFIX}/share/java/ghidra
+       mv 
${PREFIX}/share/java/ghidra/Extensions/Ghidra/ghidra_${VERSION}_PUBLIC_*_SampleTablePlugin.zip
 \
+               
${PREFIX}/share/java/ghidra/Extensions/Ghidra/ghidra_${VERSION}_PUBLIC_${GHIDRA_DATE}_SampleTablePlugin.zip
+       mv 
${PREFIX}/share/java/ghidra/Extensions/Ghidra/ghidra_${VERSION}_PUBLIC_*_sample.zip
 \
+               
${PREFIX}/share/java/ghidra/Extensions/Ghidra/ghidra_${VERSION}_PUBLIC_${GHIDRA_DATE}_sample.zip
+       ${INSTALL_SCRIPT} ${WRKSRC}/Ghidra/RuntimeScripts/Linux/ghidraRun \
+               ${PREFIX}/share/java/ghidra/ghidraRun
        ln -s ${TRUEPREFIX}/share/java/ghidra/ghidraRun ${PREFIX}/bin/ghidraRun
+       ${INSTALL_SCRIPT} 
${WRKSRC}/Ghidra/RuntimeScripts/Linux/support/launch.sh \
+               ${PREFIX}/share/java/ghidra/support/launch.sh
 
 .include <bsd.port.mk>
Index: distinfo
===================================================================
RCS file: /cvs/ports/security/ghidra/distinfo,v
retrieving revision 1.2
diff -u -p -r1.2 distinfo
--- distinfo    26 May 2019 02:07:44 -0000      1.2
+++ distinfo    17 Jun 2019 00:58:58 -0000
@@ -1,2 +1,6 @@
+SHA256 (ghidra-9.0.4.tar.gz) = 4kWT+0zz4dG3qN/q6F7fup/Z1EazYMel0S6WQEOHNeM=
 SHA256 (ghidra_9.0.4_PUBLIC_20190516.zip) = 
pQ0M1HXZN3MygR7q5m6Uvcnn2I5YR3xSfpxreMrsGL8=
+SHA256 (yajsw-stable-12.12.zip) = E5j8sek6uxmZLE+gbX/ldYqrtMRXgdfvMGxvV8p6cyE=
+SIZE (ghidra-9.0.4.tar.gz) = 59223815
 SIZE (ghidra_9.0.4_PUBLIC_20190516.zip) = 298503610
+SIZE (yajsw-stable-12.12.zip) = 25051676
Index: files/repos.gradle
===================================================================
RCS file: files/repos.gradle
diff -N files/repos.gradle
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ files/repos.gradle  17 Jun 2019 00:58:58 -0000
@@ -0,0 +1,7 @@
+allprojects {
+       repositories {
+               mavenCentral()
+               jcenter()
+               flatDir name:'flat', dirs:["${WRKDIR}/flatRepo"]
+       }
+}
Index: patches/patch-GPL_CabExtract_build_gradle
===================================================================
RCS file: patches/patch-GPL_CabExtract_build_gradle
diff -N patches/patch-GPL_CabExtract_build_gradle
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-GPL_CabExtract_build_gradle   17 Jun 2019 00:58:58 -0000
@@ -0,0 +1,14 @@
+$OpenBSD$
+
+Index: GPL/CabExtract/build.gradle
+--- GPL/CabExtract/build.gradle.orig
++++ GPL/CabExtract/build.gradle
+@@ -40,7 +40,7 @@ project.ext.cabextract = "cabextract-1.6"
+  *
+  * The cabextract tool requires that its 'configure' script is called before 
make.
+  
*********************************************************************************/
+-['linux64', 'osx64'].each { platform ->
++['linux64', 'osx64', 'openbsd64'].each { platform ->
+               
+       def configureName = "${platform}CabExtractConfigure"
+       def makeName = "${platform}CabExtractMake" // native Make task found 
automatically
Index: patches/patch-GPL_DemanglerGnu_Module_manifest
===================================================================
RCS file: patches/patch-GPL_DemanglerGnu_Module_manifest
diff -N patches/patch-GPL_DemanglerGnu_Module_manifest
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-GPL_DemanglerGnu_Module_manifest      17 Jun 2019 00:58:58 
-0000
@@ -0,0 +1,12 @@
+$OpenBSD$
+
+Index: GPL/DemanglerGnu/Module.manifest
+--- GPL/DemanglerGnu/Module.manifest.orig
++++ GPL/DemanglerGnu/Module.manifest
+@@ -1,3 +1,4 @@
+ MODULE FILE LICENSE: os/linux64/demangler_gnu GPL 3
+ MODULE FILE LICENSE: os/osx64/demangler_gnu GPL 3
+-MODULE FILE LICENSE: os/win64/demangler_gnu.exe GPL 3
+\ No newline at end of file
++MODULE FILE LICENSE: os/openbsd64/demangler_gnu GPL 3
++MODULE FILE LICENSE: os/win64/demangler_gnu.exe GPL 3
Index: patches/patch-GPL_DemanglerGnu_build_gradle
===================================================================
RCS file: patches/patch-GPL_DemanglerGnu_build_gradle
diff -N patches/patch-GPL_DemanglerGnu_build_gradle
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-GPL_DemanglerGnu_build_gradle 17 Jun 2019 00:58:58 -0000
@@ -0,0 +1,24 @@
+$OpenBSD$
+
+Index: GPL/DemanglerGnu/build.gradle
+--- GPL/DemanglerGnu/build.gradle.orig
++++ GPL/DemanglerGnu/build.gradle
+@@ -24,6 +24,10 @@ model {
+                       architecture 'x86_64'
+                       operatingSystem 'osx'
+               }
++              openbsd64 {
++                      architecture 'x86_64'
++                      operatingSystem 'openbsd'
++              }
+       }       
+ }
+ 
+@@ -64,6 +68,7 @@ model {
+                       targetPlatform "win64"
+                       targetPlatform "linux64"
+                       targetPlatform "osx64"
++                      targetPlatform "openbsd64"
+                       sources {
+                               c {
+                                       source {
Index: patches/patch-GPL_nativeBuildProperties_gradle
===================================================================
RCS file: patches/patch-GPL_nativeBuildProperties_gradle
diff -N patches/patch-GPL_nativeBuildProperties_gradle
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-GPL_nativeBuildProperties_gradle      17 Jun 2019 00:58:58 
-0000
@@ -0,0 +1,16 @@
+$OpenBSD$
+
+Index: GPL/nativeBuildProperties.gradle
+--- GPL/nativeBuildProperties.gradle.orig
++++ GPL/nativeBuildProperties.gradle
+@@ -75,6 +75,10 @@ model {
+                       architecture 'x86_64'
+                       operatingSystem 'osx'
+               }
++              openbsd64 {
++                      architecture 'x86_64'
++                      operatingSystem 'openbsd'
++              }
+       }       
+ }
+ 
Index: patches/patch-Ghidra_Features_Decompiler_build_gradle
===================================================================
RCS file: patches/patch-Ghidra_Features_Decompiler_build_gradle
diff -N patches/patch-Ghidra_Features_Decompiler_build_gradle
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-Ghidra_Features_Decompiler_build_gradle       17 Jun 2019 
00:58:58 -0000
@@ -0,0 +1,48 @@
+$OpenBSD$
+
+Index: Ghidra/Features/Decompiler/build.gradle
+--- Ghidra/Features/Decompiler/build.gradle.orig
++++ Ghidra/Features/Decompiler/build.gradle
+@@ -74,9 +74,9 @@ def buildDir = "../../../build"
+ task buildDecompilerDocumentationPdfs(type: Exec) {
+ 
+       // Check the OS before enabling task.
+-      if (!(org.gradle.internal.os.OperatingSystem.current().isLinux() 
+-              || 
org.gradle.internal.os.OperatingSystem.current().isMacOsX())) {
+-                      println "The '$it.name' task only works on Linux or Mac 
Os X and is therefore disabled."
++      String osName = System.getProperty("os.name")
++      if (!(isLinux(osName) || isMac(osName) || isOpenBSD(osName))) {
++                      println "The '$it.name' task only works on Linux, Mac 
OS X, or OpenBSD and is therefore disabled."
+                       it.enabled = false
+       }
+ 
+@@ -206,10 +206,10 @@ task buildDecompilerDocumentationHtml(type: Exec) {
+ 
+               // Check the OS before executing command.
+               doFirst {
+-                      if ( 
!(org.gradle.internal.os.OperatingSystem.current().isLinux() 
+-                              || 
org.gradle.internal.os.OperatingSystem.current().isMacOsX())) {
++                      String osName = System.getProperty("os.name")
++                      if ( !(isLinux(osName) || isMac(osName) || 
isOpenBSD(osName)) ) {
+                               throw new TaskExecutionException( it,
+-                                      new Exception( "The '$it.name' task 
only works on Linux or Mac Os X" ))
++                                      new Exception( "The '$it.name' task 
only works on Linux, Mac OS X, or OpenBSD" ))
+                       }
+               }
+ 
+@@ -245,6 +245,7 @@ model {
+                       targetPlatform "win64"
+                       targetPlatform "linux64"
+                       targetPlatform "osx64"
++                      targetPlatform "openbsd64"
+                       sources {
+                               cpp {
+                           source {
+@@ -342,6 +343,7 @@ model {
+                       targetPlatform "win64"
+                       targetPlatform "linux64"
+                       targetPlatform "osx64"
++                      targetPlatform "openbsd64"
+                       sources {
+                               cpp {
+                                       source {
Index: patches/patch-Ghidra_Features_Decompiler_src_decompile_cpp_Makefile
===================================================================
RCS file: patches/patch-Ghidra_Features_Decompiler_src_decompile_cpp_Makefile
diff -N patches/patch-Ghidra_Features_Decompiler_src_decompile_cpp_Makefile
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-Ghidra_Features_Decompiler_src_decompile_cpp_Makefile 17 Jun 
2019 00:58:58 -0000
@@ -0,0 +1,19 @@
+$OpenBSD$
+
+Index: Ghidra/Features/Decompiler/src/decompile/cpp/Makefile
+--- Ghidra/Features/Decompiler/src/decompile/cpp/Makefile.orig
++++ Ghidra/Features/Decompiler/src/decompile/cpp/Makefile
+@@ -33,6 +33,13 @@ ifeq ($(OS),Darwin)
+   OSDIR=osx64
+ endif
+ 
++ifeq ($(OS),OpenBSD)
++ifeq ($(ARCH),x86_64)
++  ARCH_TYPE=-m64
++  OSDIR=openbsd64
++endif
++endif
++
+ CC=gcc
+ CXX=g++
+ 
Index: patches/patch-Ghidra_Features_Decompiler_src_decompile_cpp_types_h
===================================================================
RCS file: patches/patch-Ghidra_Features_Decompiler_src_decompile_cpp_types_h
diff -N patches/patch-Ghidra_Features_Decompiler_src_decompile_cpp_types_h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-Ghidra_Features_Decompiler_src_decompile_cpp_types_h  17 Jun 
2019 00:58:58 -0000
@@ -0,0 +1,15 @@
+$OpenBSD$
+
+Index: Ghidra/Features/Decompiler/src/decompile/cpp/types.h
+--- Ghidra/Features/Decompiler/src/decompile/cpp/types.h.orig
++++ Ghidra/Features/Decompiler/src/decompile/cpp/types.h
+@@ -86,7 +86,8 @@ typedef char int1;
+ typedef uint4 uintp;
+ #endif
+ 
+-#if defined (__linux__) && defined (__x86_64__)
++#if defined (__linux__) && defined (__x86_64__) || \
++    (defined (__OpenBSD__) && defined (__x86_64__))
+ #define HOST_ENDIAN 0
+ typedef unsigned int uintm;
+ typedef int intm;
Index: patches/patch-Ghidra_Features_FunctionID_build_gradle
===================================================================
RCS file: patches/patch-Ghidra_Features_FunctionID_build_gradle
diff -N patches/patch-Ghidra_Features_FunctionID_build_gradle
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-Ghidra_Features_FunctionID_build_gradle       17 Jun 2019 
00:58:58 -0000
@@ -0,0 +1,19 @@
+$OpenBSD$
+
+Index: Ghidra/Features/FunctionID/build.gradle
+--- Ghidra/Features/FunctionID/build.gradle.orig
++++ Ghidra/Features/FunctionID/build.gradle
+@@ -93,10 +93,10 @@ task buildFidDocumentationPdf(type: Exec) {
+ 
+       // Check the OS before executing command.
+       doFirst {
+-              if ( 
!(org.gradle.internal.os.OperatingSystem.current().isLinux() 
+-                      || 
org.gradle.internal.os.OperatingSystem.current().isMacOsX())) {
++              String osName = System.getProperty("os.name")
++              if ( !(isLinux(osName) || isMac(osName) || isOpenBSD(osName))) {
+                       throw new TaskExecutionException( it,
+-                              new Exception( "The '$it.name' task only works 
on Linux or Mac Os X" ))
++                              new Exception( "The '$it.name' task only works 
on Linux, Mac OS X, or OpenBSD" ))
+               }
+       }
+ 
Index: 
patches/patch-Ghidra_Framework_Generic_src_main_java_ghidra_framework_Platform_java
===================================================================
RCS file: 
patches/patch-Ghidra_Framework_Generic_src_main_java_ghidra_framework_Platform_java
diff -N 
patches/patch-Ghidra_Framework_Generic_src_main_java_ghidra_framework_Platform_java
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ 
patches/patch-Ghidra_Framework_Generic_src_main_java_ghidra_framework_Platform_java
 17 Jun 2019 00:58:58 -0000
@@ -0,0 +1,41 @@
+$OpenBSD$
+
+Index: Ghidra/Framework/Generic/src/main/java/ghidra/framework/Platform.java
+--- Ghidra/Framework/Generic/src/main/java/ghidra/framework/Platform.java.orig
++++ Ghidra/Framework/Generic/src/main/java/ghidra/framework/Platform.java
+@@ -71,6 +71,21 @@ public enum Platform {
+       MAC_UNKNOWN(OperatingSystem.MAC_OS_X, Architecture.UNKNOWN, "osx64", 
".dylib", ""),
+ 
+       /**
++       * Identifies an OpenBSD OS for the Intel x86 32-bit platform.
++       */
++      OPENBSD(OperatingSystem.OPENBSD, Architecture.X86, "openbsd32", ".so", 
""),
++
++      /**
++       * Identifies an OpenBSD OS for the Intel x86 64-bit platform.
++       */
++      OPENBSD_64(OperatingSystem.OPENBSD, Architecture.X86_64, "openbsd64", 
".so", ""),
++
++      /**
++       * Identifies an OpenBSD OS, the architecture for which we do not know 
or have not encountered
++       */
++      OPENBSD_UNKNOWN(OperatingSystem.OPENBSD, Architecture.UNKNOWN, 
"openbsd32", ".so", ""),
++
++      /**
+        * Identifies an unsupported OS.
+        */
+       UNSUPPORTED(OperatingSystem.UNSUPPORTED, Architecture.UNKNOWN, null, 
null, "");
+@@ -140,6 +155,13 @@ public enum Platform {
+               if (operatingSystem == OperatingSystem.LINUX) {
+                       paths.add("/bin");
+                       paths.add("/lib");
++                      paths.add("/usr/bin");
++                      paths.add("/usr/lib");
++                      paths.add("/usr/X11R6/bin");
++                      paths.add("/usr/X11R6/lib");
++              }
++              else if (operatingSystem == OperatingSystem.OPENBSD) {
++                      paths.add("/bin");
+                       paths.add("/usr/bin");
+                       paths.add("/usr/lib");
+                       paths.add("/usr/X11R6/bin");
Index: patches/patch-Ghidra_Framework_Help_src_main_java_help_GHelpBuilder_java
===================================================================
RCS file: 
patches/patch-Ghidra_Framework_Help_src_main_java_help_GHelpBuilder_java
diff -N patches/patch-Ghidra_Framework_Help_src_main_java_help_GHelpBuilder_java
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-Ghidra_Framework_Help_src_main_java_help_GHelpBuilder_java    
17 Jun 2019 00:58:58 -0000
@@ -0,0 +1,24 @@
+$OpenBSD$
+
+GHelpBuilder.java builds the Ghidra help files during build and it logs to
+$HOME/.ghidra/.ghidra-${VERSION}/application.log.  The 
GhidraApplicationLayout()
+constructor calls ApplicationUtilities.getDefaultUserSettingsDir() which in 
turn
+uses System.getproperty("user.home") to form the above path to application.log.
+
+To prevent $HOME from being touched during build, this patch changes user.home
+to ${WRKDIR}/home before the GhidraApplicationLayout() constructor is called so
+that logging goes to ${WRKDIR}/home/.ghidra/.ghidra-${VERSION}/application.log
+instead.
+
+Index: Ghidra/Framework/Help/src/main/java/help/GHelpBuilder.java
+--- Ghidra/Framework/Help/src/main/java/help/GHelpBuilder.java.orig
++++ Ghidra/Framework/Help/src/main/java/help/GHelpBuilder.java
+@@ -68,6 +68,8 @@ public class GHelpBuilder {
+               builder.exitOnError = true;
+ 
+               ApplicationConfiguration config = new 
ApplicationConfiguration();
++
++              System.setProperty("user.home", "${WRKDIR}/home");
+               Application.initializeApplication(new 
GhidraApplicationLayout(), config);
+ 
+               builder.build(args);
Index: 
patches/patch-Ghidra_Framework_Utility_src_main_java_ghidra_framework_OperatingSystem_java
===================================================================
RCS file: 
patches/patch-Ghidra_Framework_Utility_src_main_java_ghidra_framework_OperatingSystem_java
diff -N 
patches/patch-Ghidra_Framework_Utility_src_main_java_ghidra_framework_OperatingSystem_java
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ 
patches/patch-Ghidra_Framework_Utility_src_main_java_ghidra_framework_OperatingSystem_java
  17 Jun 2019 00:58:58 -0000
@@ -0,0 +1,13 @@
+$OpenBSD$
+
+Index: 
Ghidra/Framework/Utility/src/main/java/ghidra/framework/OperatingSystem.java
+--- 
Ghidra/Framework/Utility/src/main/java/ghidra/framework/OperatingSystem.java.orig
++++ 
Ghidra/Framework/Utility/src/main/java/ghidra/framework/OperatingSystem.java
+@@ -20,6 +20,7 @@ public enum OperatingSystem {
+       WINDOWS("Windows"),
+       LINUX("Linux"),
+       MAC_OS_X("Mac OS X"),
++      OPENBSD("OpenBSD"),
+       UNSUPPORTED("Unsupported Operating System");
+ 
+       /**
Index: patches/patch-Ghidra_RuntimeScripts_Linux_support_launch_sh
===================================================================
RCS file: patches/patch-Ghidra_RuntimeScripts_Linux_support_launch_sh
diff -N patches/patch-Ghidra_RuntimeScripts_Linux_support_launch_sh
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-Ghidra_RuntimeScripts_Linux_support_launch_sh 17 Jun 2019 
00:58:58 -0000
@@ -0,0 +1,30 @@
+$OpenBSD$
+
+Index: Ghidra/RuntimeScripts/Linux/support/launch.sh
+--- Ghidra/RuntimeScripts/Linux/support/launch.sh.orig
++++ Ghidra/RuntimeScripts/Linux/support/launch.sh
+@@ -89,13 +89,13 @@ else
+ fi
+ 
+ # Make sure some kind of java is on the path.  It's required to run the 
LaunchSupport program.
+-if ! [ -x "$(command -v java)" ] ; then
++if ! [ -x "$(javaPathHelper -c ghidra)" ] ; then
+       echo "Java runtime not found.  Please refer to the Ghidra Installation 
Guide's Troubleshooting section."
+       exit 1
+ fi
+ 
+ # Get the JDK that will be used to launch Ghidra
+-JAVA_HOME="$(java -cp "${LS_CPATH}" LaunchSupport "${INSTALL_DIR}" -jdk_home 
-save)"
++JAVA_HOME="$(javaPathHelper -h ghidra)"
+ if [ ! $? -eq 0 ]; then
+       # No JDK has been setup yet.  Let the user choose one.
+       java -cp "${LS_CPATH}" LaunchSupport "${INSTALL_DIR}" -jdk_home -ask
+@@ -111,7 +111,7 @@ fi
+ JAVA_CMD="${JAVA_HOME}/bin/java"
+ 
+ # Get the configurable VM arguments from the launch properties
+-VMARG_LIST+=" $(java -cp "${LS_CPATH}" LaunchSupport "${INSTALL_DIR}" 
-vmargs)"
++VMARG_LIST+=" $("${JAVA_CMD}" -cp "${LS_CPATH}" LaunchSupport 
"${INSTALL_DIR}" -vmargs)"
+ 
+ # Add extra macOS VM arguments
+ if [ "$(uname -s)" = "Darwin" ]; then
Index: patches/patch-build_gradle
===================================================================
RCS file: patches/patch-build_gradle
diff -N patches/patch-build_gradle
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-build_gradle  17 Jun 2019 00:58:58 -0000
@@ -0,0 +1,64 @@
+$OpenBSD$
+
+Disable the Gradle check because we are using a later version of Gradle to 
build
+Ghidra.
+
+Index: build.gradle
+--- build.gradle.orig
++++ build.gradle
+@@ -4,13 +4,6 @@ apply from: "gradleScripts/eclipseLauncher.gradle"
+ 
+ 
+ 
/***************************************************************************************
+- * Make sure the correct version of gradle is being used
+- 
***************************************************************************************/
+-if (gradle.gradleVersion != "5.0") {
+-      throw new GradleException("Requires Gradle 5.0, but was run with 
$gradle.gradleVersion")
+-}
+-
+-/***************************************************************************************
+  * Define the location of JAVA_HOME
+  
***************************************************************************************/
+ if (System.env.JAVA_HOME) {
+@@ -58,7 +51,7 @@ apply from: "gradleScripts/setupJacoco.gradle" // Has 
+  *            project.OS_NAMES.each {...}
+  ****************************************************************************/
+ 
+-project.ext.set("OS_NAMES", ["osx64", "win32", "win64", "linux64"])
++project.ext.set("OS_NAMES", ["osx64", "win32", "win64", "linux64", 
"openbsd64"])
+ 
+ 
/*********************************************************************************
+  * Imports
+@@ -120,7 +113,20 @@ def isMac(String platformName) {
+       }
+ }
+ 
++/*********************************************************************************
++ * Returns true if the platform is an OpenBSD machine
++ 
*********************************************************************************/
++def isOpenBSD(String platformName) {
+ 
++      if (platformName.toLowerCase().startsWith("openbsd")) {
++              return true
++      }
++      else {
++              return false
++      }
++}
++
++
+ 
/*********************************************************************************
+  * Returns true if the platform is a Windows machine.
+  
*********************************************************************************/
+@@ -278,6 +284,11 @@ String getCurrentPlatformName() {
+       else if (osName.startsWith("Mac OS X")) {
+               if (isX86_64) {
+                       return 'osx64'
++              }
++      }
++      else if (osName.startsWith("OpenBSD")) {
++              if (isX86_64) {
++                      return 'openbsd64'
+               }
+       }
+       throw new GradleException("Unrecognized current platform -> osName = 
$osName, archName = $archName")
Index: patches/patch-gradleScripts_distribution_gradle
===================================================================
RCS file: patches/patch-gradleScripts_distribution_gradle
diff -N patches/patch-gradleScripts_distribution_gradle
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-gradleScripts_distribution_gradle     17 Jun 2019 00:58:58 
-0000
@@ -0,0 +1,13 @@
+$OpenBSD$
+
+Index: gradleScripts/distribution.gradle
+--- gradleScripts/distribution.gradle.orig
++++ gradleScripts/distribution.gradle
+@@ -987,6 +987,7 @@ task createMultiPlatformInstallationZip(type: Zip) { t
+       dependsOn ":assemblewin64"
+       dependsOn ":assemblelinux64"
+       dependsOn ":assembleosx64"
++      dependsOn ":assembleopenbsd64"
+       dependsOn ":assembleSourceCommon"
+ 
+       addDecompilerPdfsToZip(t)
Index: patches/patch-gradleScripts_ip_gradle
===================================================================
RCS file: patches/patch-gradleScripts_ip_gradle
diff -N patches/patch-gradleScripts_ip_gradle
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-gradleScripts_ip_gradle       17 Jun 2019 00:58:58 -0000
@@ -0,0 +1,25 @@
+$OpenBSD$
+
+Explicitly exclude *.orig and *.beforesubst files left behind by our patch to
+prevent getIpForModule() from breaking like this:
+
+* Where:
+Script 
'/usr/ports/pobj/ghidra-9.0.4/ghidra-Ghidra_9.0.4_build/gradleScripts/ip.gradle'
 line: 131
+
+* What went wrong:
+Execution failed for task ':CabExtract:ip'.
+> No IP found for 
/usr/ports/pobj/ghidra-9.0.4/ghidra-Ghidra_9.0.4_build/GPL/CabExtract/build.gradle.orig
 in module: /usr/ports/pobj/ghidra-9.0.4/ghidra-Ghidra_9.0.4_build
+/GPL/CabExtract. Expression: (ip != null). Values: ip = null
+
+Index: gradleScripts/ip.gradle
+--- gradleScripts/ip.gradle.orig
++++ gradleScripts/ip.gradle
+@@ -125,6 +125,8 @@ def Map<String, List<String>> getIpForModule(Project p
+               exclude "**/.settings/**"
+               exclude "**/.vs/**"
+               exclude "**/*.vcxproj.user"
++              exclude "**/*.orig"
++              exclude "**/*.beforesubst"
+       }
+       tree.each { file ->
+                       String ip = getIp(p.projectDir, file)
Index: patches/patch-support_launch_sh
===================================================================
RCS file: patches/patch-support_launch_sh
diff -N patches/patch-support_launch_sh
--- patches/patch-support_launch_sh     14 May 2019 07:01:32 -0000      1.1.1.1
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,30 +0,0 @@
-$OpenBSD: patch-support_launch_sh,v 1.1.1.1 2019/05/14 07:01:32 rpointel Exp $
-
-Index: support/launch.sh
---- support/launch.sh.orig
-+++ support/launch.sh
-@@ -89,13 +89,13 @@ else
- fi
- 
- # Make sure some kind of java is on the path.  It's required to run the 
LaunchSupport program.
--if ! [ -x "$(command -v java)" ] ; then
-+if ! [ -x "$(javaPathHelper -c ghidra)" ] ; then
-       echo "Java runtime not found.  Please refer to the Ghidra Installation 
Guide's Troubleshooting section."
-       exit 1
- fi
- 
- # Get the JDK that will be used to launch Ghidra
--JAVA_HOME="$(java -cp "${LS_CPATH}" LaunchSupport "${INSTALL_DIR}" -jdk_home 
-save)"
-+JAVA_HOME="$(javaPathHelper -h ghidra)"
- if [ ! $? -eq 0 ]; then
-       # No JDK has been setup yet.  Let the user choose one.
-       java -cp "${LS_CPATH}" LaunchSupport "${INSTALL_DIR}" -jdk_home -ask
-@@ -111,7 +111,7 @@ fi
- JAVA_CMD="${JAVA_HOME}/bin/java"
- 
- # Get the configurable VM arguments from the launch properties
--VMARG_LIST+=" $(java -cp "${LS_CPATH}" LaunchSupport "${INSTALL_DIR}" 
-vmargs)"
-+VMARG_LIST+=" $("${JAVA_CMD}" -cp "${LS_CPATH}" LaunchSupport 
"${INSTALL_DIR}" -vmargs)"
- 
- # Add extra macOS VM arguments
- if [ "$(uname -s)" = "Darwin" ]; then
Index: pkg/PLIST
===================================================================
RCS file: /cvs/ports/security/ghidra/pkg/PLIST,v
retrieving revision 1.2
diff -u -p -r1.2 PLIST
--- pkg/PLIST   26 May 2019 02:07:44 -0000      1.2
+++ pkg/PLIST   17 Jun 2019 00:58:58 -0000
@@ -5,7 +5,6 @@ share/java/ghidra/
 share/java/ghidra/Extensions/
 share/java/ghidra/Extensions/Eclipse/
 share/java/ghidra/Extensions/Eclipse/GhidraDev/
-share/java/ghidra/Extensions/Eclipse/GhidraDev/GhidraDev-2.0.1.zip
 share/java/ghidra/Extensions/Eclipse/GhidraDev/GhidraDev_README.html
 share/java/ghidra/Extensions/Ghidra/
 share/java/ghidra/Extensions/Ghidra/Skeleton/
@@ -57,8 +56,8 @@ share/java/ghidra/Extensions/Ghidra/Skel
 share/java/ghidra/Extensions/Ghidra/Skeleton/src/test/
 share/java/ghidra/Extensions/Ghidra/Skeleton/src/test/java/
 share/java/ghidra/Extensions/Ghidra/Skeleton/src/test/java/README.test.txt
-share/java/ghidra/Extensions/Ghidra/ghidra_9.0.4_PUBLIC_20190516_SampleTablePlugin.zip
-share/java/ghidra/Extensions/Ghidra/ghidra_9.0.4_PUBLIC_20190516_sample.zip
+share/java/ghidra/Extensions/Ghidra/ghidra_${VERSION}_PUBLIC_${GHIDRA_DATE}_SampleTablePlugin.zip
+share/java/ghidra/Extensions/Ghidra/ghidra_${VERSION}_PUBLIC_${GHIDRA_DATE}_sample.zip
 share/java/ghidra/Extensions/IDAPro/
 share/java/ghidra/Extensions/IDAPro/Python/
 share/java/ghidra/Extensions/IDAPro/Python/6xx/
@@ -156,12 +155,8 @@ share/java/ghidra/GPL/DemanglerGnu/LICEN
 share/java/ghidra/GPL/DemanglerGnu/Module.manifest
 share/java/ghidra/GPL/DemanglerGnu/build.gradle
 share/java/ghidra/GPL/DemanglerGnu/os/
-share/java/ghidra/GPL/DemanglerGnu/os/linux64/
-share/java/ghidra/GPL/DemanglerGnu/os/linux64/demangler_gnu
-share/java/ghidra/GPL/DemanglerGnu/os/osx64/
-share/java/ghidra/GPL/DemanglerGnu/os/osx64/demangler_gnu
-share/java/ghidra/GPL/DemanglerGnu/os/win64/
-share/java/ghidra/GPL/DemanglerGnu/os/win64/demangler_gnu.exe
+share/java/ghidra/GPL/DemanglerGnu/os/openbsd64/
+@bin share/java/ghidra/GPL/DemanglerGnu/os/openbsd64/demangler_gnu
 share/java/ghidra/GPL/DemanglerGnu/src/
 share/java/ghidra/GPL/DemanglerGnu/src/demangler_gnu/
 share/java/ghidra/GPL/DemanglerGnu/src/demangler_gnu/README.txt
@@ -535,15 +530,9 @@ share/java/ghidra/Ghidra/Features/Decomp
 share/java/ghidra/Ghidra/Features/Decompiler/lib/Decompiler-src.zip
 share/java/ghidra/Ghidra/Features/Decompiler/lib/Decompiler.jar
 share/java/ghidra/Ghidra/Features/Decompiler/os/
-share/java/ghidra/Ghidra/Features/Decompiler/os/linux64/
-share/java/ghidra/Ghidra/Features/Decompiler/os/linux64/decompile
-share/java/ghidra/Ghidra/Features/Decompiler/os/linux64/sleigh
-share/java/ghidra/Ghidra/Features/Decompiler/os/osx64/
-share/java/ghidra/Ghidra/Features/Decompiler/os/osx64/decompile
-share/java/ghidra/Ghidra/Features/Decompiler/os/osx64/sleigh
-share/java/ghidra/Ghidra/Features/Decompiler/os/win64/
-share/java/ghidra/Ghidra/Features/Decompiler/os/win64/decompile.exe
-share/java/ghidra/Ghidra/Features/Decompiler/os/win64/sleigh.exe
+share/java/ghidra/Ghidra/Features/Decompiler/os/openbsd64/
+@bin share/java/ghidra/Ghidra/Features/Decompiler/os/openbsd64/decompile
+@bin share/java/ghidra/Ghidra/Features/Decompiler/os/openbsd64/sleigh
 share/java/ghidra/Ghidra/Features/DecompilerDependent/
 share/java/ghidra/Ghidra/Features/DecompilerDependent/LICENSE.txt
 share/java/ghidra/Ghidra/Features/DecompilerDependent/Module.manifest
@@ -610,18 +599,6 @@ share/java/ghidra/Ghidra/Features/Functi
 share/java/ghidra/Ghidra/Features/FunctionID/data/building_fid.txt
 share/java/ghidra/Ghidra/Features/FunctionID/data/common_symbols_win32.txt
 share/java/ghidra/Ghidra/Features/FunctionID/data/common_symbols_win64.txt
-share/java/ghidra/Ghidra/Features/FunctionID/data/vs1998_x86.fidbf
-share/java/ghidra/Ghidra/Features/FunctionID/data/vs2003_x86.fidbf
-share/java/ghidra/Ghidra/Features/FunctionID/data/vs2005_x64.fidbf
-share/java/ghidra/Ghidra/Features/FunctionID/data/vs2005_x86.fidbf
-share/java/ghidra/Ghidra/Features/FunctionID/data/vs2008_x64.fidbf
-share/java/ghidra/Ghidra/Features/FunctionID/data/vs2008_x86.fidbf
-share/java/ghidra/Ghidra/Features/FunctionID/data/vs2010_x64.fidbf
-share/java/ghidra/Ghidra/Features/FunctionID/data/vs2010_x86.fidbf
-share/java/ghidra/Ghidra/Features/FunctionID/data/vs2012_x64.fidbf
-share/java/ghidra/Ghidra/Features/FunctionID/data/vs2012_x86.fidbf
-share/java/ghidra/Ghidra/Features/FunctionID/data/vs2015_x64.fidbf
-share/java/ghidra/Ghidra/Features/FunctionID/data/vs2015_x86.fidbf
 share/java/ghidra/Ghidra/Features/FunctionID/ghidra_scripts/
 
share/java/ghidra/Ghidra/Features/FunctionID/ghidra_scripts/CollectFailedRelocations.java
 
share/java/ghidra/Ghidra/Features/FunctionID/ghidra_scripts/CreateMultipleLibraries.java
@@ -769,9 +746,6 @@ share/java/ghidra/Ghidra/Features/PDB/Mo
 share/java/ghidra/Ghidra/Features/PDB/lib/
 share/java/ghidra/Ghidra/Features/PDB/lib/PDB-src.zip
 share/java/ghidra/Ghidra/Features/PDB/lib/PDB.jar
-share/java/ghidra/Ghidra/Features/PDB/os/
-share/java/ghidra/Ghidra/Features/PDB/os/win64/
-share/java/ghidra/Ghidra/Features/PDB/os/win64/pdb.exe
 share/java/ghidra/Ghidra/Features/PDB/src/
 share/java/ghidra/Ghidra/Features/PDB/src/pdb/
 share/java/ghidra/Ghidra/Features/PDB/src/pdb/README.txt
@@ -3290,7 +3264,6 @@ share/java/ghidra/docs/languages/index.h
 share/java/ghidra/docs/languages/manual_index.txt
 share/java/ghidra/docs/languages/versioning.html
 share/java/ghidra/ghidraRun
-share/java/ghidra/ghidraRun.bat
 share/java/ghidra/licenses/
 share/java/ghidra/licenses/Apache_License_2.0.txt
 share/java/ghidra/licenses/BSD.txt
@@ -3311,39 +3284,13 @@ share/java/ghidra/licenses/Oxygen_Icons_
 share/java/ghidra/licenses/Public_Domain.txt
 share/java/ghidra/licenses/Tango_Icons_-_Public_Domain.txt
 share/java/ghidra/server/
-share/java/ghidra/server/ghidraSvr
-share/java/ghidra/server/ghidraSvr.bat
 share/java/ghidra/server/server.conf
-share/java/ghidra/server/svrAdmin
-share/java/ghidra/server/svrAdmin.bat
-share/java/ghidra/server/svrInstall
-share/java/ghidra/server/svrInstall.bat
 share/java/ghidra/server/svrREADME.html
-share/java/ghidra/server/svrUninstall
-share/java/ghidra/server/svrUninstall.bat
 share/java/ghidra/support/
 share/java/ghidra/support/LaunchSupport.jar
-share/java/ghidra/support/README_createPdbXmlFiles.txt
-share/java/ghidra/support/analyzeHeadless
-share/java/ghidra/support/analyzeHeadless.bat
 share/java/ghidra/support/analyzeHeadlessREADME.html
 share/java/ghidra/support/buildExtension.gradle
-share/java/ghidra/support/buildGhidraJar
-share/java/ghidra/support/buildGhidraJar.bat
 share/java/ghidra/support/buildGhidraJarREADME.txt
-share/java/ghidra/support/convertStorage
-share/java/ghidra/support/convertStorage.bat
-share/java/ghidra/support/createPdbXmlFiles.bat
 share/java/ghidra/support/debug.log4j.xml
-share/java/ghidra/support/dumpGhidraThreads
-share/java/ghidra/support/dumpGhidraThreads.bat
-share/java/ghidra/support/ghidra.ico
-share/java/ghidra/support/ghidraDebug
-share/java/ghidra/support/ghidraDebug.bat
-share/java/ghidra/support/launch.bat
 share/java/ghidra/support/launch.properties
 share/java/ghidra/support/launch.sh
-share/java/ghidra/support/pythonRun
-share/java/ghidra/support/pythonRun.bat
-share/java/ghidra/support/sleigh
-share/java/ghidra/support/sleigh.bat

Reply via email to