Pino Toscano
2015-Sep-08 17:10 UTC
[Libguestfs] [PATCH] inspect: recognize the Frugalware distribution
Just basic identification, name and version. --- 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 13c8bc8..2f0ad0b 100644 --- a/generator/actions.ml +++ b/generator/actions.ml @@ -1099,6 +1099,10 @@ FreeBSD. FreeDOS. +=item \"frugalware\" + +Frugalware. + =item \"gentoo\" Gentoo. diff --git a/src/guestfs-internal.h b/src/guestfs-internal.h index 6cf3dad..f0eb28a 100644 --- a/src/guestfs-internal.h +++ b/src/guestfs-internal.h @@ -554,6 +554,7 @@ enum inspect_os_distro { OS_DISTRO_COREOS, OS_DISTRO_ALPINE_LINUX, OS_DISTRO_ALTLINUX, + OS_DISTRO_FRUGALWARE, }; enum inspect_os_package_format { diff --git a/src/inspect-fs-unix.c b/src/inspect-fs-unix.c index abbae35..65ab8ef 100644 --- a/src/inspect-fs-unix.c +++ b/src/inspect-fs-unix.c @@ -85,6 +85,7 @@ 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) +COMPILE_REGEXP (re_frugalware, "Frugalware (\\d+)\\.(\\d+)", 0) static void check_architecture (guestfs_h *g, struct inspect_fs *fs); static int check_hostname_unix (guestfs_h *g, struct inspect_fs *fs); @@ -632,6 +633,26 @@ guestfs_int_check_linux_root (guestfs_h *g, struct inspect_fs *fs) if (guestfs_int_parse_major_minor (g, fs) == -1) return -1; } + else if (guestfs_is_file_opts (g, "/etc/frugalware-release", + GUESTFS_IS_FILE_OPTS_FOLLOWSYMLINKS, 1, -1) > 0) { + fs->distro = OS_DISTRO_FRUGALWARE; + + if (parse_release_file (g, fs, "/etc/frugalware-release") == -1) + return -1; + + if (match2 (g, fs->product_name, re_frugalware, &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; + } + } skip_release_checks:; diff --git a/src/inspect-fs.c b/src/inspect-fs.c index b239302..b6f03ee 100644 --- a/src/inspect-fs.c +++ b/src/inspect-fs.c @@ -499,6 +499,7 @@ guestfs_int_check_package_format (guestfs_h *g, struct inspect_fs *fs) case OS_DISTRO_FREEBSD: case OS_DISTRO_NETBSD: case OS_DISTRO_OPENBSD: + case OS_DISTRO_FRUGALWARE: case OS_DISTRO_UNKNOWN: fs->package_format = OS_PACKAGE_FORMAT_UNKNOWN; break; @@ -575,6 +576,7 @@ guestfs_int_check_package_management (guestfs_h *g, struct inspect_fs *fs) case OS_DISTRO_FREEBSD: case OS_DISTRO_NETBSD: case OS_DISTRO_OPENBSD: + case OS_DISTRO_FRUGALWARE: case OS_DISTRO_UNKNOWN: fs->package_management = OS_PACKAGE_MANAGEMENT_UNKNOWN; break; diff --git a/src/inspect-icon.c b/src/inspect-icon.c index 93cd67a..33d0aa7 100644 --- a/src/inspect-icon.c +++ b/src/inspect-icon.c @@ -184,6 +184,7 @@ guestfs_impl_inspect_get_icon (guestfs_h *g, const char *root, size_t *size_r, case OS_DISTRO_OPENBSD: case OS_DISTRO_ALPINE_LINUX: case OS_DISTRO_ALTLINUX: + case OS_DISTRO_FRUGALWARE: case OS_DISTRO_UNKNOWN: ; /* nothing */ } diff --git a/src/inspect.c b/src/inspect.c index c01888a..7c7ee0c 100644 --- a/src/inspect.c +++ b/src/inspect.c @@ -266,6 +266,7 @@ guestfs_impl_inspect_get_distro (guestfs_h *g, const char *root) case OS_DISTRO_FEDORA: ret = safe_strdup (g, "fedora"); break; case OS_DISTRO_FREEBSD: ret = safe_strdup (g, "freebsd"); break; case OS_DISTRO_FREEDOS: ret = safe_strdup (g, "freedos"); break; + case OS_DISTRO_FRUGALWARE: ret = safe_strdup (g, "frugalware"); break; case OS_DISTRO_GENTOO: ret = safe_strdup (g, "gentoo"); break; case OS_DISTRO_LINUX_MINT: ret = safe_strdup (g, "linuxmint"); break; case OS_DISTRO_MAGEIA: ret = safe_strdup (g, "mageia"); break; -- 2.1.0
Richard W.M. Jones
2015-Sep-08 17:28 UTC
Re: [Libguestfs] [PATCH] inspect: recognize the Frugalware distribution
On Tue, Sep 08, 2015 at 07:10:46PM +0200, Pino Toscano wrote:> Just basic identification, name and version. > --- > 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 13c8bc8..2f0ad0b 100644 > --- a/generator/actions.ml > +++ b/generator/actions.ml > @@ -1099,6 +1099,10 @@ FreeBSD. > > FreeDOS. > > +=item \"frugalware\" > + > +Frugalware. > + > =item \"gentoo\" > > Gentoo. > diff --git a/src/guestfs-internal.h b/src/guestfs-internal.h > index 6cf3dad..f0eb28a 100644 > --- a/src/guestfs-internal.h > +++ b/src/guestfs-internal.h > @@ -554,6 +554,7 @@ enum inspect_os_distro { > OS_DISTRO_COREOS, > OS_DISTRO_ALPINE_LINUX, > OS_DISTRO_ALTLINUX, > + OS_DISTRO_FRUGALWARE, > }; > > enum inspect_os_package_format { > diff --git a/src/inspect-fs-unix.c b/src/inspect-fs-unix.c > index abbae35..65ab8ef 100644 > --- a/src/inspect-fs-unix.c > +++ b/src/inspect-fs-unix.c > @@ -85,6 +85,7 @@ 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) > +COMPILE_REGEXP (re_frugalware, "Frugalware (\\d+)\\.(\\d+)", 0) > > static void check_architecture (guestfs_h *g, struct inspect_fs *fs); > static int check_hostname_unix (guestfs_h *g, struct inspect_fs *fs); > @@ -632,6 +633,26 @@ guestfs_int_check_linux_root (guestfs_h *g, struct inspect_fs *fs) > if (guestfs_int_parse_major_minor (g, fs) == -1) > return -1; > } > + else if (guestfs_is_file_opts (g, "/etc/frugalware-release", > + GUESTFS_IS_FILE_OPTS_FOLLOWSYMLINKS, 1, -1) > 0) { > + fs->distro = OS_DISTRO_FRUGALWARE; > + > + if (parse_release_file (g, fs, "/etc/frugalware-release") == -1) > + return -1; > + > + if (match2 (g, fs->product_name, re_frugalware, &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; > + } > + } > > skip_release_checks:; > > diff --git a/src/inspect-fs.c b/src/inspect-fs.c > index b239302..b6f03ee 100644 > --- a/src/inspect-fs.c > +++ b/src/inspect-fs.c > @@ -499,6 +499,7 @@ guestfs_int_check_package_format (guestfs_h *g, struct inspect_fs *fs) > case OS_DISTRO_FREEBSD: > case OS_DISTRO_NETBSD: > case OS_DISTRO_OPENBSD: > + case OS_DISTRO_FRUGALWARE: > case OS_DISTRO_UNKNOWN: > fs->package_format = OS_PACKAGE_FORMAT_UNKNOWN; > break; > @@ -575,6 +576,7 @@ guestfs_int_check_package_management (guestfs_h *g, struct inspect_fs *fs) > case OS_DISTRO_FREEBSD: > case OS_DISTRO_NETBSD: > case OS_DISTRO_OPENBSD: > + case OS_DISTRO_FRUGALWARE: > case OS_DISTRO_UNKNOWN: > fs->package_management = OS_PACKAGE_MANAGEMENT_UNKNOWN; > break; > diff --git a/src/inspect-icon.c b/src/inspect-icon.c > index 93cd67a..33d0aa7 100644 > --- a/src/inspect-icon.c > +++ b/src/inspect-icon.c > @@ -184,6 +184,7 @@ guestfs_impl_inspect_get_icon (guestfs_h *g, const char *root, size_t *size_r, > case OS_DISTRO_OPENBSD: > case OS_DISTRO_ALPINE_LINUX: > case OS_DISTRO_ALTLINUX: > + case OS_DISTRO_FRUGALWARE: > case OS_DISTRO_UNKNOWN: > ; /* nothing */ > } > diff --git a/src/inspect.c b/src/inspect.c > index c01888a..7c7ee0c 100644 > --- a/src/inspect.c > +++ b/src/inspect.c > @@ -266,6 +266,7 @@ guestfs_impl_inspect_get_distro (guestfs_h *g, const char *root) > case OS_DISTRO_FEDORA: ret = safe_strdup (g, "fedora"); break; > case OS_DISTRO_FREEBSD: ret = safe_strdup (g, "freebsd"); break; > case OS_DISTRO_FREEDOS: ret = safe_strdup (g, "freedos"); break; > + case OS_DISTRO_FRUGALWARE: ret = safe_strdup (g, "frugalware"); break; > case OS_DISTRO_GENTOO: ret = safe_strdup (g, "gentoo"); break; > case OS_DISTRO_LINUX_MINT: ret = safe_strdup (g, "linuxmint"); break; > case OS_DISTRO_MAGEIA: ret = safe_strdup (g, "mageia"); break;Looks good, 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/
Apparently Analagous Threads
- [PATCH 1/2] inspect: recognize the ALT Linux distribution
- [PATCH 1/3] inspect: recognize the Void Linux distribution
- [PATCH] inspect: try to use /etc/os-release on Linux guests
- [PATCH 1/2] inspect: recognize the Alpine Linux distribution
- [PATCH 2/2] inspect: support the APK package manager and its format