-
Notifications
You must be signed in to change notification settings - Fork 87
Add support for libmagic. #249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
5242f32
a66dca9
3271306
dde5b32
133e66b
28170f6
caa20a2
42754eb
f802f9f
cc258f0
5d8868a
500f290
b63b2a5
1aa159f
ea4b93b
4fa3909
9131bda
220cf6a
093af12
8c4f3c8
cde9100
fa61df7
a933c5d
ae22ff0
6968521
e883722
7871d11
554df3c
8845ccc
86dcebc
9d3e141
79398d7
6a2bcdc
78a1cd1
8dd4432
e4a9372
b936245
2e8d26b
7e63385
c4dddb9
3366268
9189dfa
e460673
bfcdab2
f8f278c
dccce2d
b1230e2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
libpcre |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
PKGURL=https://github.com/threatstack/libmagic/archive/5.18.tar.gz | ||
PKGHASH=ce734a1cc24bddbfd8b21f4ffdfe721ab74eeed9 | ||
|
||
package_download $PKGURL $PKGHASH | ||
package_patch | ||
|
||
EXTRACONF= | ||
|
||
if [ "$SYS_PLATFORM" != "$SYS_HOSTPLATFORM" ]; then | ||
EXTRACONF="$EXTRACONF --host=$SYS_ARCH" | ||
fi | ||
|
||
# pretend libgnurx exists by masking libpcre | ||
|
||
test -L $SYS_PREFIX/include/regex.h || ln -s pcreposix.h $SYS_PREFIX/include/regex.h | ||
|
||
# Mabye instead of fooling the package, it should be patched | ||
rmifexists $SYS_PREFIX/lib/libgnurx.a | ||
rmifexists $SYS_PREFIX/lib/libgnurx | ||
mkdir $SYS_PREFIX/lib/libgnurx | ||
( cd $SYS_PREFIX/lib/libgnurx | ||
mkdir a | ||
cd a | ||
$SYS_AR -x ../../libpcre.a | ||
cd .. | ||
mkdir b | ||
cd b | ||
$SYS_AR -x ../../libpcreposix.a | ||
cd .. | ||
$SYS_AR rc ../libgnurx.a a/*.o b/*.o | ||
) | ||
|
||
rm -r $SYS_PREFIX/lib/libgnurx | ||
|
||
if [ `file --version|head -1` != file-5.18 ]; then | ||
if [ ! -f $SYS_HOSTPREFIX/bin/file ]; then | ||
./configure --enable-static --disable-shared 'CFLAGS=-fPIC -O3 -DPCRE_STATIC' | ||
package_make | ||
cp src/file $SYS_HOSTPREFIX/bin || exit 1 | ||
package_cleanup | ||
package_download $PKGURL $PKGHASH | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shouldn't it already be downloaded by this time (as in line 4)? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes it should. Reading |
||
package_patch | ||
fi | ||
FILE_COMPILE=$SYS_HOSTPREFIX/bin/file | ||
fi | ||
|
||
# configure | ||
|
||
if [ "$SYS_PLATFORM" != "$SYS_HOSTPLATFORM" -a "X$FILE_COMPILE" != "X" ]; then | ||
echo patching magic/Makefile.in to use $FILE_COMPILE | ||
sed -i -es%'@IS_CROSS_COMPILE_TRUE@FILE_COMPILE = file${EXEEXT}'%"@IS_CROSS_COMPILE_TRUE@FILE_COMPILE = ${FILE_COMPILE}"% magic/Makefile.in | ||
fi | ||
|
||
package_configure --enable-static --disable-shared $EXTRACONF "'CFLAGS=-fPIC -O3 -DPCRE_STATIC -DNOSHLWAPI'" | ||
|
||
|
||
# build | ||
|
||
package_make | ||
|
||
# install | ||
|
||
cp src/.libs/libmagic.a $SYS_PREFIX/lib | ||
cp src/magic.h $SYS_PREFIX/include | ||
test -f src/file.exe && cp src/file.exe $SYS_PREFIX/bin | ||
test -d $SYS_PREFIX/etc || mkdir $SYS_PREFIX/etc | ||
cp magic/magic.mgc $SYS_PREFIX/etc | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you need this file embedded couldn't you compile it once and then include it in the module with an EMBED file? - Also does it need to be in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure. I don't really know where to put it. As you said: embedding might not be available from within the library directory. Hence we'll have to install it somewhere to be available for embedding later. |
||
|
||
# Cleanup the fooling | ||
rm -f $SYS_PREFIX/lib/libgnurx.a $SYS_PREFIX/include/regex.h | ||
|
||
package_cleanup | ||
|
||
unset EXTRACONF | ||
|
||
#eof |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- src/magic.original.c 2014-08-28 17:53:19.000000000 +0200 | ||
+++ src/magic.c 2019-08-07 17:56:04.790561769 +0200 | ||
@@ -175,7 +175,16 @@ | ||
LPTSTR dllpath = malloc(sizeof(*dllpath) * (MAX_PATH + 1)); | ||
dllpath[MAX_PATH] = 0; /* just in case long path gets truncated and not null terminated */ | ||
if (GetModuleFileNameA(NULL, dllpath, MAX_PATH)){ | ||
- PathRemoveFileSpecA(dllpath); | ||
+ // PathRemoveFileSpecA(dllpath); | ||
+ { | ||
+ // PathRemoveFileSpecA is not avail on mingw | ||
+ int i = strlen(dllpath); | ||
+ while(i>0) { | ||
+ if(dllpath[i] == '\\') break; | ||
+ dllpath[i--] = '\0'; | ||
+ } | ||
+ dllpath[i] = '\0'; | ||
+ } | ||
if (strlen(dllpath) > 3 && | ||
stricmp(&dllpath[strlen(dllpath) - 3], "bin") == 0) { | ||
if (asprintf(&tmppath, |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
PKGURL=https://ftp.pcre.org/pub/pcre/pcre-8.43.tar.gz | ||
PKGHASH=8f36ed69d3e938972fc511c19bfaa0ff27ff1d71 | ||
|
||
package_download $PKGURL $PKGHASH | ||
|
||
package_patch | ||
|
||
EXTRACONF="--enable-utf --enable-jit " | ||
|
||
if [ "$SYS_PLATFORM" != "$SYS_HOSTPLATFORM" ]; then | ||
EXTRACONF="$EXTRACONF --host=$SYS_ARCH" | ||
fi | ||
|
||
# configure | ||
|
||
lncc=`echo $SYS_CC| cut -d ' ' -f 1` | ||
case $lncc in | ||
*clang) deflncxx="CXX=${lncc}++" ;; | ||
esac | ||
package_configure $EXTRACONF "CC=$lncc $deflncxx" | ||
|
||
# build | ||
|
||
NOQUIET=yes package_make | ||
|
||
# install | ||
|
||
cp .libs/libpcre.a .libs/libpcreposix.a $SYS_PREFIX/lib || exit 1 | ||
cp pcre.h pcreposix.h pcrecpparg.h pcre_scanner.h pcre_stringpiece.h $SYS_PREFIX/include || exit 1 | ||
|
||
package_cleanup | ||
|
||
unsset deflncxx | ||
unset EXTRACONF | ||
|
||
#eof |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not quite sure about this either. Why not include that library if you depend on it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two reasons:
At least I need
pcre
anyway and I see limited reasons to have two libraries implementing the same functionality.I'd guess there might be license compatibility issues when linking against a GPLed library and
libgnurx
is AFAIK.