%define git 1 %global app_id org.gnome.OCRFeeder %global commit0 1160f3de992467e977ac415e8a9a028f9c768430 %global shortcommit0 %(c=%{commit0}; echo ${c:0:7}) %global date 20200107 %define release_number 4 %define python2_pkgversion %{nil} %if 0%{?rhel} >= 8 || 0%{?fedora} >= 28 %define python2_pkgversion 2 %endif %define python2_pkg python%{?python2_pkgversion} %define package_python_sane %{python2_pkg}-sane %if 0%{?rhel} && 0%{?rhel} <= 7 %define package_python_sane %{python2_pkg}-pillow-sane %endif %define dir_appdata metainfo %if 0%{?rhel} && 0%{?rhel} <= 7 %define dir_appdata appdata %endif %if 0%{!?_metainfodir:1} %define _metainfodir %{_datadir}/%{dir_appdata} %endif %define dir_metainfo %( echo "%{_metainfodir}" | xargs -I{} basename '{}' ) %define supports_recommends %{nil} %if 0%{?rhel}%{?fedora} %if 0%{?rhel} >= 8 %define supports_recommends 1 %else %if 0%{?fedora} >= 24 %define supports_recommends 1 %endif %endif %else %if 0%{?suse_version} %if 0%{?suse_version} >= 1000 %define supports_recommends 1 %endif %endif %endif %global _default_patch_fuzz 2 Name: ocrfeeder Version: 0.8.1 %if ! 0%{?git} Release: %{release_number}%{?dist} %else Release: %{release_number}.%{date}git%{shortcommit0}%{?dist} %endif License: GPLv3+ Group: Applications/Productivity URL: https://wiki.gnome.org/Apps/OCRFeeder Summary: Document layout analysis and optical character recognition system BuildArch: noarch %if ! 0%{?git} # https://gitlab.gnome.org/GNOME/ocrfeeder/-/archive/release_0.8.1/ocrfeeder-release_0.8.1.tar.bz2 Source0: https://gitlab.gnome.org/GNOME/%{name}/-/archive/release_%{version}/%{name}-release_%{version}.tar.bz2 %else # https://gitlab.gnome.org/GNOME/ocrfeeder/-/archive/1160f3de992467e977ac415e8a9a028f9c768430/ocrfeeder-1160f3de992467e977ac415e8a9a028f9c768430.tar.bz2 Source0: https://gitlab.gnome.org/GNOME/%{name}/-/archive/%{commit0}/%{name}-%{commit0}.tar.bz2 %endif # Upstreamed patches # Do not use exec to load a DataBox # https://gitlab.gnome.org/GNOME/ocrfeeder/commit/a9c34e1634d960bfd0833d878cb48e23ddc225cb Patch0: ocrfeeder-0.8.1-databox-no-exec.patch # Fix setting the OCR engine for the first time in the BoxEditor # https://gitlab.gnome.org/GNOME/ocrfeeder/commit/f3b6e1e89814f0ff8927a8f0f71b10390c9a260f Patch1: ocrfeeder-0.8.1-boxeditor-ocr-engine.patch # Update Brazilian Portuguese translation (2020-01-12) # https://gitlab.gnome.org/GNOME/ocrfeeder/commit/4625e7b764eb849dfb89907ac7f57bcc1012b46f Patch2: ocrfeeder-0.8.1-update-translations-pt-br-20200112.patch # Update Polish translation (2020-01-12) # https://gitlab.gnome.org/GNOME/ocrfeeder/commit/7f32b3be5733c321643ed11f301661504c34685d Patch3: ocrfeeder-0.8.1-update-translations-pl-20200112.patch # Fix scanner support #1 # Fix Gtk.Box.pack_start() # TypeError: Gtk.Box.pack_start() takes exactly 5 non-keyword arguments (2 given) # https://github.com/sugarlabs/sugar-docs/blob/master/src/gtk3-porting-guide.md#hbox-vbox-pack_start-and-pack_end # https://gitlab.gnome.org/GNOME/ocrfeeder/issues/17#bug-1 # https://gitlab.gnome.org/GNOME/ocrfeeder/merge_requests/3 # https://gitlab.gnome.org/scx/ocrfeeder/commit/c8bdf0693cde45c772b62a5985c6302612894e1e Patch4: ocrfeeder-0.8.1-fix-scanning-1.patch # Fix scanner support #2 # Fix Scanner Chooser Dialog: unable to select any scanner # No scanner devices were found # https://gitlab.gnome.org/GNOME/ocrfeeder/issues/17#bug-2 # https://gitlab.gnome.org/GNOME/ocrfeeder/merge_requests/3 # https://gitlab.gnome.org/scx/ocrfeeder/commit/eafa8f61443bb76318efdad5b9963de227924082 Patch5: ocrfeeder-0.8.1-fix-scanning-2.patch # Fix scanner support #3 # Fix __scanFinishedCb() # Need to specify the parent window # TypeError: could not convert value for property `transient_for' from str to GtkWindow # https://gitlab.gnome.org/GNOME/ocrfeeder/issues/17#bug-3 # https://gitlab.gnome.org/GNOME/ocrfeeder/merge_requests/3 # https://gitlab.gnome.org/scx/ocrfeeder/commit/8a3e6696724474ebc175a1b02ba1f96f436a4abb Patch6: ocrfeeder-0.8.1-fix-scanning-3.patch # Fix scanner support #4 # Invalid scanner options lead to an unrecoverable error. # Some scanners don't support the Resolution parameter at all. # Supported modes may be vary across different scanners. Not all of them support the "Color" mode. For example, some of them support "Color24" or "Color48" instead. # Error scanning page # https://gitlab.gnome.org/GNOME/ocrfeeder/issues/17#bug-4 # https://gitlab.gnome.org/GNOME/ocrfeeder/merge_requests/3 # https://gitlab.gnome.org/scx/ocrfeeder/commit/873af2169e1fde039cbf3e53db9b386189afb92b Patch7: ocrfeeder-0.8.1-fix-scanning-4.patch # Fix scanner support #5 # Try to maximize scan area # https://gitlab.gnome.org/GNOME/ocrfeeder/issues/17#bug-5 # https://gitlab.gnome.org/GNOME/ocrfeeder/merge_requests/3 # https://gitlab.gnome.org/scx/ocrfeeder/commit/9a2480f73ade36d58f623b539c656f1d728e9d3d Patch8: ocrfeeder-0.8.1-fix-scanning-5.patch # Fix spell checker window # https://gitlab.gnome.org/GNOME/ocrfeeder/issues/16 # https://gitlab.gnome.org/GNOME/ocrfeeder/merge_requests/6 # https://gitlab.gnome.org/scx/ocrfeeder/commit/9808ce235fd7e1f8be951ff4a735ca397ed65566 Patch9: ocrfeeder-0.8.1-fix-spellchecker-window.patch # Install app icon in XDG directory # Move org.gnome.OCRFeeder.svg from the $(datadir)/ocrfeeder/icons/ dir to the $(datadir)/icons/hicolor/scalable/apps/ dir. # https://gitlab.gnome.org/GNOME/ocrfeeder/issues/18 # https://gitlab.gnome.org/GNOME/ocrfeeder/merge_requests/4 # https://gitlab.gnome.org/scx/ocrfeeder/commit/d136e7db6aa09803ff08bc2a80ea9fe30dce7f2c Patch10: ocrfeeder-0.8.1-xdg-icon.patch # Update Basque translation (2020-01-04) # Provide basic translation of the AppData file # https://gitlab.gnome.org/GNOME/ocrfeeder/merge_requests/5 # https://gitlab.gnome.org/scx/ocrfeeder/commit/01b179e240340b19600c796709c2d6d7f920d88d Patch11: ocrfeeder-0.8.1-update-translations-eu-20200104.patch # Update desktop file # Update the Keywords tag and make it translatable # https://gitlab.gnome.org/GNOME/ocrfeeder/commit/c75683d02d2f5e12fd025893e61bc8ec9154428d#note_677586 # https://gitlab.gnome.org/GNOME/ocrfeeder/merge_requests/5 # https://gitlab.gnome.org/scx/ocrfeeder/commit/d14435cec3519fe3a9490ba210911f28bc20f90d Patch12: ocrfeeder-0.8.1-desktop-keywords.patch # Updated Spanish translation (2020-01-23) # https://gitlab.gnome.org/GNOME/ocrfeeder/commit/2df0dfd0e373390011c3e1303c2cea93dfc650f6 Patch13: ocrfeeder-0.8.1-update-translations-es-20200123.patch # Update Polish translation (2020-01-26) # https://gitlab.gnome.org/GNOME/ocrfeeder/commit/a4014ffa0b00895066b7e34d815c058154007d31 Patch14: ocrfeeder-0.8.1-update-translations-pl-20200126.patch # Update bugtracker URL # https://gitlab.gnome.org/GNOME/ocrfeeder/commit/325682fb3b52439d8cf98eb620ada9c5f9ba4a7d Patch15: ocrfeeder-0.8.1-update-bugtracker-url.patch # Updated Spanish translation (2020-01-28) # https://gitlab.gnome.org/GNOME/ocrfeeder/commit/b9450893729182a799da53c482ec6922ae5e369f Patch16: ocrfeeder-0.8.1-update-translations-es-20200128.patch # Upstreamable patches # Fix PDF import: execute Ghostscript in proper way # Some changes are required to execute commands in the current Python properly # https://gitlab.gnome.org/GNOME/ocrfeeder/issues/19 # https://gitlab.gnome.org/GNOME/ocrfeeder/merge_requests/7 # https://gitlab.gnome.org/scx/ocrfeeder/commit/7fc56e7d873d0dcbcdf59fde6ae17e632898207c Patch50: ocrfeeder-0.8.1-fix-pdf-import-popen.patch # Fix PDF import: handle special chars in filename # We need to create a temp symlink as a workaround for gs limitations # https://gitlab.gnome.org/GNOME/ocrfeeder/issues/20 # https://gitlab.gnome.org/GNOME/ocrfeeder/merge_requests/7 # https://gitlab.gnome.org/scx/ocrfeeder/commit/55659f69e65458bad86240668d3b4bb47988bf96 Patch51: ocrfeeder-0.8.1-fix-pdf-import-symlink.patch # Fix PDF import: replace deprecated os.popen() by subprocess.Popen() # The os.popen() method is obsolete since Python 2.6, so we should use the subprocess module instead # https://gitlab.gnome.org/GNOME/ocrfeeder/merge_requests/7 # https://gitlab.gnome.org/scx/ocrfeeder/commit/2bbe236f1d44eeed0bcc06e04117e3e32e5161a1 Patch52: ocrfeeder-0.8.1-fix-pdf-import-subprocess.patch # Package-specific patches # Fix scanner support #0 # Always display Scanner Chooser Dialog # https://gitlab.gnome.org/scx/ocrfeeder/commit/5236cb220e3b98cdec300db5872a877bb09a205f Patch100: ocrfeeder-0.8.1-fix-scanning-0.patch BuildRequires: intltool BuildRequires: gnome-doc-utils # for glib-gettextize BuildRequires: glib2-devel # for gnome-autogen.sh BuildRequires: gnome-common # for GooCanvas-2.0.typelib BuildRequires: goocanvas2 # for Gtk-3.0.typelib BuildRequires: gtk3 # for GtkSpell-3.0.typelib BuildRequires: gtkspell3 BuildRequires: %{python2_pkg}-devel # for pygobject3 BuildRequires: %{python2_pkg}-gobject BuildRequires: %{python2_pkg}-enchant BuildRequires: %{python2_pkg}-lxml BuildRequires: %{python2_pkg}-pillow BuildRequires: %{package_python_sane} BuildRequires: %{python2_pkg}-reportlab #BuildRequires: %{python2_pkg}-odfpy # for rsvg-convert BuildRequires: librsvg2-tools BuildRequires: desktop-file-utils BuildRequires: libappstream-glib Requires: gtk3 Requires: goocanvas2 Requires: gtkspell3 Requires: %{python2_pkg} Requires: %{python2_pkg}-gobject Requires: %{python2_pkg}-enchant Requires: %{python2_pkg}-lxml Requires: %{python2_pkg}-pillow Requires: %{package_python_sane} Requires: %{python2_pkg}-reportlab #Requires: %{python2_pkg}-odfpy Requires: unpaper Requires: ghostscript Requires: GraphicsMagick Requires: yelp Requires: tesseract %if 0%{?supports_recommends} Recommends: gocr Recommends: ocrad Recommends: cuneiform %endif # https://fedoraproject.org/wiki/Packaging:Scriptlets # https://fedoraproject.org/wiki/PackagingDrafts/ScriptletSnippets Requires(post): coreutils Requires(postun): coreutils Requires(posttrans): coreutils # gtk-update-icon-cache Requires(postun): gtk-update-icon-cache Requires(posttrans): gtk-update-icon-cache # update-desktop-database Requires(post): desktop-file-utils Requires(postun): desktop-file-utils %if "%{name}" != "%{app_id}" Provides: %{app_id} = %{version}-%{release} %endif Provides: ocrfeeder-cli = %{version}-%{release} %description OCRFeeder is a document layout analysis and OCR system. Given the images it will automatically outline its contents, distinguish between what's graphics and text and perform OCR over the latter. It generates multiple formats being its main one ODT. It features a complete GTK graphical user interface that allows the users to correct any unrecognized characters, defined or correct bounding boxes, set paragraph styles, clean the input images, import PDFs, save and load the project, export everything to multiple formats, etc. %prep %if ! 0%{?git} %setup -q -n "%{name}-release_%{version}" %else %setup -q -n "%{name}-%{commit0}" %endif %if 0%{?git} %patch0 -p1 %patch1 -p1 %patch2 -p1 %patch3 -p1 %patch4 -p1 %patch5 -p1 %patch6 -p1 %patch7 -p1 %patch8 -p1 %patch9 -p1 %patch10 -p1 %patch11 -p1 %patch12 -p1 %patch13 -p1 %patch14 -p1 %patch15 -p1 %patch16 -p1 %patch50 -p1 %patch51 -p1 %patch52 -p1 %patch100 -p1 %endif %build ./autogen.sh %configure --enable-maintainer-mode %{make_build} %install %{__make} install DESTDIR="%{buildroot}" # fix shebang for f in "%{buildroot}%{_bindir}/%{name}"*; do sed -i -re 's|^(#!/usr/bin/env python)$|\12|' "${f}" done # install icons icon_in="resources/icons/%{app_id}.svg" icon_out="%{app_id}.png" for s in {16,22,24,32,48,64,72,96,128,192,256,512}; do [[ ! -f "%{buildroot}%{_datadir}/icons/hicolor/${s}x${s}/apps/${icon_out}" ]] || continue rsvg-convert "${icon_in}" -w "${s}" -h "${s}" -a -f png -o "${icon_out}" %{__install} -p -D -m 0644 "${icon_out}" "%{buildroot}%{_datadir}/icons/hicolor/${s}x${s}/apps/%{app_id}.png" done if [[ ! -f "%{buildroot}%{_datadir}/icons/hicolor/scalable/apps/%{app_id}.svg" ]]; then %{__install} -p -D -m 0644 "${icon_in}" "%{buildroot}%{_datadir}/icons/hicolor/scalable/apps/%{app_id}.svg" fi # fix appdata dir %if "%{dir_metainfo}" != "metainfo" [[ -d "%{buildroot}%{_metainfodir}" || ! -d "%{buildroot}%{_datadir}/metainfo" ]] || %{__mv} "%{buildroot}%{_datadir}/metainfo" "%{buildroot}%{_metainfodir}" %endif %find_lang "%{name}" --with-gnome %check /usr/bin/desktop-file-validate "%{buildroot}/%{_datadir}/applications/%{app_id}.desktop" /usr/bin/appstream-util validate-relax --nonet "%{buildroot}%{_metainfodir}/%{app_id}.appdata.xml" %post /bin/touch --no-create "%{_datadir}/icons/hicolor" &> /dev/null || : /usr/bin/update-desktop-database &> /dev/null || : %postun /usr/bin/update-desktop-database &> /dev/null || : if [[ "${1}" -eq "0" ]]; then /bin/touch --no-create "%{_datadir}/icons/hicolor" &> /dev/null || : /usr/bin/gtk-update-icon-cache "%{_datadir}/icons/hicolor" &> /dev/null || : fi %posttrans /usr/bin/gtk-update-icon-cache "%{_datadir}/icons/hicolor" &> /dev/null || : %files -f "%{name}.lang" %doc AUTHORS NEWS README TRANSLATORS %license COPYING %{_bindir}/%{name} %{_bindir}/%{name}-cli %{_datadir}/%{name}/ %{_datadir}/applications/%{app_id}.desktop %{_datadir}/icons/hicolor/*/*/%{app_id}.* %{_mandir}/man1/%{name}* %{_metainfodir}/%{app_id}.appdata.xml %{python2_sitelib}/%{name}/ %changelog * Sun Feb 09 2020 Tomasz Tomasik 0.8.1-4.20200107git1160f3d - Fix PDF import * Thu Jan 23 2020 Tomasz Tomasik 0.8.1-3.20200107git1160f3d - Update to the latest Python2-based version with built-in odfpy * Tue Feb 05 2019 Tomasz Tomasik 0.8.1-2.20181218git51483c4 - Update patches https://gitlab.gnome.org/GNOME/ocrfeeder/merge_requests/1 * Wed Jan 23 2019 Tomasz Tomasik 0.8.1-1.20181218git51483c4 - Update to the latest version * Wed Jan 23 2019 Tomasz Tomasik 0.8.1-1 - Initial packaging