From e3bdd5ea6af8c44ec5338b43f91d49518f604d3a Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Fri, 5 Dec 2014 13:09:10 +0000
Subject: [PATCH] v2v: Don't use epoch prefix on RPM command line for RHEL <= 4
(RHBZ#1170685).
See the explanation here:
https://bugzilla.redhat.com/show_bug.cgi?id=1170685#c7
(cherry picked from commit 205a8c7ca1ed1d66bef56d75c3c244e726e3bbbf)
---
v2v/linux.ml | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/v2v/linux.ml b/v2v/linux.ml
index 4287a4f..32a4a21 100644
--- a/v2v/linux.ml
+++ b/v2v/linux.ml
@@ -129,9 +129,22 @@ let file_list_of_package verbose (g : Guestfs.guestfs) inspect app =
sprintf "%s-%s-%s" app.G.app2_name
app.G.app2_version app.G.app2_release in
let pkg_name =
- if app.G.app2_epoch > 0_l then
- sprintf "%ld:%s" app.G.app2_epoch pkg_name
- else
+ if app.G.app2_epoch > 0_l then (
+ (* RHEL 3/4 'rpm' does not support using the epoch prefix.
+ * (RHBZ#1170685).
+ *)
+ let is_rhel_lt_5 =
+ match inspect with
+ | { i_type = "linux";
+ i_distro = "rhel" | "centos" | "scientificlinux" |
+ "redhat-based";
+ i_major_version = v } when v < 5 -> true
+ | _ -> false in
+ if is_rhel_lt_5 then
+ pkg_name
+ else
+ sprintf "%ld:%s" app.G.app2_epoch pkg_name
+ ) else
pkg_name in
let cmd = [| "rpm"; "-ql"; pkg_name |] in
if verbose then eprintf "%s\n%!" (String.concat " " (Array.to_list cmd));
--
1.8.3.1