Add support for dnf5 (RHBZ#2209412)

This commit is contained in:
Richard W.M. Jones 2023-05-30 09:24:07 +01:00
parent 8b8563ecd9
commit 27e02e0188
5 changed files with 295 additions and 8 deletions

View File

@ -1,7 +1,7 @@
From 86fd6f3e86ab99d54a22b475aecccfc19bdff07e Mon Sep 17 00:00:00 2001 From 86fd6f3e86ab99d54a22b475aecccfc19bdff07e Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com> From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Sat, 21 Jan 2023 09:38:55 +0000 Date: Sat, 21 Jan 2023 09:38:55 +0000
Subject: [PATCH] rpm: New RPM database location in /usr/lib/sysimage/rpm Subject: [PATCH 1/4] 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 A few years ago the RPM database was moved from /var to /usr. This is
now feeding through to Linux distros. now feeding through to Linux distros.
@ -46,5 +46,5 @@ index 85557fe..2c199c1 100644
(* Return the best provider of a particular RPM requirement. (* Return the best provider of a particular RPM requirement.
* *
-- --
2.39.0 2.40.1

View File

@ -0,0 +1,98 @@
From f8774efbe02d3651cde449333cf108e79adba48c Mon Sep 17 00:00:00 2001
From: Kate <kit.ty.kate@disroot.org>
Date: Wed, 16 Nov 2022 19:30:01 +0000
Subject: [PATCH 2/4] Add support for OCaml 5.0
---
src/mode_build.ml | 4 ++--
src/supermin.ml | 16 ++++++++--------
src/utils.ml | 4 ++--
3 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/src/mode_build.ml b/src/mode_build.ml
index 7c48295..f81341d 100644
--- a/src/mode_build.ml
+++ b/src/mode_build.ml
@@ -123,7 +123,7 @@ let rec build debug
(PackageSet.cardinal packages);
if debug >= 2 then (
List.iter (printf " - %s\n") pretty_packages;
- flush Pervasives.stdout
+ flush Stdlib.stdout
)
);
@@ -207,7 +207,7 @@ let rec build debug
(List.length files);
if debug >= 2 then (
List.iter (fun { ft_path = path } -> printf " - %s\n" path) files;
- flush Pervasives.stdout
+ flush Stdlib.stdout
)
);
diff --git a/src/supermin.ml b/src/supermin.ml
index 659e857..bef9db6 100644
--- a/src/supermin.ml
+++ b/src/supermin.ml
@@ -296,27 +296,27 @@ let () =
main ()
with
| Unix.Unix_error (code, fname, "") -> (* from a syscall *)
- Printexc.print_backtrace Pervasives.stderr;
+ Printexc.print_backtrace Stdlib.stderr;
error "error: %s: %s" fname (Unix.error_message code)
| Unix.Unix_error (code, fname, param) -> (* from a syscall *)
- Printexc.print_backtrace Pervasives.stderr;
+ Printexc.print_backtrace Stdlib.stderr;
error "error: %s: %s: %s" fname (Unix.error_message code) param
| Failure msg -> (* from failwith/failwithf *)
- Printexc.print_backtrace Pervasives.stderr;
+ Printexc.print_backtrace Stdlib.stderr;
error "failure: %s" msg
| Librpm.Multiple_matches (package, count) -> (* from librpm *)
- Printexc.print_backtrace Pervasives.stderr;
+ Printexc.print_backtrace Stdlib.stderr;
error "RPM error: %d occurrences for %s" count package
| Invalid_argument msg -> (* probably should never happen *)
- Printexc.print_backtrace Pervasives.stderr;
+ Printexc.print_backtrace Stdlib.stderr;
error "internal error: invalid argument: %s" msg
| Assert_failure (file, line, char) -> (* should never happen *)
- Printexc.print_backtrace Pervasives.stderr;
+ Printexc.print_backtrace Stdlib.stderr;
error "internal error: assertion failed at %s, line %d, char %d"
file line char
| Not_found -> (* should never happen *)
- Printexc.print_backtrace Pervasives.stderr;
+ Printexc.print_backtrace Stdlib.stderr;
error "internal error: Not_found exception was thrown"
| exn -> (* something not matched above *)
- Printexc.print_backtrace Pervasives.stderr;
+ Printexc.print_backtrace Stdlib.stderr;
error "exception: %s" (Printexc.to_string exn)
diff --git a/src/utils.ml b/src/utils.ml
index 521d49e..ae99294 100644
--- a/src/utils.ml
+++ b/src/utils.ml
@@ -40,7 +40,7 @@ let dir_exists name =
try (stat name).st_kind = S_DIR
with Unix_error _ -> false
-let uniq ?(cmp = Pervasives.compare) xs =
+let uniq ?(cmp = Stdlib.compare) xs =
let rec loop acc = function
| [] -> acc
| [x] -> x :: acc
@@ -51,7 +51,7 @@ let uniq ?(cmp = Pervasives.compare) xs =
in
List.rev (loop [] xs)
-let sort_uniq ?(cmp = Pervasives.compare) xs =
+let sort_uniq ?(cmp = Stdlib.compare) xs =
let xs = List.sort cmp xs in
let xs = uniq ~cmp xs in
xs
--
2.40.1

View File

@ -0,0 +1,125 @@
From 3efe663421d94376694f292ca1fcf2732a82149f Mon Sep 17 00:00:00 2001
From: Kate <kit.ty.kate@disroot.org>
Date: Wed, 16 Nov 2022 19:59:36 +0000
Subject: [PATCH 3/4] Restore compatibility with OCaml < 4.07
---
src/mode_build.ml | 6 ++++--
src/supermin.ml | 18 ++++++++++--------
src/utils.ml | 6 ++++--
3 files changed, 18 insertions(+), 12 deletions(-)
diff --git a/src/mode_build.ml b/src/mode_build.ml
index f81341d..f0e5e09 100644
--- a/src/mode_build.ml
+++ b/src/mode_build.ml
@@ -16,6 +16,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*)
+let stdlib_stdout = stdout
+
open Unix
open Unix.LargeFile
open Printf
@@ -123,7 +125,7 @@ let rec build debug
(PackageSet.cardinal packages);
if debug >= 2 then (
List.iter (printf " - %s\n") pretty_packages;
- flush Stdlib.stdout
+ flush stdlib_stdout
)
);
@@ -207,7 +209,7 @@ let rec build debug
(List.length files);
if debug >= 2 then (
List.iter (fun { ft_path = path } -> printf " - %s\n" path) files;
- flush Stdlib.stdout
+ flush stdlib_stdout
)
);
diff --git a/src/supermin.ml b/src/supermin.ml
index bef9db6..d49c1e8 100644
--- a/src/supermin.ml
+++ b/src/supermin.ml
@@ -16,6 +16,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*)
+let stdlib_stderr = stderr
+
open Unix
open Unix.LargeFile
open Printf
@@ -296,27 +298,27 @@ let () =
main ()
with
| Unix.Unix_error (code, fname, "") -> (* from a syscall *)
- Printexc.print_backtrace Stdlib.stderr;
+ Printexc.print_backtrace stdlib_stderr;
error "error: %s: %s" fname (Unix.error_message code)
| Unix.Unix_error (code, fname, param) -> (* from a syscall *)
- Printexc.print_backtrace Stdlib.stderr;
+ Printexc.print_backtrace stdlib_stderr;
error "error: %s: %s: %s" fname (Unix.error_message code) param
| Failure msg -> (* from failwith/failwithf *)
- Printexc.print_backtrace Stdlib.stderr;
+ Printexc.print_backtrace stdlib_stderr;
error "failure: %s" msg
| Librpm.Multiple_matches (package, count) -> (* from librpm *)
- Printexc.print_backtrace Stdlib.stderr;
+ Printexc.print_backtrace stdlib_stderr;
error "RPM error: %d occurrences for %s" count package
| Invalid_argument msg -> (* probably should never happen *)
- Printexc.print_backtrace Stdlib.stderr;
+ Printexc.print_backtrace stdlib_stderr;
error "internal error: invalid argument: %s" msg
| Assert_failure (file, line, char) -> (* should never happen *)
- Printexc.print_backtrace Stdlib.stderr;
+ Printexc.print_backtrace stdlib_stderr;
error "internal error: assertion failed at %s, line %d, char %d"
file line char
| Not_found -> (* should never happen *)
- Printexc.print_backtrace Stdlib.stderr;
+ Printexc.print_backtrace stdlib_stderr;
error "internal error: Not_found exception was thrown"
| exn -> (* something not matched above *)
- Printexc.print_backtrace Stdlib.stderr;
+ Printexc.print_backtrace stdlib_stderr;
error "exception: %s" (Printexc.to_string exn)
diff --git a/src/utils.ml b/src/utils.ml
index ae99294..1dc4310 100644
--- a/src/utils.ml
+++ b/src/utils.ml
@@ -16,6 +16,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*)
+let stdlib_compare = compare
+
open Unix
open Unix.LargeFile
open Printf
@@ -40,7 +42,7 @@ let dir_exists name =
try (stat name).st_kind = S_DIR
with Unix_error _ -> false
-let uniq ?(cmp = Stdlib.compare) xs =
+let uniq ?(cmp = stdlib_compare) xs =
let rec loop acc = function
| [] -> acc
| [x] -> x :: acc
@@ -51,7 +53,7 @@ let uniq ?(cmp = Stdlib.compare) xs =
in
List.rev (loop [] xs)
-let sort_uniq ?(cmp = Stdlib.compare) xs =
+let sort_uniq ?(cmp = stdlib_compare) xs =
let xs = List.sort cmp xs in
let xs = uniq ~cmp xs in
xs
--
2.40.1

