From 4112f94e9b20b3a845d36bdedf6a2dc446f248d5 Mon Sep 17 00:00:00 2001 From: Tomas Smetana Date: Jan 24 2008 09:27:31 +0000 Subject: - build a separate python-magic package; thanks to Terje Rosten --- diff --git a/file-4.21-efi.patch b/file-4.21-efi.patch new file mode 100644 index 0000000..d98bce3 --- /dev/null +++ b/file-4.21-efi.patch @@ -0,0 +1,68 @@ +diff -up file-4.21/magic/Magdir/msdos.efi file-4.21/magic/Magdir/msdos +--- file-4.21/magic/Magdir/msdos.efi 2007-12-06 13:45:05.000000000 +0100 ++++ file-4.21/magic/Magdir/msdos 2007-12-06 13:48:18.000000000 +0100 +@@ -49,7 +49,8 @@ + # + # many of the compressed formats were extraced from IDARC 1.23 source code + # +-0 string MZ MS-DOS executable ++0 string MZ ++>0x18 leshort <0x40 MS-DOS executable + >0 string MZ\0\0\0\0\0\0\0\0\0\0PE\0\0 \b, PE for MS Windows + >>&18 leshort&0x2000 >0 (DLL) + >>&88 leshort 0 (unknown subsystem) +@@ -70,27 +71,35 @@ + >>>(&0.l+(4)) string MSCF \b, WinHKI CAB self-extracting archive + + >0x18 leshort >0x3f +->>(0x3c.l) string PE\0\0 PE ++>>(0x3c.l) string PE\0\0 PE ++>>>(0x3c.l+25) byte 1 \b32 executable ++>>>(0x3c.l+25) byte 2 \b32+ executable + # hooray, there's a DOS extender using the PE format, with a valid PE + # executable inside (which just prints a message and exits if run in win) +->>>(8.s*16) string 32STUB for MS-DOS, 32rtm DOS extender +->>>(8.s*16) string !32STUB for MS Windows +->>>>(0x3c.l+22) leshort&0x2000 >0 (DLL) +->>>>(0x3c.l+92) leshort 0 (unknown subsystem) +->>>>(0x3c.l+92) leshort 1 (native) +->>>>(0x3c.l+92) leshort 2 (GUI) +->>>>(0x3c.l+92) leshort 3 (console) +->>>>(0x3c.l+92) leshort 7 (POSIX) +->>>>(0x3c.l+4) leshort 0x0 unknown processor +->>>>(0x3c.l+4) leshort 0x14c Intel 80386 +->>>>(0x3c.l+4) leshort 0x166 MIPS R4000 +->>>>(0x3c.l+4) leshort 0x184 Alpha +->>>>(0x3c.l+4) leshort 0x268 Motorola 68000 +->>>>(0x3c.l+4) leshort 0x1f0 PowerPC +->>>>(0x3c.l+4) leshort 0x290 PA-RISC +->>>>(0x3c.l+22) leshort&0x0100 >0 32-bit +->>>>(0x3c.l+22) leshort&0x1000 >0 system file +->>>>(0x3c.l+232) lelong >0 Mono/.Net assembly ++>>>(0x3c.l+92) leshort <10 ++>>>>(8.s*16) string 32STUB for MS-DOS, 32rtm DOS extender ++>>>>(8.s*16) string !32STUB for MS Windows ++>>>>>(0x3c.l+22) leshort&0x2000 >0 (DLL) ++>>>>>(0x3c.l+92) leshort 0 (unknown subsystem) ++>>>>>(0x3c.l+92) leshort 1 (native) ++>>>>>(0x3c.l+92) leshort 2 (GUI) ++>>>>>(0x3c.l+92) leshort 3 (console) ++>>>>>(0x3c.l+92) leshort 7 (POSIX) ++>>>(0x3c.l+92) leshort 10 (EFI application) ++>>>(0x3c.l+92) leshort 11 (EFI boot service driver) ++>>>(0x3c.l+92) leshort 12 (EFI runtime driver) ++>>>(0x3c.l+92) leshort 13 (XBOX) ++>>>(0x3c.l+4) leshort 0x0 unknown processor ++>>>(0x3c.l+4) leshort 0x14c Intel 80386 ++>>>(0x3c.l+4) leshort 0x166 MIPS R4000 ++>>>(0x3c.l+4) leshort 0x184 Alpha ++>>>(0x3c.l+4) leshort 0x268 Motorola 68000 ++>>>(0x3c.l+4) leshort 0x1f0 PowerPC ++>>>(0x3c.l+4) leshort 0x290 PA-RISC ++>>>(0x3c.l+4) leshort 0x200 Intel Itanium ++>>>(0x3c.l+22) leshort&0x0100 >0 32-bit ++>>>(0x3c.l+22) leshort&0x1000 >0 system file ++>>>(0x3c.l+232) lelong >0 Mono/.Net assembly + + >>>>(0x3c.l+0xf8) string UPX0 \b, UPX compressed + >>>>(0x3c.l+0xf8) search/0x140 PEC2 \b, PECompact2 compressed diff --git a/file-4.21-pybuild.patch b/file-4.21-pybuild.patch new file mode 100644 index 0000000..ed835d7 --- /dev/null +++ b/file-4.21-pybuild.patch @@ -0,0 +1,14 @@ +diff -up file-4.21/python/setup.py.pybuild file-4.21/python/setup.py +--- file-4.21/python/setup.py.pybuild 2007-12-11 09:40:29.000000000 +0100 ++++ file-4.21/python/setup.py 2007-12-11 09:40:59.000000000 +0100 +@@ -3,8 +3,8 @@ from distutils.core import setup, Extens + + magic_module = Extension('magic', + libraries = ['magic'], +- library_dirs = ['./','../','../src','/usr/lib/'], +- include_dirs = ['./','../','../src','/usr/include/'], ++ library_dirs = ['./','../','../src','../src/.libs','/usr/lib/'], ++ include_dirs = ['./','../','../src','../src/.libs','/usr/include/'], + sources = ['py_magic.c']) + + setup (name = 'Magic file extensions', diff --git a/file.spec b/file.spec index 48b2f7a..417d751 100644 --- a/file.spec +++ b/file.spec @@ -1,13 +1,15 @@ +%{!?python_sitelib: %define python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")} +%{!?python_sitearch: %define python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib(1)")} %define __libtoolize : Summary: A utility for determining file types Name: file Version: 4.21 -Release: 3%{?dist} -License: Distributable +Release: 5%{?dist} +License: BSD Group: Applications/File Source0: ftp://ftp.astron.com/pub/file/file-%{version}.tar.gz -URL: http://www.darwinsys.com/file/ +URL: http://www.darwinsys.com/file/ Patch1: file-4.19-debian.patch Patch2: file-selinux.patch Patch3: file-4.21-magic.patch @@ -22,6 +24,8 @@ Patch21: file-4.19-ELF.patch Patch22: file-4.19-ooffice.patch patch23: file-4.21-core_from.patch patch24: file-4.21-msoffice.patch +patch25: file-4.21-efi.patch +patch26: file-4.21-pybuild.patch Requires: file-libs = %{version}-%{release} BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) @@ -53,6 +57,16 @@ Requires: %{name} = %{version}-%{release} The file-devel package contains the header files and libmagic library necessary for developing programs using libmagic. +%package -n python-magic +Summary: Python bindings for the libmagic API +Group: Development/Libraries +BuildRequires: python-devel +Requires: %{name} = %{version}-%{release} + +%description -n python-magic +This package contains the Python bindings to allow access to the +libmagic API. The libmagic library is also used by the familiar +file(1) command. %prep %setup -q @@ -70,8 +84,11 @@ necessary for developing programs using libmagic. %patch22 -p1 -b .ooffice %patch23 -p1 -b .core_from %patch24 -p1 -b .msoffice +%patch25 -p1 -b .efi +%patch26 -p1 -b .pybuild 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 %build @@ -81,7 +98,8 @@ CFLAGS="%{optflags} -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE" \ 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 make - +cd python +CFLAGS="%{optflags}" %{__python} setup.py build %install rm -rf $RPM_BUILD_ROOT @@ -90,13 +108,18 @@ mkdir -p ${RPM_BUILD_ROOT}%{_mandir}/man1 mkdir -p ${RPM_BUILD_ROOT}%{_mandir}/man5 mkdir -p ${RPM_BUILD_ROOT}%{_datadir}/misc -%makeinstall +make DESTDIR=${RPM_BUILD_ROOT} install rm -f ${RPM_BUILD_ROOT}%{_libdir}/*.la ln -s file/magic ${RPM_BUILD_ROOT}%{_datadir}/magic ln -s file/magic.mime ${RPM_BUILD_ROOT}%{_datadir}/magic.mime ln -s ../magic ${RPM_BUILD_ROOT}%{_datadir}/misc/magic +cd python +%{__python} setup.py install -O1 --skip-build --root ${RPM_BUILD_ROOT} +%{__install} -d ${RPM_BUILD_ROOT}%{_datadir}/%{name} +%{__install} -D example.py ${RPM_BUILD_ROOT}/%{_docdir}/python-magic-%{version} + %clean rm -rf $RPM_BUILD_ROOT @@ -125,8 +148,21 @@ rm -rf $RPM_BUILD_ROOT %{_includedir}/magic.h %{_mandir}/man3/* +%files -n python-magic +%defattr(-, root, root, -) +%doc python/README LEGAL.NOTICE python/example.py +%{python_sitearch}/magic.so +%if 0%{?fedora} >= 9 +%{python_sitearch}/*egg-info +%endif %changelog +* Thu Jan 24 2008 Tomas Smetana - 4.21-5 +- build a separate python-magic package; thanks to Terje Rosten + +* Thu Dec 06 2007 Tomas Smetana - 4.21-4 +- add PE32/PE32+ magic + * Wed Aug 15 2007 Martin Bacovsky - 4.21-3 - resolves: #172015: no longer reports filename of crashed app when run on core files. - resolves: #249578: Weird output from "file -i" @@ -134,7 +170,8 @@ rm -rf $RPM_BUILD_ROOT * Wed Jul 4 2007 Martin Bacovsky - 4.21-2 - resolves: #246700: RPM description isn't related to product -- resolves: #238789: file-devel depends on %{version} but not on %{version}-%{release} +- resolves: #238789: file-devel depends on %%{version} + but not on %%{version}-%%{release} - resolves: #235267: for core files, file doesn't display the executable name * Tue May 29 2007 Martin Bacovsky - 4.21-1