Deal with new RPM database location

https://fedoraproject.org/wiki/Changes/RelocateRPMToUsr
This commit is contained in:
Richard W.M. Jones 2023-01-21 09:42:55 +00:00
parent aa8ebc6a2e
commit 29efa3fac5
2 changed files with 58 additions and 1 deletions

View File

@ -0,0 +1,50 @@
From 86fd6f3e86ab99d54a22b475aecccfc19bdff07e Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Sat, 21 Jan 2023 09:38:55 +0000
Subject: [PATCH] rpm: New RPM database location in /usr/lib/sysimage/rpm
A few years ago the RPM database was moved from /var to /usr. This is
now feeding through to Linux distros.
http://lists.rpm.org/pipermail/rpm-maint/2017-October/006723.html
https://fedoraproject.org/wiki/Changes/RelocateRPMToUsr
https://src.fedoraproject.org/rpms/rpm/pull-request/21
---
src/ph_rpm.ml | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/src/ph_rpm.ml b/src/ph_rpm.ml
index 85557fe..2c199c1 100644
--- a/src/ph_rpm.ml
+++ b/src/ph_rpm.ml
@@ -236,12 +236,22 @@ let rpm_package_name pkg =
let rpm = rpm_of_pkg pkg in
rpm.name
+let rpmdb_locations = [
+ "/usr/lib/sysimage/rpm/rpmdb.sqlite";
+ "/var/lib/rpm/rpmdb.sqlite";
+ "/var/lib/rpm/Packages"
+]
+
+let find_rpmdb () =
+ let rec loop = function
+ | [] -> error "rpm: cannot locate RPM database; if this is a normal RPM-based Linux distro then this is probably a supermin bug"
+ | db :: rest ->
+ if Sys.file_exists db then db else loop rest
+ in
+ loop rpmdb_locations
+
let rpm_get_package_database_mtime () =
- (try
- lstat "/var/lib/rpm/rpmdb.sqlite"
- with Unix_error (ENOENT, _, _) ->
- lstat "/var/lib/rpm/Packages"
- ).st_mtime
+ (lstat (find_rpmdb ())).st_mtime
(* Return the best provider of a particular RPM requirement.
*
--
2.39.0

View File

@ -31,7 +31,7 @@
Summary: Tool for creating supermin appliances Summary: Tool for creating supermin appliances
Name: supermin Name: supermin
Version: 5.3.3 Version: 5.3.3
Release: 2%{?dist} Release: 3%{?dist}
License: GPLv2+ License: GPLv2+
ExclusiveArch: %{kernel_arches} ExclusiveArch: %{kernel_arches}
@ -46,6 +46,9 @@ Source1: http://download.libguestfs.org/supermin/%{source_directory}/%{nam
# Keyring used to verify tarball signature. # Keyring used to verify tarball signature.
Source2: libguestfs.keyring Source2: libguestfs.keyring
# https://fedoraproject.org/wiki/Changes/RelocateRPMToUsr
Patch1: 0001-rpm-New-RPM-database-location-in-usr-lib-sysimage-rp.patch
BuildRequires: gcc BuildRequires: gcc
BuildRequires: make BuildRequires: make
BuildRequires: autoconf, automake BuildRequires: autoconf, automake
@ -187,6 +190,10 @@ make check || {
%changelog %changelog
* Sat Jan 21 2023 Richard W.M. Jones <rjones@redhat.com> - 5.3.3-3
- Deal with new RPM database location
- https://fedoraproject.org/wiki/Changes/RelocateRPMToUsr
* Sat Jan 21 2023 Fedora Release Engineering <releng@fedoraproject.org> - 5.3.3-2 * Sat Jan 21 2023 Fedora Release Engineering <releng@fedoraproject.org> - 5.3.3-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild - Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild