How to remove unnecessary libs from snap artefact?

I am trying to make my snap slimmer by not including some libraries. My Question is: How exactly does snapcraft decide which libs to pack into the snap?

I am using the same method as electron-builder does here: https://github.com/electron-userland/electron-builder/blob/28cb86bdcb6dd0b10e75a69ccd34ece6cca1d204/packages/app-builder-lib/templates/snap/snapcraft.yaml#L29

If I remove too much, I get warnings. But I can remove some things without warning. And, and this puzzles me: Some things (for example gconv) I cannot get rid of.

What is the logic here?

Does it start by copying everything from the base snap…?

take a look at this post from our beloved @diddledani

1 Like

Thank you, however to understand what this does… it cleans up things added by content-snaps? What are those? The plugins below?

  gnome-3-28-1804:
    interface: content
    target: $SNAP/gnome-platform
    default-provider: gnome-3-28-1804
  gtk-3-themes:
    interface: content
    target: $SNAP/data-dir/themes
    default-provider: gtk-common-themes
  icon-themes:
    interface: content
    target: $SNAP/data-dir/icons
    default-provider: gtk-common-themes
  sound-themes:
    interface: content
    target: $SNAP/data-dir/sounds
    default-provider: gtk-common-themes

well, not sure what you are using these plugs for given you do not have any apps: defined at all … usually you would have an apps: section and in there use one of the desktop extensions (which automatically adds these plugs, so you do not need to add them explicitly)

the script does check for libs existing in any of the defined extensions as well as in your defined base snap and then removes all duplicated files your snap might ship …

My bad, what I pasted was the plugs part of my snapcraft.yaml. There are apps defined. But thank you for reminding me of extensions. So if I added

extensions: [gnome-3-28]

to my app then it would probably expand to something similar as above.

Also thanks for clarifying what the cleanup part does.

well, if it is the snapcraft.yaml you linked in the original post there are no apps defined, all i see is a part that is called “app:” … but it does not have a toplevel apps: entry …

Ah now I understand. I just linked to this file in electron-builder to show how I exclude files. (the line should be marked when the link is clicked.) However you are right, this is not a complete file. They are using it to create the final snapcraft.yaml before creating the snap.

1 Like