Blob Blame History Raw
From bca633bfd14aeeb8ae1331d468db75d1ef31f9ff Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bernhard=20Rosenkr=C3=A4nzer?= <bero@lindev.ch>
Date: Tue, 2 Apr 2019 08:28:06 +0100
Subject: [PATCH 04/12] Add OpenMandriva support (RHBZ#1694267).

---
 src/ph_rpm.ml        | 28 +++++++++++++++++++++++++---
 tests/test-harder.sh | 31 +++++++++++++++++++++++++++++++
 2 files changed, 56 insertions(+), 3 deletions(-)

diff --git a/src/ph_rpm.ml b/src/ph_rpm.ml
index 46b7f1f..3ff5c94 100644
--- a/src/ph_rpm.ml
+++ b/src/ph_rpm.ml
@@ -50,6 +50,12 @@ let mageia_detect () =
     (Os_release.get_id () = "mageia" ||
      try (stat "/etc/mageia-release").st_kind = S_REG with Unix_error _ -> false)
 
+let openmandriva_detect () =
+  Config.rpm <> "no" && Config.rpm2cpio <> "no" && rpm_is_available () &&
+    ((Config.urpmi <> "no" && Config.fakeroot <> "no") || Config.dnf <> "no") &&
+    (Os_release.get_id () = "openmandriva" ||
+     try (stat "/etc/openmandriva-release").st_kind = S_REG with Unix_error _ -> false)
+
 let ibm_powerkvm_detect () =
   Config.rpm <> "no" && Config.rpm2cpio <> "no" && rpm_is_available () &&
     Config.yumdownloader <> "no" &&
@@ -386,17 +392,27 @@ and opensuse_download_all_packages pkgs dir =
 
   rpm_unpack tdir dir
 
+and openmandriva_download_all_packages pkgs dir =
+  let tdir = !settings.tmpdir // string_random8 () in
+
+  if Config.dnf <> "no" then
+    download_all_packages_with_dnf pkgs dir tdir
+  else (* Config.urpmi <> "no" && Config.fakeroot <> "no" *)
+    download_all_packages_with_urpmi pkgs dir tdir;
+
+  rpm_unpack tdir dir
+
 and mageia_download_all_packages pkgs dir =
   let tdir = !settings.tmpdir // string_random8 () in
 
   if Config.dnf <> "no" then
     download_all_packages_with_dnf pkgs dir tdir
   else (* Config.urpmi <> "no" && Config.fakeroot <> "no" *)
-    mageia_download_all_packages_with_urpmi pkgs dir tdir;
+    download_all_packages_with_urpmi pkgs dir tdir;
 
   rpm_unpack tdir dir
 
-and mageia_download_all_packages_with_urpmi pkgs dir tdir =
+and download_all_packages_with_urpmi pkgs dir tdir =
   let rpms = List.map rpm_package_name (PackageSet.elements pkgs) in
 
   let cmd =
@@ -484,4 +500,10 @@ let () =
     ph_detect = mageia_detect;
     ph_download_package = PHDownloadAllPackages mageia_download_all_packages;
   } in
-  register_package_handler "mageia" "rpm" mageia
+  register_package_handler "mageia" "rpm" mageia;
+  let openmandriva = {
+    fedora with
+    ph_detect = openmandriva_detect;
+    ph_download_package = PHDownloadAllPackages openmandriva_download_all_packages;
+  } in
+  register_package_handler "openmandriva" "rpm" openmandriva
diff --git a/tests/test-harder.sh b/tests/test-harder.sh
index c827f13..aceef21 100755
--- a/tests/test-harder.sh
+++ b/tests/test-harder.sh
@@ -31,6 +31,7 @@ if [ -f /etc/os-release ]; then
         fedora|rhel|centos) distro=redhat ;;
         opensuse*|sled|sles) distro=suse ;;
         ubuntu) distro=debian ;;
+        openmandriva) distro=openmandriva ;;
     esac
 elif [ -f /etc/arch-release ]; then
     distro=arch
@@ -77,6 +78,9 @@ case $distro in
     ibm-powerkvm)
 	pkgs="augeas hivex tar"
 	;;
+    openmandriva)
+        pkgs="augeas hivex rpm"
+        ;;
     *)
 	echo "Unhandled distro '$distro'"
 	exit 77
@@ -153,6 +157,33 @@ case $distro in
 	    exit 1
 	fi
 	;;
+    openmandriva)
+	if [ ! -x $d2/usr/bin/augtool ]; then
+	    echo "$0: $distro: augtool binary not installed in chroot"
+	    ls -lR $d2
+	    exit 1
+	fi
+	if [ "$(find $d2/lib* $d2/usr/lib* -name libaugeas.so.0 | wc -l)" -lt 1 ]; then
+	    echo "$0: $distro: augeas library not installed in chroot"
+	    ls -lR $d2
+	    exit 1
+	fi
+	if [ ! -x $d2/usr/bin/hivexget ]; then
+	    echo "$0: $distro: hivexget binary not installed in chroot"
+	    ls -lR $d2
+	    exit 1
+	fi
+	if [ "$(find $d2/usr/lib* -name libhivex.so.0 | wc -l)" -lt 1 ]; then
+	    echo "$0: $distro: hivex library not installed in chroot"
+	    ls -lR $d2
+	    exit 1
+	fi
+	if [ ! -x $d2/bin/rpm ]; then
+	    echo "$0: $distro: rpm binary not installed in chroot"
+	    ls -lR $d2
+	    exit 1
+	fi
+	;;
     redhat)
 	if [ ! -x $d2/usr/bin/augtool ]; then
 	    echo "$0: $distro: augtool binary not installed in chroot"
-- 
2.23.0