void-linux / void-packages

The Void source packages collection
https://voidlinux.org
Other
2.59k stars 2.15k forks source link

Package request: qtwebengine_dictionaries #49030

Closed Eloitor closed 8 months ago

Eloitor commented 8 months ago

Package name

qtwebengine_dictionaries

Package homepage

https://doc.qt.io/qt-6.6/qt-add-webengine-dictionary.html

Description

I'm not sure about this. The use case is to provide spell checking for the dooble Browser.

  1. Install and launch the dooble browser.
  2. Edit -> Settings -> Web -> Spell Checkers

You get a warning that qtwebengines_dictionary cannot be accessed. I searched using xlocate "\.bdic" and didn't find any package that provided such (only Grammalecte for french).

Reading from https://doc.qt.io/qt-6.6/qt-add-webengine-dictionary.html

A spell checker in Qt Web Engine needs dictionaries in a specific binary format. This CMake command converts dictionaries from the Hunspell project. into the bdict binary format.

Does the requested package meet the package requirements?

System, Compiled

Is the requested package released?

Yes

chrysos349 commented 8 months ago

I'm not sure about this.

You missed a rather important bit: all the *.bdict dictionaries are generate automatically by dooble build system.

Modify the template by adding this to do_install()

vcopy qtwebengine_dictionaries usr/share/dooble

then add this patch

--- a/Source/dooble_settings.cc
+++ b/Source/dooble_settings.cc
@@ -2271,7 +2271,7 @@ void dooble_settings::show_qtwebengine_dictionaries_warning_label(void)

   if(bytes.trimmed().isEmpty())
     {
-      bytes = "qtwebengine_dictionaries";
+      bytes = "/usr/share/dooble/qtwebengine_dictionaries";

       if(!QFileInfo(bytes).isReadable())
    {
Eloitor commented 8 months ago

Wow thank you! I didn't realized that :)

Eloitor commented 8 months ago

Looking at https://doc.qt.io/qt-6/qtwebengine-features.html#spellchecker maybe it is better to add the qtwebengine_dictionaries as a separate package and install them to QT_INSTALL_PREFIX/qtwebengine_dictionaries...

Is QT_INSTALL_PREFIX just /usr/share/qt6 ? I think not... I think it is just /usr?? But installing the dictionaries in /usr/qtwebengine_dictionaries is odd....

sgn commented 8 months ago

https://groups.google.com/g/linux.debian.bugs.dist/c/dvznQNLhfIQ

Eloitor commented 8 months ago
$ qmake6 -query | grep QT_INSTALL_DATA 
QT_INSTALL_DATA:/usr/share/qt6

So the dictionaries could be placed in /usr/share/qt6/qtwebengine_dictionaries.

Do we have any package with qt5 which could potentially use those dictionaries? If not, we could not care about symlinking them to the qt5 folder.

Should we name the packages like qtwebengine-dict-en-us?

chrysos349 commented 8 months ago

archlinux has *.bdic in hunspell-<LANG> packages: See here - https://gitlab.archlinux.org/archlinux/packaging/packages/hunspell-de/-/blob/main/PKGBUILD?ref_type=heads#L64

# Install webengine dictionaries
  install -d "$pkgdir"/usr/share/qt{,6}/qtwebengine_dictionaries/
  for _file in "$pkgdir"/usr/share/hunspell/*.dic; do
  _filename=$(basename $_file)
    /usr/lib/qt6/qwebengine_convert_dict $_file "$pkgdir"/usr/share/qt6/qtwebengine_dictionaries/${_filename/\.dic/\.bdic}
  ln -rs "$pkgdir"/usr/share/qt6/qtwebengine_dictionaries/${_filename/\.dic/\.bdic} "$pkgdir"/usr/share/qt/qtwebengine_dictionaries/
  done
chrysos349 commented 8 months ago

In a similar manner hunspell-<LANG> templates can be modified, e.g. hunspell-en_US:

diff --git a/srcpkgs/hunspell-en_US/template b/srcpkgs/hunspell-en_US/template
index ce4df5e1a..2d60aa496 100644
--- a/srcpkgs/hunspell-en_US/template
+++ b/srcpkgs/hunspell-en_US/template
@@ -3,7 +3,7 @@ pkgname=hunspell-en_US
 version=2020.12.07
 revision=1
 create_wrksrc=yes
-hostmakedepends="unzip"
+hostmakedepends="unzip qt6-webengine"
 short_desc="American English en_US dictionary for hunspell"
 maintainer="Leah Neukirchen <leah@vuxu.org>"
 license="SCOWL" # not in SPDX
@@ -15,4 +15,15 @@ do_install() {
    vinstall en_US.aff 644 /usr/share/hunspell
    vinstall en_US.dic 644 /usr/share/hunspell
    vlicense README_en_US.txt SCOWL
+   
+   # add qtwebengine_dictionaries
+   vmkdir /usr/share/qt6/qtwebengine_dictionaries
+   vmkdir /usr/share/qt5/qtwebengine_dictionaries
+   for f in ${DESTDIR}/usr/share/hunspell/*.dic; do
+       fa=$(basename $f .dic)
+       /usr/lib/qt6/libexec/qwebengine_convert_dict $f \
+           ${DESTDIR}/usr/share/qt6/qtwebengine_dictionaries/${fa}.bdic
+       ln -s /usr/share/qt6/qtwebengine_dictionaries/${fa}.bdic \
+           ${DESTDIR}/usr/share/qt5/qtwebengine_dictionaries
+   done
 }
classabbyamp commented 8 months ago

it can't be exactly like that, as that would make it impossible to build on architectures that can't have qt6-webengine

chrysos349 commented 8 months ago

you are correct. forgot about those architectures.

UPD. What about enabling only when crossbuilding?

if [ "$CROSS_BUILD" ]; then
        ...
fi
sgn commented 8 months ago

Can be built by qt5-webengine (it's only needed in host).

sgn commented 8 months ago

Another possible approach is xbps-triggers that will regenerate .bdic files upon installation into /usr/share/hunspell and/or qt5-webengine and/or qt6-webengine.

sgn commented 8 months ago

https://github.com/void-linux/void-packages/pull/49189