From: Richard W.M. Jones Date: Thu, 21 Apr 2011 14:09:11 +0000 (+0100) Subject: inspect: "centos" and "scientificlinux" are now separate distros. X-Git-Tag: 1.11.3~6 X-Git-Url: http://git.annexia.org/?a=commitdiff_plain;h=2b0ca7e7b8d369a42a51b1feec72ae8f17257c78;p=libguestfs.git inspect: "centos" and "scientificlinux" are now separate distros. Previously we returned "rhel" for these, which was not accurate. --- diff --git a/generator/generator_actions.ml b/generator/generator_actions.ml index 26dc64e..58c5f84 100644 --- a/generator/generator_actions.ml +++ b/generator/generator_actions.ml @@ -791,6 +791,10 @@ Currently defined distros are: Arch Linux. +=item \"centos\" + +CentOS. + =item \"debian\" Debian. @@ -825,7 +829,11 @@ Some Red Hat-derived distro. =item \"rhel\" -Red Hat Enterprise Linux and some derivatives. +Red Hat Enterprise Linux. + +=item \"scientificlinux\" + +Scientific Linux. =item \"slackware\" diff --git a/src/guestfs-internal.h b/src/guestfs-internal.h index c6d7c87..b5a7053 100644 --- a/src/guestfs-internal.h +++ b/src/guestfs-internal.h @@ -241,6 +241,8 @@ enum inspect_os_distro { OS_DISTRO_LINUX_MINT, OS_DISTRO_MANDRIVA, OS_DISTRO_SLACKWARE, + OS_DISTRO_CENTOS, + OS_DISTRO_SCIENTIFIC_LINUX, }; enum inspect_os_package_format { diff --git a/src/inspect.c b/src/inspect.c index fc8d8df..7061208 100644 --- a/src/inspect.c +++ b/src/inspect.c @@ -194,6 +194,7 @@ guestfs__inspect_get_distro (guestfs_h *g, const char *root) char *ret; switch (fs->distro) { case OS_DISTRO_ARCHLINUX: ret = safe_strdup (g, "archlinux"); break; + case OS_DISTRO_CENTOS: ret = safe_strdup (g, "centos"); break; case OS_DISTRO_DEBIAN: ret = safe_strdup (g, "debian"); break; case OS_DISTRO_FEDORA: ret = safe_strdup (g, "fedora"); break; case OS_DISTRO_GENTOO: ret = safe_strdup (g, "gentoo"); break; @@ -203,6 +204,7 @@ guestfs__inspect_get_distro (guestfs_h *g, const char *root) case OS_DISTRO_PARDUS: ret = safe_strdup (g, "pardus"); break; case OS_DISTRO_REDHAT_BASED: ret = safe_strdup (g, "redhat-based"); break; case OS_DISTRO_RHEL: ret = safe_strdup (g, "rhel"); break; + case OS_DISTRO_SCIENTIFIC_LINUX: ret = safe_strdup (g, "scientificlinux"); break; case OS_DISTRO_SLACKWARE: ret = safe_strdup (g, "slackware"); break; case OS_DISTRO_WINDOWS: ret = safe_strdup (g, "windows"); break; case OS_DISTRO_UBUNTU: ret = safe_strdup (g, "ubuntu"); break; diff --git a/src/inspect_fs.c b/src/inspect_fs.c index 15d6f96..d258ec4 100644 --- a/src/inspect_fs.c +++ b/src/inspect_fs.c @@ -376,6 +376,8 @@ check_package_format (guestfs_h *g, struct inspect_fs *fs) case OS_DISTRO_REDHAT_BASED: case OS_DISTRO_RHEL: case OS_DISTRO_MANDRIVA: + case OS_DISTRO_CENTOS: + case OS_DISTRO_SCIENTIFIC_LINUX: fs->package_format = OS_PACKAGE_FORMAT_RPM; break; @@ -415,6 +417,8 @@ check_package_management (guestfs_h *g, struct inspect_fs *fs) case OS_DISTRO_REDHAT_BASED: case OS_DISTRO_RHEL: + case OS_DISTRO_CENTOS: + case OS_DISTRO_SCIENTIFIC_LINUX: if (fs->major_version >= 5) fs->package_management = OS_PACKAGE_MANAGEMENT_YUM; else diff --git a/src/inspect_fs_unix.c b/src/inspect_fs_unix.c index cf1affa..a34d691 100644 --- a/src/inspect_fs_unix.c +++ b/src/inspect_fs_unix.c @@ -57,6 +57,12 @@ static pcre *re_fedora; static pcre *re_rhel_old; static pcre *re_rhel; static pcre *re_rhel_no_minor; +static pcre *re_centos_old; +static pcre *re_centos; +static pcre *re_centos_no_minor; +static pcre *re_scientific_linux_old; +static pcre *re_scientific_linux; +static pcre *re_scientific_linux_no_minor; static pcre *re_major_minor; static pcre *re_aug_seq; static pcre *re_xdev; @@ -83,11 +89,23 @@ compile_regexps (void) COMPILE (re_fedora, "Fedora release (\\d+)", 0); COMPILE (re_rhel_old, - "(?:Red Hat|CentOS|Scientific Linux).*release (\\d+).*Update (\\d+)", 0); + "Red Hat.*release (\\d+).*Update (\\d+)", 0); COMPILE (re_rhel, - "(?:Red Hat|CentOS|Scientific Linux).*release (\\d+)\\.(\\d+)", 0); + "Red Hat.*release (\\d+)\\.(\\d+)", 0); COMPILE (re_rhel_no_minor, - "(?:Red Hat|CentOS|Scientific Linux).*release (\\d+)", 0); + "Red Hat.*release (\\d+)", 0); + COMPILE (re_centos_old, + "CentOS.*release (\\d+).*Update (\\d+)", 0); + COMPILE (re_centos, + "CentOS.*release (\\d+)\\.(\\d+)", 0); + COMPILE (re_centos_no_minor, + "CentOS.*release (\\d+)", 0); + COMPILE (re_scientific_linux_old, + "Scientific Linux.*release (\\d+).*Update (\\d+)", 0); + COMPILE (re_scientific_linux, + "Scientific Linux.*release (\\d+)\\.(\\d+)", 0); + COMPILE (re_scientific_linux_no_minor, + "Scientific Linux.*release (\\d+)", 0); COMPILE (re_major_minor, "(\\d+)\\.(\\d+)", 0); COMPILE (re_aug_seq, "/\\d+$", 0); COMPILE (re_xdev, "^/dev/(?:h|s|v|xv)d([a-z]\\d*)$", 0); @@ -101,6 +119,12 @@ free_regexps (void) pcre_free (re_rhel_old); pcre_free (re_rhel); pcre_free (re_rhel_no_minor); + pcre_free (re_centos_old); + pcre_free (re_centos); + pcre_free (re_centos_no_minor); + pcre_free (re_scientific_linux_old); + pcre_free (re_scientific_linux); + pcre_free (re_scientific_linux_no_minor); pcre_free (re_major_minor); pcre_free (re_aug_seq); pcre_free (re_xdev); @@ -285,6 +309,50 @@ guestfs___check_linux_root (guestfs_h *g, struct inspect_fs *fs) return -1; fs->minor_version = 0; } + else if (match2 (g, fs->product_name, re_centos_old, &major, &minor) || + match2 (g, fs->product_name, re_centos, &major, &minor)) { + fs->distro = OS_DISTRO_CENTOS; + fs->major_version = guestfs___parse_unsigned_int (g, major); + free (major); + if (fs->major_version == -1) { + free (minor); + return -1; + } + fs->minor_version = guestfs___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->distro = OS_DISTRO_CENTOS; + fs->major_version = guestfs___parse_unsigned_int (g, major); + free (major); + if (fs->major_version == -1) + return -1; + fs->minor_version = 0; + } + else if (match2 (g, fs->product_name, re_scientific_linux_old, &major, &minor) || + match2 (g, fs->product_name, re_scientific_linux, &major, &minor)) { + fs->distro = OS_DISTRO_SCIENTIFIC_LINUX; + fs->major_version = guestfs___parse_unsigned_int (g, major); + free (major); + if (fs->major_version == -1) { + free (minor); + return -1; + } + fs->minor_version = guestfs___parse_unsigned_int (g, minor); + free (minor); + if (fs->minor_version == -1) + return -1; + } + else if ((major = match1 (g, fs->product_name, re_scientific_linux_no_minor)) != NULL) { + fs->distro = OS_DISTRO_SCIENTIFIC_LINUX; + fs->major_version = guestfs___parse_unsigned_int (g, major); + free (major); + if (fs->major_version == -1) + return -1; + fs->minor_version = 0; + } } else if (guestfs_exists (g, "/etc/debian_version") > 0) { fs->distro = OS_DISTRO_DEBIAN;