View File

@ -0,0 +1,58 @@
From 92d5d7e8c27088fa3fb8e5e6e9c5b8d3209053d6 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Tue, 30 May 2023 09:12:14 +0100
Subject: [PATCH 4/4] rpm: Detect dnf5 and omit missing options
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2209412
---
src/ph_rpm.ml | 23 +++++++++++++++++++++--
1 file changed, 21 insertions(+), 2 deletions(-)
diff --git a/src/ph_rpm.ml b/src/ph_rpm.ml
index 2c199c1..3e803c6 100644
--- a/src/ph_rpm.ml
+++ b/src/ph_rpm.ml
@@ -482,19 +482,38 @@ and download_all_packages_with_dnf pkgs dir tdir =
(* Old dnf didn't create the destdir directory, newer versions do. *)
mkdir tdir 0o700;
+ (* dnf5 lacks various options so we have to detect it:
+ * https://github.com/rpm-software-management/dnf5/issues/580
+ * https://github.com/rpm-software-management/dnf5/issues/581
+ *)
+ let is_dnf5 = is_dnf5 () in
+ let debug_quiet_option =
+ if !settings.debug < 1 then " -q"
+ else if not is_dnf5 then " -v"
+ else "" in
+
let rpms = pkgs_as_NA_rpms pkgs in
let cmd =
- sprintf "%s download%s%s --destdir=%s --disableexcludes=all %s"
+ sprintf "%s download%s%s%s --destdir=%s %s"
Config.dnf
- (if !settings.debug >= 1 then " -v" else " -q")
+ debug_quiet_option
(match !settings.packager_config with
| None -> ""
| Some filename -> sprintf " -c %s" (quote filename))
+ (if not is_dnf5 then " --disableexcludes=all" else "")
(quote tdir)
(quoted_list rpms) in
run_command cmd
+and is_dnf5 () =
+ let cmd = sprintf "%s --version" Config.dnf in
+ let lines = run_command_get_lines cmd in
+ match lines with
+ | [] -> error "rpm: no output from '%s' command" cmd
+ | line :: _ when find line "version 5" >= 0 -> true
+ | _ -> false
+
and pkgs_as_NA_rpms pkgs =
let rpms = List.map rpm_of_pkg (PackageSet.elements pkgs) in
List.map (
--
2.40.1

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: 5%{?dist} Release: 6%{?dist}
License: GPLv2+ License: GPLv2+
ExclusiveArch: %{kernel_arches} ExclusiveArch: %{kernel_arches}
@ -47,7 +47,12 @@ Source1: http://download.libguestfs.org/supermin/%{source_directory}/%{nam
Source2: libguestfs.keyring Source2: libguestfs.keyring
# https://fedoraproject.org/wiki/Changes/RelocateRPMToUsr # https://fedoraproject.org/wiki/Changes/RelocateRPMToUsr
Patch1: 0001-rpm-New-RPM-database-location-in-usr-lib-sysimage-rp.patch Patch: 0001-rpm-New-RPM-database-location-in-usr-lib-sysimage-rp.patch
# OCaml 5 compatibility:
Patch: 0002-Add-support-for-OCaml-5.0.patch
Patch: 0003-Restore-compatibility-with-OCaml-4.07.patch
# dnf5 (https://bugzilla.redhat.com/show_bug.cgi?id=2209412):
Patch: 0004-rpm-Detect-dnf5-and-omit-missing-options.patch
BuildRequires: gcc BuildRequires: gcc
BuildRequires: make BuildRequires: make
@ -56,8 +61,7 @@ BuildRequires: /usr/bin/pod2man
BuildRequires: /usr/bin/pod2html BuildRequires: /usr/bin/pod2html
BuildRequires: rpm BuildRequires: rpm
BuildRequires: rpm-devel BuildRequires: rpm-devel
BuildRequires: dnf BuildRequires: dnf5
BuildRequires: dnf-plugins-core
BuildRequires: /usr/sbin/mke2fs BuildRequires: /usr/sbin/mke2fs
BuildRequires: e2fsprogs-devel BuildRequires: e2fsprogs-devel
BuildRequires: findutils BuildRequires: findutils
@ -124,8 +128,7 @@ Requires: %{name} = %{version}-%{release}
Requires: rpm-build Requires: rpm-build
# Dependencies needed for supermin --prepare # Dependencies needed for supermin --prepare
Requires: dnf Requires: dnf5
Requires: dnf-plugins-core
Requires: findutils Requires: findutils
@ -190,6 +193,9 @@ make check || {
%changelog %changelog
* Tue May 30 2023 Richard W.M. Jones <rjones@redhat.com> - 5.3.3-6
- Add support for dnf5 (RHBZ#2209412)
* Fri May 19 2023 Richard W.M. Jones <rjones@redhat.com> - 5.3.3-5 * Fri May 19 2023 Richard W.M. Jones <rjones@redhat.com> - 5.3.3-5
- Rebuild against librpm 10 - Rebuild against librpm 10