#2 Update dependencies and improve SPEC file
Merged 2 years ago by kevin. Opened 2 years ago by aimylios.
rpms/ aimylios/calibre clean-up-spec-4.8.0  into  master

file modified
+30 -50
@@ -6,7 +6,7 @@ 

  

  Name:           calibre

  Version:        4.8.0

- Release:        1%{?dist}

+ Release:        2%{?dist}

  Summary:        E-book converter and library manager

  License:        GPLv3

  URL:            https://calibre-ebook.com/
@@ -36,6 +36,7 @@ 

  Patch5:         https://github.com/keszybz/calibre/commit/01bf854923741bf8d6a6328f17d61e0ec5ac3c9f.patch

  

  ExclusiveArch: %{qt5_qtwebengine_arches}

+ 

  BuildRequires:  python3-devel

  BuildRequires:  python3-setuptools

  BuildRequires:  python3-qt5-devel
@@ -44,7 +45,6 @@ 

  BuildRequires:  desktop-file-utils

  BuildRequires:  xdg-utils

  BuildRequires:  chmlib-devel

- BuildRequires:  python3-cssutils >= 0.9.9

  BuildRequires:  sqlite-devel

  BuildRequires:  libicu-devel

  BuildRequires:  libpng-devel
@@ -53,7 +53,6 @@ 

  BuildRequires:  web-assets-devel

  BuildRequires:  qt5-qtbase-static

  BuildRequires:  libXrender-devel

- BuildRequires:  systemd-devel

  BuildRequires:  openssl-devel

  # calibre installer is so smart that it check for the presence of the

  # directory (and then installs in the wrong place)
@@ -82,11 +81,11 @@ 

  BuildRequires:  python3dist(html2text)

  BuildRequires:  python3dist(zeroconf)

  BuildRequires:  python3dist(markdown) >= 3.0

- BuildRequires:  python3dist(dukpy)

  BuildRequires:  hunspell-devel

  BuildRequires:  qt5-qtwebengine-devel

  BuildRequires:  python-qt5-webengine

  BuildRequires:  hyphen-devel

+ BuildRequires:  mathjax

  # Those are only used for tests. Do not add to runtime deps.

  BuildRequires:  /usr/bin/jpegtran

  BuildRequires:  /usr/bin/JxrDecApp
@@ -112,7 +111,6 @@ 

  Requires:       liberation-mono-fonts

  Requires:       mathjax

  Requires:       optipng

- Requires:       python3dist(cssutils)

  Requires:       python3dist(odfpy)

  Requires:       python3dist(lxml)

  Requires:       python3dist(pillow)
@@ -152,27 +150,38 @@ 

  %autosetup -n calibre-%{version} -p1

  

  # remove shebangs

+ sed -i -e '/^#!\//, 1d' src/calibre/*/*/*/*/*.py

  sed -i -e '/^#!\//, 1d' src/calibre/*/*/*/*.py

  sed -i -e '/^#!\//, 1d' src/calibre/*/*/*.py

  sed -i -e '/^#![ ]*\//, 1d' src/calibre/*/*.py

  sed -i -e '/^#!\//, 1d' src/calibre/*.py

+ sed -i -e '/^#!\//, 1d' src/css_selectors/*.py

+ sed -i -e '/^#!\//, 1d' src/polyglot/*.py

  sed -i -e '/^#!\//, 1d' src/templite/*.py

+ sed -i -e '/^#!\//, 1d' src/tinycss/*/*.py

+ sed -i -e '/^#!\//, 1d' src/tinycss/*.py

  sed -i -e '/^#!\//, 1d' resources/default_tweaks.py

- #sed -i -e '/^#!\//, 1d' resources/catalog/section_list_templates.py

  

  chmod -x src/calibre/*/*/*/*.py \

      src/calibre/*/*/*.py \

      src/calibre/*/*.py \

      src/calibre/*.py

  

+ # remove bundled MathJax

  rm -rvf resources/mathjax

  

  # Skip tests that require removed fonts

  sed -r -i 's/\b(test_actual_case|test_clone|test_file_add|test_file_removal|test_file_rename|test_folder_type_map_case|test_merge_file)\b/_skipped_\1/' src/calibre/ebooks/oeb/polish/tests/container.py

  # Skip test that fails in mock

- sed  -r -i 's/\btest_bonjour\b/_skipped_\0/' src/calibre/srv/tests/loop.py

+ sed -r -i 's/\btest_bonjour\b/_skipped_\0/' src/calibre/srv/tests/loop.py

  

  %build

+ # unbundle MathJax

+ CALIBRE_PY3_PORT=1 \

+ %__python3 setup.py mathjax \

+     --system-mathjax \

+     --path-to-mathjax %{_jsdir}/mathjax/

+ 

  OVERRIDE_CFLAGS="%{optflags}" \

  CALIBRE_PY3_PORT=1 \

  %__python3 setup.py build
@@ -180,15 +189,6 @@ 

  %install

  mkdir -p %{buildroot}%{_datadir}

  

- # create directories for xdg-utils

- mkdir -p %{buildroot}%{_datadir}/icons

- mkdir -p %{buildroot}%{_datadir}/icons/hicolor

- mkdir -p %{buildroot}%{_datadir}/packages

- mkdir -p %{buildroot}%{_datadir}/mime

- mkdir -p %{buildroot}%{_datadir}/mime/packages

- mkdir -p %{buildroot}%{_datadir}/applications

- mkdir -p %{buildroot}%{_datadir}/desktop-directories

- 

  # create directory for calibre environment module

  # the install script assumes it's there.

  mkdir -p %{buildroot}%{python3_sitelib}
@@ -198,13 +198,12 @@ 

  mkdir -p %{buildroot}%{_datadir}/bash-completion/completions

  mkdir -p %{buildroot}%{_datadir}/zsh/site-functions

  

- XDG_DATA_DIRS="%{buildroot}%{_datadir}" \

- XDG_UTILS_INSTALL_MODE="system" \

  LIBPATH="%{_libdir}" \

  CALIBRE_PY3_PORT=1 \

  %__python3 setup.py install --root=%{buildroot}%{_prefix} \

                              --prefix=%{_prefix} \

                              --libdir=%{_libdir} \

+                             --staging-root=%{buildroot}%{_prefix} \

                              --staging-libdir=%{buildroot}%{_libdir} \

                              --staging-sharedir=%{buildroot}%{_datadir}

  
@@ -224,21 +223,18 @@ 

  cp -p resources/images/tweak.png                 \

     %{buildroot}%{_datadir}/pixmaps/calibre-ebook-edit.png

  

- # every file is empty here

- find %{buildroot}%{_datadir}/mime -maxdepth 1 -type f -print -delete

- 

  # packages aren't allowed to register mimetypes like this

  rm -f %{buildroot}%{_datadir}/applications/defaults.list

  rm -f %{buildroot}%{_datadir}/applications/mimeinfo.cache

  rm -f %{buildroot}%{_datadir}/mime/application/*.xml

  rm -f %{buildroot}%{_datadir}/mime/text/*.xml

  

+ # check .desktop files

  desktop-file-validate \

- %{buildroot}%{_datadir}/applications/calibre-ebook-viewer.desktop

- desktop-file-validate \

- %{buildroot}%{_datadir}/applications/calibre-gui.desktop

- desktop-file-validate \

- %{buildroot}%{_datadir}/applications/calibre-lrfviewer.desktop

+     %{buildroot}%{_datadir}/applications/calibre-ebook-edit.desktop \

+     %{buildroot}%{_datadir}/applications/calibre-ebook-viewer.desktop \

+     %{buildroot}%{_datadir}/applications/calibre-gui.desktop \

+     %{buildroot}%{_datadir}/applications/calibre-lrfviewer.desktop

  

  # mimetype icon for lrf

  rm -rf %{buildroot}%{_datadir}/icons/hicolor/128x128
@@ -253,16 +249,6 @@ 

  # these are provided as separate packages

  rm -rf %{buildroot}%{_libdir}/calibre/odf

  

- # # rm empty feedparser files.

- # rm -rf %{buildroot}%{_libdir}/calibre/calibre/web/feeds/feedparser.*

- 

- # ln -s %{python3_sitelib}/feedparser.py \

- #       %{buildroot}%{_libdir}/calibre/calibre/web/feeds/feedparser.py

- # ln -s %{python3_sitelib}/feedparser.pyc \

- #       %{buildroot}%{_libdir}/calibre/calibre/web/feeds/feedparser.pyc

- # ln -s %{python3_sitelib}/feedparser.pyo \

- #       %{buildroot}%{_libdir}/calibre/calibre/web/feeds/feedparser.pyo

- 

  # link to system fonts after we have deleted (see Source0) the non-free ones

  # http://bugs.calibre-ebook.com/ticket/3832

  %if 0%{?fedora} >= 31
@@ -342,11 +328,6 @@ 

        %{buildroot}%{_datadir}/calibre/fonts/liberation/LiberationSerif-Regular.ttf

  %endif

  

- # delete locales, calibre stores them in a zip file now

- rm -rf %{buildroot}%{_datadir}/calibre/localization/locales/

- 

- rm -f %{buildroot}%{_bindir}/calibre-uninstall

- 

  # Remove these 2 appdata files, we can only include one

  rm -f %{buildroot}/%{_datadir}/metainfo/calibre-ebook-edit.appdata.xml

  rm -f %{buildroot}/%{_datadir}/metainfo/calibre-ebook-viewer.appdata.xml
@@ -362,14 +343,9 @@ 

  

  appstream-util validate-relax --nonet %{buildroot}%{_datadir}/metainfo/calibre-gui.appdata.xml

  

- %preun

- rm -f %{_datadir}/calibre/mathjax

- 

- %posttrans

- ln -s %{_jsdir}/mathjax %{_datadir}/calibre/

- 

  %files

- %doc COPYRIGHT LICENSE Changelog.yaml

+ %license LICENSE

+ %doc Changelog.yaml COPYRIGHT README.md

  %{_bindir}/calibre

  %{_bindir}/calibre-complete

  %{_bindir}/calibre-customize
@@ -380,7 +356,9 @@ 

  %{_bindir}/calibredb

  %{_bindir}/ebook-convert

  %{_bindir}/ebook-device

+ %{_bindir}/ebook-edit

  %{_bindir}/ebook-meta

+ %{_bindir}/ebook-polish

  %{_bindir}/ebook-viewer

  %{_bindir}/fetch-ebook-metadata

  %{_bindir}/lrf2lrs
@@ -388,8 +366,6 @@ 

  %{_bindir}/lrs2lrf

  %{_bindir}/markdown-calibre

  %{_bindir}/web2disk

- %{_bindir}/ebook-polish

- %{_bindir}/ebook-edit

  %{_libdir}/calibre/

  %{_datadir}/calibre/

  %{_datadir}/pixmaps/*
@@ -404,6 +380,10 @@ 

  %{_datadir}/metainfo/*.appdata.xml

  

  %changelog

+ * Sun Jan 12 2020 Marcus A. Romer <aimylios@gmx.de> - 4.8.0-2

+ - Update dependencies.

+ - Remove some obsolete packaging workarounds.

+ 

  * Fri Jan 03 2020 Jan Grulich <jgrulich@redhat.com> - 4.8.0-1

  - Update to 4.8.0

  

This PR aims at cleaning up and simplifying the SPEC file by removing some obsolete packaging workarounds, updating dependencies, and improving the formatting of some of its parts.

These are the individual changes:
- BuildRequires & Requires python3-cssutils is dropped (obsolete as of 3.37.0, see https://github.com/kovidgoyal/calibre/commit/dd7d8ea3c4f47e315623d882d6b68339da959ab9).
- BuildRequires python3-dukpy is dropped (obsolete as of 4.0.0, see https://github.com/kovidgoyal/calibre/commit/82083ddbb85b6dfedb72389f05c90063a8aa8be2).
- BuildRequires systemd-devel is dropped, as it is not a build-time dependency (any more?).
- Python shebangs are removed from all source files, not just some.
- The method of unbundling MathJax is switched to the one implemented by upstream, which also properly creates the manifest.json. The main difference is that it will create absolute symlinks to individual files instead of a relative symlink to the folder, but I think this might be justified in this case. Calibre would have to be patched to make it create relative symlinks.
- Workaround for xdg-utils is dropped (obsolete as of 3.43.0, see https://github.com/kovidgoyal/calibre/commit/2a63948440fe2d60a5573b829f27000d5c0389e2).
- .desktop file validation extended and simplified.
- References to various files and folders that don't exist any more are removed.
- Some whitespace cleanup and alphabetical sorting of %files.

The RPMs and build logs for F31 and Rawhide based on this PR are available in my private Copr repository:
https://copr.fedorainfracloud.org/coprs/aimylios/calibre-python3/build/1143543/

Please let me know what you think, and if you see the need for any adaptations before this can be merged.

The simple-koji-ci build failed on i686 and armv7hl with the following error message:

test_qt (calibre.test_build.BuildTest) ... ../../3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/sigsys_handlers.cc:**CRASHING**:seccomp-bpf failure in syscall 0403
../../3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/sigsys_handlers.cc:**CRASHING**:seccomp-bpf failure in syscall 0403
../../3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/sigsys_handlers.cc:**CRASHING**:seccomp-bpf failure in syscall 0403
ERROR [9 s]

======================================================================
ERROR: test_qt (calibre.test_build.BuildTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/calibre-4.8.0/src/calibre/test_build.py", line 239, in test_qt
    self.assertEqual(callback.result, 2, 'Simple JS computation failed')
AttributeError: 'function' object has no attribute 'result'
----------------------------------------------------------------------

But I believe this has nothing to do with my changes, and is related to QTBUG-57709. I've triggered another Copr build including i386 for Rawhide, and that did not show the same issue:
https://copr.fedorainfracloud.org/coprs/aimylios/calibre-python3/build/1143556/

Looks great to me! Thanks a bunch for working on this... I'll merge and build for rawhide now and we can fix anything that shows up before we push to stable...

Pull-Request has been merged by kevin

2 years ago

Thank you for reviewing and merging so quickly!

I see you had to disable the tests on i686 and armv7hl. Hopefully this can be fixed somehow.

In my opinion there is no need to explicitly push 4.8.0-2 to stable F31, as the changes visible to the user are minimal and it just creates "update noise". But it should be included in case F31 gets 4.9.0 or any later version, of course.

So, a few issues...

  1. 32 bit was failing for me as well on official builds. I just ignored the tests for now until we can sort that out...

  2. Upgrades are broken due to mathjax..

Error: Transaction test error:
file /usr/share/calibre/mathjax/MathJax.js from install of calibre-4.8.0-2.fc32.x86_64 conflicts with file from package mathjax-2.7.4-5.fc31.noarch
file /usr/share/calibre/mathjax/extensions/AssistiveMML.js from install of calibre-4.8.0-2.fc32.x86_64 conflicts with file from package mathjax-2.7.4-5.fc31.noarch
file /usr/share/calibre/mathjax/extensions/CHTML-preview.js from install of calibre-4.8.0-2.fc32.x86_64 conflicts with file from package mathjax-2.7.4-5.fc31.noarch
file /usr/share/calibre/mathjax/extensions/FontWarnings.js from install of calibre-4.8.0-2.fc32.x86_64 conflicts with file from package mathjax-2.7.4-5.fc31.noarch
file /usr/share/calibre/mathjax/extensions/HTML-CSS/handle-floats.js from install of calibre-4.8.0-2.fc32.x86_64 conflicts with file from package mathjax-2.7.4-5.fc31.noarch
file /usr/share/calibre/mathjax/extensions/HelpDialog.js from install of calibre-4.8.0-2.fc32.x86_64 confli
cts with file from package mathjax-2.7.4-5.fc31.noarch
...

I'll try and look in the coming days but I don't have time today... if you want to look, please feel free. :)

Oh, you are right, mea culpa. I guess I only tested the upgrade from one of my local builds which already had some of those changes, and not the official RPM. It is most likely caused by the symlink to the %{_jsdir}/mathjax folder generated in %posttrans in the old package not being removed before the new version of calibre tries to set up its per-file symlinks. Installing 4.8.0-2 on a system without an earlier version of calibre being installed therefore works without problems. I can take a closer look at this issue tonight and try to come up with a workaround.

Thanks. I untagged the build so it wouldn't go out in todays rawhide as well...

The problem that breaks the update process is indeed caused by the old method of unbundling MathJax through a symlink. I first thought this could be handled with some scriptlet magic (i.e., to remove the symlink before the new files get installed), but it seems like no scriptlet is executed before dnf does its transaction test (is this correct?)

Therefore I only see the following options:
1. Revert back to the old method of unbundling MathJax. This is less than ideal, because then the manifest.json that is used by Calibre will still not be available (which is what I wanted to fix). But this approach could quickly fix the issue until we come up with an alternative solution.
2. Keep the new unbundling method, but rename or move the /usr/share/calibre/mathjax folder and patch Calibre to search for it at the new location. This is rather intrusive, but would allow us to get rid of the scriptlets. And in the long term, when it's safe to assume no user will try to update from 4.8.0-1 or earlier, this workaround could be dropped completely.
3. Keep the new unbundling method, but rename the /usr/share/calibre/mathjax folder and let the scriptlets create a symlink, like they did before. This doesn't solve the underlying problem, as it means the workaround would have to be kept forever (unless MathJax will ever be handled in a different way or be dropped from Calibre).

I don't really have a preference, but would be happy to take some advice from experienced packagers on how to handle this situation. Maybe there is another option that I am missing here.

As a proof-of-concept, I have implemented the third variant: https://src.fedoraproject.org/fork/aimylios/rpms/calibre/c/22c988098ced5cc5e932675c341f51e50d8ca8aa?branch=upgrade-from-4.8.0-1
The RPMs and build logs are available on Copr: https://copr.fedorainfracloud.org/coprs/aimylios/calibre-python3/build/1144183/
Updating from 4.8.0-1 to 4.8.0-3 works with this solution, but I didn't yet have the time for any functional tests.

Sorry again for the mess this PR has caused. Next time I'll have to test my changes more systematically before submitting them.

I think 3 is ok for now.

I don't like 1, and I am not sure 2 is possible. ;(

Do you want to do a PR on that?

OK, I will then clean up my branch and submit a PR later today.

If I find the time, I'll also take a look at the second option. Might be something to be considered for a future update.