From 34f6939450dba09359c01025a100dfc59aff835d Mon Sep 17 00:00:00 2001 From: hy Date: Sat, 28 Mar 2020 17:54:51 +0800 Subject: [PATCH 1/8] add make check in file.spec. Conflicts: file.spec --- file.spec | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/file.spec b/file.spec index 6b9cf43..2547fa3 100644 --- a/file.spec +++ b/file.spec @@ -1,6 +1,6 @@ Name: file -Version: 5.39 -Release: 1 +Version: 5.38 +Release: 2 Summary: A tool to identify the type of a particular file type License: BSD URL: http://www.darwinsys.com/file/ @@ -108,6 +108,9 @@ cd %{py3dir} %ldconfig_scriptlets libs +%check +make check + %files %doc ChangeLog README %license COPYING @@ -149,14 +152,17 @@ cd %{py3dir} %{python3_sitelib}/__pycache__/* %changelog -* Thu Jul 30 2020 yanglongkang - 5.39-1 -- update to 5.39 version +* Tue Sep 28 2021 hy - 5.38-2 +- Type:enhancemnet +- ID:NA +- SUG:restart +- DESC:add make check * Fri Jan 10 2020 Huangzheng - 5.38-1 - Type:enhancemnet - ID:NA - SUG:restart -- DESCi:upgrade package +- DESC:upgrade package * Thu Dec 26 2019 openEuler Buildteam - 5.34-9 - reupload patches -- Gitee From 631f5808dfa5e0ee1fd29407c5d679c9cf8b3de9 Mon Sep 17 00:00:00 2001 From: Zhiqiang Liu Date: Tue, 21 Jul 2020 19:56:05 +0800 Subject: [PATCH 2/8] file: update to 5.39 version file: update to 5.39 version here we tmp remove 'make check' because the test needs to install the built rpm firstly. Signed-off-by: Zhiqiang Liu Conflicts: 0001-file-localmagic.patch file.spec --- 0001-file-localmagic.patch | 1 + file.spec | 13 ++++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/0001-file-localmagic.patch b/0001-file-localmagic.patch index 895f5ee..3144a80 100644 --- a/0001-file-localmagic.patch +++ b/0001-file-localmagic.patch @@ -61,3 +61,4 @@ index 1437bcc..b609dd1 100644 if (map == NULL) -- 1.8.3.1 + diff --git a/file.spec b/file.spec index 2547fa3..46050e4 100644 --- a/file.spec +++ b/file.spec @@ -1,12 +1,12 @@ Name: file -Version: 5.38 -Release: 2 +Version: 5.39 +Release: 1 Summary: A tool to identify the type of a particular file type License: BSD URL: http://www.darwinsys.com/file/ Source0: ftp://ftp.astron.com/pub/file/file-%{version}.tar.gz -Patch1: 0001-file-localmagic.patch +Patch1: 0001-file-localmagic.patch Requires: %{name}-libs = %{version}-%{release} BuildRequires: autoconf automake libtool git zlib-devel @@ -109,7 +109,7 @@ cd %{py3dir} %ldconfig_scriptlets libs %check -make check +#make check %files %doc ChangeLog README @@ -152,7 +152,10 @@ make check %{python3_sitelib}/__pycache__/* %changelog -* Tue Sep 28 2021 hy - 5.38-2 +* Tue Sep 28 2021 zhanchengbin - 5.39-1 +- update to 5.39 version and tmp remove 'make check' + +* Tue Sep 28 2021 zhanchengbin - 5.38-2 - Type:enhancemnet - ID:NA - SUG:restart -- Gitee From f8e758caa76733e3302af64769548de6b5aadd86 Mon Sep 17 00:00:00 2001 From: Zhiqiang Liu Date: Sat, 25 Jul 2020 17:39:26 +0800 Subject: [PATCH 3/8] file: enable make check file: enable make check Signed-off-by: Zhiqiang Liu Conflicts: file.spec --- file.spec | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/file.spec b/file.spec index 46050e4..099ceaa 100644 --- a/file.spec +++ b/file.spec @@ -1,6 +1,6 @@ Name: file Version: 5.39 -Release: 1 +Release: 2 Summary: A tool to identify the type of a particular file type License: BSD URL: http://www.darwinsys.com/file/ @@ -109,7 +109,7 @@ cd %{py3dir} %ldconfig_scriptlets libs %check -#make check +make check %files %doc ChangeLog README @@ -152,6 +152,9 @@ cd %{py3dir} %{python3_sitelib}/__pycache__/* %changelog +* Tue Sep 28 2021 zhanchengbin - 5.39-2 +- enable make check + * Tue Sep 28 2021 zhanchengbin - 5.39-1 - update to 5.39 version and tmp remove 'make check' -- Gitee From ab996ab0c970145df93a23b24bcac7401583d046 Mon Sep 17 00:00:00 2001 From: zhangyouming Date: Mon, 24 Aug 2020 20:20:51 +0800 Subject: [PATCH 4/8] improve detection of static-pie binaries Conflicts: file.spec --- ...ove-detection-of-static-pie-binaries.patch | 133 ++++++++++++++++++ file.spec | 8 +- 2 files changed, 139 insertions(+), 2 deletions(-) create mode 100644 0002-improve-detection-of-static-pie-binaries.patch diff --git a/0002-improve-detection-of-static-pie-binaries.patch b/0002-improve-detection-of-static-pie-binaries.patch new file mode 100644 index 0000000..63ad1f1 --- /dev/null +++ b/0002-improve-detection-of-static-pie-binaries.patch @@ -0,0 +1,133 @@ +From 363d7fcf703ad3ebf37b45693b2c9e43eb8b4176 Mon Sep 17 00:00:00 2001 +From: Christos Zoulas +Date: Sat, 22 Aug 2020 18:04:18 +0000 +Subject: [PATCH] Improve detection of static-pie binaries, and don't call them + "dynamically linked", but call them "static-pie" linked. + +--- + src/readelf.c | 37 ++++++++++++++++++++++++++----------- + 1 file changed, 26 insertions(+), 11 deletions(-) + +diff --git a/src/readelf.c b/src/readelf.c +index cf1dc91..d390d5f 100644 +--- a/src/readelf.c ++++ b/src/readelf.c +@@ -27,7 +27,7 @@ + #include "file.h" + + #ifndef lint +-FILE_RCSID("@(#)$File: readelf.c,v 1.173 2020/06/07 22:12:54 christos Exp $") ++FILE_RCSID("@(#)$File: readelf.c,v 1.174 2020/08/22 18:04:18 christos Exp $") + #endif + + #ifdef BUILTIN_ELF +@@ -1099,7 +1099,7 @@ do_auxv_note(struct magic_set *ms, unsigned char *nbuf, uint32_t type, + + private size_t + dodynamic(struct magic_set *ms, void *vbuf, size_t offset, size_t size, +- int clazz, int swap) ++ int clazz, int swap, int *pie, size_t *need) + { + Elf32_Dyn dh32; + Elf64_Dyn dh64; +@@ -1117,11 +1117,15 @@ dodynamic(struct magic_set *ms, void *vbuf, size_t offset, size_t size, + + switch (xdh_tag) { + case DT_FLAGS_1: ++ *pie = 1; + if (xdh_val & DF_1_PIE) + ms->mode |= 0111; + else + ms->mode &= ~0111; + break; ++ case DT_NEEDED: ++ (*need)++; ++ break; + default: + break; + } +@@ -1608,9 +1612,10 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num, + } + + /* +- * Look through the program headers of an executable image, searching +- * for a PT_INTERP section; if one is found, it's dynamically linked, +- * otherwise it's statically linked. ++ * Look through the program headers of an executable image, to determine ++ * if it is statically or dynamically linked. If it has a dynamic section, ++ * it is pie, and does not have an interpreter or needed libraries, we ++ * call it static pie. + */ + private int + dophn_exec(struct magic_set *ms, int clazz, int swap, int fd, off_t off, +@@ -1619,12 +1624,13 @@ dophn_exec(struct magic_set *ms, int clazz, int swap, int fd, off_t off, + { + Elf32_Phdr ph32; + Elf64_Phdr ph64; +- const char *linking_style = "statically"; ++ const char *linking_style; + unsigned char nbuf[BUFSIZ]; + char ibuf[BUFSIZ]; + char interp[BUFSIZ]; + ssize_t bufsize; +- size_t offset, align, len; ++ size_t offset, align, len, need = 0; ++ int pie = 0, dynamic = 0; + + if (num == 0) { + if (file_printf(ms, ", no program header") == -1) +@@ -1654,7 +1660,6 @@ dophn_exec(struct magic_set *ms, int clazz, int swap, int fd, off_t off, + switch (xph_type) { + case PT_DYNAMIC: + doread = 1; +- linking_style = "dynamically"; + break; + case PT_NOTE: + if (sh_num) /* Did this through section headers */ +@@ -1694,6 +1699,7 @@ dophn_exec(struct magic_set *ms, int clazz, int swap, int fd, off_t off, + /* Things we can determine when we seek */ + switch (xph_type) { + case PT_DYNAMIC: ++ dynamic = 1; + offset = 0; + // Let DF_1 determine if we are PIE or not. + ms->mode &= ~0111; +@@ -1701,7 +1707,8 @@ dophn_exec(struct magic_set *ms, int clazz, int swap, int fd, off_t off, + if (offset >= CAST(size_t, bufsize)) + break; + offset = dodynamic(ms, nbuf, offset, +- CAST(size_t, bufsize), clazz, swap); ++ CAST(size_t, bufsize), clazz, swap, ++ &pie, &need); + if (offset == 0) + break; + } +@@ -1710,6 +1717,7 @@ dophn_exec(struct magic_set *ms, int clazz, int swap, int fd, off_t off, + break; + + case PT_INTERP: ++ need++; + if (ms->flags & MAGIC_MIME) + continue; + if (bufsize && nbuf[0]) { +@@ -1744,8 +1752,15 @@ dophn_exec(struct magic_set *ms, int clazz, int swap, int fd, off_t off, + } + if (ms->flags & MAGIC_MIME) + return 0; +- if (file_printf(ms, ", %s linked", linking_style) +- == -1) ++ if (dynamic) { ++ if (pie && need == 0) ++ linking_style = "static-pie"; ++ else ++ linking_style = "dynamically"; ++ } else { ++ linking_style = "statically"; ++ } ++ if (file_printf(ms, ", %s linked", linking_style) == -1) + return -1; + if (interp[0]) + if (file_printf(ms, ", interpreter %s", +-- +1.8.3.1 + diff --git a/file.spec b/file.spec index 099ceaa..04cf114 100644 --- a/file.spec +++ b/file.spec @@ -1,12 +1,13 @@ Name: file Version: 5.39 -Release: 2 +Release: 3 Summary: A tool to identify the type of a particular file type License: BSD URL: http://www.darwinsys.com/file/ Source0: ftp://ftp.astron.com/pub/file/file-%{version}.tar.gz -Patch1: 0001-file-localmagic.patch +Patch1: 0001-file-localmagic.patch +Patch2: 0002-improve-detection-of-static-pie-binaries.patch Requires: %{name}-libs = %{version}-%{release} BuildRequires: autoconf automake libtool git zlib-devel @@ -152,6 +153,9 @@ make check %{python3_sitelib}/__pycache__/* %changelog +* Tue Sep 28 2021 zhanchengbin - 5.39-3 +- improve detection of static-pie binaries + * Tue Sep 28 2021 zhanchengbin - 5.39-2 - enable make check -- Gitee From 11ae3e610c491ffb785e8ea40a6c345b430aada9 Mon Sep 17 00:00:00 2001 From: jinzhimin369 Date: Fri, 30 Oct 2020 10:58:37 +0800 Subject: [PATCH 5/8] remove python2 dependency Conflicts: file.spec --- file.spec | 29 ++++------------------------- 1 file changed, 4 insertions(+), 25 deletions(-) diff --git a/file.spec b/file.spec index 04cf114..808dc0a 100644 --- a/file.spec +++ b/file.spec @@ -1,6 +1,6 @@ Name: file Version: 5.39 -Release: 3 +Release: 4 Summary: A tool to identify the type of a particular file type License: BSD URL: http://www.darwinsys.com/file/ @@ -44,17 +44,6 @@ Requires: man %description help This contains man files for the using of file -%package -n python2-magic -Summary: Python 2 bindings for the libmagic API -Requires: %{name} = %{version}-%{release} -BuildRequires: python2-devel -BuildArch: noarch -%{?python_provide:%python_provide python2-magic} - -%description -n python2-magic -This package contains the Python 2 bindings to access the libmagic -API. The libmagic library is also used by the familiar file(1) command. - %package -n python3-magic Summary: Python 3 bindings for the libmagic API Requires: %{name} = %{version}-%{release} @@ -84,8 +73,6 @@ sed -i 's/^hardcode_libdir_flag_spec=.*/hardcode_libdir_flag_spec=""/g' libtool sed -i 's/^runpath_var=LD_RUN_PATH/runpath_var=DIE_RPATH_DIE/g' libtool export LD_LIBRARY_PATH=%{_builddir}/%{name}-%{version}/src/.libs make %{?_smp_mflags} V=1 -cd python -CFLAGS="%{optflags}" %{__python2} setup.py build cd %{py3dir} CFLAGS="%{optflags}" %{__python3} setup.py build @@ -101,8 +88,6 @@ cat magic/Magdir/* > ${RPM_BUILD_ROOT}%{_datadir}/misc/magic ln -s misc/magic ${RPM_BUILD_ROOT}%{_datadir}/magic ln -s ../magic ${RPM_BUILD_ROOT}%{_datadir}/file/magic -cd python -%{__python2} setup.py install -O1 --skip-build --root ${RPM_BUILD_ROOT} cd %{py3dir} %{__python3} setup.py install -O1 --skip-build --root ${RPM_BUILD_ROOT} %{__install} -d ${RPM_BUILD_ROOT}%{_datadir}/%{name} @@ -135,15 +120,6 @@ make check %files help %{_mandir}/man* -%files -n python2-magic -%doc python/README.md python/example.py -%{!?_licensedir:%global license %%doc} -%license COPYING -%{python2_sitelib}/magic.py -%{python2_sitelib}/magic.pyc -%{python2_sitelib}/magic.pyo -%{python2_sitelib}/*egg-info - %files -n python3-magic %doc python/README.md python/example.py %{!?_licensedir:%global license %%doc} @@ -153,6 +129,9 @@ make check %{python3_sitelib}/__pycache__/* %changelog +* Tue Sep 28 2021 zhanchengbin - 5.39-4 +- remove python2 dependency + * Tue Sep 28 2021 zhanchengbin - 5.39-3 - improve detection of static-pie binaries -- Gitee From 4e3679ba03b966486f9ed87e22280201ad50fbe6 Mon Sep 17 00:00:00 2001 From: chenyanpanHW Date: Fri, 30 Jul 2021 22:37:34 +0800 Subject: [PATCH 6/8] delete -S git from %autosetup, and delete BuildRequires git Conflicts: file.spec --- file.spec | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/file.spec b/file.spec index 808dc0a..8890e86 100644 --- a/file.spec +++ b/file.spec @@ -1,6 +1,6 @@ Name: file Version: 5.39 -Release: 4 +Release: 5 Summary: A tool to identify the type of a particular file type License: BSD URL: http://www.darwinsys.com/file/ @@ -10,7 +10,7 @@ Patch1: 0001-file-localmagic.patch Patch2: 0002-improve-detection-of-static-pie-binaries.patch Requires: %{name}-libs = %{version}-%{release} -BuildRequires: autoconf automake libtool git zlib-devel +BuildRequires: autoconf automake libtool zlib-devel %description The program checks to see if the file is empty,or if @@ -55,7 +55,7 @@ This package contains the Python 3 bindings to access to the libmagic API. The libmagic library is also used by the familiar file(1) command. %prep -%autosetup -p1 -S git +%autosetup -p1 iconv doc/libmagic.man -f iso-8859-1 -t utf-8 -o doc/libmagic.man_ touch -r doc/libmagic.man doc/libmagic.man_ @@ -129,19 +129,22 @@ make check %{python3_sitelib}/__pycache__/* %changelog -* Tue Sep 28 2021 zhanchengbin - 5.39-4 +* Tue Sep 28 2021 zhanchengbin - 5.39-5 +- DESC: delete -S git from %autosetup, and delete BuildRequires git + +* Tue Sep 28 2021 zhanchengbin - 5.39-4 - remove python2 dependency -* Tue Sep 28 2021 zhanchengbin - 5.39-3 +* Tue Sep 28 2021 zhanchengbin - 5.39-3 - improve detection of static-pie binaries -* Tue Sep 28 2021 zhanchengbin - 5.39-2 +* Tue Sep 28 2021 zhanchengbin - 5.39-2 - enable make check -* Tue Sep 28 2021 zhanchengbin - 5.39-1 +* Tue Sep 28 2021 zhanchengbin - 5.39-1 - update to 5.39 version and tmp remove 'make check' -* Tue Sep 28 2021 zhanchengbin - 5.38-2 +* Tue Sep 28 2021 zhanchengbin - 5.38-2 - Type:enhancemnet - ID:NA - SUG:restart -- Gitee From 24f02057856c77cbf906f8c4933c387d11c87de5 Mon Sep 17 00:00:00 2001 From: zhanchengbin Date: Wed, 29 Sep 2021 11:39:00 +0800 Subject: [PATCH 7/8] Revert "remove python2 dependency" This reverts commit 11ae3e610c491ffb785e8ea40a6c345b430aada9. Conflicts: file.spec --- file.spec | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/file.spec b/file.spec index 8890e86..6e6b2ab 100644 --- a/file.spec +++ b/file.spec @@ -44,6 +44,17 @@ Requires: man %description help This contains man files for the using of file +%package -n python2-magic +Summary: Python 2 bindings for the libmagic API +Requires: %{name} = %{version}-%{release} +BuildRequires: python2-devel +BuildArch: noarch +%{?python_provide:%python_provide python2-magic} + +%description -n python2-magic +This package contains the Python 2 bindings to access the libmagic +API. The libmagic library is also used by the familiar file(1) command. + %package -n python3-magic Summary: Python 3 bindings for the libmagic API Requires: %{name} = %{version}-%{release} @@ -73,6 +84,8 @@ sed -i 's/^hardcode_libdir_flag_spec=.*/hardcode_libdir_flag_spec=""/g' libtool sed -i 's/^runpath_var=LD_RUN_PATH/runpath_var=DIE_RPATH_DIE/g' libtool export LD_LIBRARY_PATH=%{_builddir}/%{name}-%{version}/src/.libs make %{?_smp_mflags} V=1 +cd python +CFLAGS="%{optflags}" %{__python2} setup.py build cd %{py3dir} CFLAGS="%{optflags}" %{__python3} setup.py build @@ -88,6 +101,8 @@ cat magic/Magdir/* > ${RPM_BUILD_ROOT}%{_datadir}/misc/magic ln -s misc/magic ${RPM_BUILD_ROOT}%{_datadir}/magic ln -s ../magic ${RPM_BUILD_ROOT}%{_datadir}/file/magic +cd python +%{__python2} setup.py install -O1 --skip-build --root ${RPM_BUILD_ROOT} cd %{py3dir} %{__python3} setup.py install -O1 --skip-build --root ${RPM_BUILD_ROOT} %{__install} -d ${RPM_BUILD_ROOT}%{_datadir}/%{name} @@ -120,6 +135,15 @@ make check %files help %{_mandir}/man* +%files -n python2-magic +%doc python/README.md python/example.py +%{!?_licensedir:%global license %%doc} +%license COPYING +%{python2_sitelib}/magic.py +%{python2_sitelib}/magic.pyc +%{python2_sitelib}/magic.pyo +%{python2_sitelib}/*egg-info + %files -n python3-magic %doc python/README.md python/example.py %{!?_licensedir:%global license %%doc} @@ -132,9 +156,6 @@ make check * Tue Sep 28 2021 zhanchengbin - 5.39-5 - DESC: delete -S git from %autosetup, and delete BuildRequires git -* Tue Sep 28 2021 zhanchengbin - 5.39-4 -- remove python2 dependency - * Tue Sep 28 2021 zhanchengbin - 5.39-3 - improve detection of static-pie binaries -- Gitee From 7728635459807961a682a663537e401c83823cac Mon Sep 17 00:00:00 2001 From: zhanchengbin Date: Wed, 29 Sep 2021 11:39:00 +0800 Subject: [PATCH 8/8] Revert "remove python2 dependency" This reverts commit 11ae3e610c491ffb785e8ea40a6c345b430aada9. Conflicts: file.spec --- file.spec | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/file.spec b/file.spec index 8890e86..8d77d37 100644 --- a/file.spec +++ b/file.spec @@ -1,6 +1,6 @@ Name: file Version: 5.39 -Release: 5 +Release: 6 Summary: A tool to identify the type of a particular file type License: BSD URL: http://www.darwinsys.com/file/ @@ -44,6 +44,17 @@ Requires: man %description help This contains man files for the using of file +%package -n python2-magic +Summary: Python 2 bindings for the libmagic API +Requires: %{name} = %{version}-%{release} +BuildRequires: python2-devel +BuildArch: noarch +%{?python_provide:%python_provide python2-magic} + +%description -n python2-magic +This package contains the Python 2 bindings to access the libmagic +API. The libmagic library is also used by the familiar file(1) command. + %package -n python3-magic Summary: Python 3 bindings for the libmagic API Requires: %{name} = %{version}-%{release} @@ -73,6 +84,8 @@ sed -i 's/^hardcode_libdir_flag_spec=.*/hardcode_libdir_flag_spec=""/g' libtool sed -i 's/^runpath_var=LD_RUN_PATH/runpath_var=DIE_RPATH_DIE/g' libtool export LD_LIBRARY_PATH=%{_builddir}/%{name}-%{version}/src/.libs make %{?_smp_mflags} V=1 +cd python +CFLAGS="%{optflags}" %{__python2} setup.py build cd %{py3dir} CFLAGS="%{optflags}" %{__python3} setup.py build @@ -88,6 +101,8 @@ cat magic/Magdir/* > ${RPM_BUILD_ROOT}%{_datadir}/misc/magic ln -s misc/magic ${RPM_BUILD_ROOT}%{_datadir}/magic ln -s ../magic ${RPM_BUILD_ROOT}%{_datadir}/file/magic +cd python +%{__python2} setup.py install -O1 --skip-build --root ${RPM_BUILD_ROOT} cd %{py3dir} %{__python3} setup.py install -O1 --skip-build --root ${RPM_BUILD_ROOT} %{__install} -d ${RPM_BUILD_ROOT}%{_datadir}/%{name} @@ -120,6 +135,15 @@ make check %files help %{_mandir}/man* +%files -n python2-magic +%doc python/README.md python/example.py +%{!?_licensedir:%global license %%doc} +%license COPYING +%{python2_sitelib}/magic.py +%{python2_sitelib}/magic.pyc +%{python2_sitelib}/magic.pyo +%{python2_sitelib}/*egg-info + %files -n python3-magic %doc python/README.md python/example.py %{!?_licensedir:%global license %%doc} @@ -129,12 +153,9 @@ make check %{python3_sitelib}/__pycache__/* %changelog -* Tue Sep 28 2021 zhanchengbin - 5.39-5 +* Tue Sep 28 2021 zhanchengbin - 5.39-6 - DESC: delete -S git from %autosetup, and delete BuildRequires git -* Tue Sep 28 2021 zhanchengbin - 5.39-4 -- remove python2 dependency - * Tue Sep 28 2021 zhanchengbin - 5.39-3 - improve detection of static-pie binaries -- Gitee