When detecting kernels we have to list the files in the package to
find the right /boot/vmlinuz file.
In virt-v2v 1.28 we ran:
rpm -ql kernel
Because multiple kernels can be installed this gave incorrect results,
which was reported in RHBZ#1161250 and initially fixed in
commit 377bc302f11db3da4263f894c76a7d280fb25dbd. This changed the
command to:
rpm -ql [epoch:]kernel-version.release
where the epoch: prefix was only used if the epoch was != 0.
However this in fact failed if epoch was != 0 (which isn't the case
for ordinary RHEL kernels in RHEL >= 5). Since it broke RHEL <= 4
this was reported as bug RHBZ#1170685 and fixed only for RHEL 3/4 in
commit 205a8c7ca1ed1d66bef56d75c3c244e726e3bbbf.
That fix removed the optional epoch: prefix for RHEL 3/4. But the
prefix is wrong on all versions of RPM, even the latest one. eg. on
Fedora 29:
$ rpm -ql 2:qemu-3.1.0-4.fc30.x86_64
package 2:qemu-3.1.0-4.fc30.x86_64 is not installed
(In fact latest RPM does let you use name-epoch:version.release, but
that was not true in RHEL 6 or 7).
The solution here is to remove the epoch entirely. It's rather
unlikely that two kernels will be installed with identical NVR and
different Epoch. Just using NVR is sufficient to fix the original bug
RHBZ#1161250.
Thanks: Germano Veit Michel for bug reporting and analysis.
---
v2v/linux.ml | 20 +-------------------
1 file changed, 1 insertion(+), 19 deletions(-)
diff --git a/v2v/linux.ml b/v2v/linux.ml
index 43449157b..663db8697 100644
--- a/v2v/linux.ml
+++ b/v2v/linux.ml
@@ -80,29 +80,11 @@ let file_list_of_package (g : Guestfs.guestfs) inspect app =
| "rpm" ->
(* Since RPM allows multiple packages installed with the same
- * name, always check the full ENVR here (RHBZ#1161250).
+ * name, always check the full NVR here (RHBZ#1161250).
*)
let pkg_name =
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 (
- (* 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" |
- "oraclelinux" | "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
debug "%s" (String.concat " " (Array.to_list cmd));
let files = g#command_lines cmd in
--
2.20.1