Skip to content

Commit e1041cb

Browse files
committed
fix(os): prune non-runtime production payload
1 parent 2abe628 commit e1041cb

4 files changed

Lines changed: 31 additions & 1 deletion

File tree

os/mkosi/build.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ EOF
6767
mkosi --directory "$SELF" --force --extra-tree="$stage" "${devargs[@]}" \
6868
--format=directory --output-directory="$work" --output=rootfs \
6969
--compress-output=no --bootable=no build
70+
if [[ $flavor == prod ]]; then
71+
"$SELF/scripts/prune-rootfs.sh" "$tree"
72+
fi
7073
# ldconfig's binary auxiliary cache records traversal-dependent ordering.
7174
# /var is volatile at runtime, so ship no host-generated cache.
7275
rm -f "$tree/var/cache/ldconfig/aux-cache"

os/mkosi/mkosi.conf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ Packages=
5050
parted
5151
busybox-static
5252
cryptsetup-bin
53-
ovmf
5453
systemd-boot-efi
5554
acpid
5655
numactl

os/mkosi/scripts/prune-rootfs.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
# SPDX-License-Identifier: Apache-2.0
3+
set -euo pipefail
4+
5+
ROOTFS=$(realpath -m "${1:?rootfs tree required}")
6+
7+
# Match Yocto's production packaging policy: development inputs, translated
8+
# messages and package-manager metadata are not part of the immutable guest.
9+
# /var/cache and /var/lib are hidden by volatile bind mounts at runtime.
10+
for path in \
11+
usr/include \
12+
usr/share/OVMF \
13+
usr/share/ovmf \
14+
usr/share/doc \
15+
usr/share/info \
16+
usr/share/locale \
17+
usr/share/man \
18+
var/cache/debconf \
19+
var/lib/dpkg \
20+
var/lib/ucf; do
21+
rm -rf "${ROOTFS:?}/$path"
22+
done
23+
24+
# Static archives and libtool metadata are build inputs. All production
25+
# consumers use the corresponding shared objects.
26+
find "$ROOTFS/usr" -type f \( -name '*.a' -o -name '*.la' \) -delete

os/mkosi/tests/acceptance.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ grep -q 'build-ovmf.sh' "$D/scripts/build-components.sh"
2525
grep -q 'fbe0805b2091393406952e84724188f8c1941837' "$D/scripts/build-ovmf.sh"
2626
grep -q 'AmdSev/AmdSevX64.dsc' "$D/scripts/build-ovmf.sh"
2727
grep -q 'objcopy --strip-debug' "$D/build.sh"
28+
grep -q 'prune-rootfs.sh' "$D/build.sh"
29+
! grep -q '^[[:space:]]*ovmf$' "$D/mkosi.conf"
2830
grep -q '"firmware_sev":"files/ovmf-sev.fd"' "$D/scripts/make-release-artifacts.sh"
2931
grep -q 'measurement.snp.cbor' "$D/tests/check-output.sh"
3032
grep -q '0001-validate-ocsp-response-freshness.patch' "$D/scripts/build-nvattest.sh"

0 commit comments

Comments
 (0)