Pino Toscano
2015-Aug-25 15:40 UTC
[Libguestfs] [PATCH 1/2] inspect: recognize the ALT Linux distribution
Check its presence ahead of /etc/redhat-release, as the distro provides it and thus previously it was recognized as "redhat-based". --- generator/actions.ml | 4 ++++ src/guestfs-internal.h | 1 + src/inspect-fs-unix.c | 21 +++++++++++++++++++++ src/inspect-fs.c | 2 ++ src/inspect-icon.c | 1 + src/inspect.c | 1 + 6 files changed, 30 insertions(+) diff --git a/generator/actions.ml b/generator/actions.ml index 1c22f9f..13c8bc8 100644 --- a/generator/actions.ml +++ b/generator/actions.ml @@ -1059,6 +1059,10 @@ Currently defined distros are: Alpine Linux. +=item \"altlinux\" + +ALT Linux. + =item \"archlinux\" Arch Linux. diff --git a/src/guestfs-internal.h b/src/guestfs-internal.h index 0c8857c..6cf3dad 100644 --- a/src/guestfs-internal.h +++ b/src/guestfs-internal.h @@ -553,6 +553,7 @@ enum inspect_os_distro { OS_DISTRO_NETBSD, OS_DISTRO_COREOS, OS_DISTRO_ALPINE_LINUX, + OS_DISTRO_ALTLINUX, }; enum inspect_os_package_format { diff --git a/src/inspect-fs-unix.c b/src/inspect-fs-unix.c index abfa527..abbae35 100644 --- a/src/inspect-fs-unix.c +++ b/src/inspect-fs-unix.c @@ -84,6 +84,7 @@ COMPILE_REGEXP (re_openbsd, "^OpenBSD (\\d+|\\?)\\.(\\d+|\\?)", 0) COMPILE_REGEXP (re_openbsd_duid, "^[0-9a-f]{16}\\.[a-z]", 0) COMPILE_REGEXP (re_openbsd_dev, "^/dev/(s|w)d([0-9])([a-z])$", 0) COMPILE_REGEXP (re_netbsd_dev, "^/dev/(l|s)d([0-9])([a-z])$", 0) +COMPILE_REGEXP (re_altlinux, " (?:(\\d+)(?:\\.(\\d+)(?:[\\.\\d]+)?)?)\\s+\\((?:[^)]+)\\)$", 0) static void check_architecture (guestfs_h *g, struct inspect_fs *fs); static int check_hostname_unix (guestfs_h *g, struct inspect_fs *fs); @@ -414,6 +415,26 @@ guestfs_int_check_linux_root (guestfs_h *g, struct inspect_fs *fs) fs->minor_version = 0; } } + else if (guestfs_is_file_opts (g, "/etc/altlinux-release", + GUESTFS_IS_FILE_OPTS_FOLLOWSYMLINKS, 1, -1) > 0) { + fs->distro = OS_DISTRO_ALTLINUX; + + if (parse_release_file (g, fs, "/etc/altlinux-release") == -1) + return -1; + + if (match2 (g, fs->product_name, re_altlinux, &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 (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. */ diff --git a/src/inspect-fs.c b/src/inspect-fs.c index aa198ad..b239302 100644 --- a/src/inspect-fs.c +++ b/src/inspect-fs.c @@ -465,6 +465,7 @@ guestfs_int_check_package_format (guestfs_h *g, struct inspect_fs *fs) case OS_DISTRO_CENTOS: case OS_DISTRO_SCIENTIFIC_LINUX: case OS_DISTRO_ORACLE_LINUX: + case OS_DISTRO_ALTLINUX: fs->package_format = OS_PACKAGE_FORMAT_RPM; break; @@ -536,6 +537,7 @@ guestfs_int_check_package_management (guestfs_h *g, struct inspect_fs *fs) case OS_DISTRO_DEBIAN: case OS_DISTRO_UBUNTU: case OS_DISTRO_LINUX_MINT: + case OS_DISTRO_ALTLINUX: fs->package_management = OS_PACKAGE_MANAGEMENT_APT; break; diff --git a/src/inspect-icon.c b/src/inspect-icon.c index 77256a3..93cd67a 100644 --- a/src/inspect-icon.c +++ b/src/inspect-icon.c @@ -183,6 +183,7 @@ guestfs_impl_inspect_get_icon (guestfs_h *g, const char *root, size_t *size_r, case OS_DISTRO_NETBSD: case OS_DISTRO_OPENBSD: case OS_DISTRO_ALPINE_LINUX: + case OS_DISTRO_ALTLINUX: case OS_DISTRO_UNKNOWN: ; /* nothing */ } diff --git a/src/inspect.c b/src/inspect.c index 9332fc4..c01888a 100644 --- a/src/inspect.c +++ b/src/inspect.c @@ -256,6 +256,7 @@ guestfs_impl_inspect_get_distro (guestfs_h *g, const char *root) switch (fs->distro) { case OS_DISTRO_ALPINE_LINUX: ret = safe_strdup (g, "alpinelinux"); break; + case OS_DISTRO_ALTLINUX: ret = safe_strdup (g, "altlinux"); break; case OS_DISTRO_ARCHLINUX: ret = safe_strdup (g, "archlinux"); break; case OS_DISTRO_BUILDROOT: ret = safe_strdup (g, "buildroot"); break; case OS_DISTRO_CENTOS: ret = safe_strdup (g, "centos"); break; -- 2.1.0
Pino Toscano
2015-Aug-25 15:40 UTC
[Libguestfs] [PATCH 2/2] osinfo: add altlinux and mageia distributions
--- src/osinfo.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/osinfo.c b/src/osinfo.c index 0454b45..f7e1548 100644 --- a/src/osinfo.c +++ b/src/osinfo.c @@ -492,7 +492,9 @@ parse_distro (guestfs_h *g, xmlNodePtr node, struct osinfo *osinfo) content = (char *) xmlNodeGetContent (node); if (content) { - if (STREQ (content, "centos")) + if (STREQ (content, "altlinux")) + osinfo->distro = OS_DISTRO_ALTLINUX; + else if (STREQ (content, "centos")) osinfo->distro = OS_DISTRO_CENTOS; else if (STREQ (content, "debian")) osinfo->distro = OS_DISTRO_DEBIAN; @@ -500,6 +502,8 @@ parse_distro (guestfs_h *g, xmlNodePtr node, struct osinfo *osinfo) osinfo->distro = OS_DISTRO_FEDORA; else if (STREQ (content, "freebsd")) osinfo->distro = OS_DISTRO_FREEBSD; + else if (STREQ (content, "mageia")) + osinfo->distro = OS_DISTRO_MAGEIA; else if (STREQ (content, "mandriva")) osinfo->distro = OS_DISTRO_MANDRIVA; else if (STREQ (content, "netbsd")) -- 2.1.0
Richard W.M. Jones
2015-Aug-25 18:40 UTC
Re: [Libguestfs] [PATCH 2/2] osinfo: add altlinux and mageia distributions
On Tue, Aug 25, 2015 at 05:40:52PM +0200, Pino Toscano wrote:> --- > src/osinfo.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/src/osinfo.c b/src/osinfo.c > index 0454b45..f7e1548 100644 > --- a/src/osinfo.c > +++ b/src/osinfo.c > @@ -492,7 +492,9 @@ parse_distro (guestfs_h *g, xmlNodePtr node, struct osinfo *osinfo) > > content = (char *) xmlNodeGetContent (node); > if (content) { > - if (STREQ (content, "centos")) > + if (STREQ (content, "altlinux")) > + osinfo->distro = OS_DISTRO_ALTLINUX; > + else if (STREQ (content, "centos")) > osinfo->distro = OS_DISTRO_CENTOS; > else if (STREQ (content, "debian")) > osinfo->distro = OS_DISTRO_DEBIAN; > @@ -500,6 +502,8 @@ parse_distro (guestfs_h *g, xmlNodePtr node, struct osinfo *osinfo) > osinfo->distro = OS_DISTRO_FEDORA; > else if (STREQ (content, "freebsd")) > osinfo->distro = OS_DISTRO_FREEBSD; > + else if (STREQ (content, "mageia")) > + osinfo->distro = OS_DISTRO_MAGEIA; > else if (STREQ (content, "mandriva")) > osinfo->distro = OS_DISTRO_MANDRIVA; > else if (STREQ (content, "netbsd")) > -- > 2.1.0ACK series. Thanks, Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 100 libraries supported. http://fedoraproject.org/wiki/MinGW
Possibly Parallel Threads
- [PATCH] inspect: recognize the Frugalware distribution
- [PATCH 2/2] osinfo: add altlinux and mageia distributions
- [PATCH v2 0/7] Introducing virt-builder-repository
- [PATCH v7 0/9] Introducing virt-builder-repository
- [PATCH v3 00/10] Introducing virt-builder-repository