[Pkg-libvirt-commits] [libguestfs] 100/384: inspection: Recognise 'dnf' as the package manager in Fedora 22.
Hilko Bengen
bengen at moszumanska.debian.org
Sun Mar 29 16:55:52 UTC 2015
This is an automated email from the git hooks/post-receive script.
bengen pushed a commit to branch experimental
in repository libguestfs.
commit d3e93e1011fa4bf0099c3c0538022bfd9c2473f2
Author: Richard W.M. Jones <rjones at redhat.com>
Date: Mon Dec 15 14:29:51 2014 +0000
inspection: Recognise 'dnf' as the package manager in Fedora 22.
Also fix virt-sysprep and virt-customize so they can work with dnf.
I also sorted some of the lists alphabetically.
---
customize/customize_run.ml | 4 ++++
generator/actions.ml | 10 +++++-----
src/guestfs-internal.h | 1 +
src/inspect-fs.c | 11 ++++++++++-
src/inspect.c | 7 ++++---
sysprep/sysprep_operation_package_manager_cache.ml | 10 ++++++----
6 files changed, 30 insertions(+), 13 deletions(-)
diff --git a/customize/customize_run.ml b/customize/customize_run.ml
index 09ada7d..19b7a7d 100644
--- a/customize/customize_run.ml
+++ b/customize/customize_run.ml
@@ -93,6 +93,8 @@ exec >>%s 2>&1
apt-get $apt_opts update
apt-get $apt_opts install %s
" quoted_args
+ | "dnf" ->
+ sprintf "dnf -y install %s" quoted_args
| "pisi" ->
sprintf "pisi it %s" quoted_args
| "pacman" ->
@@ -119,6 +121,8 @@ exec >>%s 2>&1
apt-get $apt_opts update
apt-get $apt_opts upgrade
"
+ | "dnf" ->
+ sprintf "dnf -y update"
| "pisi" ->
sprintf "pisi upgrade"
| "pacman" ->
diff --git a/generator/actions.ml b/generator/actions.ml
index 340a0bc..13a9d80 100644
--- a/generator/actions.ml
+++ b/generator/actions.ml
@@ -1752,8 +1752,8 @@ C<guestfs_add_drive_opts>." };
This function and C<guestfs_inspect_get_package_management> return
the package format and package management tool used by the
inspected operating system. For example for Fedora these
-functions would return C<rpm> (package format) and
-C<yum> (package management).
+functions would return C<rpm> (package format), and
+C<yum> or C<dnf> (package management).
This returns the string C<unknown> if we could not determine the
package format I<or> if the operating system does not have
@@ -1773,14 +1773,14 @@ Please read L<guestfs(3)/INSPECTION> for more details." };
C<guestfs_inspect_get_package_format> and this function return
the package format and package management tool used by the
inspected operating system. For example for Fedora these
-functions would return C<rpm> (package format) and
-C<yum> (package management).
+functions would return C<rpm> (package format), and
+C<yum> or C<dnf> (package management).
This returns the string C<unknown> if we could not determine the
package management tool I<or> if the operating system does not have
a real packaging system (eg. Windows).
-Possible strings include: C<yum>, C<up2date>,
+Possible strings include: C<yum>, C<dnf>, C<up2date>,
C<apt> (for all Debian derivatives),
C<portage>, C<pisi>, C<pacman>, C<urpmi>, C<zypper>.
Future versions of libguestfs may return other strings.
diff --git a/src/guestfs-internal.h b/src/guestfs-internal.h
index 0b25407..222a562 100644
--- a/src/guestfs-internal.h
+++ b/src/guestfs-internal.h
@@ -567,6 +567,7 @@ enum inspect_os_package_management {
OS_PACKAGE_MANAGEMENT_PISI,
OS_PACKAGE_MANAGEMENT_URPMI,
OS_PACKAGE_MANAGEMENT_ZYPPER,
+ OS_PACKAGE_MANAGEMENT_DNF,
};
struct inspect_fs {
diff --git a/src/inspect-fs.c b/src/inspect-fs.c
index 7b116db..dfc3fd3 100644
--- a/src/inspect-fs.c
+++ b/src/inspect-fs.c
@@ -493,11 +493,20 @@ void
guestfs___check_package_management (guestfs_h *g, struct inspect_fs *fs)
{
switch (fs->distro) {
- case OS_DISTRO_FEDORA:
case OS_DISTRO_MEEGO:
fs->package_management = OS_PACKAGE_MANAGEMENT_YUM;
break;
+ case OS_DISTRO_FEDORA:
+ /* If Fedora >= 22 and dnf is installed, say "dnf". */
+ if (fs->major_version >= 22 &&
+ guestfs_is_file_opts (g, "/usr/bin/dnf",
+ GUESTFS_IS_FILE_OPTS_FOLLOWSYMLINKS, 1, -1) > 0)
+ fs->package_management = OS_PACKAGE_MANAGEMENT_DNF;
+ else
+ fs->package_management = OS_PACKAGE_MANAGEMENT_YUM;
+ break;
+
case OS_DISTRO_REDHAT_BASED:
case OS_DISTRO_RHEL:
case OS_DISTRO_CENTOS:
diff --git a/src/inspect.c b/src/inspect.c
index 8c00f80..715db67 100644
--- a/src/inspect.c
+++ b/src/inspect.c
@@ -490,13 +490,14 @@ guestfs__inspect_get_package_management (guestfs_h *g, const char *root)
return NULL;
switch (fs->package_management) {
- case OS_PACKAGE_MANAGEMENT_YUM: ret = safe_strdup (g, "yum"); break;
- case OS_PACKAGE_MANAGEMENT_UP2DATE: ret = safe_strdup (g, "up2date"); break;
case OS_PACKAGE_MANAGEMENT_APT: ret = safe_strdup (g, "apt"); break;
+ case OS_PACKAGE_MANAGEMENT_DNF: ret = safe_strdup (g, "dnf"); break;
case OS_PACKAGE_MANAGEMENT_PACMAN: ret = safe_strdup (g, "pacman"); break;
- case OS_PACKAGE_MANAGEMENT_PORTAGE: ret = safe_strdup (g, "portage"); break;
case OS_PACKAGE_MANAGEMENT_PISI: ret = safe_strdup (g, "pisi"); break;
+ case OS_PACKAGE_MANAGEMENT_PORTAGE: ret = safe_strdup (g, "portage"); break;
+ case OS_PACKAGE_MANAGEMENT_UP2DATE: ret = safe_strdup (g, "up2date"); break;
case OS_PACKAGE_MANAGEMENT_URPMI: ret = safe_strdup (g, "urpmi"); break;
+ case OS_PACKAGE_MANAGEMENT_YUM: ret = safe_strdup (g, "yum"); break;
case OS_PACKAGE_MANAGEMENT_ZYPPER: ret = safe_strdup (g, "zypper"); break;
case OS_PACKAGE_MANAGEMENT_UNKNOWN:
ret = safe_strdup (g, "unknown");
diff --git a/sysprep/sysprep_operation_package_manager_cache.ml b/sysprep/sysprep_operation_package_manager_cache.ml
index 835153b..bd6b2e5 100644
--- a/sysprep/sysprep_operation_package_manager_cache.ml
+++ b/sysprep/sysprep_operation_package_manager_cache.ml
@@ -26,12 +26,14 @@ let package_manager_cache_perform ~verbose ~quiet g root side_effects =
let packager = g#inspect_get_package_management root in
let cache_dirs =
match packager with
- | "zypper" ->
- Some (Array.to_list (g#glob_expand "/var/cache/zypp*"))
- | "yum" ->
- Some [ "/var/cache/yum/" ]
| "apt" ->
Some [ "/var/cache/apt/archives/" ]
+ | "dnf" ->
+ Some [ "/var/cache/dnf/" ]
+ | "yum" ->
+ Some [ "/var/cache/yum/" ]
+ | "zypper" ->
+ Some (Array.to_list (g#glob_expand "/var/cache/zypp*"))
| _ -> None in
match cache_dirs with
| Some dirs -> List.iter (rm_rf_only_files g) dirs
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-libvirt/libguestfs.git
More information about the Pkg-libvirt-commits
mailing list