Rebase for upstream/5.28 72/77172/1
authorAnas Nashif <anas.nashif@intel.com>
Mon, 5 Nov 2012 01:26:58 +0000 (17:26 -0800)
committerDongHun Kwak <dh0128.kwak@samsung.com>
Tue, 28 Jun 2016 04:53:49 +0000 (13:53 +0900)
Change-Id: I6fdc6b2b9f5ae0703347f1f9bcbfb81e20477da2
Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
packaging/baselibs.conf [new file with mode: 0644]
packaging/file.changes [new file with mode: 0644]
packaging/file.manifest [new file with mode: 0644]
packaging/file.spec [new file with mode: 0644]
packaging/python-magic.spec [new file with mode: 0644]
python/magic.py
src/readcdf.c

diff --git a/packaging/baselibs.conf b/packaging/baselibs.conf
new file mode 100644 (file)
index 0000000..8e7ce75
--- /dev/null
@@ -0,0 +1 @@
+libmagic
diff --git a/packaging/file.changes b/packaging/file.changes
new file mode 100644 (file)
index 0000000..8c1bae6
--- /dev/null
@@ -0,0 +1,12 @@
+* Wed Nov 6 2013 Ronan Le Martret <ronan@fridu.net> 7d17da5
+- Fix python-magic build. (PTREL-158)
+
+* Sat Jun 29 2013 Alexandru Cornea <alexandru.cornea@intel.com> 4795cb8
+- resetting manifest requested domain to floor
+
+* Sun Mar 17 2013 Anas Nashif <anas.nashif@intel.com> submit/trunk/20121215.172437@b91fca2
+- Update package groups
+
+* Sat Dec 15 2012 Anas Nashif <anas.nashif@intel.com> upstream/5.11@8e6268a
+- add python module
+
diff --git a/packaging/file.manifest b/packaging/file.manifest
new file mode 100644 (file)
index 0000000..017d22d
--- /dev/null
@@ -0,0 +1,5 @@
+<manifest>
+ <request>
+    <domain name="_"/>
+ </request>
+</manifest>
diff --git a/packaging/file.spec b/packaging/file.spec
new file mode 100644 (file)
index 0000000..8ddd7bc
--- /dev/null
@@ -0,0 +1,127 @@
+%global         _miscdir    %{_datadir}/misc
+
+Name:           file
+BuildRequires:  findutils
+BuildRequires:  libtool
+BuildRequires:  zlib-devel
+Url:            http://www.darwinsys.com/file/
+Version:        5.18
+Release:        0
+Summary:        A Tool to Determine File Types
+License:        BSD-2-Clause
+Group:          System/Utilities
+
+### SOURCES BEGIN ###
+Source2:        baselibs.conf
+Source1001:     file.manifest
+### SOURCES END ###
+Source:         ftp://ftp.astron.com/pub/file/file-%{version}.tar.gz
+
+%description
+With the file command, you can obtain information on the file type of a
+specified file. File type recognition is controlled by the file
+/etc/magic, which contains the classification criteria. This command is
+used by apsfilter to permit automatic printing of different file types.
+
+%package -n libmagic-data
+Summary:        The magic files for libmagic to use
+Group:          System/Libraries
+
+%description -n libmagic-data
+This package contains the basic magic files that libmagic reads and uses
+to estimate a file's type.
+
+%package -n libmagic
+Summary:        Library with file's functionality
+Group:          System/Libraries
+Requires:       libmagic-data = %{version}
+Provides:       libfile
+Obsoletes:      libfile =< 5.04
+
+%description -n libmagic
+This library reads magic files and detects file types. Used by file command
+
+%package -n file-devel
+Summary:        Include Files and Libraries mandatory for Development
+Group:          System/Libraries
+Provides:       file:/usr/include/magic.h
+Requires:       glibc-devel
+Requires:       libmagic = %{version}
+
+%description -n file-devel
+This package contains all necessary include files and libraries needed
+to develop applications that require the magic "file" interface.
+
+%prep
+%setup -q -n file-%{version}
+### PREP BEGIN ###
+cp %{SOURCE1001} .
+### PREP END ###
+
+%build
+### BUILD BEGIN ###
+export LANG=POSIX
+export LC_ALL=POSIX
+rm -f Magdir/*,v Magdir/*~
+rm -f ltcf-c.sh ltconfig ltmain.sh
+autoreconf -fiv
+CFLAGS="$RPM_OPT_FLAGS -DHOWMANY=69632"
+%configure --disable-silent-rules --datadir=%{_miscdir} --disable-static --with-pic --enable-fsect-man5
+%{__make} %{?_smp_mflags} pkgdatadir='$(datadir)'
+%if 0%{?build_python_bindings:1}
+pushd python
+python setup.py build
+popd
+%endif
+### BUILD END ###
+
+%install
+export LANG=POSIX
+export LC_ALL=POSIX
+mkdir  %{buildroot}%{_sysconfdir}
+make DESTDIR=%{buildroot} install pkgdatadir='$(datadir)'
+rm -vf %{buildroot}%{_sysconfdir}/magic
+echo '# Localstuff: file(1) magic(5) for locally observed files' > %{buildroot}%{_sysconfdir}/magic
+echo '#     global magic file is %{_miscdir}/magic(.mgc)'   >> %{buildroot}%{_sysconfdir}/magic
+%{nil install -s dcore %{buildroot}%{_bindir}}
+# Check out that the binary does not bail out:
+LD_LIBRARY_PATH=%{buildroot}%{_libdir}
+export LD_LIBRARY_PATH
+find %{buildroot}%{_bindir}/file %{_bindir}/ /%{_lib}/ %{_libdir}/ | \
+    xargs %{buildroot}%{_bindir}/file -m %{buildroot}%{_miscdir}/magic
+unset LD_LIBRARY_PATH
+%{__rm} -f %{buildroot}%{_libdir}/*.la
+
+%post -n libmagic -p /sbin/ldconfig
+
+%postun -n libmagic -p /sbin/ldconfig
+
+%files -n libmagic
+%manifest %{name}.manifest
+%defattr (644,root,root,755)
+%license COPYING 
+%{_libdir}/lib*.so.*
+
+%files -n libmagic-data
+%manifest %{name}.manifest
+%defattr (644,root,root,755)
+%config(noreplace) %{_sysconfdir}/magic
+#%%{_miscdir}/magic
+%{_miscdir}/magic.mgc
+%doc %{_mandir}/man5/magic.5.gz
+
+%files
+%manifest %{name}.manifest
+%defattr (644,root,root,755)
+%{nil %{_bindir}/dcore}
+%attr(755,root,root) %{_bindir}/file
+%doc %{_mandir}/man1/file.1.gz
+%license COPYING 
+
+%files -n file-devel
+%manifest %{name}.manifest
+%defattr (644,root,root,755)
+%{_libdir}/lib*.so
+%{_includedir}/magic.h
+%doc %{_mandir}/man3/libmagic.3.gz
+%license COPYING
diff --git a/packaging/python-magic.spec b/packaging/python-magic.spec
new file mode 100644 (file)
index 0000000..0f7c422
--- /dev/null
@@ -0,0 +1,42 @@
+%define build_python_bindings 1
+%global         _miscdir    %{_datadir}/misc
+
+Name:           python-magic
+BuildRequires:  findutils
+BuildRequires:  libtool
+BuildRequires:  python-devel
+BuildRequires:  zlib-devel
+Url:            http://www.darwinsys.com/file/
+Version:        5.18
+Release:        0
+Summary:        Python module to use libmagic
+License:        BSD-3-Clause and BSD-4-Clause
+Group:          Platform Development/Python
+Source99:       file.spec
+BuildArch:      noarch
+
+%{expand:%(sed -n -e '/^### SOURCES BEGIN ###/,/^### SOURCES END ###/p' <%_sourcedir/file.spec)}
+Source:         ftp://ftp.astron.com/pub/file/file-%{version}.tar.gz
+
+%description 
+This package contains the python binding that require the magic "file"
+interface.
+
+
+%prep
+%setup -q -n file-%{version}
+%{expand:%(sed -n -e '/^### PREP BEGIN ###/,/^### PREP END ###/p' <%_sourcedir/file.spec)}
+
+%build
+%{expand:%(sed -n -e '/^### BUILD BEGIN ###/,/^### BUILD END ###/p' <%_sourcedir/file.spec)}
+
+%install
+pushd python
+python setup.py install --root=%{buildroot} \
+                        --prefix=%{_prefix} \
+                        --record-rpm=../python_files
+popd
+
+%files -f python_files
+%defattr(-,root,root)
+
index c48f7d5..3c7a1b2 100644 (file)
@@ -123,18 +123,11 @@ class Magic(object):
         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.
         """
-        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).encode('utf-8')
+        try: # attempt python3 approach first
+            bi = bytes(filename, 'utf-8')
+            return str(_file(self._magic_t, bi), 'utf-8')
+        except:
+            return _file(self._magic_t, filename)
 
     def descriptor(self, fd):
         """
index d125da5..a6c2f29 100644 (file)
@@ -26,7 +26,7 @@
 #include "file.h"
 
 #ifndef lint
-FILE_RCSID("@(#)$File: readcdf.c,v 1.56 2016/03/03 22:20:03 christos Exp $")
+FILE_RCSID("@(#)$File: readcdf.c,v 1.42 2014/05/07 10:13:12 christos Exp $")
 #endif
 
 #include <assert.h>
@@ -80,7 +80,7 @@ static const struct cv {
        const char *mime;
 } clsid2mime[] = {
        {
-               { 0x00000000000c1084ULL, 0x46000000000000c0ULL  },
+               { 0x00000000000c1084LLU, 0x46000000000000c0LLU  },
                "x-msi",
        },
        {       { 0,                     0                      },
@@ -88,7 +88,7 @@ static const struct cv {
        },
 }, clsid2desc[] = {
        {
-               { 0x00000000000c1084ULL, 0x46000000000000c0ULL  },
+               { 0x00000000000c1084LLU, 0x46000000000000c0LLU  },
                "MSI Installer",
        },
        {       { 0,                     0                      },