diff --git a/.fmf/version b/.fmf/version new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/.fmf/version @@ -0,0 +1 @@ +1 diff --git a/.gitignore b/.gitignore index bbf3d51..495602f 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,5 @@ unpaper-0.3.tar.gz +/unpaper-6.1.tar.xz +/unpaper-6.1.tar.xz.sig +/unpaper-6.1^20220117.gite515408.tar.xz +/unpaper-7.0.0.tar.xz diff --git a/.rpmlint b/.rpmlint deleted file mode 100644 index 2e2d927..0000000 --- a/.rpmlint +++ /dev/null @@ -1,2 +0,0 @@ -from Config import * -addFilter("spelling-error .* deskewing"); diff --git a/gating.yaml b/gating.yaml new file mode 100644 index 0000000..c778f75 --- /dev/null +++ b/gating.yaml @@ -0,0 +1,16 @@ +--- !Policy +product_versions: + - fedora-rawhide +decision_context: bodhi_update_push_stable +subject_type: koji_build +rules: + - !PassingTestCaseRule {test_case_name: fedora-ci.koji-build.rpmdeplint.functional} +--- !Policy +product_versions: + - fedora-* +decision_context: bodhi_update_push_stable +subject_type: koji_build +rules: + - !PassingTestCaseRule {test_case_name: fedora-ci.koji-build.installability.functional} + - !PassingTestCaseRule {test_case_name: fedora-ci.koji-build.rpminspect.static-analysis} + - !PassingTestCaseRule {test_case_name: fedora-ci.koji-build.tier0.functional} diff --git a/gpgkey-BDAEF3008A1CC62079C2A16847664B94E36B629F.gpg b/gpgkey-BDAEF3008A1CC62079C2A16847664B94E36B629F.gpg new file mode 100644 index 0000000..80e7276 Binary files /dev/null and b/gpgkey-BDAEF3008A1CC62079C2A16847664B94E36B629F.gpg differ diff --git a/plans/sanity.fmf b/plans/sanity.fmf new file mode 100644 index 0000000..a72ded4 --- /dev/null +++ b/plans/sanity.fmf @@ -0,0 +1,5 @@ +summary: Sanity tests +discover: + how: fmf +execute: + how: tmt diff --git a/sources b/sources index 7ff82af..19a18e1 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -be41eaf8556e7df39ab53939c99c4f7b unpaper-0.3.tar.gz +SHA512 (unpaper-7.0.0.tar.xz) = 58da969e773bf16ffee98b96f903ac5347f66d9a93c63bdb9131f5d45f4d7973c09f364ac2f27f8cb61f75de0421c6b01aa248fa9619fbdbde30fcebc76aa484 diff --git a/tests/upstream-tests.fmf b/tests/upstream-tests.fmf new file mode 100644 index 0000000..8db150f --- /dev/null +++ b/tests/upstream-tests.fmf @@ -0,0 +1,5 @@ +summary: Upstream tests +component: unpaper +require: unpaper-tests +test: /usr/libexec/unpaper/test +duration: 12m diff --git a/unpaper-0.3-format-security.patch b/unpaper-0.3-format-security.patch deleted file mode 100644 index 40b01f2..0000000 --- a/unpaper-0.3-format-security.patch +++ /dev/null @@ -1,55 +0,0 @@ -diff --git a/src/unpaper.c b/src/unpaper.c -index f967d92..53f55b0 100644 ---- a/src/unpaper.c -+++ b/src/unpaper.c -@@ -1,9 +1,9 @@ - /* --------------------------------------------------------------------------- - unpaper - written by Jens Gulden 2005-2007 */ - --const char* VERSION = "0.3"; -+const char VERSION[] = "0.3"; - --const char* README = -+const char README[] = - "unpaper is a post-processing tool for scanned sheets of paper, especially for\n" - "book pages that have been scanned from previously created photocopies.\n" - "The main purpose is to make scanned book pages better readable on screen\n" -@@ -29,7 +29,7 @@ const char* README = - "Conversion to PDF can e.g. be achieved with the Linux tools pgm2tiff, tiffcp\n" - "and tiff2pdf."; - --const char* COMPILE = -+const char COMPILE[] = - "gcc -D TIMESTAMP=\"\" -lm -O3 -funroll-all-loops -fomit-frame-pointer -ftree-vectorize -o unpaper unpaper.c\n"; - - /* ------------------------------------------------------------------------ */ -@@ -46,17 +46,17 @@ const char* BUILD = TIMESTAMP; - const char* BUILD = NULL; - #endif - --const char* WELCOME = -+const char WELCOME[] = - "unpaper %s - written by Jens Gulden 2005-2007.\n" - "Licensed under the GNU General Public License, this comes with no warranty.\n"; - --const char* USAGE = -+const char USAGE[] = - "Usage: unpaper [options] \n\n" - "Filenames may contain a formatting placeholder starting with '%%' to insert a\n" - "page counter for multi-page processing. E.g.: 'scan%%03d.pbm' to process files\n" - "scan001.pbm, scan002.pbm, scan003.pbm etc.\n"; - --const char* OPTIONS = -+const char OPTIONS[] = - "-l --layout single Set default layout options for a sheet:\n" - " |double 'single': One page per sheet.\n" - " |none 'double': Two pages per sheet, landscape\n" -@@ -558,7 +558,7 @@ const char* OPTIONS = - //--help-compile Undocumented. - - --const char* HELP = -+const char HELP[] = - "Run 'unpaper --help' for usage information.\n"; - - diff --git a/unpaper-7.0.0-Set-the-update-option-to-suppress-the-ffmpeg-5.1-war.patch b/unpaper-7.0.0-Set-the-update-option-to-suppress-the-ffmpeg-5.1-war.patch new file mode 100644 index 0000000..f8eb9be --- /dev/null +++ b/unpaper-7.0.0-Set-the-update-option-to-suppress-the-ffmpeg-5.1-war.patch @@ -0,0 +1,44 @@ +From a2a88fe837fd6770ac94f08b2eb841f0dc9d2430 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Diego=20Elio=20Petten=C3=B2?= +Date: Sat, 8 Oct 2022 10:14:46 +0100 +Subject: [PATCH] Set the `update` option to suppress the ffmpeg 5.1 warning. +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +This addresses Issue #113, the spurious warning coming from ffmpeg 5.1+ +about the filename not being an image sequence (we do our own sequencing +so we do not want it to be seen by ffmpeg at all!) + +Signed-off-by: Petr Písař +--- + file.c | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/file.c b/file.c +index fc24a4c..53ef727 100644 +--- a/file.c ++++ b/file.c +@@ -13,6 +13,7 @@ + #include + #include + #include ++#include + + #include "tools.h" + #include "unpaper.h" +@@ -142,6 +143,11 @@ void saveImage(char *filename, AVFrame *input, int outputPixFmt) { + errOutput("unable to allocate output context."); + } + ++ if ((ret = av_opt_set(out_ctx->priv_data, "update", "true", 0)) < 0) { ++ av_strerror(ret, errbuff, sizeof(errbuff)); ++ errOutput("unable to configure update option: %s", errbuff); ++ } ++ + switch (outputPixFmt) { + case AV_PIX_FMT_RGB24: + output_codec = AV_CODEC_ID_PPM; +-- +2.37.3 + diff --git a/unpaper-7.0.0-Use-avformat_alloc_output_context2-to-create-the-out.patch b/unpaper-7.0.0-Use-avformat_alloc_output_context2-to-create-the-out.patch new file mode 100644 index 0000000..b388b1f --- /dev/null +++ b/unpaper-7.0.0-Use-avformat_alloc_output_context2-to-create-the-out.patch @@ -0,0 +1,55 @@ +From d29fd2cf84ea386c67ecb0302adebc0700088d94 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Diego=20Elio=20Petten=C3=B2?= +Date: Sat, 8 Oct 2022 00:16:20 +0100 +Subject: [PATCH] Use avformat_alloc_output_context2() to create the out + context. +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +This simplifies the API usage quite a bit, while maintaining the same +logic as previously. + +Signed-off-by: Petr Písař +--- + file.c | 14 ++------------ + 1 file changed, 2 insertions(+), 12 deletions(-) + +diff --git a/file.c b/file.c +index d9c239e..fc24a4c 100644 +--- a/file.c ++++ b/file.c +@@ -127,7 +127,6 @@ void loadImage(const char *filename, AVFrame **image) { + * @return true on success, false on failure + */ + void saveImage(char *filename, AVFrame *input, int outputPixFmt) { +- const AVOutputFormat *fmt = NULL; + enum AVCodecID output_codec = -1; + const AVCodec *codec; + AVFormatContext *out_ctx; +@@ -138,20 +137,11 @@ void saveImage(char *filename, AVFrame *input, int outputPixFmt) { + int ret; + char errbuff[1024]; + +- fmt = av_guess_format("image2", NULL, NULL); +- +- if (!fmt) { +- errOutput("could not find suitable output fmt."); +- } +- +- out_ctx = avformat_alloc_context(); +- if (!out_ctx) { ++ if (avformat_alloc_output_context2(&out_ctx, NULL, "image2", filename) < 0 || ++ out_ctx == NULL) { + errOutput("unable to allocate output context."); + } + +- out_ctx->oformat = fmt; +- out_ctx->url = av_strdup(filename); +- + switch (outputPixFmt) { + case AV_PIX_FMT_RGB24: + output_codec = AV_CODEC_ID_PPM; +-- +2.37.3 + diff --git a/unpaper.rpmlintrc b/unpaper.rpmlintrc new file mode 100644 index 0000000..d67411a --- /dev/null +++ b/unpaper.rpmlintrc @@ -0,0 +1,2 @@ +addFilter('spelling-error .* deskewing') +addFilter('-tests\.noarch: W: no-documentation') diff --git a/unpaper.spec b/unpaper.spec index e0b2bcb..505acaa 100644 --- a/unpaper.spec +++ b/unpaper.spec @@ -1,15 +1,67 @@ Name: unpaper -Version: 0.3 -Release: 26%{?dist} +Version: 7.0.0 +Release: 18%{?dist} Summary: Post-processing of scanned and photocopied book pages -# Licensed under any GPL version since none is specified -License: GPL+ -URL: http://unpaper.berlios.de/ -Source0: http://download.berlios.de/%{name}/%{name}-%{version}.tar.gz -Patch0: unpaper-0.3-format-security.patch -BuildRequires: coreutils +# AUTHORS: GPL-2.0-only +# constants.h: GPL-2.0-only +# doc/basic-concepts.md: GPL-2.0-only +# doc/file-formats.md: GPL-2.0-only +# doc/image-processing.md: GPL-2.0-only +# doc/img/*.png.license: GPL-2.0-only +# doc/unpaper.1.rst: GPL-2.0-only +# file.c: GPL-2.0-only +# imageprocess.c: GPL-2.0-only +# imageprocess.h: GPL-2.0-only +# LICENSES/0BSD.txt: 0BSD text +# LICENSES/GPL-2.0-only.txt: GPL-2.0 text +# other files: GPL-2.0-only +# README.md: GPL-2.0-only +# version.h.in: 0BSD +## In tests subpackage +# LICENSES/MIT.txt: MIT text +# tests/golden_images/*.license GPL-2.0-only +# tests/source_images/*.license GPL-2.0-only +# tests/unpaper_tests.py: GPL-2.0-only AND MIT +## Not in any binary package +# doc/conf.py: MIT +# LICENSES/Apache-2.0.txt: Apache-2.0 text +# meson.build: MIT +# .dir-locals.el: MIT +# .editorconfig: 0BSD +# .github/workflows/meson-build-and-test.yml: Apache-2.0 +# .github/workflows/pre-commit.yml: MIT +# .gitignore: MIT +# .mailmap: MIT +# .mergify.yml: MIT +# .pre-commit-config.yaml: MIT +SourceLicense: GPL-2.0-only AND 0BSD AND MIT AND Apache-2.0 +License: GPL-2.0-only AND 0BSD +URL: https://www.flameeyes.eu/projects/%{name} +Source0: https://www.flameeyes.eu/files/%{name}-%{version}.tar.xz +# Missing a signature, requested by e-mail +# . +#Source1: https://www.flameeyes.eu/files/%%{name}-%%{version}.tar.xz.sig +## A key exported from keyserver on 2022-02-25. +#Source2: gpgkey-BDAEF3008A1CC62079C2A16847664B94E36B629F.gpg +# 1/2Set an update option to supress a warning with ffmpeg-5.1, +# in upstream after 7.0.0, +# +Patch0: unpaper-7.0.0-Use-avformat_alloc_output_context2-to-create-the-out.patch +# 2/2 Set an update option to supress a warning with ffmpeg-5.1, +# in upstream after 7.0.0, +# +Patch1: unpaper-7.0.0-Set-the-update-option-to-suppress-the-ffmpeg-5.1-war.patch BuildRequires: gcc -BuildRequires: sed +#BuildRequires: gnupg2 +BuildRequires: meson >= 0.57 +BuildRequires: pkgconfig(libavcodec) +BuildRequires: pkgconfig(libavformat) +BuildRequires: pkgconfig(libavutil) +BuildRequires: python3-sphinx >= 3.4 +# Tests: +BuildRequires: python3dist(pytest) +# python3-pillow for PIL Python module +BuildRequires: python3-pillow %description unpaper is a post-processing tool for scanned sheets of paper, especially for @@ -17,33 +69,134 @@ book pages that have been scanned from previously created photocopies. The main purpose is to make scanned book pages better readable on screen after conversion to PDF. Additionally, unpaper might be useful to enhance the quality of scanned pages before performing optical character recognition (OCR). + unpaper tries to clean scanned images by removing dark edges that appeared through scanning or copying on areas outside the actual page content (e.g. dark -areas between the left-hand-side and the right-hand-side of a double- sided -book-page scan). The program also tries to detect misaligned centering and -rotation of pages and will automatically straighten each page by rotating it to -the correct angle. This process is called "deskewing". +areas between the left-hand-side and the right-hand-side of a double-sided +book-page scan). + +The program also tries to detect misaligned centering and rotation of pages +and will automatically straighten each page by rotating it to the correct +angle. This process is called "deskewing". + +%package tests +Summary: Tests for %{name} +License: GPL-2.0-only AND MIT +BuildArch: noarch +Requires: %{name} = %{?epoch:%{epoch}:}%{version}-%{release} +# python3-pillow for PIL Python module +Requires: python3-pillow +Requires: python3-pytest +# Parallelize tests +Requires: python3-pytest-xdist + +%description tests +Tests from %{name}. Execute them +with "%{_libexecdir}/%{name}/test". %prep -%setup -q -%patch0 -p1 -# fix eol encoding in LICENSE -sed -i -e 's/\r//' LICENSE +#%%{gpgverify} --keyring='%%{SOURCE2}' --signature='%%{SOURCE1}' --data='%%{SOURCE0}' +%autosetup -p1 %build -cd src -gcc $RPM_OPT_FLAGS $RPM_LD_FLAGS -o unpaper unpaper.c -lm +%meson +%meson_build + +%check +%meson_test %install -install -d $RPM_BUILD_ROOT/%{_bindir} -install -p -m 0755 src/unpaper $RPM_BUILD_ROOT/%{_bindir} +%meson_install +# Install tests +mkdir -p %{buildroot}%{_libexecdir}/%{name} +cp -a tests %{buildroot}%{_libexecdir}/%{name} +cat > %{buildroot}%{_libexecdir}/%{name}/test << 'EOF' +#!/bin/sh +export TEST_IMGSRC_DIR=tests/source_images +export TEST_GOLDEN_DIR=tests/golden_images +export TEST_UNPAPER_BINARY=%{_bindir}/unpaper +cd %{_libexecdir}/%{name} && exec pytest -v -n "$(getconf _NPROCESSORS_ONLN)" tests/unpaper_tests.py +EOF +chmod +x %{buildroot}%{_libexecdir}/%{name}/test +%{_fixperms} %{buildroot}/* %files -%license LICENSE -%{_bindir}/* -%doc doc CHANGELOG README +%license LICENSES/0BSD.txt LICENSES/GPL-2.0-only.txt +%{_bindir}/unpaper +%{_mandir}/man1/unpaper.* +%doc AUTHORS doc/*.md doc/img NEWS README.md + +%files tests +%license LICENSES/MIT.txt +%{_libexecdir}/%{name} %changelog +* Thu Sep 03 2026 Dominik Mierzejewski - 7.0.0-18 +- Rebuilt for FFmpeg 9 + +* Fri Jul 17 2026 Fedora Release Engineering - 7.0.0-17 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_45_Mass_Rebuild + +* Sat Jan 17 2026 Fedora Release Engineering - 7.0.0-16 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_44_Mass_Rebuild + +* Wed Oct 15 2025 Dominik Mierzejewski - 7.0.0-15 +- Rebuilt for FFmpeg 8 + +* Fri Jul 25 2025 Fedora Release Engineering - 7.0.0-14 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_43_Mass_Rebuild + +* Sun Jan 19 2025 Fedora Release Engineering - 7.0.0-13 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_42_Mass_Rebuild + +* Mon Sep 23 2024 Fabio Valentini - 7.0.0-12 +- Rebuild for ffmpeg 7 + +* Mon Sep 23 2024 Petr Pisar - 7.0.0-11 +- Define a license of a source package + +* Sat Jul 20 2024 Fedora Release Engineering - 7.0.0-10 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild + +* Sat Jan 27 2024 Fedora Release Engineering - 7.0.0-9 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild + +* Sat Jul 22 2023 Fedora Release Engineering - 7.0.0-8 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild + +* Sun Mar 12 2023 Neal Gompa - 7.0.0-7 +- Rebuild for ffmpeg 6.0 + +* Wed Feb 08 2023 Petr Pisar - 7.0.0-6 +- Convert license tags to an SPDX format + +* Sat Jan 21 2023 Fedora Release Engineering - 7.0.0-5 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild + +* Mon Oct 10 2022 Petr Pisar - 7.0.0-4 +- Set an update option to supress a warning with ffmpeg-5.1 (upstream #113) + +* Mon Aug 29 2022 Neal Gompa - 7.0.0-3 +- Rebuild for ffmpeg 5.1 (#2121070) + +* Sat Jul 23 2022 Fedora Release Engineering - 7.0.0-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild + +* Tue May 31 2022 Petr Pisar - 7.0.0-1 +- 7.0.0 bump +- License changed from (GPLv2) to (GPLv2 and 0BSD and MIT) +- Package the tests + +* Tue Mar 08 2022 Neal Gompa - 6.1^20220117.gite515408-2 +- Rebuild for ffmpeg 5.0 ABI fix (#2061392) + +* Fri Feb 25 2022 Petr Pisar - 6.1^20220117.gite515408-1 +- 6.1 bump from upstream git tree +- License changed to GPLv2 + +* Sat Jan 22 2022 Fedora Release Engineering - 0.3-27 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild + * Fri Jul 23 2021 Fedora Release Engineering - 0.3-26 - Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild