[Pkg-libvirt-commits] [libguestfs] 19/31: inspection: fix CentOS 7 detection
Hilko Bengen
bengen at moszumanska.debian.org
Sun Nov 1 17:13:06 UTC 2015
This is an automated email from the git hooks/post-receive script.
bengen pushed a commit to annotated tag upstream/1.29.46
in repository libguestfs.
commit 1ff463e8692aae4313bd5b42bb6f09932bb63392
Author: Pino Toscano <ptoscano at redhat.com>
Date: Fri May 29 16:01:26 2015 +0200
inspection: fix CentOS 7 detection
In newer CentOS 7 versions /etc/redhat-release says that the distro is
derived from RHEL, so we need to look at /etc/centos-release for
actually identifying it as CentOS.
The old code is needed as sub-case of /etc/redhat-release, as on
CentOS < 7 that file is a symlink to /etc/centos-release.
---
src/inspect-fs-unix.c | 32 ++++++++++++++++++++++++++++++--
1 file changed, 30 insertions(+), 2 deletions(-)
diff --git a/src/inspect-fs-unix.c b/src/inspect-fs-unix.c
index ff50b2a..8ffd85d 100644
--- a/src/inspect-fs-unix.c
+++ b/src/inspect-fs-unix.c
@@ -355,8 +355,8 @@ guestfs_int_check_linux_root (guestfs_h *g, struct inspect_fs *fs)
goto skip_release_checks;
}
- /* Oracle Linux includes a "/etc/redhat-release" file, hence the Oracle check
- * needs to be performed before the Red-Hat one.
+ /* RHEL-based distros include a "/etc/redhat-release" file, hence their
+ * checks need to be performed before the Red-Hat one.
*/
if (guestfs_is_file_opts (g, "/etc/oracle-release",
GUESTFS_IS_FILE_OPTS_FOLLOWSYMLINKS, 1, -1) > 0) {
@@ -386,6 +386,34 @@ guestfs_int_check_linux_root (guestfs_h *g, struct inspect_fs *fs)
fs->minor_version = 0;
}
}
+ else if (guestfs_is_file_opts (g, "/etc/centos-release",
+ GUESTFS_IS_FILE_OPTS_FOLLOWSYMLINKS, 1, -1) > 0) {
+ fs->distro = OS_DISTRO_CENTOS;
+
+ if (parse_release_file (g, fs, "/etc/centos-release") == -1)
+ return -1;
+
+ if (match2 (g, fs->product_name, re_centos_old, &major, &minor) ||
+ match2 (g, fs->product_name, re_centos, &major, &minor)) {
+ fs->major_version = guestfs_int_parse_unsigned_int (g, major);
+ free (major);
+ if (fs->major_version == -1) {
+ free (minor);
+ return -1;
+ }
+ fs->minor_version = guestfs_int_parse_unsigned_int (g, minor);
+ free (minor);
+ if (fs->minor_version == -1)
+ return -1;
+ }
+ else if ((major = match1 (g, fs->product_name, re_centos_no_minor)) != NULL) {
+ fs->major_version = guestfs_int_parse_unsigned_int (g, major);
+ free (major);
+ if (fs->major_version == -1)
+ return -1;
+ fs->minor_version = 0;
+ }
+ }
else if (guestfs_is_file_opts (g, "/etc/redhat-release",
GUESTFS_IS_FILE_OPTS_FOLLOWSYMLINKS, 1, -1) > 0) {
fs->distro = OS_DISTRO_REDHAT_BASED; /* Something generic Red Hat-like. */
--
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