How to make my Snap package smaller

my application is so big about 300mb for simple screen recorder
how I can reduce it’s size?

in store:


source:

use one of the gnome- extensions (see snapcraft list-extensions) and see what stage-packages you can drop that the extension already ships …

also, drop the compression line from your snapcrft.yaml (this will make the first startup a little slower, but significantly reduce your package size)

after I change the compressing it still big about 228M
can I reduce it more?

try using an extension … that should shove off some more … though since you need to ship ffmpeg inside your snap, there is a limit on how low you can go in size …

I just installed your snap and run ncdu /snap/blue-recorder/current to see what’s big inside the snap. You’ve got cc1plus, cc and lto1 in your usr/lib/gcc/x86_64-linux-gnu/7 folder (each of which are over 20MB) which may not need to be there? Are you staging things you perhaps shouldn’t?
Looking at your yaml, I’d bet the fact you’re staging gettext will not help. You probably want that as a build-package not staged.

4 Likes

Also helpful if you’re unsure which packages are supplied by the extension and core snaps, is the cleanup example at https://snapcraft-utils-library.readthedocs.io/en/latest/lib/cleanup.html#manually-adding-to-snapcraft-yaml. This will remove any files that exist in the named content snaps.

3 Likes

full packages:
lzo = 300M
xz = 228M

only needed packages:
lzo = 226M
xz = 170M

stage-snaps:
  - ffmpeg
stage-packages:
  - libappindicator3-dev
  - x11-utils
  - xdg-utils
build-packages:
  - libappindicator3-dev
  - clang
  - gettext
  - build-essential
override-build: |
  snapcraftctl build
  cp -a data interfaces po $SNAPCRAFT_PART_INSTALL
  cp -a target/release/blue-recorder $SNAPCRAFT_PART_INSTALL/blue-recorder

still big size
can I reduce it more?

You also have ibappindicator3-dev as a stage package which probably pulls in things you don’t need. That’s a header package used at build time.

1 Like

after I remove it from stage the snap package size reduced a lot (from 226M to 112M) but I got error

/snap/blue-recorder/x1/blue-recorder: error while loading shared libraries: libappindicator3.so.1: cannot open shared object file: No such file or directory

I think it important in stage and build state
Can I connect it to host library?

You need libappindicator3-1 as the stage-package, you can probably leave libappindicator3-dev as the build-package if it’s needed

2 Likes

snap package size reduced to 146M with LZO compressing algorithm
it fine :smiley:

2 Likes