1
0
mirror of https://github.com/containers/bootc.git synced 2026-02-05 15:45:53 +01:00

install: Add cleanup option to install to-existing-root

When set, the bootc-destructive-cleanup flag is added to /sysroot/etc
which enables the bootc-destructive-cleanup systemd service to remove
the previous installation's rpm packages and podman containers/images.

The service is only installed on fedora based systems.

Signed-off-by: ckyrouac <ckyrouac@redhat.com>
This commit is contained in:
ckyrouac
2025-04-30 11:22:31 -04:00
parent b1fb35c0f4
commit 85b2419f09
5 changed files with 70 additions and 6 deletions

View File

@@ -0,0 +1,14 @@
#!/bin/bash
# An implementation of --cleanup for bootc installs on Fedora derivatives
set -xeuo pipefail
# Remove all RPMs installed in the physical root (i.e. the previous OS)
mount -o remount,rw /sysroot
rpm -qa --root=/sysroot --dbpath=/usr/lib/sysimage/rpm | xargs rpm -e --root=/sysroot --dbpath=/usr/lib/sysimage/rpm
# Remove all container images (including the one that was used to install)
# Note that this does not remove stopped containers, and so some storage
# may leak. This may change in the future.
mount --bind -o rw /sysroot/var/lib/containers /var/lib/containers
podman system prune --all -f