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

Upgrade snap to core24 - iteration #2 #169

Draft
wants to merge 18 commits into
base: core24
Choose a base branch
from
Draft

Conversation

furgo16
Copy link
Contributor

@furgo16 furgo16 commented Feb 13, 2025

Continuation of #123

  • Publish freecad-deps-core24 test snap => https://github.com/furgo16/freecad-deps-snap/tree/core24/ and http://snapcraft.io/furgo-freecad-deps-core24/ (unlisted, to be deleted when the official freecad-deps-core24 snap is available)
  • Backport changes from the core22 branch
  • Upgrade VTK 7 => 9
  • Upgrade .deb packages 22.04 => 24.04
  • Upgrade Python packages 3.10 => 3.12
  • Get FreeCAD to build
  • Resolve: kf5-core24 in the plugs section (point 1 in "To be resolved") => removed, it's expanded by kde-neon
  • Resolve: LD_LIBRARY_PATH definition does not seem to be working properly (point 2 in "To be resolved")
  • Resolve: kde-qt5-core24-sdk package needs to be specified to build FreeCAD (point 3 in "To be resolved") => has workaround (either leave as it is, or specify kf5-core22 in the cleanup part instead of kf5-core22)
  • Resolve: improve cleanup part (point 4 in "To be resolved") => alternative cleanup part
  • Resolve: snap/command-chain/hooks-configure-desktop path is hardcoded to kf6 (point 5 in "To be resolved") => Fix committed, needs rebuild and reupload
  • Resolve: kde-neon extension bugs => kde-neon extension fixes canonical/snapcraft#5261
  • Get snap package to build: ❌ FAILING
  • Test snap package

Test build available at: https://github.com/furgo16/FreeCAD-snap/actions/runs/13313463891/job/37181598919

Currently, FreeCAD builds without errors, but the snap packing step fails with this error:

Cannot pack snap: error: cannot validate snap "freecad": layout "/usr/share/X11/XErrorDB" underneath prior layout item "/usr/share/X11"
Detailed information: Command '['snap', 'pack', '--check-skeleton', PosixPath('/root/prime')]' returned non-zero exit status 1.

I cannot figure out what it is. It comes from https://github.com/canonical/snapd/blob/f381bfd88038c3d7e27329decc51de4243c6398d/snap/validate.go#L1044-L1048

To be resolved

  1. Why is it necessary to define kf5-core24 in the plugs section here? Should this not happen implicitly when adding the kde-neon extension?
    kf5-core24:
    content: kf5-core24-all
    interface: content
    default-provider: kf5-core24
    target: $SNAP/kf5
  2. The LD_LIBRARY_PATH definition does not seem to be working properly. If a library is deleted from the snap at the prime step, but that library is already provided by the kf5-core24-sdk snap, it is not seen by FreeCAD.
    LD_LIBRARY_PATH: "$SNAP/usr/lib/:$SNAP/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/:$SNAP/kf5/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/:$SNAP/kf5/usr/lib:/$SNAP/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/blas:$SNAP/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/lapack:$LD_LIBRARY_PATH"
  3. The kde-qt5-core24-sdk package needs to be specified here to be able to build FreeCAD, as it contains the Qt CMake files. Before, those files were in the kf5-qt5-core24-sdk package, so that this step (and yet another snap) was not necessary. Is there a better way to do this?
        build-snaps:
       - furgo-freecad-deps-core24/candidate
       - kde-qt5-core24-sdk
  4. The cleanup part's deletion step has proved to be problematic. It deletes only files but leaves the directories, which causes Python modules to load from empty directories. Also when it deletes a required library from the main snap, it cannot be loaded, even if it's already on the sdk snap (probably because point 2 with LD_LIBRARY_PATH is not working)
    for snap in "kf5-core24-sdk"; do # List all content-snaps you're using here
    cd "/snap/$snap/current" && find . -type f,l -exec rm -f "$CRAFT_PRIME/{}" "$CRAFT_PRIME/usr/{}" \;
    done

