Skip to content

Commit 755931d

Browse files
committed
install: Add alongside-cleanup systemd service
This will remove all rpms and containers/images from the previous install (found in /sysroot) on reboot after running `install to-existing-root.` Signed-off-by: ckyrouac <[email protected]>
1 parent df879ed commit 755931d

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

contrib/packaging/bootc.spec

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ Recommends: podman
7272
This package provides a utility to simplify reinstalling the current system to a given bootc image.
7373

7474
%global system_reinstall_bootc_install_podman_path %{_prefix}/lib/system-reinstall-bootc/install-podman
75+
%global install_alongside_cleanup %{_prefix}/lib/bootc/install-alongside-cleanup
7576

7677
%prep
7778
%autosetup -p1 -a1
@@ -82,6 +83,7 @@ cat vendor-config.toml >> .cargo/config.toml
8283
rm vendor-config.toml
8384

8485
%build
86+
export INSTALL_ALONGSIDE_CLEANUP=%{install_alongside_cleanup}
8587
# Build the main bootc binary
8688
%if 0%{?fedora} || 0%{?rhel} >= 10
8789
%cargo_build %{?with_rhsm:-f rhsm}
@@ -115,13 +117,26 @@ sed -i -e '/https:\/\//d' cargo-vendor.txt
115117
%if %{with ostree_ext}
116118
make install-ostree-hooks DESTDIR=%{?buildroot}
117119
%endif
120+
118121
mkdir -p %{buildroot}/%{dirname:%{system_reinstall_bootc_install_podman_path}}
119122
cat >%{?buildroot}/%{system_reinstall_bootc_install_podman_path} <<EOF
120123
#!/bin/bash
121124
exec dnf -y install podman
122125
EOF
123126
chmod +x %{?buildroot}/%{system_reinstall_bootc_install_podman_path}
124127

128+
mkdir -p %{buildroot}/%{dirname:%{install_alongside_cleanup}}
129+
cat >%{?buildroot}/%{install_alongside_cleanup} <<EOF
130+
#!/bin/bash
131+
set -xeuo pipefail
132+
mount --o remount,rw /sysroot
133+
rpm -qa --root=/mnt --dbpath=/usr/lib/sysimage/rpm | xargs rpm -e --root=/mnt --dbpath=/usr/lib/sysimage/rpm
134+
135+
mount --bind -o rw /sysroot/var/lib/containers /var/lib/containers
136+
podman images system prune --all
137+
EOF
138+
chmod +x %{?buildroot}/%{install_alongside_cleanup}
139+
125140
%if %{with check}
126141
%check
127142
%cargo_test
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[Unit]
2+
Description=Cleanup previous the installation after an alongside installation
3+
Documentation=man:bootc(8)
4+
ConditionPathExists=/run/ostree-booted
5+
6+
[Service]
7+
Type=oneshot
8+
ExecStart=/usr/lib/bootc/install-alongside-cleanup
9+
PrivateMounts=true
10+
11+
[Install]
12+
WantedBy=multi-user.target

0 commit comments

Comments
 (0)