[Libguestfs] [PATCH] Add missing oraclelinux cases.

Jamie Iles jamie.iles at oracle.com
Tue Aug 1 12:08:14 UTC 2017


oraclelinux is the same as redhat/centos/scientificlinux, so add it
where it is missing.  This fixes amongst other things, running sysprep
on an Oracle Linux image where it would previously fail operations like
setting the hostname, saying that it was not supported on that distro.
---
 customize/firstboot.ml                    | 2 +-
 customize/hostname.ml                     | 4 ++--
 customize/password.ml                     | 4 ++--
 customize/random_seed.ml                  | 2 +-
 p2v/virt-p2v-make-disk.in                 | 2 +-
 sysprep/sysprep_operation_net_hostname.ml | 2 +-
 sysprep/sysprep_operation_net_hwaddr.ml   | 2 +-
 sysprep/sysprep_operation_pacct_log.ml    | 2 +-
 v2v/linux.ml                              | 2 +-
 9 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/customize/firstboot.ml b/customize/firstboot.ml
index ddcb5627143d..b07bda00165a 100644
--- a/customize/firstboot.ml
+++ b/customize/firstboot.ml
@@ -154,7 +154,7 @@ WantedBy=%s
 
   and install_sysvinit_service g root distro major =
     match distro with
-    | "fedora"|"rhel"|"centos"|"scientificlinux"|"redhat-based" ->
+    | "fedora"|"rhel"|"centos"|"scientificlinux"|"oraclelinux"|"redhat-based" ->
       install_sysvinit_redhat g
     | "opensuse"|"sles"|"suse-based" ->
       install_sysvinit_suse g
diff --git a/customize/hostname.ml b/customize/hostname.ml
index b49db8714df1..ee2c91e6a55d 100644
--- a/customize/hostname.ml
+++ b/customize/hostname.ml
@@ -36,7 +36,7 @@ let rec set_hostname (g : Guestfs.guestfs) root hostname =
     update_etc_machine_info g hostname;
     true
 
-  | "linux", ("rhel"|"centos"|"scientificlinux"|"redhat-based"), v
+  | "linux", ("rhel"|"centos"|"scientificlinux"|"oraclelinux"|"redhat-based"), v
     when v >= 7 ->
     update_etc_hostname g hostname;
     update_etc_machine_info g hostname;
@@ -48,7 +48,7 @@ let rec set_hostname (g : Guestfs.guestfs) root hostname =
     replace_host_in_etc_hosts g old_hostname hostname;
     true
 
-  | "linux", ("fedora"|"rhel"|"centos"|"scientificlinux"|"redhat-based"), _ ->
+  | "linux", ("fedora"|"rhel"|"centos"|"scientificlinux"|"oraclelinux"|"redhat-based"), _ ->
     replace_line_in_file g "/etc/sysconfig/network" "HOSTNAME" hostname;
     true
 
diff --git a/customize/password.ml b/customize/password.ml
index d26b9486590e..dc69b8eb718d 100644
--- a/customize/password.ml
+++ b/customize/password.ml
@@ -144,9 +144,9 @@ and default_crypto g root =
   let distro = g#inspect_get_distro root in
   let major = g#inspect_get_major_version root in
   match distro, major with