@furgo16 furgo16 changed the title Upgrade snap to core24 Upgrade snap to core24 - iteration #2 Feb 13, 2025
@furgo16
Copy link
Contributor Author

furgo16 commented Feb 15, 2025

  1. During testing, and after locally removing the cleanup part, I hit another roadblock:
Failed to generate snap metadata: The command-chain item 'snap/command-chain/hooks-configure-desktop' defined in hook 'configure' does not exist or is not executable.

I believe the cause is because the snap/command-chain/hooks-configure-desktop path is hardcoded to kf6, whereas it should be pointing to kfe5 instead:

set -- "${SNAP}/kf6/command-chain/hooks-configure-desktop" "$@"

Source: https://github.com/canonical/snapcraft/blob/main/extensions/desktop/command-chain-kde/hooks-configure-desktop

I see that the desktop-launch hook has a conditional statement that selects the right path according to the Qt version:

#!/bin/bash

if [ "$QT_VERSION" == "6" ]; then

set -- "${SNAP}/kf6/snap/command-chain/desktop-launch6" "$@"
# shellcheck source=/dev/null
source "${SNAP}/snap/command-chain/run"

elif [ "$QT_VERSION" == "5" ]; then

set -- "${SNAP}/kf5/snap/command-chain/desktop-launch" "$@"
# shellcheck source=/dev/null
source "${SNAP}/snap/command-chain/run"

fi

Source: https://github.com/canonical/snapcraft/blob/main/extensions/desktop/command-chain-kde/desktop-launch

The desktop hooks are at: https://invent.kde.org/neon/snap-packaging/snapcraft-desktop-integration

Should hooks-configure-desktop (and hooks-configure-fonts) not check for the Qt version to set the right path as well?

@furgo16
Copy link
Contributor Author

furgo16 commented Feb 15, 2025

  1. Unrelated, but I think this upstream hook has a typo: https://invent.kde.org/neon/snap-packaging/snapcraft-desktop-integration/-/blob/master/command-chain/hooks-configure-desktop?ref_type=heads. Mentioning in case this hits us later

hooks-configure-desktop:

#!/bin/bash

- set -- "${SNAP}/kf6/command-chain/hooks-configure-fonts" "$@"
+ set -- "${SNAP}/kf6/command-chain/hooks-configure-desktop" "$@"
# shellcheck source=/dev/null
source "${SNAP}/snap/command-chain/run"

@furgo16
Copy link
Contributor Author

furgo16 commented Feb 17, 2025

@ScarlettGatelyMoore do you have suggestions on any of the points above? Thanks!

@ScarlettGatelyMoore
Copy link
Contributor

@ScarlettGatelyMoore do you have suggestions on any of the points above? Thanks!

https://invent.kde.org/neon/snap-packaging/snapcraft-desktop-integration/-/commit/44bfe759fde903bbc018d97d1b54c7eccf92312d Fixed, thanks! I am rebuilding kf5-core24 to bring in changes

@ScarlettGatelyMoore
Copy link
Contributor

Just an FYI I have another snapcraft PR for kde-neon fixes canonical/snapcraft#5261

@furgo16

This comment was marked as resolved.

@ScarlettGatelyMoore
Copy link
Contributor

No, it is correct. desktop-configure-fonts actually gets overwritten later in the process with actual font configuration stuff

@furgo16
Copy link
Contributor Author

furgo16 commented Feb 17, 2025

@ScarlettGatelyMoore Great, then I'll wait until the snapcraft change is merged and there's a new upstream release. In the meantime, do you have any feedback on points 1 and 3?

@ScarlettGatelyMoore
Copy link
Contributor

@ScarlettGatelyMoore Great, then I'll wait until the snapcraft change is merged and there's a new upstream release. In the meantime, do you have any feedback on points 1 and 3?

