From c44fb49ddb8d8f1015e97f28d28ebada9f252ccc Mon Sep 17 00:00:00 2001 From: Theodore Tsirpanis Date: Thu, 3 Oct 2024 02:20:09 +0300 Subject: [PATCH] Update the libmagic vcpkg port overlay to version 5.45. (#5332) [SC-56749](https://app.shortcut.com/tiledb-inc/story/56749/update-the-libmagic-vcpkg-port-overlay-to-version-5-45) This PR updates our custom vcpkg port overlay for libmagic to version 5.45. Unlike the last time we attempted this (#4673), this PR does not replace the port with the upstream autotools-based one, and is not expected to be a build-breaking change. --- TYPE: IMPROVEMENT DESC: Updated libmagic to version 5.45. --- ports/README.md | 2 +- .../0003-Fix-WIN32-macro-checks.patch | 8 ++-- ...ude-dirent.h-for-S_ISREG-and-S_ISDIR.patch | 9 +++-- .../0006-Remove-Wrap-POSIX-headers.patch | 2 +- ports/libmagic/0009-No-fcntl-in-magic.c.patch | 25 ------------ ...y-check-for-the-presence-of-bitmasks.patch | 2 +- ...ve-pipe-related-functions-in-funcs.c.patch | 12 +++--- .../0014-Define-POSIX-macros-if-missing.patch | 38 ------------------- .../0015-MSYS2-Remove-ioctl-call.patch | 4 +- ports/libmagic/CMakeLists.txt | 1 + ports/libmagic/portfile.cmake | 6 +-- ports/libmagic/vcpkg.json | 2 +- 12 files changed, 23 insertions(+), 88 deletions(-) delete mode 100644 ports/libmagic/0009-No-fcntl-in-magic.c.patch delete mode 100644 ports/libmagic/0014-Define-POSIX-macros-if-missing.patch diff --git a/ports/README.md b/ports/README.md index 26e98d4e502..fdc0a7f389a 100644 --- a/ports/README.md +++ b/ports/README.md @@ -34,5 +34,5 @@ For ease of review when patching existing ports, you are recommended to make one |---------------|----------------------------------------------------------------------------------------------------------------------------| | `aws-c-io` | Patching to fix MinGW build failures. (https://github.com/awslabs/aws-c-io/pull/664) | | `aws-sdk-cpp` | Patching to fix MinGW build failures, and to avoid building test-only SDKs (https://github.com/aws/aws-sdk-cpp/pull/3061). | -| `libmagic` | Updating to the upstream port deferred due to failures. | +| `libmagic` | Using a custom CMake-based port that is not accepted upstream. | | `libfaketime` | Port does not yet exist upstream | diff --git a/ports/libmagic/0003-Fix-WIN32-macro-checks.patch b/ports/libmagic/0003-Fix-WIN32-macro-checks.patch index 44ab2ddea2a..3bb22a1b14b 100644 --- a/ports/libmagic/0003-Fix-WIN32-macro-checks.patch +++ b/ports/libmagic/0003-Fix-WIN32-macro-checks.patch @@ -31,13 +31,13 @@ index 299ac0c..2c365a6 100644 #define PATHSEP ':' @@ -103,7 +103,7 @@ - #define private static + #define file_private static -#if HAVE_VISIBILITY && !defined(WIN32) +#if HAVE_VISIBILITY && !defined(_WIN32) - #define public __attribute__ ((__visibility__("default"))) - #ifndef protected - #define protected __attribute__ ((__visibility__("hidden"))) + #define file_public __attribute__ ((__visibility__("default"))) + #ifndef file_protected + #define file_protected __attribute__ ((__visibility__("hidden"))) -- 2.29.2.windows.2 diff --git a/ports/libmagic/0005-Include-dirent.h-for-S_ISREG-and-S_ISDIR.patch b/ports/libmagic/0005-Include-dirent.h-for-S_ISREG-and-S_ISDIR.patch index 76cbc1222c8..afcb658d889 100644 --- a/ports/libmagic/0005-Include-dirent.h-for-S_ISREG-and-S_ISDIR.patch +++ b/ports/libmagic/0005-Include-dirent.h-for-S_ISREG-and-S_ISDIR.patch @@ -11,14 +11,15 @@ diff --git a/src/file.h b/src/file.h index 0332506..4aa9f60 100644 --- a/src/file.h +++ b/src/file.h -@@ -88,6 +88,7 @@ +@@ -88,7 +88,8 @@ /* Do this here and now, because struct stat gets re-defined on solaris */ #include #include +#include - - #define ENABLE_CONDITIONALS - + #include + #if defined(HAVE_XLOCALE_H) + #include + #endif -- 2.29.2.windows.2 diff --git a/ports/libmagic/0006-Remove-Wrap-POSIX-headers.patch b/ports/libmagic/0006-Remove-Wrap-POSIX-headers.patch index 56efac24815..169561d2437 100644 --- a/ports/libmagic/0006-Remove-Wrap-POSIX-headers.patch +++ b/ports/libmagic/0006-Remove-Wrap-POSIX-headers.patch @@ -161,7 +161,7 @@ index 3ab52d1..fc48d84 100644 --- a/src/pread.c +++ b/src/pread.c @@ -3,7 +3,9 @@ - FILE_RCSID("@(#)$File: pread.c,v 1.2 2013/04/02 16:23:07 christos Exp $") + FILE_RCSID("@(#)$File: pread.c,v 1.5 2022/09/24 20:30:13 christos Exp $") #endif /* lint */ #include +#ifdef HAVE_UNISTD_H diff --git a/ports/libmagic/0009-No-fcntl-in-magic.c.patch b/ports/libmagic/0009-No-fcntl-in-magic.c.patch deleted file mode 100644 index 47bf16165ef..00000000000 --- a/ports/libmagic/0009-No-fcntl-in-magic.c.patch +++ /dev/null @@ -1,25 +0,0 @@ -From 6d10bef865b69764f6e0ddd2b0f6a84e484cdb37 Mon Sep 17 00:00:00 2001 -From: Long Nguyen -Date: Sun, 9 May 2021 13:25:14 +0700 -Subject: [PATCH 09/14] No fcntl in magic.c - ---- - src/magic.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/magic.c b/src/magic.c -index e9aeafa..382bd96 100644 ---- a/src/magic.c -+++ b/src/magic.c -@@ -462,7 +462,7 @@ file_or_fd(struct magic_set *ms, const char *inname, int fd) - rv = 0; - goto done; - } --#if O_CLOEXEC == 0 -+#if O_CLOEXEC == 0 && !defined(_WIN32) - (void)fcntl(fd, F_SETFD, FD_CLOEXEC); - #endif - } --- -2.29.2.windows.2 - diff --git a/ports/libmagic/0010-Properly-check-for-the-presence-of-bitmasks.patch b/ports/libmagic/0010-Properly-check-for-the-presence-of-bitmasks.patch index f0d8738e465..e241f5e49c0 100644 --- a/ports/libmagic/0010-Properly-check-for-the-presence-of-bitmasks.patch +++ b/ports/libmagic/0010-Properly-check-for-the-presence-of-bitmasks.patch @@ -17,7 +17,7 @@ index 5204f20..7244841 100644 #undef HAVE_MAJOR -#ifdef S_IFLNK +#if S_IFLNK != 0 - private int + file_private int bad_link(struct magic_set *ms, int err, char *buf) { @@ -108,7 +108,7 @@ file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb) diff --git a/ports/libmagic/0011-Remove-pipe-related-functions-in-funcs.c.patch b/ports/libmagic/0011-Remove-pipe-related-functions-in-funcs.c.patch index ae2720ca361..13c24faaca0 100644 --- a/ports/libmagic/0011-Remove-pipe-related-functions-in-funcs.c.patch +++ b/ports/libmagic/0011-Remove-pipe-related-functions-in-funcs.c.patch @@ -11,21 +11,19 @@ diff --git a/src/funcs.c b/src/funcs.c index b926625..b585486 100644 --- a/src/funcs.c +++ b/src/funcs.c -@@ -809,6 +809,7 @@ file_print_guid(char *str, size_t len, const uint64_t *guid) - g->data4[6], g->data4[7]); +@@ -888,5 +888,6 @@ } +#ifndef _WIN32 - protected int + file_protected int file_pipe_closexec(int *fds) { -@@ -827,6 +828,7 @@ protected int - file_clear_closexec(int fd) { - return fcntl(fd, F_SETFD, 0); +@@ -914,5 +915,6 @@ + #endif } +#endif - protected char * + file_protected char * file_strtrim(char *str) -- 2.29.2.windows.2 diff --git a/ports/libmagic/0014-Define-POSIX-macros-if-missing.patch b/ports/libmagic/0014-Define-POSIX-macros-if-missing.patch deleted file mode 100644 index 09ac7a11926..00000000000 --- a/ports/libmagic/0014-Define-POSIX-macros-if-missing.patch +++ /dev/null @@ -1,38 +0,0 @@ -From fa0e11f36bb0e322250e1e488ced9f2bf166874f Mon Sep 17 00:00:00 2001 -From: Long Nguyen -Date: Fri, 14 May 2021 18:11:39 +0700 -Subject: [PATCH 14/14] Define POSIX macros if missing - ---- - src/file.h | 15 +++++++++++++++ - 1 file changed, 15 insertions(+) - -diff --git a/src/file.h b/src/file.h -index ccfe0da..98cd37b 100644 ---- a/src/file.h -+++ b/src/file.h -@@ -100,6 +100,21 @@ - #include - #include - -+#if !defined(S_IFBLK) -+#define S_IFBLK 0 -+#define S_ISBLK(mode) (((mode) & S_IFMT) == S_IFBLK) -+#endif -+ -+#if !defined(S_IFLNK) -+#define S_IFLNK 0 -+#define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK) -+#endif -+ -+#if !defined(S_IFSOCK) -+#define S_IFSOCK 0 -+#define S_ISSOCK(mode) (((mode) & S_IFMT) == S_IFSOCK) -+#endif -+ - #define ENABLE_CONDITIONALS - - #ifndef MAGIC --- -2.29.2.windows.2 - diff --git a/ports/libmagic/0015-MSYS2-Remove-ioctl-call.patch b/ports/libmagic/0015-MSYS2-Remove-ioctl-call.patch index da8ef79df29..0c95d556b60 100644 --- a/ports/libmagic/0015-MSYS2-Remove-ioctl-call.patch +++ b/ports/libmagic/0015-MSYS2-Remove-ioctl-call.patch @@ -11,7 +11,7 @@ index 33ce2bc..f172eda 100644 sread(int fd, void *buf, size_t n, int canbepipe __attribute__((__unused__))) { ssize_t rv; --#ifdef FIONREAD +-#if defined(FIONREAD) && !defined(__MINGW32__) +#if defined(FIONREAD) && !defined(__MINGW32__) && !defined(WIN32) int t = 0; #endif @@ -20,7 +20,7 @@ index 33ce2bc..f172eda 100644 if (fd == STDIN_FILENO) goto nocheck; --#ifdef FIONREAD +-#if defined(FIONREAD) && !defined(__MINGW32__) +#if defined(FIONREAD) && !defined(__MINGW32__) && !defined(WIN32) if (canbepipe && (ioctl(fd, FIONREAD, &t) == -1 || t == 0)) { #ifdef FD_ZERO diff --git a/ports/libmagic/CMakeLists.txt b/ports/libmagic/CMakeLists.txt index 3d731affe3d..e338d9a70e5 100644 --- a/ports/libmagic/CMakeLists.txt +++ b/ports/libmagic/CMakeLists.txt @@ -58,6 +58,7 @@ list(APPEND LIBMAGIC_SOURCE_FILES ${LIBMAGIC_SOURCE_DIR}/fsmagic.c ${LIBMAGIC_SOURCE_DIR}/funcs.c ${LIBMAGIC_SOURCE_DIR}/is_json.c + ${LIBMAGIC_SOURCE_DIR}/is_simh.c ${LIBMAGIC_SOURCE_DIR}/is_tar.c ${LIBMAGIC_SOURCE_DIR}/magic.c ${LIBMAGIC_SOURCE_DIR}/print.c diff --git a/ports/libmagic/portfile.cmake b/ports/libmagic/portfile.cmake index c40c3e2bac6..7135ef3a915 100644 --- a/ports/libmagic/portfile.cmake +++ b/ports/libmagic/portfile.cmake @@ -11,10 +11,8 @@ if(VCPKG_TARGET_IS_WINDOWS) "0006-Remove-Wrap-POSIX-headers.patch" "0007-Substitute-unistd-macros-for-MSVC.patch" "0008-Add-FILENO-defines.patch" - "0009-No-fcntl-in-magic.c.patch" "0010-Properly-check-for-the-presence-of-bitmasks.patch" "0011-Remove-pipe-related-functions-in-funcs.c.patch" - "0014-Define-POSIX-macros-if-missing.patch" "0015-MSYS2-Remove-ioctl-call.patch" ) endif() @@ -22,8 +20,8 @@ endif() vcpkg_from_github( OUT_SOURCE_PATH SOURCE_PATH REPO file/file - REF FILE5_40 - SHA512 d76bfe5326e1b40368e055c2e049a24b4ffdbd727371f4f3aa1dd3f53787d16b88550b3cc71ecf02151e2fb3e567eb2598e4707badab8c391eb71113c2dcc319 + REF FILE5_45 + SHA512 fdd4c5d13d5ea1d25686c76d8ebc3252c54040c4871e3f0f623c4548b3841795d4e36050292a9453eedf0fbf932573890e9d6ac9fa63ccf577215598ae84b9ea HEAD_REF master PATCHES ${PATCHES} ) diff --git a/ports/libmagic/vcpkg.json b/ports/libmagic/vcpkg.json index 63944114b56..63065b51aee 100644 --- a/ports/libmagic/vcpkg.json +++ b/ports/libmagic/vcpkg.json @@ -1,6 +1,6 @@ { "name": "libmagic", - "version-string": "5.40", + "version-string": "5.45", "port-version": 1, "description": "This library can be used to classify files according to magic number tests.", "homepage": "https://github.com/file/file",