diff --git a/.gitignore b/.gitignore index e69de29..131dab8 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1 @@ +/olefile-bc9d196.tar.gz diff --git a/olefile_no-olefile2.patch b/olefile_no-olefile2.patch new file mode 100644 index 0000000..4fdc23e --- /dev/null +++ b/olefile_no-olefile2.patch @@ -0,0 +1,21 @@ +diff -rupN olefile-bc9d196b02e9be2d179c5b75c696a8e041232254/OleFileIO_PL.py olefile-bc9d196b02e9be2d179c5b75c696a8e041232254-new/OleFileIO_PL.py +--- olefile-bc9d196b02e9be2d179c5b75c696a8e041232254/OleFileIO_PL.py 2016-11-29 23:09:20.000000000 +0100 ++++ olefile-bc9d196b02e9be2d179c5b75c696a8e041232254-new/OleFileIO_PL.py 2017-01-02 18:39:48.255899000 +0100 +@@ -24,14 +24,6 @@ See source code and LICENSE.txt for info + + # The OleFileIO_PL module is for backward compatibility + +-try: +- # first try to import olefile for Python 2.6+/3.x +- from olefile.olefile import * +- # import metadata not covered by *: +- from olefile.olefile import __version__, __author__, __date__ +- +-except: +- # if it fails, fallback to the old version olefile2 for Python 2.x: +- from olefile.olefile2 import * +- # import metadata not covered by *: +- from olefile.olefile2 import __doc__, __version__, __author__, __date__ ++from olefile.olefile import * ++# import metadata not covered by *: ++from olefile.olefile import __version__, __author__, __date__ diff --git a/olefile_skip-doc.patch b/olefile_skip-doc.patch new file mode 100644 index 0000000..2b72b03 --- /dev/null +++ b/olefile_skip-doc.patch @@ -0,0 +1,12 @@ +diff -rupN olefile-0.43/setup.py olefile-0.43-new/setup.py +--- olefile-0.43/setup.py 2016-01-29 10:24:20.000000000 +0100 ++++ olefile-0.43-new/setup.py 2017-01-02 17:19:56.757160114 +0100 +@@ -259,7 +259,7 @@ def main(): + license=license, + ## package_dir=package_dir, + packages=packages, +- package_data = package_data, ++# package_data = package_data, + py_modules = modules, + download_url=download_url, + # data_files=data_files, diff --git a/python-olefile.spec b/python-olefile.spec new file mode 100644 index 0000000..a580680 --- /dev/null +++ b/python-olefile.spec @@ -0,0 +1,121 @@ +%global srcname olefile +%global commit bc9d196b02e9be2d179c5b75c696a8e041232254 +%global shortcommit %(c=%{commit}; echo ${c:0:7}) + +%global _description \ +olefile is a Python package to parse, read and write Microsoft OLE2 files\ +(also called Structured Storage, Compound File Binary Format or Compound\ +Document File Format), such as Microsoft Office 97-2003 documents,\ +vbaProject.bin in MS Office 2007+ files, Image Composer and FlashPix files,\ +Outlook messages, StickyNotes, several Microscopy file formats, McAfee\ +antivirus quarantine files, etc. + +Name: python-%{srcname} +Version: 0.44 +Release: 0.4%{?commit:.git%shortcommit}%{?dist} +Summary: Python package to parse, read and write Microsoft OLE2 files + +License: BSD +URL: https://github.com/decalage2/olefile/ +%if %{defined commit} +Source0: %{url}/archive/%{commit}/%{srcname}-%{shortcommit}.tar.gz +%else +Source0: %{url}/archive/%{version}/%{srcname}-%{version}.tar.gz +%endif +# Don't install docs (they are installed through %%doc) +Patch0: olefile_skip-doc.patch +# Remove reference to olefile2 (a pre python2.6 compatibility version) +Patch1: olefile_no-olefile2.patch + +BuildArch: noarch + + +%description %{_description} + + +%package -n python2-%{srcname} +Summary: %{summary} +BuildRequires: python2-devel +%{?python_provide:%python_provide python2-%{srcname}} + +%description -n python2-%{srcname} %{_description} + +Python2 version. + + +%package -n python3-%{srcname} +Summary: %{summary} +BuildRequires: python3-devel +%{?python_provide:%python_provide python3-%{srcname}} + +%description -n python3-%{srcname} %{_description} + +Python3 version. + + +%prep +%if %{defined commit} +%autosetup -p1 -n %{srcname}-%{commit} +%else +%autosetup -p1 -n %{srcname}-%{version} +%endif + +# olefile2 is a pre python2.6 compatibility version +rm -f olefile/olefile2.* +# Remove shebang from non-executable scripts +sed -i -e '1{\@^#!/usr/local/bin/python@d}' OleFileIO_PL.py +sed -i -e '1{\@^#!/usr/local/bin/python@d}' olefile/__init__.py +sed -i -e '1{\@^#!/usr/bin/env python@d}' olefile/olefile.py +# Fix incorrect line endings +sed -i -e "s/\r//" olefile/doc/*.md +sed -i -e "s/\r//" OleFileIO_PL.py + + +%build +%py2_build +%py3_build + + +%install +%py2_install +%py3_install + + +%check +PYTHONPATH=%{buildroot}%{python2_sitelib} %{__python2} tests/test_olefile.py +PYTHONPATH=%{buildroot}%{python3_sitelib} %{__python3} tests/test_olefile.py + + +%files -n python2-%{srcname} +%doc README.md olefile/doc/* +%license olefile/doc/License.* +%{python2_sitelib}/OleFileIO_PL.py* +%{python2_sitelib}/olefile-*.egg-info +%{python2_sitelib}/olefile/ + +%files -n python3-%{srcname} +%doc README.md olefile/doc/* +%license olefile/doc/License.* +%{python3_sitelib}/OleFileIO_PL.py* +%{python3_sitelib}/__pycache__/OleFileIO_PL.* +%{python3_sitelib}/olefile-*.egg-info +%{python3_sitelib}/olefile/ + + +%changelog +* Mon Jan 02 2017 Sandro Mani - 0.44-0.4.gitbc9d196 +- Fix incorrect line endings +- Remove shebang from non-executable scripts + +* Mon Jan 02 2017 Sandro Mani - 0.44-0.3.gitbc9d196 +- Further reduce duplicate text +- Add python_provides + +* Mon Jan 02 2017 Sandro Mani - 0.44-0.2.gitbc9d196 +- Use %%py_build and %%py_install macros +- Use %%summary, %%url to reduce duplicate text +- Add %%check +- Move BR to subpackages + +* Mon Jan 02 2017 Sandro Mani - 0.44-0.1.gitbc9d196 +- Initial package diff --git a/sources b/sources index e69de29..8a76016 100644 --- a/sources +++ b/sources @@ -0,0 +1 @@ +SHA512 (olefile-bc9d196.tar.gz) = abcadc7cef109c4e8f98d390f662eeb8d6851f39fb998e97213f17f2a72ee1e7f7bedf3e56ede2c940bb652a802bbbb9863ac5fb4d11e0df41c1d981f67fa5b4