|
|
a034fe |
From f3574733eeda9952aa13f36e4ae40a8c5c0a5479 Mon Sep 17 00:00:00 2001
|
|
|
a034fe |
From: Pino Toscano <ptoscano@redhat.com>
|
|
|
a034fe |
Date: Tue, 26 Mar 2019 17:02:02 +0100
|
|
|
a034fe |
Subject: [PATCH] v2v: linux: add helper functions for pkg arch and extension
|
|
|
a034fe |
|
|
|
a034fe |
Add helper functions to get the typical extension of binary packages
|
|
|
a034fe |
for a package manager, and the string for an architecture.
|
|
|
a034fe |
|
|
|
a034fe |
(cherry picked from commit 13ef175a7b3a010175d57d60b2c4c51bc0efb171)
|
|
|
a034fe |
---
|
|
|
a034fe |
v2v/linux.ml | 21 +++++++++++++++++++++
|
|
|
a034fe |
v2v/linux.mli | 8 ++++++++
|
|
|
a034fe |
2 files changed, 29 insertions(+)
|
|
|
a034fe |
|
|
|
a034fe |
diff --git a/v2v/linux.ml b/v2v/linux.ml
|
|
|
a034fe |
index 99b0e0e7b..4949c8e16 100644
|
|
|
a034fe |
--- a/v2v/linux.ml
|
|
|
a034fe |
+++ b/v2v/linux.ml
|
|
|
a034fe |
@@ -179,3 +179,24 @@ let is_package_manager_save_file filename =
|
|
|
a034fe |
(* Recognized suffixes of package managers. *)
|
|
|
a034fe |
let suffixes = [ ".dpkg-old"; ".dpkg-new"; ".rpmsave"; ".rpmnew"; ] in
|
|
|
a034fe |
List.exists (Filename.check_suffix filename) suffixes
|
|
|
a034fe |
+
|
|
|
a034fe |
+let binary_package_extension { i_package_format = package_format } =
|
|
|
a034fe |
+ match package_format with
|
|
|
a034fe |
+ | "deb" -> "deb"
|
|
|
a034fe |
+ | "rpm" -> "rpm"
|
|
|
a034fe |
+ | format ->
|
|
|
a034fe |
+ error (f_"don’t know what is the extension of binary packages using %s")
|
|
|
a034fe |
+ format
|
|
|
a034fe |
+
|
|
|
a034fe |
+let architecture_string { i_package_format = package_format; i_arch = arch;
|
|
|
a034fe |
+ i_distro = distro } =
|
|
|
a034fe |
+ match package_format, distro, arch with
|
|
|
a034fe |
+ | "deb", _, "x86_64" -> "amd64"
|
|
|
a034fe |
+ | "deb", _, a -> a
|
|
|
a034fe |
+ | "rpm", ("sles"|"suse-based"|"opensuse"), "i386" -> "i586"
|
|
|
a034fe |
+ | "rpm", ("sles"|"suse-based"|"opensuse"), a -> a
|
|
|
a034fe |
+ | "rpm", _, "i386" -> "i686"
|
|
|
a034fe |
+ | "rpm", _, a -> a
|
|
|
a034fe |
+ | format, distro, arch ->
|
|
|
a034fe |
+ error (f_"don’t know what is the architecture string of %s using %s on %s")
|
|
|
a034fe |
+ arch format distro
|
|
|
a034fe |
diff --git a/v2v/linux.mli b/v2v/linux.mli
|
|
|
a034fe |
index 0a5991d12..30099745c 100644
|
|
|
a034fe |
--- a/v2v/linux.mli
|
|
|
a034fe |
+++ b/v2v/linux.mli
|
|
|
a034fe |
@@ -38,3 +38,11 @@ val is_file_owned : Guestfs.guestfs -> Types.inspect -> string -> bool
|
|
|
a034fe |
val is_package_manager_save_file : string -> bool
|
|
|
a034fe |
(** Return true if the filename is something like [*.rpmsave], ie.
|
|
|
a034fe |
a package manager save-file. *)
|
|
|
a034fe |
+
|
|
|
a034fe |
+val binary_package_extension : Types.inspect -> string
|
|
|
a034fe |
+(** Return the extension typically used for binary packages in the
|
|
|
a034fe |
+ specified package format. *)
|
|
|
a034fe |
+
|
|
|
a034fe |
+val architecture_string : Types.inspect -> string
|
|
|
a034fe |
+(** Return the architecture string typically used for binary packages
|
|
|
a034fe |
+ in the specified package format, and for the specified distro. *)
|
|
|
a034fe |
--
|
|
|
a034fe |
2.21.0
|
|
|
a034fe |
|