Next try: Packaging Anki Desktop for aarch64 Alpine Linux (Postmarket OS)

After I gave up last year, I have restarted efforts to build Anki Desktop for Alpine Linux (Postmarket OS). You can see my current efforts in this merge request.

After some to and fro, I decided that I’d go the same route as was taken in the FreeBSD ports:

  1. Build the rust part manually (i.e. without bazel).
  2. Use bazel for the rest.

I now have successfully built a package, but it seems to be missing the translations. When I start anki I get the following stack trace:

Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/aqt/main.py", line 129, in __init__
    self.setupUI()
  File "/usr/lib/python3.10/site-packages/aqt/main.py", line 164, in setupUI
    self.setupMainWindow()
  File "/usr/lib/python3.10/site-packages/aqt/main.py", line 829, in setupMainWindow
    self.form.setupUi(self)
  File "/usr/lib/python3.10/site-packages/aqt/forms/main.py", line 134, in setupUi
    self.retranslateUi(MainWindow)
  File "/usr/lib/python3.10/site-packages/aqt/forms/main.py", line 139, in retranslateUi
    self.menuHelp.setTitle(tr.qt_accel_help())
AttributeError: 'Translations' object has no attribute 'qt_accel_help'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/aqt/__init__.py", line 437, in run
    _run()
  File "/usr/lib/python3.10/site-packages/aqt/__init__.py", line 616, in _run
    mw = aqt.main.AnkiQt(app, pm, backend, opts, args)
  File "/usr/lib/python3.10/site-packages/aqt/main.py", line 133, in __init__
    showInfo(tr.qt_misc_error_during_startup(val=traceback.format_exc()))

Maybe I inadvertently patched the build step away that downloads the translations, but I don’t know where to start looking. Which folders/files should exist if the translation step was successful? Which build file is responsible for the translations?

For reference:
Here are the latest (at the time of this writing) logs: logs · Artifacts · build-aarch64 (#584060) · Jobs · Frank Oltmanns / aports · GitLab

pylib/_backend/__init__.py imports a file created by genfluent.py

Thanks, from the logs I can see that genfluent.py is being run from bazel:

SUBCOMMAND: # //pylib/anki/_backend:fluent_gen [action 'Executing genrule //pylib/anki/_backend:fluent_gen', configuration: 78c8422d51e79bf471adddfaa0935cab02ea4b413972ddf1cd770c601dc7e331, execution platform: @local_config_platform//:host]
(cd /home/buildozer/.cache/bazel/_bazel_buildozer/b3ac9790c15d3abd0d87bb3b48528140/execroot/ankidesktop && \
  exec env - \
    PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \
    PYTHON_SITE_PACKAGES=/usr/lib/python3.10/site-packages \
  /bin/bash -c 'source external/bazel_tools/tools/genrule/genrule-setup.sh; bazel-out/host/bin/pylib/anki/_backend/genfluent bazel-out/host/bin/rslib/i18n/strings.json bazel-out/aarch64-opt/bin/pylib/anki/_backend/fluent.py')

However, there is no qt_accel_help or qt-accel-help in the strings.json (and therefore also not in the resulting fluent.py).

My strings.json is 7659 lines. I guess, you have found the culprit. I need to dig into how the strings.json is being generated. As far as I understand that happens in the rust part, which I could not get to compile through bazel on Alpine. So I (like the people at FreeBSD) had to run the manually. I probably messed sth. up there.

I only start cargo with the pylib/rsbridge/Cargo.toml. I assume I need to run the other tomls as well.

rg EXTRA_FTL_ROOT
rslib/BUILD.bazel
19: “EXTRA_FTL_ROOT”: “$(location @extra_ftl//:l10n.toml)”,

rslib/i18n/BUILD.bazel
16: “EXTRA_FTL_ROOT”: “$(location @extra_ftl//:l10n.toml)”,

rslib/i18n/build/gather.rs
9://! - EXTRA_FTL_ROOT should normally be set to the l10n.toml file inside the qt translation
109: std::env::var(“EXTRA_FTL_ROOT”)

Okay, I get it now. During the build you are pulling a specific commit from the anki-core-i18n and anki-desktop-ftl repos on github. I’ll try to do that manually as well.

Thanks! It works now.

1 Like

Great! If there’s some canonical location for your patches/docs, please let me know and I’ll add a link to them in Anki’s dev docs.

I think the only complete description I have are the build-files themselves. There is quite some patching involved. Which I don’t think are worth describing, because they are alpine and/or musl specific.So I guess anyone interested in building Anki for another musl-distro should look at alpine’s build file.

Note, that the merge request is not excepted yet. But I made my reviews today on my pinephone. So, I can confirm it works. :slight_smile:

I’ll add a link here when the merge request has been accepted.

1 Like