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

Reduce snap size #224

Merged
merged 7 commits into from
Dec 5, 2023
21 changes: 17 additions & 4 deletions snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1585,13 +1585,18 @@ parts:
- raft
- sqlite
- squashfs-tools-ng
- swtpm
- vim
- virtiofsd
- xfs
- xz
- wrappers
- xtables
- zfs-0-8
- zfs-2-0
- zfs-2-1
- zfs-2-2
- zstd
- lxc
- lxcfs
- criu
Expand All @@ -1603,6 +1608,13 @@ parts:
override-prime: |
set -x

# XXX: remove unneeded files/directories
rm -rf "${CRAFT_PRIME}/lib/python3/dist-packages/*.egg-info/"
rm -rf "${CRAFT_PRIME}/lib/systemd/"
rm -rf "${CRAFT_PRIME}/lib/udev/"
rm -rf "${CRAFT_PRIME}/usr/local/"
rm -rf "${CRAFT_PRIME}/usr/share/"

# Strip binaries (excluding shell scripts)
find "${CRAFT_PRIME}"/bin -type f \
-not -path "${CRAFT_PRIME}/bin/ceph" \
Expand All @@ -1614,11 +1626,13 @@ parts:
-not -path "${CRAFT_PRIME}/bin/xfs_admin" \
-exec strip -s {} +

# Strip all versions of zfs utils
find "${CRAFT_PRIME}"/zfs-*/ -type f \
-exec strip -s {} +

# Strip libraries (excluding python3 scripts)
find "${CRAFT_PRIME}"/lib -type f \
-not -path "${CRAFT_PRIME}/lib/python3/*" \
-not -path "${CRAFT_PRIME}/lib/udev/rules.d/*" \
-not -path "${CRAFT_PRIME}/lib/systemd/system/*" \
-exec strip -s {} +

if [ "$(uname -m)" != "riscv64" ]; then
Expand All @@ -1630,8 +1644,7 @@ parts:

# XXX: look for broken symlinks indicating missing/invalid prime
broken_symlinks="$(find "${CRAFT_PRIME}/" -xtype l \
-not -path "${CRAFT_PRIME}/lxc/config/common.conf.d/*" \
-not -path "${CRAFT_PRIME}/usr/share/doc/uuid-runtime/*")"
-not -path "${CRAFT_PRIME}/lxc/config/common.conf.d/*")"
if [ -n "${broken_symlinks}" ]; then
echo "Found broken symlinks:"
echo "${broken_symlinks}"
Expand Down
Loading