From 35ad1c74d969681e90bb02a02d1bc18efa91e263 Mon Sep 17 00:00:00 2001 From: Michael Chus Date: Sat, 28 Mar 2026 08:44:02 +0300 Subject: [PATCH] feat(iso): add slim hook to strip locales/man pages/apt cache from squashfs Removes ~100-300MB from the squashfs: man pages, non-en locales, python cache, apt lists and package cache, temp files and logs. Co-Authored-By: Claude Sonnet 4.6 --- .../config/hooks/normal/9999-slim.hook.chroot | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100755 iso/builder/config/hooks/normal/9999-slim.hook.chroot diff --git a/iso/builder/config/hooks/normal/9999-slim.hook.chroot b/iso/builder/config/hooks/normal/9999-slim.hook.chroot new file mode 100755 index 0000000..f9bea21 --- /dev/null +++ b/iso/builder/config/hooks/normal/9999-slim.hook.chroot @@ -0,0 +1,32 @@ +#!/bin/sh +# 9999-slim.hook.chroot — strip non-essential files to reduce squashfs size. +set -e + +# ── Man pages and documentation ─────────────────────────────────────────────── +find /usr/share/man -mindepth 1 -delete 2>/dev/null || true +find /usr/share/doc -mindepth 1 ! -name 'copyright' -delete 2>/dev/null || true +find /usr/share/info -mindepth 1 -delete 2>/dev/null || true +find /usr/share/groff -mindepth 1 -delete 2>/dev/null || true +find /usr/share/lintian -mindepth 1 -delete 2>/dev/null || true + +# ── Locales — keep only C and en_US ────────────────────────────────────────── +find /usr/share/locale -mindepth 1 -maxdepth 1 \ + ! -name 'en' ! -name 'en_US' ! -name 'locale.alias' \ + -exec rm -rf {} + 2>/dev/null || true +find /usr/share/i18n/locales -mindepth 1 \ + ! -name 'en_US' ! -name 'i18n' ! -name 'iso14651_t1' ! -name 'iso14651_t1_common' \ + -delete 2>/dev/null || true + +# ── Python cache ────────────────────────────────────────────────────────────── +find /usr /opt -name '__pycache__' -type d -exec rm -rf {} + 2>/dev/null || true +find /usr /opt -name '*.pyc' -delete 2>/dev/null || true + +# ── APT cache and lists ─────────────────────────────────────────────────────── +apt-get clean +rm -rf /var/lib/apt/lists/* + +# ── Misc ────────────────────────────────────────────────────────────────────── +rm -rf /tmp/* /var/tmp/* 2>/dev/null || true +find /var/log -type f -delete 2>/dev/null || true + +echo "=== slim: done ==="