Hi, as pointed out by Neal Gompa, Mageia recently introduced dnf in the distribution (currently only in Cauldron, which is the future Mageia 6), and most probably it will replace urpmi in the future. As such, on Mageia make supermin prefer dnf over urpmi when found, using the same code already used for Fedora. Related change: make test-harder.sh work explicitly also on Mageia ("broken" since the recent switch to /etc/os-release). Thanks, Pino Toscano (4): tests: add Mageia checks in test-harder rpm: move fedora_download_all_packages_with_dnf around rpm: isolate actual mageia download in own function rpm: mageia: prefer dnf over urpmi README | 3 +-- src/rpm.ml | 49 +++++++++++++++++++++++++++---------------------- tests/test-harder.sh | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+), 24 deletions(-) -- 2.7.4
Pino Toscano
2016-Oct-31 14:36 UTC
[Libguestfs] [PATCH 1/4] tests: add Mageia checks in test-harder
Previously it was implicitly caught by the 'redhat' case (since /etc/redhat-release exists on mageia), and since the switch to /etc/os-release the 'mageia' distro was considered unhandled. Copy most of what the 'redhat' case does, with the tar -> rpm change (as tar on mageia has currently no epoch, while rpm does). --- tests/test-harder.sh | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/tests/test-harder.sh b/tests/test-harder.sh index 7e1b8df..cfa448a 100755 --- a/tests/test-harder.sh +++ b/tests/test-harder.sh @@ -36,6 +36,8 @@ elif [ -f /etc/arch-release ]; then distro=arch elif [ -f /etc/debian_version ]; then distro=debian +elif [ -f /etc/mageia-release ]; then # before the redhat checks + distro=mageia elif [ -f /etc/redhat-release ]; then distro=redhat elif [ -f /etc/SuSE-release ]; then @@ -59,6 +61,11 @@ case $distro in debian) pkgs="augeas-tools libaugeas0 libhivex0 libhivex-bin" ;; + mageia) + # Choose rpm because it has an epoch > 0 and is commonly + # installed. (See commit fb40baade8e3441b73ce6fd10a32fbbfe49cc4da) + pkgs="augeas hivex rpm" + ;; redhat) # Choose tar because it has an epoch > 0 and is commonly # installed. (See commit fb40baade8e3441b73ce6fd10a32fbbfe49cc4da) @@ -119,6 +126,33 @@ case $distro in exit 1 fi ;; + mageia) + 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/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.7.4
Pino Toscano
2016-Oct-31 14:36 UTC
[Libguestfs] [PATCH 2/4] rpm: move fedora_download_all_packages_with_dnf around
Move it after mageia_download_all_packages, and remove the "fedora_" prefix from its name (as it will be soon used also for a distribution different than fedora). This is mostly code motion, no behaviour changes. --- src/rpm.ml | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/rpm.ml b/src/rpm.ml index 0c7aae2..152a5c8 100644 --- a/src/rpm.ml +++ b/src/rpm.ml @@ -306,29 +306,12 @@ let rec fedora_download_all_packages pkgs dir let tdir = !settings.tmpdir // string_random8 () in if Config.dnf <> "no" then - fedora_download_all_packages_with_dnf pkgs dir tdir + download_all_packages_with_dnf pkgs dir tdir else (* Config.yumdownloader <> "no" *) fedora_download_all_packages_with_yum pkgs dir tdir; rpm_unpack tdir dir -and fedora_download_all_packages_with_dnf pkgs dir tdir - (* Old dnf didn't create the destdir directory, newer versions do. *) - mkdir tdir 0o700; - - let rpms = pkgs_as_NA_rpms pkgs in - - let cmd - sprintf "%s download%s%s --destdir=%s --disableexcludes=all %s" - Config.dnf - (if !settings.debug >= 1 then " -v" else " -q") - (match !settings.packager_config with - | None -> "" - | Some filename -> sprintf " -c %s" (quote filename)) - (quote tdir) - (quoted_list rpms) in - run_command cmd - and fedora_download_all_packages_with_yum pkgs dir tdir (* It's quite complex to get yumdownloader to download specific * RPMs. If we use the full NVR, then it will refuse if an installed @@ -424,6 +407,23 @@ and mageia_download_all_packages pkgs dir rpm_unpack tdir dir +and download_all_packages_with_dnf pkgs dir tdir + (* Old dnf didn't create the destdir directory, newer versions do. *) + mkdir tdir 0o700; + + let rpms = pkgs_as_NA_rpms pkgs in + + let cmd + sprintf "%s download%s%s --destdir=%s --disableexcludes=all %s" + Config.dnf + (if !settings.debug >= 1 then " -v" else " -q") + (match !settings.packager_config with + | None -> "" + | Some filename -> sprintf " -c %s" (quote filename)) + (quote tdir) + (quoted_list rpms) in + run_command cmd + and pkgs_as_NA_rpms pkgs let rpms = List.map rpm_of_pkg (PackageSet.elements pkgs) in List.map ( -- 2.7.4
Pino Toscano
2016-Oct-31 14:36 UTC
[Libguestfs] [PATCH 3/4] rpm: isolate actual mageia download in own function
Isolate the code downloading the packages with urpmi (for mageia) in an own function, much like it was done already for the fedora case. This is mostly code motion, no behaviour changes. --- src/rpm.ml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/rpm.ml b/src/rpm.ml index 152a5c8..820d7c1 100644 --- a/src/rpm.ml +++ b/src/rpm.ml @@ -389,6 +389,11 @@ and opensuse_download_all_packages pkgs dir and mageia_download_all_packages pkgs dir let tdir = !settings.tmpdir // string_random8 () in + mageia_download_all_packages_with_urpmi pkgs dir tdir; + + rpm_unpack tdir dir + +and mageia_download_all_packages_with_urpmi pkgs dir tdir let rpms = List.map rpm_package_name (PackageSet.elements pkgs) in let cmd @@ -403,9 +408,7 @@ and mageia_download_all_packages pkgs dir (if !settings.debug >= 1 then " --verbose" else " --quiet") (quote tdir) (quoted_list rpms) in - run_command cmd; - - rpm_unpack tdir dir + run_command cmd and download_all_packages_with_dnf pkgs dir tdir (* Old dnf didn't create the destdir directory, newer versions do. *) -- 2.7.4
Pino Toscano
2016-Oct-31 14:36 UTC
[Libguestfs] [PATCH 4/4] rpm: mageia: prefer dnf over urpmi
Mageia introduced dnf as alternative package manager for the next version 6, with the possibility to replace urpmi as primary in the future. As such, prefer dnf over urpmi+fakeroot to download rpm packages. Thanks to Neal Gompa for his heads-up. --- README | 3 +-- src/rpm.ml | 8 +++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/README b/README index 79fcfd8..679bf70 100644 --- a/README +++ b/README @@ -81,8 +81,7 @@ For Mageia: rpm librpm - urpmi - fakeroot + urpmi & fakeroot, or 'dnf download' plugin For Arch Linux: diff --git a/src/rpm.ml b/src/rpm.ml index 820d7c1..b0a5eb2 100644 --- a/src/rpm.ml +++ b/src/rpm.ml @@ -45,8 +45,7 @@ let opensuse_detect () let mageia_detect () Config.rpm <> "no" && Config.rpm2cpio <> "no" && rpm_is_available () && - Config.urpmi <> "no" && - Config.fakeroot <> "no" && + ((Config.urpmi <> "no" && Config.fakeroot <> "no") || Config.dnf <> "no") && (Os_release.get_id () = "mageia" || try (stat "/etc/mageia-release").st_kind = S_REG with Unix_error _ -> false) @@ -389,7 +388,10 @@ and opensuse_download_all_packages pkgs dir and mageia_download_all_packages pkgs dir let tdir = !settings.tmpdir // string_random8 () in - mageia_download_all_packages_with_urpmi pkgs dir tdir; + 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; rpm_unpack tdir dir -- 2.7.4
Richard W.M. Jones
2016-Nov-01 10:22 UTC
Re: [Libguestfs] [PATCH 4/4] rpm: mageia: prefer dnf over urpmi
On Mon, Oct 31, 2016 at 03:36:30PM +0100, Pino Toscano wrote:> Mageia introduced dnf as alternative package manager for the next > version 6, with the possibility to replace urpmi as primary in the > future. > > As such, prefer dnf over urpmi+fakeroot to download rpm packages. > > Thanks to Neal Gompa for his heads-up.ACK series. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-df lists disk usage of guests without needing to install any software inside the virtual machine. Supports Linux and Windows. http://people.redhat.com/~rjones/virt-df/