Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AppImage: increase compatibility & add tests #17

Merged
merged 1 commit into from
Sep 7, 2024

Conversation

git-developer
Copy link

@git-developer git-developer commented Sep 7, 2024

This PR aims to improve the compatibility of created AppImages.

Current Problems

The current AppImages are based on Ubuntu LTS releases Jammy and Noble. They crash on some environments, at least:

  1. On Batocera 40 as reported here.
    The commented environment requires an AppImage build based on Ubuntu Lunar while Lunar is EOL.
  2. On Debian 12 as reported here

Causes

The crashes have different causes:

  1. The AppImage does not contain all required libraries. Thus some libraries are loaded from the host system. These are sometimes incompatible to other contained libraries.
  2. The AppImage is based on a glibc that is newer than the host.
  3. The directory tree within the AppImage is incompatible to the tree of current OS distros (i.e. using AppImageBuilder to build an AppImage basd on Ubuntu Noble creates an invalid AppImage).

The AppImage documentation explains some concepts which are important for compatibility, e.g.:

  • Build on old systems, run on newer systems
  • Do not depend on system-provided resources

The current AppImages are not based on these concepts.

Solutions

  1. Library exclusions have been revisited.

  2. According to the first concept ("Build on old systems"), additional AppImages are built for popular Debian-based distributions:

    OS Codename glibc python3-gi libglib2.0
    Ubuntu Focal 2.31 3.36 2.64
    Ubuntu Jammy 2.35 3.42 2.66
    Ubuntu Noble 2.39 3.48 2.80
    Debian Bullseye 2.31 3.38 2.66
    Debian Bookworm 2.36 3.42 2.74
    Debian Trixie 2.39 3.48 2.82
  3. The build contains a test job that runs sc-controller with the existing check-dependency argument. A build success now means that a) all required dependencies are part of the AppImage and b) the libraries are compatible to the host systems (at least to the extent of check-dependency). The test job runs in a Docker container for several popular linux distributions:

    • Ubuntu Focal, Jammy, Noble
    • Debian Bullseye, Bookworm, Trixie
    • Fedora 39 , 40
    • ArchLinux

Implementation notes

  • The error reported in Package for Flatpak #15 is fixed. It was caused by a missing /lib64 directory in Ubuntu Noble.
  • Excluded libraries have been revisited to avoid crashes. The new AppImages are slightly bigger, but more compatible now.
  • Debian Bullseye and Ubuntu Focal require a separate AppImageBuilder.yml because no apt package python3-vdf exists for these distributions. When they run EOL, these extra files can be deleted.
  • The tests run on amd64 arch only (I didn't figure out how to run them on arm64).
  • A GitHub Action result and Release is available.
  • Currently, the most compatible Appmage is based on Ubuntu Jammy. But since the test only checks the dependencies and doesn't really use the application, I didn't remove the other AppImages so that users have the choice.

Known issues

There's an open compatibility issue concerning the AppImages for newer AppImages (primarily Ubuntu Noble & Debian Trixie). They cause a segmentation fault on most distributions. The test job knows about this issue and does not fail. Here is the summary of some manual and CI tests:

Host AppImage
OS Codename Kernel glibc Focal Jammy Noble Bullseye Bookworm Trixie
Ubuntu Jammy 5.15 2.35 OK OK SEGFAULT OK SEGFAULT SEGFAULT
Ubuntu Noble 6.8 2.39 OK OK SEGFAULT OK OK SEGFAULT
Batocera 40 6.9 2.38 OK OK SEGFAULT OK OK SEGFAULT
Fedora 39 GitHub 2.38 OK OK SEGFAULT OK OK SEGFAULT
Fedora 40 GitHub 2.39 OK OK SEGFAULT OK OK SEGFAULT
Ubuntu Focal GitHub 2.31 OK OK SEGFAULT OK SEGFAULT SEGFAULT
Ubuntu Jammy GitHub 2.35 OK OK SEGFAULT OK SEGFAULT SEGFAULT
Ubuntu Noble GitHub 2.39 OK OK SEGFAULT OK OK SEGFAULT
Debian Bullseye GitHub 2.31 OK OK SEGFAULT OK SEGFAULT SEGFAULT
Debian Bookworm GitHub 2.36 OK OK SEGFAULT OK SEGFAULT SEGFAULT
Debian Trixie GitHub 2.39 OK OK OK OK OK OK
ArchLinux 2024-09-07 GitHub 2.40 OK OK OK OK OK OK

The segmentation fault occurs in ld-linux-x86-64.so.2 (part of glibc) loaded by the python3 process. The kernel reports

segfault at 7fec1b53e014 ip 00007fc81bc8dd57 sp 00007ffdad0b0490 error 6 in ld-linux-x86-64.so.2[7fc81bc81000+25000]
[2057583.497148] Code: 30 48 0f 44 d0 49 8b 87 58 01 00 00 48 8b 70 08 48 01 d6 48 39 f2 73 63 31 ff eb 1a 0f 1f 80 00 00 00 00 4c 01 f0 48 83 c2 08 <4c> 01 30 48 8d 78 08 48 39 f2 73 35 48 8b 02 a8 01 74 e6 48 d1 e8

@C0rn3j
Copy link
Owner

C0rn3j commented Sep 7, 2024

Wow, the compatibility issues are a mess.

Thanks a lot for digging into this and making such a detailed writeup.
LGTM other than the small issue with return vs exit.

I am not sure about providing builds for Focal if it looks like Jammy builds should be equally compatible, but I suppose we might as well, since the distro is EOL in half a year anyway.

I am still planning to look into Flatpak at an unknown future date, hopefully it will:

  • Be less of a mess to write the build scripts for - those excludes look terrifying
  • Get us rid of these compat issues between hosts and the necessity to provide multiple build images
  • Be easier to install for users while being easily updatable
  • We'll get a sandbox for free on top

@git-developer
Copy link
Author

git-developer commented Sep 7, 2024

Thanks for looking at this so quickly!

LGTM other than the small issue with return vs exit.

Could you give some details about that one?

I am not sure about providing builds for Focal if it looks like Jammy builds should be equally compatible, but I suppose we might as well, since the distro is EOL in half a year anyway.

I think it doesn't hurt to create an AppImage for Focal now and drop it in 04/2025 (EOL is 2032). Maybe it helps someone.

@C0rn3j
Copy link
Owner

C0rn3j commented Sep 7, 2024

Could you give some details about that one?

return sets the return code, finishes the function and continues executing.

exit sets the return code and exits the script.

#!/bin/bash

crashonerror() {
    return 1
}

crashonerror
echo 'all good'

This script returns 'all good' and RC is 0 - because return code of the last exec was from echo.
If you remove the echo, returns 1, because there's no further code that could run below.

I just noticed you're doing it in another place too.

I think it doesn't hurt to create an AppImage for Focal now and drop it in 04/2025 (EOL is 2032). Maybe it helps someone.

Yeah that's what I meant but worded it ambiguously, won't hurt and you already tested it.
I know it's still technically supported with the Pro subscription but... yeah, it's a subscription, and the newer build works, we'll just drop it next year.

@git-developer
Copy link
Author

Regarding exit vs. return: I start scripts with set -eu to avoid that. -e causes the script to stop immediately on the first non-zero return code. I never use exit in functions to give callers the chance to explicitely handle the error (by using an if or ||) or to close resources.

@C0rn3j
Copy link
Owner

C0rn3j commented Sep 7, 2024

Oh, i forgot that you put -e there.

@C0rn3j C0rn3j merged commit cf39960 into C0rn3j:python3 Sep 7, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants