Pino Toscano
2014-Aug-19 13:47 UTC
[Libguestfs] [PATCH 0/4] supermin: improve OpenSUSE support
Hi, this series for supermin improve the support for OpenSUSE, using the recent "download" command of zypper to download the packages instead of "installing" them. In the latter case, recommends are disabled now to reduce the amount of stuff being downloaded. Pino Toscano (4): rpm: opensuse: extract the version of zypper rpm: opensuse: use zypper download if available tests: add OpenSUSE checks in test-harder rpm: opensuse: disable recommends with old zypper src/rpm.ml | 104 ++++++++++++++++++++++++++++++++++++++++----------- tests/test-harder.sh | 32 ++++++++++++++++ 2 files changed, 114 insertions(+), 22 deletions(-) -- 2.0.4
Pino Toscano
2014-Aug-19 13:47 UTC
[Libguestfs] [PATCH 1/4] rpm: opensuse: extract the version of zypper
--- src/rpm.ml | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/src/rpm.ml b/src/rpm.ml index adb5c89..f79b357 100644 --- a/src/rpm.ml +++ b/src/rpm.ml @@ -43,8 +43,9 @@ let mageia_detect () let settings = ref no_settings let rpm_major, rpm_minor = ref 0, ref 0 +let zypper_major, zypper_minor, zypper_patch = ref 0, ref 0, ref 0 -let rpm_init s +let rec rpm_init s settings := s; (* Get RPM version. We have to adjust some RPM commands based on @@ -76,6 +77,44 @@ let rpm_init s if !settings.debug >= 1 then printf "supermin: rpm: detected RPM version %d.%d\n" major minor +and opensuse_init s + rpm_init s; + + (* Get zypper version. We can use better zypper commands with more + * recent versions. + *) + let cmd = sprintf "%s --version | awk '{print $2}'" Config.zypper in + let lines = run_command_get_lines cmd in + let major, minor, patch + match lines with + | [] -> + eprintf "supermin: zypper --version command had no output\n"; + exit 1 + | line :: _ -> + let line = string_split "." line in + match line with + | [] -> + eprintf "supermin: unable to parse empty output of zypper --version\n"; + exit 1 + | [x] -> + eprintf "supermin: unable to parse output of zypper --version: %s\n" x; + exit 1 + | major :: minor :: [] -> + (try int_of_string major, int_of_string minor, 0 + with Failure "int_of_string" -> + eprintf "supermin: unable to parse output of zypper --version: non-numeric\n"; + exit 1) + | major :: minor :: patch :: _ -> + (try int_of_string major, int_of_string minor, int_of_string patch + with Failure "int_of_string" -> + eprintf "supermin: unable to parse output of zypper --version: non-numeric\n"; + exit 1) in + zypper_major := major; + zypper_minor := minor; + zypper_patch := patch; + if !settings.debug >= 1 then + printf "supermin: rpm: detected zypper version %d.%d.%d\n" major minor patch + type rpm_t = { name : string; epoch : int32; @@ -346,6 +385,7 @@ let () let opensuse = { fedora with ph_detect = opensuse_detect; + ph_init = opensuse_init; ph_download_package = PHDownloadAllPackages opensuse_download_all_packages; } in register_package_handler "opensuse" "rpm" opensuse; -- 2.0.4
Pino Toscano
2014-Aug-19 13:47 UTC
[Libguestfs] [PATCH 2/4] rpm: opensuse: use zypper download if available
Use the "download" command of zypper, if it is >= 1.9.14. --- src/rpm.ml | 62 +++++++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 41 insertions(+), 21 deletions(-) diff --git a/src/rpm.ml b/src/rpm.ml index f79b357..ee3a163 100644 --- a/src/rpm.ml +++ b/src/rpm.ml @@ -306,28 +306,48 @@ and opensuse_download_all_packages pkgs dir sprintf "%s.%s" name arch ) rpms in - (* This isn't quite right because zypper will resolve the dependencies - * of the listed packages against the public repos and download all the - * dependencies too. We only really want it to download the named - * packages. XXX - *) + let is_zypper_1_9_14 + !zypper_major > 1 + || (!zypper_major = 1 && !zypper_minor > 9) + || (!zypper_major = 1 && !zypper_minor = 9 && !zypper_patch >= 14) in + let cmd - sprintf " - %s%s \\ - --root %s \\ - --reposd-dir /etc/zypp/repos.d \\ - --cache-dir %s \\ - --pkg-cache-dir %s \\ - --gpg-auto-import-keys --no-gpg-checks --non-interactive \\ - install \\ - --auto-agree-with-licenses --download-only \\ - %s" - Config.zypper - (if !settings.debug >= 1 then " --verbose --verbose" else " --quiet") - (quote tdir) - (quote tdir) - (quote tdir) - (quoted_list rpms) in + if is_zypper_1_9_14 then + sprintf " + %s%s \\ + --reposd-dir /etc/zypp/repos.d \\ + --cache-dir %s \\ + --pkg-cache-dir %s \\ + --gpg-auto-import-keys --no-gpg-checks --non-interactive \\ + download \\ + %s" + Config.zypper + (if !settings.debug >= 1 then " --verbose --verbose" else " --quiet") + (quote tdir) + (quote tdir) + (quoted_list rpms) + else + (* This isn't quite right because zypper will resolve the dependencies + * of the listed packages against the public repos and download all the + * dependencies too. We only really want it to download the named + * packages. XXX + *) + sprintf " + %s%s \\ + --root %s \\ + --reposd-dir /etc/zypp/repos.d \\ + --cache-dir %s \\ + --pkg-cache-dir %s \\ + --gpg-auto-import-keys --no-gpg-checks --non-interactive \\ + install \\ + --auto-agree-with-licenses --download-only \\ + %s" + Config.zypper + (if !settings.debug >= 1 then " --verbose --verbose" else " --quiet") + (quote tdir) + (quote tdir) + (quote tdir) + (quoted_list rpms) in run_command cmd; rpm_unpack tdir dir -- 2.0.4
Pino Toscano
2014-Aug-19 13:47 UTC
[Libguestfs] [PATCH 3/4] tests: add OpenSUSE checks in test-harder
Basically copied from the redhat ones. --- tests/test-harder.sh | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tests/test-harder.sh b/tests/test-harder.sh index e8bb32f..0f80980 100755 --- a/tests/test-harder.sh +++ b/tests/test-harder.sh @@ -31,6 +31,8 @@ elif [ -f /etc/debian_version ]; then distro=debian elif [ -f /etc/redhat-release ]; then distro=redhat +elif [ -f /etc/SuSE-release ]; then + distro=suse else exit 77 fi @@ -53,6 +55,9 @@ case $distro in # installed. (See commit fb40baade8e3441b73ce6fd10a32fbbfe49cc4da) pkgs="augeas hivex tar" ;; + suse) + pkgs="augeas hivex tar" + ;; esac test "$USE_NETWORK" = 1 || USE_INSTALLED=--use-installed @@ -125,6 +130,33 @@ case $distro in exit 1 fi ;; + suse) + 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/tar ]; then + echo "$0: $distro: tar binary not installed in chroot" + ls -lR $d2 + exit 1 + fi + ;; esac # Need to chmod $d2 since rm -r can't remove unwritable directories. -- 2.0.4
Pino Toscano
2014-Aug-19 13:47 UTC
[Libguestfs] [PATCH 4/4] rpm: opensuse: disable recommends with old zypper
When using zypper < 1.9.14, disable the recommends when "installing" packages locally, reducing the number of packages being downloaded. --- src/rpm.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpm.ml b/src/rpm.ml index ee3a163..434f15b 100644 --- a/src/rpm.ml +++ b/src/rpm.ml @@ -340,7 +340,7 @@ and opensuse_download_all_packages pkgs dir --pkg-cache-dir %s \\ --gpg-auto-import-keys --no-gpg-checks --non-interactive \\ install \\ - --auto-agree-with-licenses --download-only \\ + --auto-agree-with-licenses --download-only --no-recommends \\ %s" Config.zypper (if !settings.debug >= 1 then " --verbose --verbose" else " --quiet") -- 2.0.4
Richard W.M. Jones
2014-Aug-19 14:52 UTC
Re: [Libguestfs] [PATCH 0/4] supermin: improve OpenSUSE support
On Tue, Aug 19, 2014 at 03:47:19PM +0200, Pino Toscano wrote:> Hi, > > this series for supermin improve the support for OpenSUSE, using the > recent "download" command of zypper to download the packages instead of > "installing" them. In the latter case, recommends are disabled now to > reduce the amount of stuff being downloaded. > > > Pino Toscano (4): > rpm: opensuse: extract the version of zypper > rpm: opensuse: use zypper download if available > tests: add OpenSUSE checks in test-harder > rpm: opensuse: disable recommends with old zypper > > src/rpm.ml | 104 ++++++++++++++++++++++++++++++++++++++++----------- > tests/test-harder.sh | 32 ++++++++++++++++ > 2 files changed, 114 insertions(+), 22 deletions(-) > > -- > 2.0.4I don't have an easy way to test this right now, but as long as it doesn't obviously break anything then ACK. 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/