-  | ("rhel"|"centos"|"scientificlinux"|"redhat-based"), v when v >= 6 ->
+  | ("rhel"|"centos"|"scientificlinux"|"oraclelinux"|"redhat-based"), v when v >= 6 ->
     `SHA512
-  | ("rhel"|"centos"|"scientificlinux"|"redhat-based"), _ ->
+  | ("rhel"|"centos"|"scientificlinux"|"oraclelinux"|"redhat-based"), _ ->
     `MD5 (* RHEL 5 does not appear to support SHA512, according to crypt(3) *)
 
   | "fedora", v when v >= 9 -> `SHA512
diff --git a/customize/random_seed.ml b/customize/random_seed.ml
index fd0d7ed22009..3ddf25471ffa 100644
--- a/customize/random_seed.ml
+++ b/customize/random_seed.ml
@@ -47,7 +47,7 @@ let rec set_random_seed (g : Guestfs.guestfs) root =
     let distro = g#inspect_get_distro root in
     let file =
       match typ, distro with
-      | "linux", ("fedora"|"rhel"|"centos"|"scientificlinux"|"redhat-based") ->
+      | "linux", ("fedora"|"rhel"|"centos"|"scientificlinux"|"oraclelinux"|"redhat-based") ->
         Some "/var/lib/random-seed"
       | "linux", ("debian"|"ubuntu") ->
         Some "/var/lib/urandom/random-seed"
diff --git a/p2v/virt-p2v-make-disk.in b/p2v/virt-p2v-make-disk.in
index 2f1bf2b052f3..987dc31d9e45 100644
--- a/p2v/virt-p2v-make-disk.in
+++ b/p2v/virt-p2v-make-disk.in
@@ -169,7 +169,7 @@ xzcat "$virt_p2v_xz_binary" > "$virt_p2v_binary"
 # Variations depending on the target distro.  The main difference
 # is in the list of distro packages we add to the base appliance.
 case "$osversion" in
-    centos-*|fedora-*|rhel-*|scientificlinux-*)
+    centos-*|fedora-*|rhel-*|scientificlinux-*|oraclelinux-*)
         depsfile="$datadir/dependencies.redhat"
         cat > $tmpdir/p2v.conf <<'EOF'
 add_drivers+=" usb-storage "
diff --git a/sysprep/sysprep_operation_net_hostname.ml b/sysprep/sysprep_operation_net_hostname.ml
index b455e5c93d66..fe3f47412d0f 100644
--- a/sysprep/sysprep_operation_net_hostname.ml
+++ b/sysprep/sysprep_operation_net_hostname.ml
@@ -28,7 +28,7 @@ let net_hostname_perform (g : Guestfs.guestfs) root side_effects =
   let typ = g#inspect_get_type root in
   let distro = g#inspect_get_distro root in
   match typ, distro with
-  | "linux", ("fedora"|"rhel"|"centos"|"scientificlinux"|"redhat-based") ->
+  | "linux", ("fedora"|"rhel"|"centos"|"scientificlinux"|"oraclelinux"|"redhat-based") ->
     let filenames = g#glob_expand "/etc/sysconfig/network-scripts/ifcfg-*" in
     Array.iter (
       fun filename ->
diff --git a/sysprep/sysprep_operation_net_hwaddr.ml b/sysprep/sysprep_operation_net_hwaddr.ml
index 21cae1be490e..344eadc5bb99 100644
--- a/sysprep/sysprep_operation_net_hwaddr.ml
+++ b/sysprep/sysprep_operation_net_hwaddr.ml
@@ -28,7 +28,7 @@ let net_hwaddr_perform (g : Guestfs.guestfs) root side_effects =
   let typ = g#inspect_get_type root in
   let distro = g#inspect_get_distro root in
   match typ, distro with
-  | "linux", ("fedora"|"rhel"|"centos"|"scientificlinux"|"redhat-based") ->
+  | "linux", ("fedora"|"rhel"|"centos"|"scientificlinux"|"oraclelinux"|"redhat-based") ->
     let filenames = g#glob_expand "/etc/sysconfig/network-scripts/ifcfg-*" in
     Array.iter (
       fun filename ->
diff --git a/sysprep/sysprep_operation_pacct_log.ml b/sysprep/sysprep_operation_pacct_log.ml
index 1f9f0be27d6b..047cb39f3ef5 100644
--- a/sysprep/sysprep_operation_pacct_log.ml
+++ b/sysprep/sysprep_operation_pacct_log.ml
@@ -25,7 +25,7 @@ let pacct_log_perform (g : Guestfs.guestfs) root side_effects =
   let typ = g#inspect_get_type root in
   let distro = g#inspect_get_distro root in
   match typ, distro with
-  | "linux", ("fedora"|"rhel"|"centos"|"scientificlinux"|"redhat-based") ->
+  | "linux", ("fedora"|"rhel"|"centos"|"scientificlinux"|"oraclelinux"|"redhat-based") ->
     let files = g#glob_expand "/var/account/pacct*" in
     Array.iter (
       fun file ->
diff --git a/v2v/linux.ml b/v2v/linux.ml
index 7996545114b3..a1c2c25a5d0b 100644
--- a/v2v/linux.ml
+++ b/v2v/linux.ml
@@ -87,7 +87,7 @@ let file_list_of_package (g : Guestfs.guestfs) inspect app =
           match inspect with
           | { i_type = "linux";
               i_distro = "rhel" | "centos" | "scientificlinux" |
-                  "redhat-based";
+                  "oraclelinux" | "redhat-based";
               i_major_version = v } when v < 5 -> true
           | _ -> false in
         if is_rhel_lt_5 then
-- 
2.13.3




More information about the Libguestfs mailing list