Correct. I have that removed on mine. The qt libraries and kde frameworks SDKs are now in two separate snaps. The kde-neon extension should have added them both as build snaps. Is it not?

@furgo16
Copy link
Contributor Author

furgo16 commented Feb 17, 2025

@ScarlettGatelyMoore

Correct. I have that removed on mine.

Great, on point 1 then I'll remove this snippet:

 kf5-core24: 
   content: kf5-core24-all 
   interface: content 
   default-provider: kf5-core24 
   target: $SNAP/kf5 

On point 3:

The qt libraries and kde frameworks SDKs are now in two separate snaps. The kde-neon extension should have added them both as build snaps. Is it not?

It is not, I think. I've just double-checked it again with a test build at https://github.com/furgo16/FreeCAD-snap/actions/runs/13378095289/job/37361464569. Unless you add kde-qt5-core24-sdk explicitly to build-snaps, the build fails. This can easily be tested by removing the kde-qt5-core24-sdk line from this PR and starting a build, which fails immediately.

On a related note, FreeCAD is not a KDE app. Is there a lightweight "Qt-libs-only" snap alternative for kde-qt5-core24-sdk we should use instead?

@ScarlettGatelyMoore
Copy link
Contributor

@ScarlettGatelyMoore

Correct. I have that removed on mine.

Great, on point 1 then I'll remove this snippet:

 kf5-core24: 
   content: kf5-core24-all 
   interface: content 
   default-provider: kf5-core24 
   target: $SNAP/kf5 

On point 3:

The qt libraries and kde frameworks SDKs are now in two separate snaps. The kde-neon extension should have added them both as build snaps. Is it not?

It is not, I think. I've just double-checked it again with a test build at https://github.com/furgo16/FreeCAD-snap/actions/runs/13378095289/job/37361464569. Unless you add kde-qt5-core24-sdk explicitly to build-snaps, the build fails. This can easily be tested by removing the kde-qt5-core24-sdk line from this PR and starting a build, which fails immediately.

Okay, I need to fix that in snapcraft. Thanks for letting me know.

On a related note, FreeCAD is not a KDE app. Is there a lightweight "Qt-libs-only" snap alternative for kde-qt5-core24-sdk we should use instead?

Not for qt5. I do however have a pr open for qt6 canonical/snapcraft#5236
When you get there it should be available.

@furgo16
Copy link
Contributor Author

furgo16 commented Feb 19, 2025

If I create a basic snap with a part that includes the [kde-neon] extension, snapcraft expand-extensions will list this extract as an addition:

  kde-neon/sdk:
    source: /snap/snapcraft/13519/share/snapcraft/extensions/desktop/command-chain-kde
    plugin: make
    build-snaps:
    - kde-qt5-core24-sdk
    - kf5-core24-sdk
    build-packages:
    - gettext
    - doxygen
    - graphviz
    - libxml2-utils
    - docbook-xml
    - docbook-xsl
    - libglx-dev
    - libgl-dev
    - libglvnd-dev
    make-parameters:
    - GPU_WRAPPER=gpu-2404-wrapper

However, in the FreeCAD snap (this PR), the relevant extract of the snapcraft expand-extensions output will only list this addition:

  kde-neon/sdk:                                                                                                                                                                  
    source: /snap/snapcraft/13519/share/snapcraft/extensions/desktop/command-chain-kde
    plugin: make
    make-parameters:
    - GPU_WRAPPER=gpu-2404-wrapper

@furgo16
Copy link
Contributor Author

furgo16 commented Feb 20, 2025

I've found out what creates this situation: if kf5-core24-sdk is listed in the build-snaps: section of the cleanup part, then kde-neon/sdk will not be fully expanded, as per the previous comment. It's a really strange trigger, but I can reproduce it every time. There might be a workaround, but I don't know of an alternative way to write the cleanup part.

Update: or should we list kf5-core22 there instead?

@ScarlettGatelyMoore let me know if this helps. Happy to look into it if you point me where in the code to look at. Thanks!

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