editors/imhex-current: Add new port

ImHex is a hex editor for reverse engineers and programmers.

This port is provided separately from existing editors/imhex port
for those who would like to use the latest version of ImHex.

The version requires FreeBSD 15-current, 14-stable, 13-stable,
or upcoming 13.3-RELEASE that has libc++ of LLVM 17 on the base
system to build it, thus it is not possible to build the version
on FreeBSD 13.2-RELEASE or 14.0-RELEASE. This situation has
prevented the update of editors/imhex port to the latest version.

This port is a tentative solution until FreeBSD 14.1-RELEASE
will be released.
This commit is contained in:
MANTANI Nobutaka 2024-03-03 19:13:49 +09:00
parent 512e4d7f30
commit 0a2e453e44
17 changed files with 1754 additions and 0 deletions

View File

@ -65,6 +65,7 @@
SUBDIR += hnb
SUBDIR += hte
SUBDIR += imhex
SUBDIR += imhex-current
SUBDIR += jed
SUBDIR += jedit
SUBDIR += joe

View File

@ -0,0 +1,133 @@
PORTNAME= imhex
PORTVERSION= 1.33.1
DISTVERSIONPREFIX= v
CATEGORIES= editors
MASTER_SITES= https://git.sr.ht/~danyspin97/xdgpp/blob/f01f810714443d0f10c333d4d1d9c0383be41375/:xdg \
https://gitlab.com/EvelynTSMG/imhex-bastion-pats/-/archive/${GL_TAG_IMHEX_BASTION_PATS}/:bastion \
https://gitlab.com/EvelynTSMG/imhex-ffx-pats/-/archive/${GL_TAG_IMHEX_FFX_PATS}/:ffx
PKGNAMESUFFIX= -current
DISTFILES= xdg.hpp:xdg \
imhex-bastion-pats-${GL_TAG_IMHEX_BASTION_PATS}.tar.bz2:bastion \
imhex-ffx-pats-${GL_TAG_IMHEX_FFX_PATS}.tar.bz2:ffx
DIST_SUBDIR= imhex
MAINTAINER= nobutaka@FreeBSD.org
COMMENT= Hex editor for reverse engineers and programmers (current version)
WWW= https://github.com/WerWolv/ImHex
LICENSE= GPLv2
LICENSE_FILE= ${WRKSRC}/LICENSE
NOT_FOR_ARCHS= i386 powerpc
NOT_FOR_ARCHS_REASON= __uint128_t and __int128_t are not supported
EXTRACT_ONLY= ${DISTNAME}${EXTRACT_SUFX} \
btzy-nativefiledialog-extended-${GH_TAG_NATIVEFILEDIALOG}_GH0${EXTRACT_SUFX} \
capstone-engine-capstone-${GH_TAG_CAPSTONE}_GH0${EXTRACT_SUFX} \
CLIUtils-CLI11-${GH_TAG_CLI11}_GH0${EXTRACT_SUFX} \
Martinsos-edlib-${GH_TAG_EDLIB}_GH0${EXTRACT_SUFX} \
fmtlib-fmt-${GH_TAG_FMT}_GH0${EXTRACT_SUFX} \
josuttis-jthread-${GH_TAG_JTHREAD}_GH0${EXTRACT_SUFX} \
VirusTotal-yara-${GH_TAG_YARA}_GH0${EXTRACT_SUFX} \
WerWolv-HashLibPlus-${GH_TAG_HASHLIBPLUS}_GH0${EXTRACT_SUFX} \
WerWolv-ImHex-Patterns-${GH_TAG_IMHEX_PATTERNS}_GH0${EXTRACT_SUFX} \
WerWolv-PatternLanguage-${GH_TAG_PATTERN_LANGUAGE}_GH0${EXTRACT_SUFX} \
WerWolv-libromfs-${GH_TAG_LIBROMFS}_GH0${EXTRACT_SUFX} \
WerWolv-libwolv-${GH_TAG_LIBWOLV}_GH0${EXTRACT_SUFX} \
imhex-bastion-pats-${GL_TAG_IMHEX_BASTION_PATS}.tar.bz2 \
imhex-ffx-pats-${GL_TAG_IMHEX_FFX_PATS}.tar.bz2
BUILD_DEPENDS= glm>0:math/glm \
${LOCALBASE}/include/range/v3/range.hpp:devel/range-v3
LIB_DEPENDS= libcurl.so:ftp/curl \
libglfw.so:graphics/glfw \
libfreetype.so:print/freetype2 \
libharfbuzz.so:print/harfbuzz \
libinotify.so:devel/libinotify \
libmbedtls.so:security/mbedtls \
libzstd.so:archivers/zstd
USES= cmake desktop-file-utils gl gnome pkgconfig python xorg
USE_GL= gl glu opengl
USE_GNOME= cairo gdkpixbuf2 gtk30
USE_XORG= x11 xcb xau xdmcp
USE_GITHUB= yes
CONFLICTS_INSTALL= imhex-1.30.*
GH_ACCOUNT= WerWolv
GH_PROJECT= ImHex
GH_TUPLE= btzy:nativefiledialog-extended:${GH_TAG_NATIVEFILEDIALOG}:nativefiledialog \
capstone-engine:capstone:${GH_TAG_CAPSTONE}:capstone \
CLIUtils:CLI11:${GH_TAG_CLI11}:cli11 \
Martinsos:edlib:${GH_TAG_EDLIB}:edlib \
fmtlib:fmt:${GH_TAG_FMT}:fmt \
josuttis:jthread:${GH_TAG_JTHREAD}:jthread \
VirusTotal:yara:${GH_TAG_YARA}:yara \
WerWolv:HashLibPlus:${GH_TAG_HASHLIBPLUS}:hashlibplus \
WerWolv:ImHex-Patterns:${GH_TAG_IMHEX_PATTERNS}:imhex_patterns \
WerWolv:PatternLanguage:${GH_TAG_PATTERN_LANGUAGE}:pattern_language \
WerWolv:libromfs:${GH_TAG_LIBROMFS}:libromfs \
WerWolv:libwolv:${GH_TAG_LIBWOLV}:libwolv \
GH_TAG_CAPSTONE= 097c04d
GH_TAG_CLI11= 20de8b7
GH_TAG_EDLIB= 931be2b
GH_TAG_FMT= 67c0c0c
GH_TAG_HASHLIBPLUS= 7609c54
GH_TAG_IMHEX_PATTERNS= ImHex-v1.33.1
GH_TAG_JTHREAD= 0fa8d39
GH_TAG_LIBROMFS= 61f7e41
GH_TAG_LIBWOLV= 7806c19
GH_TAG_NATIVEFILEDIALOG= 5786fab
GH_TAG_PATTERN_LANGUAGE= ImHex-v1.33.1
GH_TAG_YARA= 8fa55cd
GL_TAG_IMHEX_BASTION_PATS= e6deed4
GL_TAG_IMHEX_FFX_PATS= ad18b02
CFLAGS+= -I${LOCALBASE}/include
CXXFLAGS+= -I${LOCALBASE}/include
CMAKE_ARGS= -DUSE_SYSTEM_CURL=ON -DUSE_SYSTEM_NLOHMANN_JSON=OFF \
-DIMHEX_STRIP_RELEASE=OFF -DIMHEX_PLUGINS_IN_SHARE=ON \
-DIMHEX_OFFLINE_BUILD=ON -DIMHEX_USE_GTK_FILE_PICKER=ON
PORTDOCS= README.md
OPTIONS_DEFINE= DOCS NLS
NLS_USES= gettext
.include <bsd.port.pre.mk>
.if (${OSVERSION} < 1302510) \
|| (${OSVERSION} >= 1400000 && ${OSVERSION} < 1400504)
IGNORE= requires libc++ of LLVM 17 on the base system
.endif
post-extract:
${CP} -R ${WRKSRC_libromfs}/* ${WRKSRC}/lib/external/libromfs
${CP} -R ${WRKSRC_libwolv}/* ${WRKSRC}/lib/external/libwolv
${CP} -R ${WRKSRC_pattern_language}/* ${WRKSRC}/lib/external/pattern_language
${CP} -R ${WRKSRC_cli11}/* ${WRKSRC}/lib/external/pattern_language/external/cli11
${CP} -R ${WRKSRC_fmt}/* ${WRKSRC}/lib/external/pattern_language/external/fmt
${CP} ${DISTDIR}/${DIST_SUBDIR}/xdg.hpp ${WRKSRC}/lib/third_party/xdgpp
${CP} -R ${WRKSRC_capstone}/* ${WRKSRC}/lib/third_party/capstone
${CP} -R ${WRKSRC_edlib}/* ${WRKSRC}/lib/third_party/edlib
${CP} -R ${WRKSRC_fmt}/* ${WRKSRC}/lib/third_party/fmt
${CP} -R ${WRKSRC_hashlibplus}/* ${WRKSRC}/lib/third_party/HashLibPlus
${CP} -R ${WRKSRC_jthread}/* ${WRKSRC}/lib/third_party/jthread
${CP} -R ${WRKSRC_nativefiledialog}/* ${WRKSRC}/lib/third_party/nativefiledialog
${CP} -R ${WRKSRC_yara}/* ${WRKSRC}/lib/third_party/yara/yara
${MKDIR} ${WRKDIR}/.build/_deps/imhex_patterns_src
${CP} -R ${WRKSRC_imhex_patterns}/* ${WRKDIR}/.build/_deps/imhex_patterns_src
${CP} -R ${WRKDIR}/imhex-bastion-pats-${GL_TAG_IMHEX_BASTION_PATS}/* ${WRKDIR}/.build/_deps/imhex_patterns_src/patterns/bastion
${CP} -R ${WRKDIR}/imhex-ffx-pats-${GL_TAG_IMHEX_FFX_PATS}/* ${WRKDIR}/.build/_deps/imhex_patterns_src/patterns/ffx
post-patch:
${CP} -R ${WRKSRC}/lib/external/libwolv/* ${WRKSRC}/lib/external/pattern_language/external/libwolv
post-install-DOCS-on:
${MKDIR} ${STAGEDIR}${DOCSDIR}
${INSTALL_DATA} ${WRKSRC}/README.md ${STAGEDIR}${DOCSDIR}
.include <bsd.port.post.mk>

View File

@ -0,0 +1,33 @@
TIMESTAMP = 1709397327
SHA256 (imhex/xdg.hpp) = 2e08ce74adb71ff9b9aa9e1c999733fccd4b00967b9cf0c0e51dbf049392a9ec
SIZE (imhex/xdg.hpp) = 7674
SHA256 (imhex/imhex-bastion-pats-e6deed4.tar.bz2) = 841fe3fbaeb793dd1cab9f8f89221fb0458d50e0c3ebe304bc2f8da848a9857b
SIZE (imhex/imhex-bastion-pats-e6deed4.tar.bz2) = 3082
SHA256 (imhex/imhex-ffx-pats-ad18b02.tar.bz2) = d83c62f971d4603c8d82bcf66c703b2ccabedbe9c12594c8a760c4a5847d7b4b
SIZE (imhex/imhex-ffx-pats-ad18b02.tar.bz2) = 14486
SHA256 (imhex/WerWolv-ImHex-v1.33.1_GH0.tar.gz) = f4d52950431b31d7c8d09610fb7ed33b997c588ca4419301cff28a3e1332f57e
SIZE (imhex/WerWolv-ImHex-v1.33.1_GH0.tar.gz) = 9220049
SHA256 (imhex/btzy-nativefiledialog-extended-5786fab_GH0.tar.gz) = 888bbfd5c18d4ead849e0329d4eeb3d715994bf8d669fac6c6dfb2f29c8bc79b
SIZE (imhex/btzy-nativefiledialog-extended-5786fab_GH0.tar.gz) = 413495
SHA256 (imhex/capstone-engine-capstone-097c04d_GH0.tar.gz) = b45d16ee7f0dc68b818a1f44005953f89f728736ef20beca4a7dd19d8a91056e
SIZE (imhex/capstone-engine-capstone-097c04d_GH0.tar.gz) = 7653892
SHA256 (imhex/CLIUtils-CLI11-20de8b7_GH0.tar.gz) = c270e78f0db1a496204b7434f69809f4189d27693bb0e51a3178d8e86f59e580
SIZE (imhex/CLIUtils-CLI11-20de8b7_GH0.tar.gz) = 339101
SHA256 (imhex/Martinsos-edlib-931be2b_GH0.tar.gz) = a854584bf06ac11d4166caea8112f0f188df3d7c86fc82d145ab50a2d16c84a8
SIZE (imhex/Martinsos-edlib-931be2b_GH0.tar.gz) = 4319124
SHA256 (imhex/fmtlib-fmt-67c0c0c_GH0.tar.gz) = 19f12e54ad30f612e8c826fca2d406b206a09692485d7455148c44b5b9bd0778
SIZE (imhex/fmtlib-fmt-67c0c0c_GH0.tar.gz) = 854620
SHA256 (imhex/josuttis-jthread-0fa8d39_GH0.tar.gz) = ccd9c871dc2da9611e6d0cba5fc859cec9b233541be7501e5cef9eaa367e1280
SIZE (imhex/josuttis-jthread-0fa8d39_GH0.tar.gz) = 4450456
SHA256 (imhex/VirusTotal-yara-8fa55cd_GH0.tar.gz) = e8314df322401801275cb7628a2ac012ea26f658585f671620107d138c90dd42
SIZE (imhex/VirusTotal-yara-8fa55cd_GH0.tar.gz) = 2207098
SHA256 (imhex/WerWolv-HashLibPlus-7609c54_GH0.tar.gz) = df8970c0478ab7b7f762f9cf6fcb726c079addfaeb6b12ee2452520e1032572e
SIZE (imhex/WerWolv-HashLibPlus-7609c54_GH0.tar.gz) = 1200559
SHA256 (imhex/WerWolv-ImHex-Patterns-ImHex-v1.33.1_GH0.tar.gz) = 3f86f4a9453513097c5af97d022d41301caecaaab76318bcbce1cc21b38a596c
SIZE (imhex/WerWolv-ImHex-Patterns-ImHex-v1.33.1_GH0.tar.gz) = 4657125
SHA256 (imhex/WerWolv-PatternLanguage-ImHex-v1.33.1_GH0.tar.gz) = fae26a3d054665784adc29f82e5cb43137d4570409728f2f1ecaf4e4e60464ce
SIZE (imhex/WerWolv-PatternLanguage-ImHex-v1.33.1_GH0.tar.gz) = 531129
SHA256 (imhex/WerWolv-libromfs-61f7e41_GH0.tar.gz) = 8057f979d6703142e5d46c047c19b8e629dce8fae4b01cdb82d650636dd6a044
SIZE (imhex/WerWolv-libromfs-61f7e41_GH0.tar.gz) = 5184
SHA256 (imhex/WerWolv-libwolv-7806c19_GH0.tar.gz) = 9af50fc3e2f4b110793cf38ee2758a39b8270eb58d227c10ac98462d777ab28e
SIZE (imhex/WerWolv-libwolv-7806c19_GH0.tar.gz) = 39945

View File

@ -0,0 +1,11 @@
--- CMakeLists.txt.orig 2024-03-02 15:44:54 UTC
+++ CMakeLists.txt
@@ -42,8 +42,6 @@ setDefaultBuiltTypeIfUnset()
# Make sure project is configured correctly
setDefaultBuiltTypeIfUnset()
-detectBadClone()
-verifyCompiler()
detectBundledPlugins()

View File

@ -0,0 +1,18 @@
--- cmake/build_helpers.cmake.orig 2024-03-02 15:44:54 UTC
+++ cmake/build_helpers.cmake
@@ -480,13 +480,13 @@ function(downloadImHexPatternsFiles dest)
else ()
# Maybe patterns are cloned to a subdirectory
- set(imhex_patterns_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ImHex-Patterns")
+ set(imhex_patterns_SOURCE_DIR "${CMAKE_BINARY_DIR}/_deps/imhex_patterns_src")
endif ()
if (EXISTS ${imhex_patterns_SOURCE_DIR})
set(PATTERNS_FOLDERS_TO_INSTALL constants encodings includes patterns magic nodes)
foreach (FOLDER ${PATTERNS_FOLDERS_TO_INSTALL})
- install(DIRECTORY "${imhex_patterns_SOURCE_DIR}/${FOLDER}" DESTINATION ${dest} PATTERN "**/_schema.json" EXCLUDE)
+ install(DIRECTORY "${imhex_patterns_SOURCE_DIR}/${FOLDER}" DESTINATION "share/imhex/" PATTERN "**/_schema.json" EXCLUDE)
endforeach ()
endif ()

