base: Cleanup rpmdb

First, ensure we remove the `-shm` files etc; this is another
implementation of https://github.com/coreos/rpm-ostree/pull/5244
effectively, but in shell script in the container build pipeline.

Also remove the rpm-ostree-base-db because I think it's the
hardlinking here that's causing problems in gitlab CI where
we can't rely on writethrough of hardlinks.

I am hoping this fixes the gitlab CI.

Signed-off-by: Colin Walters <walters@verbum.org>
This commit is contained in:
Colin Walters 2025-01-24 14:12:50 -05:00
parent 98f6572750
commit f2fbdd7dad
2 changed files with 26 additions and 2 deletions

View File

@ -9,9 +9,9 @@
# container image. # container image.
FROM quay.io/fedora/fedora:rawhide as repos FROM quay.io/fedora/fedora:rawhide as repos
# BOOTSTRAPPING: This can be any image that has rpm-ostree and selinux-policy-targeted. # BOOTSTRAPPING: This can be any image that has the following packages.
FROM quay.io/fedora/fedora:rawhide as builder FROM quay.io/fedora/fedora:rawhide as builder
RUN dnf -y install rpm-ostree selinux-policy-targeted RUN dnf -y install rpm-ostree selinux-policy-targeted sqlite
# Copy in our source code. # Copy in our source code.
COPY . /src COPY . /src
WORKDIR /src WORKDIR /src

24
base/finalize.d/05-rpmdb.sh Executable file
View File

@ -0,0 +1,24 @@
#!/bin/bash
set -euo pipefail
# https://github.com/coreos/rpm-ostree/pull/5244
#
sysimage_rpmdb=usr/lib/sysimage/rpm/rpmdb.sqlite
rpmostree_rpmdb_dir=usr/share/rpm
rpmostree_rpmdb="${rpmostree_rpmdb_dir}/rpmdb.sqlite"
rpmostree_base_rpmdb_dir=usr/lib/sysimage/rpm-ostree-base-db
rpmostree_base_rpmdb="${rpmostree_base_rpmdb_dir}/rpmdb.sqlite"
pragma='PRAGMA journal_mode=delete;'
# Forcibly delete this because ostree hardlinking the sqlite databases
# confuses rpm. This will cause rpm-ostree to enter a fallback
# mode with package layering, but that's OK.
if test -d "${rpmostree_base_rpmdb_dir}"; then
echo "Removing ${rpmostree_base_rpmdb_dir}"
rm "${rpmostree_base_rpmdb_dir}" -rf
fi
for path in ${sysimage_rpmdb} ${rpmostree_rpmdb}; do
if test -f "${path}-shm"; then
echo "Executing in ${path}: ${pragma}"
sqlite3 "${path}" "${pragma}" >/dev/null
fi
done