forked from TileDB-Inc/TileDB
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update libmagic to version 5.45 (TileDB-Inc#4673)
[SC-38521](https://app.shortcut.com/tiledb-inc/story/38521/update-libmagic-and-use-the-upstream-vcpkg-port) Split from TileDB-Inc#4553. This PR updates libmagic to version 5.45 and switches to using a vcpkg port closer to the upstream one, which we can easily consume with find_package(unofficial-libmagic) since microsoft/vcpkg#35274. One complication is that the upstream port builds libmagic with its official autotools-based build system, which is significantly slower on Windows (on Linux it builds pretty fast). I tried to upstream the CMake-based port I had added in TileDB-Inc#4119, but the PR was rejected. Apart from binary caching, there is unfortunately nothing we can do about the build performance regression. We could maintain the CMake-based port for our own use, but it will split what we build and what a future user of TileDB from vcpkg will build, and that port is not without its problems (it failed for example when I tried cross-compiling to arm64-windows, because it tried to execute the arm64 file.exe on my x64 machine). --- TYPE: BUILD DESC: Update libmagic to version 5.45
- Loading branch information
1 parent
607d5ad
commit 7753f33
Showing
32 changed files
with
356 additions
and
1,239 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
ports/libmagic/0002-Change-zlib-lib-name-to-match-CMake-output.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
From 2fa43ece9ec7564e1fbb9867bb5852b834643aa4 Mon Sep 17 00:00:00 2001 | ||
From: Long Nguyen <[email protected]> | ||
Date: Sat, 8 May 2021 19:36:11 +0700 | ||
Subject: [PATCH 02/14] Change zlib lib name to match CMake output | ||
|
||
--- | ||
configure.ac | 6 +++--- | ||
1 file changed, 3 insertions(+), 3 deletions(-) | ||
|
||
diff --git a/configure.ac b/configure.ac | ||
index b05c334..dd4063c 100644 | ||
--- a/configure.ac | ||
+++ b/configure.ac | ||
@@ -173,7 +173,7 @@ AC_REPLACE_FUNCS(getopt_long asprintf vasprintf strlcpy strlcat getline ctime_r | ||
|
||
dnl Checks for libraries | ||
if test "$enable_zlib" != "no"; then | ||
- AC_CHECK_LIB(z, gzopen) | ||
+ AC_SEARCH_LIBS(gzopen, [z zlib zlibd], have_zlib = "yes", have_zlib = "no") | ||
fi | ||
if test "$enable_bzlib" != "no"; then | ||
AC_CHECK_LIB(bz2, BZ2_bzCompressInit) | ||
@@ -193,11 +193,11 @@ AM_CONDITIONAL(IS_CROSS_COMPILE, test "$cross_compiling" = yes) | ||
|
||
dnl Final sanity checks | ||
if test "$enable_zlib" = "yes"; then | ||
- if test "$ac_cv_header_zlib_h$ac_cv_lib_z_gzopen" != "yesyes"; then | ||
+ if test "$ac_cv_header_zlib_h$have_zlib" != "yesyes"; then | ||
AC_MSG_ERROR([zlib support requested but not found]) | ||
fi | ||
fi | ||
-if test "$ac_cv_header_zlib_h$ac_cv_lib_z_gzopen" = "yesyes"; then | ||
+if test "$ac_cv_header_zlib_h$have_zlib" = "yesyes"; then | ||
AC_DEFINE([ZLIBSUPPORT], 1, [Enable zlib compression support]) | ||
fi | ||
if test "$enable_bzlib" = "yes"; then | ||
-- | ||
2.29.2.windows.2 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
ports/libmagic/0012-Convert-MSYS2-paths-to-Windows-paths.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
From f0139ced57c1579450f3d09b6e3ae0159aae031b Mon Sep 17 00:00:00 2001 | ||
From: Long Nguyen <[email protected]> | ||
Date: Mon, 10 May 2021 08:43:28 +0700 | ||
Subject: [PATCH 12/14] Convert MSYS2 paths to Windows paths | ||
|
||
--- | ||
src/Makefile.am | 3 +++ | ||
1 file changed, 3 insertions(+) | ||
|
||
diff --git a/src/Makefile.am b/src/Makefile.am | ||
index 34781b9..26f853f 100644 | ||
--- a/src/Makefile.am | ||
+++ b/src/Makefile.am | ||
@@ -1,4 +1,7 @@ | ||
MAGIC = $(pkgdatadir)/magic | ||
+if MINGW | ||
+MAGIC != cygpath -m -a -l '$(MAGIC)' | ||
+endif | ||
lib_LTLIBRARIES = libmagic.la | ||
nodist_include_HEADERS = magic.h | ||
|
||
-- | ||
2.29.2.windows.2 | ||
|
42 changes: 42 additions & 0 deletions
42
ports/libmagic/0013-Check-for-backslash-in-argv-0-on-Windows.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
From 3f10c7d31627b64b068b84ba72e706991f672560 Mon Sep 17 00:00:00 2001 | ||
From: Long Nguyen <[email protected]> | ||
Date: Fri, 14 May 2021 08:14:05 +0700 | ||
Subject: [PATCH 13/14] Check for backslash in argv[0] on Windows | ||
|
||
--- | ||
magic/Makefile.am | 2 +- | ||
src/file.c | 5 +++++ | ||
2 files changed, 6 insertions(+), 1 deletion(-) | ||
|
||
diff --git a/magic/Makefile.am b/magic/Makefile.am | ||
index 0eb5865..170bbab 100644 | ||
--- a/magic/Makefile.am | ||
+++ b/magic/Makefile.am | ||
@@ -353,7 +353,7 @@ ${MAGIC}: $(EXTRA_DIST) $(FILE_COMPILE_DEP) | ||
@(if expr "${FILE_COMPILE}" : '.*/.*' > /dev/null; then \ | ||
echo "Using ${FILE_COMPILE} to generate ${MAGIC}" > /dev/null; \ | ||
else \ | ||
- v=$$(${FILE_COMPILE} --version | sed -e s/file-// -e q); \ | ||
+ v=$$(${FILE_COMPILE} --version | sed -e s/file${EXEEXT}-// -e q); \ | ||
if [ "$$v" != "${PACKAGE_VERSION}" ]; then \ | ||
echo "Cannot use the installed version of file ($$v) to"; \ | ||
echo "cross-compile file ${PACKAGE_VERSION}"; \ | ||
diff --git a/src/file.c b/src/file.c | ||
index 2889f8a..12a604b 100644 | ||
--- a/src/file.c | ||
+++ b/src/file.c | ||
@@ -200,6 +200,11 @@ main(int argc, char *argv[]) | ||
_wildcard(&argc, &argv); | ||
#endif | ||
|
||
+#ifdef _WIN32 | ||
+ if ((progname = strrchr(argv[0], '\\')) != NULL) | ||
+ progname++; | ||
+ else | ||
+#endif | ||
if ((progname = strrchr(argv[0], '/')) != NULL) | ||
progname++; | ||
else | ||
-- | ||
2.29.2.windows.2 | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
diff --git a/src/fsmagic.c b/src/fsmagic.c | ||
index 7244841..2c553c1 100644 | ||
--- a/src/fsmagic.c | ||
+++ b/src/fsmagic.c | ||
@@ -66,7 +66,7 @@ # define major(dev) (((dev) >> 8) & 0xff) | ||
# define minor(dev) ((dev) & 0xff) | ||
#endif | ||
#undef HAVE_MAJOR | ||
-#if S_IFLNK != 0 | ||
+#if S_IFLNK != 0 && ! defined(_WIN32) | ||
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) | ||
int ret, did = 0; | ||
int mime = ms->flags & MAGIC_MIME; | ||
int silent = ms->flags & (MAGIC_APPLE|MAGIC_EXTENSION); | ||
-#if S_IFLNK != 0 | ||
+#if S_IFLNK != 0 && ! defined(_WIN32) | ||
char buf[BUFSIZ+4]; | ||
ssize_t nch; | ||
struct stat tstatbuf; | ||
@@ -122,7 +122,7 @@ file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb) | ||
* Fstat is cheaper but fails for files you don't have read perms on. | ||
* On 4.2BSD and similar systems, use lstat() to identify symlinks. | ||
*/ | ||
-#if S_IFLNK != 0 | ||
+#if S_IFLNK != 0 && ! defined(_WIN32) | ||
if ((ms->flags & MAGIC_SYMLINK) == 0) | ||
ret = lstat(fn, sb); | ||
else | ||
@@ -290,7 +290,7 @@ file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb) | ||
return -1; | ||
break; | ||
#endif | ||
-#if S_IFLNK != 0 | ||
+#if S_IFLNK != 0 && ! defined(_WIN32) | ||
case S_IFLNK: | ||
if ((nch = readlink(fn, buf, BUFSIZ-1)) <= 0) { | ||
if (ms->flags & MAGIC_ERROR) { |
Oops, something went wrong.