%define git 1 %global app_id org.gnome.OCRFeeder %global commit0 51483c4b625c42b9bc04b2056b903a431b080935 %global shortcommit0 %(c=%{commit0}; echo ${c:0:7}) %global date 20181218 %define release_number 2 %define package_python_sane python-sane %if 0%{?rhel}%{?fedora} %if 0%{?rhel} %if 0%{?rhel} <= 7 %define package_python_sane python-pillow-sane %endif %endif %endif %define dir_appdata metainfo %if 0%{?rhel}%{?fedora} %if 0%{?rhel} %if 0%{?rhel} <= 7 %define dir_appdata appdata %endif %endif %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 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/51483c4b625c42b9bc04b2056b903a431b080935/ocrfeeder-51483c4b625c42b9bc04b2056b903a431b080935.tar.bz2 Source0: https://gitlab.gnome.org/GNOME/%{name}/-/archive/%{commit0}/%{name}-%{commit0}.tar.bz2 %endif # Upstreamable patches # Update desktop file # https://gitlab.gnome.org/GNOME/ocrfeeder/merge_requests/1#1-update-desktop-file # https://gitlab.gnome.org/scx/ocrfeeder/commit/23aa40c3c2761a7eada829f1af05ec32a210d98d Patch0: ocrfeeder-0.8.1-desktop.patch # Add AppData file # https://gitlab.gnome.org/GNOME/ocrfeeder/merge_requests/1#2-add-appdata-file # https://gitlab.gnome.org/scx/ocrfeeder/commit/dd57b0e0f646d328452f9fa43104e7163ba9abed Patch1: ocrfeeder-0.8.1-appdata.patch # Rename files because of new Application ID # https://gitlab.gnome.org/GNOME/ocrfeeder/merge_requests/1#3-rename-files-because-of-new-application-id # https://gitlab.gnome.org/scx/ocrfeeder/commit/db6735b19d45e73cc4ddfc56307b8dab571f5ee6 Patch2: ocrfeeder-0.8.1-rename-files.patch # Update translations # https://gitlab.gnome.org/GNOME/ocrfeeder/merge_requests/1#4-update-translations # https://gitlab.gnome.org/scx/ocrfeeder/commit/56d789d6b9610be8562abe0c6fa53d267111f832 Patch3: ocrfeeder-0.8.1-update-translations.patch # Update window icon # https://gitlab.gnome.org/GNOME/ocrfeeder/merge_requests/1#5-update-window-icon # https://gitlab.gnome.org/scx/ocrfeeder/commit/8d4a470c920369216ce4a09985917cfa6e8cdfd3 Patch4: ocrfeeder-0.8.1-update-window-icon.patch # Set automake strictness to foreign # https://gitlab.gnome.org/GNOME/ocrfeeder/merge_requests/1#6-set-automake-strictness-to-foreign # https://gitlab.gnome.org/scx/ocrfeeder/commit/9bb1f3d41a391d086e26d069410e84a6bda3aa1b Patch5: ocrfeeder-0.8.1-automake-foreign.patch # Add missing options to the ocrfeeder-cli manpage # https://gitlab.gnome.org/GNOME/ocrfeeder/merge_requests/1#7-add-missing-options-to-the-ocrfeeder-cli-manpage # https://gitlab.gnome.org/scx/ocrfeeder/commit/b2ed8e50dbf55241d53767e5d7f72ab9d6fbb220 Patch6: ocrfeeder-0.8.1-ocrfeeder-cli-man.patch # Fix image preview # Update box image (clip preview) after unpapering page # https://gitlab.gnome.org/GNOME/ocrfeeder/merge_requests/1#8-fix-image-preview # https://gitlab.gnome.org/scx/ocrfeeder/commit/d68960919dce237f1d5ac8335d080f435719dea3 Patch7: ocrfeeder-0.8.1-fix-image-preview.patch # Fix OCR engine list and set Tesseract as default engine # https://gitlab.gnome.org/GNOME/ocrfeeder/merge_requests/1#9-fix-ocr-engine-list-and-set-tesseract-as-default-engine # https://gitlab.gnome.org/scx/ocrfeeder/commit/43f6f0090b1ca65b518bb14ac64b0fe3cf76b03e Patch8: ocrfeeder-0.8.1-default-engine.patch # Set favorite engine as default engine for content area # If there is no favorite engine (or it is not available), use the last one (Tesseract) # Try to keep the previous choice # https://gitlab.gnome.org/GNOME/ocrfeeder/merge_requests/1#10-set-favorite-engine-as-default-engine-for-content-area # https://gitlab.gnome.org/scx/ocrfeeder/commit/c3cc23ad75e61ca3bb91d5f0d5db453de2e72957 Patch9: ocrfeeder-0.8.1-default-engine-content-area.patch # Package-specific patches # Set fixed width for both panes # https://gitlab.gnome.org/GNOME/ocrfeeder/merge_requests/1#11-set-fixed-width-for-both-panes # https://gitlab.gnome.org/scx/ocrfeeder/commit/a9f63c0e0f805a8be7a36b9ab48562b77a325024 # Related: # Fix the width for the boxes editor: # https://gitlab.gnome.org/GNOME/ocrfeeder/commit/c4d4c4afb4b73019c08e2d1ff66b780cb017f0b5 Patch10: ocrfeeder-0.8.1-panes-fixed-width.patch # Increase window size # https://gitlab.gnome.org/GNOME/ocrfeeder/merge_requests/1#12-increase-window-size # https://gitlab.gnome.org/scx/ocrfeeder/commit/efc3260c84a983c5894345a813224f5f2371e79a Patch11: ocrfeeder-0.8.1-window-size.patch # Flatpak-specific patches # Disable unpaper frame (Path to unpaper) in sandbox mode # https://gitlab.gnome.org/GNOME/ocrfeeder/merge_requests/1#13-disable-unpaper-frame-in-sandbox-mode # https://gitlab.gnome.org/scx/ocrfeeder/commit/7181042ca57086703577eac5212d3b1f41a4fafc Patch12: ocrfeeder-0.8.1-disable-unpaper-frame.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-devel # for pygobject3 BuildRequires: python-gobject BuildRequires: python-enchant BuildRequires: python-lxml BuildRequires: python-pillow BuildRequires: %{package_python_sane} BuildRequires: python-reportlab # for rsvg-convert BuildRequires: librsvg2-tools BuildRequires: desktop-file-utils BuildRequires: libappstream-glib Requires: gtk3 Requires: goocanvas2 Requires: gtkspell3 Requires: python2 Requires: python-gobject Requires: python-enchant Requires: python-lxml Requires: python-pillow Requires: %{package_python_sane} Requires: python-reportlab 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 %endif %build ./autogen.sh %configure --enable-maintainer-mode %{make_build} %install %{__make} install DESTDIR="%{buildroot}" 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 %{__install} -p -D -m 0644 "${icon_in}" "%{buildroot}%{_datadir}/icons/hicolor/scalable/apps/%{app_id}.svg" %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 * 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