View File

@ -0,0 +1,11 @@
--- lib/libimhex/include/hex/helpers/http_requests.hpp.orig 2024-03-03 03:55:21 UTC
+++ lib/libimhex/include/hex/helpers/http_requests.hpp
@@ -148,7 +148,7 @@ namespace hex {
std::string m_body;
std::promise<std::vector<u8>> m_promise;
std::map<std::string, std::string> m_headers;
- u32 m_timeout = 1000;
+ u32 m_timeout = 100000;
std::atomic<float> m_progress = 0.0F;
std::atomic<bool> m_canceled = false;

View File

@ -0,0 +1,11 @@
--- lib/libimhex/source/api/imhex_api.cpp.orig 2024-03-02 15:44:54 UTC
+++ lib/libimhex/source/api/imhex_api.cpp
@@ -658,7 +658,7 @@ namespace hex {
#if defined(OS_WINDOWS)
return "Windows";
#elif defined(OS_LINUX)
- return "Linux";
+ return "FreeBSD";
#elif defined(OS_MACOS)
return "macOS";
#elif defined(OS_WEB)

View File

@ -0,0 +1,14 @@
--- lib/libimhex/source/helpers/fs.cpp.orig 2024-03-02 15:44:54 UTC
+++ lib/libimhex/source/helpers/fs.cpp
@@ -13,7 +13,11 @@
#include <shellapi.h>
#elif defined(OS_LINUX) || defined(OS_WEB)
#include <xdg.hpp>
+# if defined(__FreeBSD__)
+ #include <sys/syslimits.h>
+# else
#include <limits.h>
+# endif
#endif
#if defined(OS_WEB)

View File

@ -0,0 +1,11 @@
--- lib/third_party/HashLibPlus/Base/Hash.h.orig 2024-02-23 13:24:13 UTC
+++ lib/third_party/HashLibPlus/Base/Hash.h
@@ -214,7 +214,7 @@ class Hash : public virtual IIHash (public)
{
if (a_length > -1)
{
- if (UInt64(a_stream.tellg() + a_length) > size)
+ if (UInt64(a_stream.tellg()) + a_length > size)
throw IndexOutOfRangeHashLibException(IndexOutOfRange);
} // end if

View File

@ -0,0 +1,11 @@
--- main/updater/CMakeLists.txt.orig 2024-02-25 20:54:48 UTC
+++ main/updater/CMakeLists.txt
@@ -5,7 +5,7 @@ target_compile_definitions(updater PRIVATE IMHEX_PROJE
)
target_compile_definitions(updater PRIVATE IMHEX_PROJECT_NAME="${PROJECT_NAME}")
-target_link_libraries(updater PRIVATE libimhex ${FMT_LIBRARIES})
+target_link_libraries(updater PRIVATE libimhex ${FMT_LIBRARIES} pthread)
add_dependencies(main updater)
if (APPLE)

View File

@ -0,0 +1,10 @@
--- plugins/builtin/include/content/providers/process_memory_provider.hpp.orig 2024-02-23 13:28:35 UTC
+++ plugins/builtin/include/content/providers/process_memory_provider.hpp
@@ -1,6 +1,6 @@
#pragma once
-#if defined(OS_WINDOWS) || defined (OS_LINUX)
+#if defined(OS_WINDOWS)
#include <hex/providers/provider.hpp>
#include <hex/api/localization_manager.hpp>

View File

@ -0,0 +1,11 @@
--- plugins/builtin/source/content/providers.cpp.orig 2024-02-23 13:52:28 UTC
+++ plugins/builtin/source/content/providers.cpp
@@ -37,7 +37,7 @@ namespace hex::plugin::builtin {
ContentRegistry::Provider::add<MemoryFileProvider>(false);
ContentRegistry::Provider::add<ViewProvider>(false);
- #if defined(OS_WINDOWS) ||defined (OS_LINUX)
+ #if defined(OS_WINDOWS)
ContentRegistry::Provider::add<ProcessMemoryProvider>();
#endif

View File

@ -0,0 +1,56 @@
--- plugins/builtin/source/content/providers/disk_provider.cpp.orig 2024-02-25 20:54:48 UTC
+++ plugins/builtin/source/content/providers/disk_provider.cpp
@@ -28,7 +28,6 @@
#elif defined(OS_LINUX)
#include <fcntl.h>
#include <unistd.h>
- #include <linux/fs.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <sys/types.h>
@@ -41,8 +40,11 @@
#include <sys/disk.h>
#endif
-#if defined(OS_LINUX)
+#if !defined(__FreeBSD__)
#define lseek lseek64
+#else
+#include <sys/disk.h>
+#define DEFAULT_SECTOR_SIZE 512
#endif
namespace hex::plugin::builtin {
@@ -77,9 +79,9 @@ namespace hex::plugin::builtin {
}
#if defined (OS_LINUX)
- #ifdef BLKSSZGET
+ #ifdef DIOCGSECTORSIZE
int blkdev_get_sector_size(int fd, int *sector_size) {
- if (ioctl(fd, BLKSSZGET, sector_size) < 0)
+ if (ioctl(fd, DIOCGSECTORSIZE, sector_size) < 0)
return -1;
return 0;
}
@@ -91,9 +93,9 @@ namespace hex::plugin::builtin {
}
#endif
- #ifdef BLKGETSIZE64
+ #ifdef DIOCGMEDIASIZE
int blkdev_get_size(int fd, u64 *bytes) {
- if (ioctl(fd, BLKGETSIZE64, bytes) < 0)
+ if (ioctl(fd, DIOCGMEDIASIZE, bytes) < 0)
return -1;
return 0;
}
@@ -107,7 +109,7 @@ namespace hex::plugin::builtin {
if (st.st_size == 0) {
// Try BLKGETSIZE
unsigned long long bytes64;
- if (ioctl(fd, BLKGETSIZE, &bytes64) >= 0) {
+ if (ioctl(fd, DIOCGMEDIASIZE, &bytes64) >= 0) {
*bytes = bytes64;
return 0;
}

View File

@ -0,0 +1,8 @@
--- plugins/builtin/source/content/providers/process_memory_provider.cpp.orig 2024-02-23 13:35:26 UTC
+++ plugins/builtin/source/content/providers/process_memory_provider.cpp
@@ -1,4 +1,4 @@
-#if defined(OS_WINDOWS) || defined (OS_LINUX)
+#if defined(OS_WINDOWS)
#include <content/providers/process_memory_provider.hpp>

View File

@ -0,0 +1,14 @@
ImHex is a hex editor for reverse engineers, programmers and people that value
their eye sight when working at 3 AM.
ImHex has many features including the following:
- Byte patching
- String and hex search
- Colorful highlighting
- Custom C++-like pattern language for parsing highlighting a file's content
- Data inspector allowing interpretation of data as many different types
(little and big endian)
- File hashing support
- Disassembler supporting many different architectures
- Bookmarks
- Data Analyzer

File diff suppressed because it is too large Load Diff

View File

@ -47,6 +47,8 @@ USE_GNOME= cairo gdkpixbuf2 gtk30
USE_XORG= x11 xcb xau xdmcp
USE_GITHUB= yes
CONFLICTS_INSTALL= imhex-current-*
GH_ACCOUNT= WerWolv
GH_PROJECT= ImHex
GH_TUPLE= btzy:nativefiledialog-extended:${GH_TAG_NATIVEFILEDIALOG}:nativefiledialog \