From 89fc9b6ba8fdb8c30300a9e2a545c46a1abe3427 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Mon, 7 Dec 2009 16:30:35 +0100 Subject: [PATCH] Add a script to install the file(1) tool Signed-off-by: Johannes Schindelin --- src/file/.gitignore | 1 + ...ude-headers-on-Windows-that-do-not-exist-.patch | 57 ++++++++++++++++++++++ ...Git-include-pthread.h-for-struct-timespec.patch | 44 +++++++++++++++++ .../0003-On-Windows-we-do-not-have-fork.patch | 37 ++++++++++++++ .../0004-Avoid-using-ELOOP-on-Windows.patch | 29 +++++++++++ ...d-one-forgotten-ifndef-O_NONBLOCK-.-endif.patch | 27 ++++++++++ ...0006-On-msysGit-include-the-whole-regex.c.patch | 27 ++++++++++ src/file/release.sh | 27 ++++++++++ 8 files changed, 249 insertions(+) create mode 100644 src/file/.gitignore create mode 100644 src/file/patches/0001-Do-not-include-headers-on-Windows-that-do-not-exist-.patch create mode 100644 src/file/patches/0002-On-msysGit-include-pthread.h-for-struct-timespec.patch create mode 100644 src/file/patches/0003-On-Windows-we-do-not-have-fork.patch create mode 100644 src/file/patches/0004-Avoid-using-ELOOP-on-Windows.patch create mode 100644 src/file/patches/0005-Add-one-forgotten-ifndef-O_NONBLOCK-.-endif.patch create mode 100644 src/file/patches/0006-On-msysGit-include-the-whole-regex.c.patch create mode 100644 src/file/release.sh diff --git a/src/file/.gitignore b/src/file/.gitignore new file mode 100644 index 00000000..8175bd28 --- /dev/null +++ b/src/file/.gitignore @@ -0,0 +1 @@ +file-* diff --git a/src/file/patches/0001-Do-not-include-headers-on-Windows-that-do-not-exist-.patch b/src/file/patches/0001-Do-not-include-headers-on-Windows-that-do-not-exist-.patch new file mode 100644 index 00000000..c5103cfe --- /dev/null +++ b/src/file/patches/0001-Do-not-include-headers-on-Windows-that-do-not-exist-.patch @@ -0,0 +1,57 @@ +From ad3ec96da42644be738aa5fcbb4a65e3a9c6284e Mon Sep 17 00:00:00 2001 +From: Johannes Schindelin +Date: Mon, 7 Dec 2009 17:20:14 +0100 +Subject: [PATCH 1/6] Do not include headers on Windows that do not exist there + +Signed-off-by: Johannes Schindelin +--- + src/compress.c | 2 ++ + src/file.c | 2 ++ + src/magic.c | 2 ++ + 3 files changed, 6 insertions(+), 0 deletions(-) + +diff --git a/src/compress.c b/src/compress.c +index 28dacd3..b220d2e 100644 +--- a/src/compress.c ++++ b/src/compress.c +@@ -45,7 +45,9 @@ FILE_RCSID("@(#)$File: compress.c,v 1.63 2009/03/23 14:21:51 christos Exp $") + #endif + #include + #include ++#ifndef WIN32 + #include ++#endif + #ifdef HAVE_SYS_WAIT_H + #include + #endif +diff --git a/src/file.c b/src/file.c +index 34aa44c..a7bb914 100644 +--- a/src/file.c ++++ b/src/file.c +@@ -70,7 +70,9 @@ FILE_RCSID("@(#)$File: file.c,v 1.131 2009/02/13 18:48:05 christos Exp $") + int getopt_long(int argc, char * const *argv, const char *optstring, const struct option *longopts, int *longindex); + #endif + ++#ifndef WIN32 + #include /* for byte swapping */ ++#endif + + #include "patchlevel.h" + +diff --git a/src/magic.c b/src/magic.c +index b89989b..5a54991 100644 +--- a/src/magic.c ++++ b/src/magic.c +@@ -57,7 +57,9 @@ FILE_RCSID("@(#)$File: magic.c,v 1.62 2009/03/20 21:25:41 christos Exp $") + #include /* for read() */ + #endif + ++#ifndef WIN32 + #include /* for byte swapping */ ++#endif + + #include "patchlevel.h" + +-- +1.6.5.1.1371.g1abf3 + diff --git a/src/file/patches/0002-On-msysGit-include-pthread.h-for-struct-timespec.patch b/src/file/patches/0002-On-msysGit-include-pthread.h-for-struct-timespec.patch new file mode 100644 index 00000000..e08479e0 --- /dev/null +++ b/src/file/patches/0002-On-msysGit-include-pthread.h-for-struct-timespec.patch @@ -0,0 +1,44 @@ +From 9c4e13e91ef1201d1cb4dd6daefc02d1b0ad58e2 Mon Sep 17 00:00:00 2001 +From: Johannes Schindelin +Date: Mon, 7 Dec 2009 17:21:21 +0100 +Subject: [PATCH 2/6] On msysGit, include pthread.h for struct timespec + +Signed-off-by: Johannes Schindelin +--- + src/cdf_time.c | 4 ++++ + src/readcdf.c | 4 ++++ + 2 files changed, 8 insertions(+), 0 deletions(-) + +diff --git a/src/cdf_time.c b/src/cdf_time.c +index 932253b..0ff4ccc 100644 +--- a/src/cdf_time.c ++++ b/src/cdf_time.c +@@ -31,6 +31,10 @@ FILE_RCSID("@(#)$File: cdf_time.c,v 1.6 2009/03/10 11:44:29 christos Exp $") + #endif + + #include ++#ifdef WIN32 ++/* definition of timespec */ ++#include ++#endif + #ifdef TEST + #include + #endif +diff --git a/src/readcdf.c b/src/readcdf.c +index 15f53fe..df14c35 100644 +--- a/src/readcdf.c ++++ b/src/readcdf.c +@@ -33,6 +33,10 @@ FILE_RCSID("@(#)$File: readcdf.c,v 1.18 2009/05/06 20:48:22 christos Exp $") + #include + #include + #include ++#ifdef WIN32 ++/* definition of timespec */ ++#include ++#endif + #include + + #include "cdf.h" +-- +1.6.5.1.1371.g1abf3 + diff --git a/src/file/patches/0003-On-Windows-we-do-not-have-fork.patch b/src/file/patches/0003-On-Windows-we-do-not-have-fork.patch new file mode 100644 index 00000000..58ac690e --- /dev/null +++ b/src/file/patches/0003-On-Windows-we-do-not-have-fork.patch @@ -0,0 +1,37 @@ +From 048a484b313ddd7054c8d3dcb9b9dc508bc1689b Mon Sep 17 00:00:00 2001 +From: Johannes Schindelin +Date: Mon, 7 Dec 2009 17:21:52 +0100 +Subject: [PATCH 3/6] On Windows, we do not have fork() + +Unfortunately, that means that we cannot easily uncompress if it is +not covered by libz. + +Signed-off-by: Johannes Schindelin +--- + src/compress.c | 5 +++++ + 1 files changed, 5 insertions(+), 0 deletions(-) + +diff --git a/src/compress.c b/src/compress.c +index b220d2e..d17c18b 100644 +--- a/src/compress.c ++++ b/src/compress.c +@@ -380,6 +380,10 @@ uncompressbuf(struct magic_set *ms, int fd, size_t method, + if (method == 2) + return uncompressgzipped(ms, old, newch, n); + #endif ++#ifdef WIN32 ++ file_printf(ms, "Cannot uncompress (fork) on Windows"); ++ return NODATA; ++#else + (void)fflush(stdout); + (void)fflush(stderr); + +@@ -493,4 +497,5 @@ err: + + return n; + } ++#endif /* WIN32 */ + } +-- +1.6.5.1.1371.g1abf3 + diff --git a/src/file/patches/0004-Avoid-using-ELOOP-on-Windows.patch b/src/file/patches/0004-Avoid-using-ELOOP-on-Windows.patch new file mode 100644 index 00000000..0154963f --- /dev/null +++ b/src/file/patches/0004-Avoid-using-ELOOP-on-Windows.patch @@ -0,0 +1,29 @@ +From 291ac13faaf652dfd33ab6393cf054208510203c Mon Sep 17 00:00:00 2001 +From: Johannes Schindelin +Date: Mon, 7 Dec 2009 17:22:32 +0100 +Subject: [PATCH 4/6] Avoid using ELOOP on Windows + +Signed-off-by: Johannes Schindelin +--- + src/fsmagic.c | 2 ++ + 1 files changed, 2 insertions(+), 0 deletions(-) + +diff --git a/src/fsmagic.c b/src/fsmagic.c +index a68cd10..d53b916 100644 +--- a/src/fsmagic.c ++++ b/src/fsmagic.c +@@ -70,9 +70,11 @@ bad_link(struct magic_set *ms, int err, char *buf) + == -1) + return -1; + else if (!mime) { ++#ifndef WIN32 + if (err == ELOOP) + errfmt = "symbolic link in a loop"; + else ++#endif + errfmt = "broken symbolic link to `%s'"; + if (ms->flags & MAGIC_ERROR) { + file_error(ms, err, errfmt, buf); +-- +1.6.5.1.1371.g1abf3 + diff --git a/src/file/patches/0005-Add-one-forgotten-ifndef-O_NONBLOCK-.-endif.patch b/src/file/patches/0005-Add-one-forgotten-ifndef-O_NONBLOCK-.-endif.patch new file mode 100644 index 00000000..301f8b1e --- /dev/null +++ b/src/file/patches/0005-Add-one-forgotten-ifndef-O_NONBLOCK-.-endif.patch @@ -0,0 +1,27 @@ +From 3c0e49bd8b776c9c08e7bf6ed07aa81675a903f3 Mon Sep 17 00:00:00 2001 +From: Johannes Schindelin +Date: Mon, 7 Dec 2009 17:22:54 +0100 +Subject: [PATCH 5/6] Add one forgotten #ifndef O_NONBLOCK ... #endif + +Signed-off-by: Johannes Schindelin +--- + src/magic.c | 2 ++ + 1 files changed, 2 insertions(+), 0 deletions(-) + +diff --git a/src/magic.c b/src/magic.c +index 5a54991..d1588aa 100644 +--- a/src/magic.c ++++ b/src/magic.c +@@ -283,7 +283,9 @@ file_or_fd(struct magic_set *ms, const char *inname, int fd) + int flags = O_RDONLY|O_BINARY; + + if (stat(inname, &sb) == 0 && S_ISFIFO(sb.st_mode)) { ++#ifdef O_NONBLOCK + flags |= O_NONBLOCK; ++#endif + ispipe = 1; + } + +-- +1.6.5.1.1371.g1abf3 + diff --git a/src/file/patches/0006-On-msysGit-include-the-whole-regex.c.patch b/src/file/patches/0006-On-msysGit-include-the-whole-regex.c.patch new file mode 100644 index 00000000..09b5c422 --- /dev/null +++ b/src/file/patches/0006-On-msysGit-include-the-whole-regex.c.patch @@ -0,0 +1,27 @@ +From 1b971dcbe6e5981c64f458f7f3bbc7eb7839057c Mon Sep 17 00:00:00 2001 +From: Johannes Schindelin +Date: Mon, 7 Dec 2009 17:23:24 +0100 +Subject: [PATCH 6/6] On msysGit, include the whole regex.c + +Signed-off-by: Johannes Schindelin +--- + src/softmagic.c | 3 +++ + 1 files changed, 3 insertions(+), 0 deletions(-) + +diff --git a/src/softmagic.c b/src/softmagic.c +index 88f5214..294ef70 100644 +--- a/src/softmagic.c ++++ b/src/softmagic.c +@@ -41,6 +41,9 @@ FILE_RCSID("@(#)$File: softmagic.c,v 1.135 2009/03/27 22:42:49 christos Exp $") + #include + #include + ++/* hack for msysGit */ ++#include ++ + + private int match(struct magic_set *, struct magic *, uint32_t, + const unsigned char *, size_t, int); +-- +1.6.5.1.1371.g1abf3 + diff --git a/src/file/release.sh b/src/file/release.sh new file mode 100644 index 00000000..e1e5d726 --- /dev/null +++ b/src/file/release.sh @@ -0,0 +1,27 @@ +#!/bin/sh + +cd "$(dirname "$0")" + +URL=ftp://ftp.astron.com/pub/file +TAR=file-5.03.tar.gz +DIR=file-5.03 + +if test ! -f $TAR +then + curl $URL/$TAR > $TAR +fi && +if test ! -d $DIR +then + tar xzvf $TAR +fi && +(cd $DIR && + git init && + git add . && + git commit -m initial && + git am ../patches/* && + CFLAGS=-I/git/compat/regex ./configure --prefix=/mingw && + make && + index=$(/share/msysGit/pre-install.sh) && + make install && + /share/msysGit/post-install.sh $INDEX Install $DIR +) -- 2.11.4.GIT