Skip to content

Commit

Permalink
Added a trick to reduce the snap size
Browse files Browse the repository at this point in the history
This trick reduces the size from 110 to 87 MBytes.
  • Loading branch information
sergio-costas committed Jun 14, 2023
1 parent 66ac603 commit ea55fce
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 39 deletions.
7 changes: 7 additions & 0 deletions scripts/launch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

export GIO_MODULE_DIR=$SNAP/gnome-platform/usr/lib/$ARCH_TRIPLET/gio/modules
export GSETTINGS_SCHEMA_DIR=$SNAP/usr/share/glib-2.0/schemas:$SNAP/gnome-platform/usr/share/glib-2.0/schemas${GSETTINGS_SCHEMA_DIR:+:$GSETTINGS_SCHEMA_DIR}
export GST_PLUGIN_PATH=$SNAP/gnome-platform/usr/lib/$ARCH_TRIPLET/gstreamer-1.0${GST_PLUGIN_PATH:+:$GST_PLUGIN_PATH}
export GST_PLUGIN_SYSTEM_PATH=$GST_PLUGIN_SYSTEM_PATH:$SNAP/gnome-platform/usr/lib/$ARCH_TRIPLET/gstreamer-1.0
exec "$@"
87 changes: 48 additions & 39 deletions snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ layout:

apps:
epiphany:
command: bin/snapcraft-preload $SNAP/usr/bin/epiphany
command: scripts/launch $SNAP/bin/snapcraft-preload $SNAP/usr/bin/epiphany
extensions: [ gnome ]
plugs:
- audio-playback
Expand All @@ -52,14 +52,52 @@ apps:
- upower-observe
desktop: usr/share/applications/org.gnome.Epiphany.desktop
environment:
GSETTINGS_SCHEMA_DIR: $SNAP/usr/share/glib-2.0/schemas
GIO_MODULE_DIR: $SNAP/gnome-platform/usr/lib/$CRAFT_ARCH_TRIPLET/gio/modules/
LD_LIBRARY_PATH: ${LD_LIBRARY_PATH:+$LD_LIBRARY_PATH:}$SNAP/usr/lib/$CRAFT_ARCH_TRIPLET/epiphany:$SNAP/usr/lib/$CRAFT_ARCH_TRIPLET:$SNAP/usr/lib/$CRAFT_ARCH_TRIPLET/blas:$SNAP/usr/lib/$CRAFT_ARCH_TRIPLET/lapack
ARCH_TRIPLET: $CRAFT_ARCH_TRIPLET
LD_LIBRARY_PATH: $SNAP/usr/lib/$CRAFT_ARCH_TRIPLET/epiphany:$SNAP/usr/lib/$CRAFT_ARCH_TRIPLET:$SNAP/usr/lib/$CRAFT_ARCH_TRIPLET/blas:$SNAP/usr/lib/$CRAFT_ARCH_TRIPLET/lapack${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}

parts:
# Install all stage packages, find files provided by the base and
# platform snap and ensure they aren't duplicated in this snap
packages:
plugin: nil
stage-packages:
- gstreamer1.0-clutter-3.0
- gstreamer1.0-gl
- gstreamer1.0-gtk3
- gstreamer1.0-libav
- gstreamer1.0-plugins-base
- gstreamer1.0-plugins-good
- gstreamer1.0-plugins-bad
- gstreamer1.0-pulseaudio
- libarchive13
- libglu1-mesa
- libgpm2
- libjavascriptcoregtk-4.0-18
- libnettle8
- libslang2
- libsphinxbase3
build-snaps: [core22, gtk-common-themes, gnome-42-2204]
override-prime: |
set -eux
craftctl default
for snap in "core22" "gtk-common-themes" "gnome-42-2204"; do
cd "/snap/$snap/current"
find . -type f,l -exec rm -f "$CRAFT_PRIME/{}" \;
done
cd $CRAFT_PRIME
rm -f usr/lib/$CRAFT_ARCH_TRIPLET/webkit2gtk-4.0
rm -f usr/lib/$CRAFT_ARCH_TRIPLET/webkit2gtk-4.1
mkdir -p usr/lib/$CRAFT_ARCH_TRIPLET
ln -s ../../../gnome-platform/usr/lib/$CRAFT_ARCH_TRIPLET/webkit2gtk-4.0 usr/lib/$CRAFT_ARCH_TRIPLET/
ln -s ../../../gnome-platform/usr/lib/$CRAFT_ARCH_TRIPLET/webkit2gtk-4.1 usr/lib/$CRAFT_ARCH_TRIPLET/
cd $CRAFT_PRIME/usr/share/glib-2.0/schemas
glib-compile-schemas .
# epiphany needs access to /dev/shm/
snapcraft-preload:
source: https://github.com/sergiusens/snapcraft-preload.git
after: [ packages ]
source-depth: 1
# ext:updatesnap
# version-format:
Expand Down Expand Up @@ -99,22 +137,6 @@ parts:
- nettle-dev
- python-gi-dev
- libgirepository1.0-dev
stage-packages:
- gstreamer1.0-clutter-3.0
- gstreamer1.0-gl
- gstreamer1.0-gtk3
- gstreamer1.0-libav
- gstreamer1.0-plugins-base
- gstreamer1.0-plugins-good
- gstreamer1.0-plugins-bad
- gstreamer1.0-pulseaudio
- libarchive13
- libglu1-mesa
- libgpm2
- libjavascriptcoregtk-4.0-18
- libnettle8
- libslang2
- libsphinxbase3
stage:
- -usr/bin/gtk-update-icon-cache
- -usr/lib/*/gtk-3.0/3.0.0/printbackends/libprintbackend*.so*
Expand All @@ -136,22 +158,9 @@ parts:
- -usr/lib/*/libsecret-1.so.*
- -usr/share/glib-2.0/schemas/org.gtk*

# Find files provided by the base and platform snap and ensure they aren't
# duplicated in this snap
cleanup:
after: [epiphany]
plugin: nil
# ext:updatesnap
# version-format:
# ignore: true
build-snaps: [core22, gtk-common-themes, gnome-42-2204]
override-prime: |
set -eux
for snap in "core22" "gtk-common-themes" "gnome-42-2204"; do
cd "/snap/$snap/current" && find . -type f,l -name *.so.* -exec rm -f "$CRAFT_PRIME/{}" \;
done
cd $CRAFT_PRIME
rm -f usr/lib/$CRAFT_ARCH_TRIPLET/webkit2gtk-4.0
rm -f usr/lib/$CRAFT_ARCH_TRIPLET/webkit2gtk-4.1
ln -s ../../../gnome-platform/usr/lib/$CRAFT_ARCH_TRIPLET/webkit2gtk-4.0 usr/lib/$CRAFT_ARCH_TRIPLET/
ln -s ../../../gnome-platform/usr/lib/$CRAFT_ARCH_TRIPLET/webkit2gtk-4.1 usr/lib/$CRAFT_ARCH_TRIPLET/
scripts:
after: [ epiphany ]
plugin: dump
source: scripts
organize:
launch.sh: scripts/launch

0 comments on commit ea55fce

Please sign in to comment.