update to new version 5.31

This commit is contained in:
Kamil Dudka 2017-05-24 09:25:49 +02:00
parent 98475a8bd8
commit 780c608c32
8 changed files with 13 additions and 263 deletions

View File

@ -1,37 +0,0 @@
From a69d6d074116d4c026d14725995988810c5fbebb Mon Sep 17 00:00:00 2001
From: Christos Zoulas <christos@zoulas.com>
Date: Tue, 21 Feb 2017 18:34:55 +0000
Subject: [PATCH] bump perl to exceed 'c'
Upstream-commit: 3c60e59aee7425ba599d208678b62efa9a4a1d3f
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
magic/Magdir/perl | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/magic/Magdir/perl b/magic/Magdir/perl
index bbe10ba..3423b5c 100644
--- a/magic/Magdir/perl
+++ b/magic/Magdir/perl
@@ -33,14 +33,14 @@
# by Dmitry V. Levin and Alexey Tourbin
# check the first line
-0 search/1024 package
+0 search/8192 package
>0 regex \^package[\ \t]+[0-9A-Za-z_:]+\ *; Perl5 module source text
-!:strength + 10
+!:strength + 40
# not 'p', check other lines
-0 search/1024 !p
+0 search/8192 !p
>0 regex \^package[\ \t]+[0-9A-Za-z_:]+\ *;
>>0 regex \^1\ *;|\^(use|sub|my)\ .*[(;{=] Perl5 module source text
-!:strength + 10
+!:strength + 75
# Perl POD documents
# From: Tom Hukins <tom@eborcom.com>
--
2.7.4

View File

@ -1,27 +0,0 @@
From 74f951c91cccc82366b6e504cc10ee2990578cc4 Mon Sep 17 00:00:00 2001
From: Christos Zoulas <christos@zoulas.com>
Date: Sat, 11 Feb 2017 18:12:03 +0000
Subject: [PATCH] fix debug info reversed logic
Upstream-commit: ee13402cb538509f4594a1ebaabc28b7d511c247
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
src/readelf.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/readelf.c b/src/readelf.c
index 4520148..d1b71cf 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -1185,7 +1185,7 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num,
{
Elf32_Shdr sh32;
Elf64_Shdr sh64;
- int stripped = 1, has_debug_info = 1;
+ int stripped = 1, has_debug_info = 0;
size_t nbadcap = 0;
void *nbuf;
off_t noff, coff, name_off;
--
2.7.4

View File

@ -1,34 +0,0 @@
From 590b893222ee6102f1bcaad7a5e3e6abf315de3a Mon Sep 17 00:00:00 2001
From: Christos Zoulas <christos@zoulas.com>
Date: Tue, 14 Feb 2017 12:56:48 +0000
Subject: [PATCH] keep "[not] stripped" last since some scripts expect it to be
there.
Upstream-commit: 1507352bc5cbdebaa9f64f1c73876ec9d8a638bc
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
src/readelf.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/readelf.c b/src/readelf.c
index d1b71cf..3695c89 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -1373,12 +1373,12 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num,
}
}
- if (file_printf(ms, ", %sstripped", stripped ? "" : "not ") == -1)
- return -1;
if (has_debug_info) {
if (file_printf(ms, ", with debug_info") == -1)
return -1;
}
+ if (file_printf(ms, ", %sstripped", stripped ? "" : "not ") == -1)
+ return -1;
if (cap_hw1) {
const cap_desc_t *cdp;
switch (mach) {
--
2.7.4

View File

@ -1,147 +0,0 @@
From 379acb2065d904acf3a9814adfd93cda71a6ca21 Mon Sep 17 00:00:00 2001
From: Christos Zoulas <christos@zoulas.com>
Date: Tue, 4 Apr 2017 20:48:40 +0000
Subject: [PATCH] retain python 2 compatibility, factoring out the conversion
functions.
Upstream-commit: 8a942980f3f705226300f43f4b49a557c0918660
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
python/magic.py | 68 ++++++++++++++++++++++++++++++++-------------------------
1 file changed, 38 insertions(+), 30 deletions(-)
diff --git a/python/magic.py b/python/magic.py
index b0f7a17..662569e 100644
--- a/python/magic.py
+++ b/python/magic.py
@@ -117,30 +117,43 @@ class Magic(object):
"""
_close(self._magic_t)
+ @staticmethod
+ def __tostr(s):
+ if s is None:
+ return None
+ if isinstance(s, str):
+ return s
+ try: # keep Python 2 compatibility
+ return str(s, 'utf-8')
+ except TypeError:
+ return str(s)
+
+ @staticmethod
+ def __tobytes(b):
+ if b is None:
+ return None
+ if isinstance(b, bytes):
+ return b
+ try: # keep Python 2 compatibility
+ return bytes(b, 'utf-8')
+ except TypeError:
+ return bytes(b)
+
def file(self, filename):
"""
Returns a textual description of the contents of the argument passed
as a filename or None if an error occurred and the MAGIC_ERROR flag
- is set. A call to errno() will return the numeric error code.
+ is set. A call to errno() will return the numeric error code.
"""
- if isinstance(filename, bytes):
- bi = filename
- else:
- try: # keep Python 2 compatibility
- bi = bytes(filename, 'utf-8')
- except TypeError:
- bi = bytes(filename)
- r = _file(self._magic_t, bi)
- if isinstance(r, str):
- return r
- else:
- return str(r, 'utf-8')
+ return Magic.__tostr(_file(self._magic_t, Magic.__tobytes(filename)))
def descriptor(self, fd):
"""
- Like the file method, but the argument is a file descriptor.
+ Returns a textual description of the contents of the argument passed
+ as a file descriptor or None if an error occurred and the MAGIC_ERROR
+ flag is set. A call to errno() will return the numeric error code.
"""
- return _descriptor(self._magic_t, fd)
+ return Magic.__tostr(_descriptor(self._magic_t, fd))
def buffer(self, buf):
"""
@@ -148,22 +161,14 @@ class Magic(object):
as a buffer or None if an error occurred and the MAGIC_ERROR flag
is set. A call to errno() will return the numeric error code.
"""
- r = _buffer(self._magic_t, buf, len(buf))
- if isinstance(r, str):
- return r
- else:
- return str(r, 'utf-8')
+ return Magic.__tostr(_buffer(self._magic_t, buf, len(buf)))
def error(self):
"""
Returns a textual explanation of the last error or None
if there was no error.
"""
- e = _error(self._magic_t)
- if isinstance(e, str):
- return e
- else:
- return str(e, 'utf-8')
+ return Magic.__tostr(_error(self._magic_t))
def setflags(self, flags):
"""
@@ -184,35 +189,38 @@ class Magic(object):
Returns 0 on success and -1 on failure.
"""
- return _load(self._magic_t, filename)
+ return _load(self._magic_t, Magic.__tobytes(filename))
def compile(self, dbs):
"""
Compile entries in the colon separated list of database files
passed as argument or the default database file if no argument.
- Returns 0 on success and -1 on failure.
The compiled files created are named from the basename(1) of each file
argument with ".mgc" appended to it.
+
+ Returns 0 on success and -1 on failure.
"""
- return _compile(self._magic_t, dbs)
+ return _compile(self._magic_t, Magic.__tobytes(dbs))
def check(self, dbs):
"""
Check the validity of entries in the colon separated list of
database files passed as argument or the default database file
if no argument.
+
Returns 0 on success and -1 on failure.
"""
- return _check(self._magic_t, dbs)
+ return _check(self._magic_t, Magic.__tobytes(dbs))
def list(self, dbs):
"""
Check the validity of entries in the colon separated list of
database files passed as argument or the default database file
if no argument.
+
Returns 0 on success and -1 on failure.
"""
- return _list(self._magic_t, dbs)
+ return _list(self._magic_t, Magic.__tobytes(dbs))
def errno(self):
"""
--
2.10.2

View File

@ -1,7 +0,0 @@
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
iEYEABECAAYFAlid+B8ACgkQcREqsWyzOzqaygCfbxYMlxymrZ7Wh0P8UtfFdNr/
d8wAoIJiovAYOijFWLAcRqVoszPESSxo
=ekW2
-----END PGP SIGNATURE-----

6
file-5.31.tar.gz.asc Normal file
View File

@ -0,0 +1,6 @@
-----BEGIN PGP SIGNATURE-----
iEYEABECAAYFAlkkdXQACgkQcREqsWyzOzo0vwCg2YsLRBAmUk7Qukg81uiCwUjp
iggAoJJ3ftx9zysH6PPNCmc2q8tMRlaJ
=Cxli
-----END PGP SIGNATURE-----

View File

@ -2,8 +2,8 @@
Summary: A utility for determining file types
Name: file
Version: 5.30
Release: 6%{?dist}
Version: 5.31
Release: 1%{?dist}
License: BSD
Group: Applications/File
Source0: ftp://ftp.astron.com/pub/file/file-%{version}.tar.gz
@ -17,10 +17,7 @@ Patch4: file-5.04-volume_key.patch
Patch5: file-5.04-man-return-code.patch
# picked from upstream
Patch18: file-5.30-fix-debug-info-reversed-logic.patch
Patch19: file-5.30-keep-not-stripped-last.patch
Patch20: file-5.30-bump-perl-to-exceed-c.patch
Patch21: file-5.30-python-utf8.patch
URL: http://www.darwinsys.com/file/
Requires: file-libs = %{version}-%{release}
@ -83,10 +80,6 @@ file(1) command.
%prep
%autosetup -p1
# Patches can generate *.orig files, which can't stay in the magic dir,
# otherwise there will be problems with compiling magic file!
rm -fv magic/Magdir/*.orig
iconv -f iso-8859-1 -t utf-8 < doc/libmagic.man > doc/libmagic.man_
touch -r doc/libmagic.man doc/libmagic.man_
mv doc/libmagic.man_ doc/libmagic.man
@ -189,6 +182,9 @@ cd %{py3dir}
%endif
%changelog
* Wed May 24 2017 Kamil Dudka <kdudka@redhat.com> - 5.31-1
- update to new version 5.31
* Wed Apr 05 2017 Kamil Dudka <kdudka@redhat.com> - 5.30-6
- fix utf-8 conversion in Python 2 bindings (#1433364)

View File

@ -1 +1 @@
SHA512 (file-5.30.tar.gz) = 473ee57517b449bae0832c17c9db914162c2404f0c669951f13a53f44ae288e6075907bac44fcfa8915f3d9313981a8bc15ea7e9851f584f95988bc76b2f20fc
SHA512 (file-5.31.tar.gz) = 0d024787b5b1fdd6469627d2b4081082fa66fff7a1a84ce06a0710db1dad6b9bd395dc2b758ebc733d14b7e9d135fc2fefcb62919fb98bd140b88445bac89651