From f2fbdd7dad6d2e6b3fbb634c4720c6d3168db30c Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Fri, 24 Jan 2025 14:12:50 -0500 Subject: [PATCH] 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 --- Containerfile.base | 4 ++-- base/finalize.d/05-rpmdb.sh | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) create mode 100755 base/finalize.d/05-rpmdb.sh diff --git a/Containerfile.base b/Containerfile.base index ef4ac22..689976a 100644 --- a/Containerfile.base +++ b/Containerfile.base @@ -9,9 +9,9 @@ # container image. 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 -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 . /src WORKDIR /src diff --git a/base/finalize.d/05-rpmdb.sh b/base/finalize.d/05-rpmdb.sh new file mode 100755 index 0000000..f4eea57 --- /dev/null +++ b/base/finalize.d/05-rpmdb.sh @@ -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