aboutsummaryrefslogtreecommitdiff
diff options
from:
to:
context:
space:
mode:
authorGravatar Asahi Lina <lina@asahilina.net> 2024-10-02 12:34:24 +0200
committerGravatar asahilina <lina@asahilina.net> 2024-12-09 20:00:23 +0000
commit9f4dd7cb88f9d89b5e8961d95dc3e32344e328f7 (patch)
tree91dc98821e63536e5af8830940263195114651f5
parentbb3a746ddab30a2be0d7a3d712aab44f7b59e25d (diff)
downloadkiwi-descriptions-9f4dd7cb88f9d89b5e8961d95dc3e32344e328f7.tar.gz
kiwi-descriptions-9f4dd7cb88f9d89b5e8961d95dc3e32344e328f7.zip
teams/asahi: FEX: Minimize rootfs by removing most data files and executables
We only really need i686/x86_64 libraries, and executables which do not exist (or do not work equivalently) on the arm64 host system. In particular, removing libexec avoids situations where random dbus services are started under emulation for no reason.
-rwxr-xr-xconfig.sh74
-rw-r--r--fex-excludes.yaml34
2 files changed, 81 insertions, 27 deletions
diff --git a/config.sh b/config.sh
index d169c98..fcc6461 100755
--- a/config.sh
+++ b/config.sh
@@ -309,4 +309,78 @@ EOF
/usr/bin/glib-compile-schemas /usr/share/glib-2.0/schemas
fi
+if [[ "$kiwi_profiles" == *"FEX"* ]]; then
+ # Remove most things except libraries used by FEX and wine stuff.
+ # Most binaries that are present in non-x86 architectures should be removed,
+ # so they do not run under emulation.
+
+ # rm mingw static libs and headers
+ rm -rf /usr/{x86_64,i686}-w64-mingw32/sys-root/mingw/{lib,include}
+
+ # rm everything in libexec
+ rm -rf /usr/libexec
+
+ # rm everything in /usr/share except wine and mesa related stuff
+ find /usr/share -mindepth 1 -maxdepth 1 \
+ \! -name wine -a \
+ \! -name mesa-demos -a \
+ \! -name drirc.d -a \
+ \! -name vulkan \
+ \! -name licenses \
+ -exec rm -rf {} \;
+
+ # rm everything in /etc except /etc/alternatives and ld stuff
+ find /etc -mindepth 1 -maxdepth 1 \
+ \! -name alternatives -a \
+ \! -name 'ld.so*' -a \
+ \! -name '*.kiwi' \
+ -exec rm -rf {} \;
+
+ # rm non-libs in lib/lib64
+ rm -rf /usr/{lib,lib64}/{locale,tmpfiles.d,systemd,modprobe.d,kbd,cmake}
+ rm -rf /usr/{lib,lib64}/python*
+
+ # lib/clc and lib64/clc are identical, replace with a symlink
+ rm -rf /usr/lib/clc
+ ln -s ../lib64/clc /usr/lib/clc
+
+ # rm sbin except for ldconfig, we don't even have root in some setups
+ find /usr/sbin -mindepth 1 -maxdepth 1 \
+ \! -name 'ldconfig' \
+ -exec rm -rf {} \;
+
+ # rm misc stuff
+ rm -rf /usr/{include,games,local,src,tmp}
+
+ # Finally, remove most binaries except Wine stuff, Mesa stuff, the shell,
+ # path-related stuff, and system info tools.
+ find /usr/bin -mindepth 1 -maxdepth 1 \
+ \! -name 'wine*' -a \
+ \! -name 'mango*' -a \
+ \! -name notepad -a \
+ \! -name 'msi*' -a \
+ \! -name regedit -a \
+ \! -name regsvr32 -a \
+ \! -name 'vulkan*' -a \
+ \! -name 'vk*' -a \
+ \! -name ulimit -a \
+ \! -name ldd -a \
+ \! -name env -a \
+ \! -name sh -a \
+ \! -name bash -a \
+ \! -name ls -a \
+ \! -name stat -a \
+ \! -name dirname -a \
+ \! -name realpath -a \
+ \! -name basename -a \
+ \! -name nproc -a \
+ \! -name uname -a \
+ \! -name arch -a \
+ \! -name rm \
+ -exec rm -rf {} \;
+
+ # Do this last for obvious reasons.
+ rm /usr/bin/rm
+fi
+
exit 0
diff --git a/fex-excludes.yaml b/fex-excludes.yaml
index 3597228..3582368 100644
--- a/fex-excludes.yaml
+++ b/fex-excludes.yaml
@@ -1,35 +1,15 @@
exclude:
-- /dev
-- /sys
-- /proc
-- /etc/hosts
-- /etc/resolv.conf
-- /etc/timezone
-- /etc/localtime
-- /etc/passwd
-- /etc/passwd-
-- /etc/group
-- /etc/group-
-- /etc/shadow
-- /etc/shadow-
-- /etc/gshadow
-- /etc/gshadow-
-- /etc/fstab
-- /etc/mtab
-- /etc/subuid
-- /etc/subgid
-- /etc/machine-id
+- /afs
- /boot
+- /dev
- /home
- /media
- /mnt
+- /opt
+- /proc
- /root
+- /run
- /srv
+- /sys
- /tmp
-- /run
-- /opt
-- /usr/share/fonts
-- /var/tmp
-- /var/run
-- /var/lock
-- /var/lib/dbus/machine-id
+- /var