Pino Toscano
2016-May-24 16:21 UTC
[Libguestfs] [PATCH 1/3] inspect: recognize the Void Linux distribution
Since Void Linux provides only an /etc/os-release with no VERSION_ID field, then special-case it to avoid that the os-release parsing ignore it. This provides basic distro identification, and icon. --- generator/actions.ml | 4 ++++ inspector/virt-inspector.rng | 1 + src/guestfs-internal.h | 1 + src/inspect-fs-unix.c | 14 ++++++++++++-- src/inspect-fs.c | 2 ++ src/inspect-icon.c | 13 +++++++++++++ src/inspect.c | 1 + 7 files changed, 34 insertions(+), 2 deletions(-) diff --git a/generator/actions.ml b/generator/actions.ml index b17808e..25d3c0d 100644 --- a/generator/actions.ml +++ b/generator/actions.ml @@ -1183,6 +1183,10 @@ Ubuntu. The distro could not be determined. +=item \"voidlinux\" + +Void Linux. + =item \"windows\" Windows does not have distributions. This string is diff --git a/inspector/virt-inspector.rng b/inspector/virt-inspector.rng index c861c80..c4c423c 100644 --- a/inspector/virt-inspector.rng +++ b/inspector/virt-inspector.rng @@ -108,6 +108,7 @@ <value>suse-based</value> <value>ttylinux</value> <value>ubuntu</value> + <value>voidlinux</value> <value>windows</value> <!-- "unknown" is intentionally left out --> </choice> diff --git a/src/guestfs-internal.h b/src/guestfs-internal.h index 0340687..8a36ab7 100644 --- a/src/guestfs-internal.h +++ b/src/guestfs-internal.h @@ -569,6 +569,7 @@ enum inspect_os_distro { OS_DISTRO_ALTLINUX, OS_DISTRO_FRUGALWARE, OS_DISTRO_PLD_LINUX, + OS_DISTRO_VOID_LINUX, }; enum inspect_os_package_format { diff --git a/src/inspect-fs-unix.c b/src/inspect-fs-unix.c index 0e64e33..4d41086 100644 --- a/src/inspect-fs-unix.c +++ b/src/inspect-fs-unix.c @@ -216,6 +216,8 @@ parse_os_release (guestfs_h *g, struct inspect_fs *fs, const char *filename) distro = OS_DISTRO_SLES; else if (VALUE_IS ("ubuntu")) distro = OS_DISTRO_UBUNTU; + else if (VALUE_IS ("void")) + distro = OS_DISTRO_VOID_LINUX; } else if (STRPREFIX (line, "PRETTY_NAME=")) { free (product_name); product_name = safe_strndup (g, value, value_len); @@ -229,10 +231,18 @@ parse_os_release (guestfs_h *g, struct inspect_fs *fs, const char *filename) } /* If we haven't got all the fields, exit right away. */ - if (distro == OS_DISTRO_UNKNOWN || product_name == NULL || - version.v_major == -1 || version.v_minor == -1) + if (distro == OS_DISTRO_UNKNOWN || product_name == NULL) return 0; + if (version.v_major == -1 || version.v_minor == -1) { + /* Void Linux has no VERSION_ID (yet), but since it's a rolling + * distro and has no other version/release-like file. */ + if (distro == OS_DISTRO_VOID_LINUX) + version_init_null (&version); + else + return 0; + } + /* Apparently, os-release in Debian and CentOS does not provide the full * version number in VERSION_ID, but just the "major" part of it. * Hence, if version.v_minor is 0, act as there was no information in diff --git a/src/inspect-fs.c b/src/inspect-fs.c index ca96667..c718773 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_OPENBSD: case OS_DISTRO_FRUGALWARE: case OS_DISTRO_PLD_LINUX: + case OS_DISTRO_VOID_LINUX: case OS_DISTRO_UNKNOWN: fs->package_format = OS_PACKAGE_FORMAT_UNKNOWN; break; @@ -583,6 +584,7 @@ guestfs_int_check_package_management (guestfs_h *g, struct inspect_fs *fs) case OS_DISTRO_OPENBSD: case OS_DISTRO_FRUGALWARE: case OS_DISTRO_PLD_LINUX: + case OS_DISTRO_VOID_LINUX: 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 2f084b7..e8edee0 100644 --- a/src/inspect-icon.c +++ b/src/inspect-icon.c @@ -61,6 +61,7 @@ static char *icon_opensuse (guestfs_h *g, struct inspect_fs *fs, size_t *size_r) #if CAN_DO_CIRROS static char *icon_cirros (guestfs_h *g, struct inspect_fs *fs, size_t *size_r); #endif +static char *icon_voidlinux (guestfs_h *g, struct inspect_fs *fs, size_t *size_r); #if CAN_DO_WINDOWS static char *icon_windows (guestfs_h *g, struct inspect_fs *fs, size_t *size_r); #endif @@ -158,6 +159,10 @@ guestfs_impl_inspect_get_icon (guestfs_h *g, const char *root, size_t *size_r, #endif break; + case OS_DISTRO_VOID_LINUX: + r = icon_voidlinux (g, fs, &size); + break; + /* These are just to keep gcc warnings happy. */ case OS_DISTRO_ARCHLINUX: case OS_DISTRO_BUILDROOT: @@ -420,6 +425,14 @@ icon_cirros (guestfs_h *g, struct inspect_fs *fs, size_t *size_r) #endif /* CAN_DO_CIRROS */ +#define VOIDLINUX_ICON "/usr/share/void-artwork/void-logo.png" + +static char * +icon_voidlinux (guestfs_h *g, struct inspect_fs *fs, size_t *size_r) +{ + return get_png (g, fs, VOIDLINUX_ICON, size_r, 20480); +} + #if CAN_DO_WINDOWS /* Windows, as usual, has to be much more complicated and stupid than diff --git a/src/inspect.c b/src/inspect.c index bd32d8f..29b4f85 100644 --- a/src/inspect.c +++ b/src/inspect.c @@ -291,6 +291,7 @@ guestfs_impl_inspect_get_distro (guestfs_h *g, const char *root) case OS_DISTRO_TTYLINUX: ret = safe_strdup (g, "ttylinux"); break; case OS_DISTRO_WINDOWS: ret = safe_strdup (g, "windows"); break; case OS_DISTRO_UBUNTU: ret = safe_strdup (g, "ubuntu"); break; + case OS_DISTRO_VOID_LINUX: ret = safe_strdup (g, "voidlinux"); break; case OS_DISTRO_UNKNOWN: ret = safe_strdup (g, "unknown"); break; } -- 2.5.5
Pino Toscano
2016-May-24 16:21 UTC
[Libguestfs] [PATCH 2/3] inspect: support the xbps package manager and its format
Associate the Void Linux distribution with it. --- generator/actions.ml | 5 +++-- inspector/virt-inspector.rng | 2 ++ src/guestfs-internal.h | 2 ++ src/inspect-apps.c | 1 + src/inspect-fs.c | 10 ++++++++-- src/inspect.c | 2 ++ 6 files changed, 18 insertions(+), 4 deletions(-) diff --git a/generator/actions.ml b/generator/actions.ml index 25d3c0d..a40dbdc 100644 --- a/generator/actions.ml +++ b/generator/actions.ml @@ -1826,7 +1826,8 @@ package format I<or> if the operating system does not have a real packaging system (eg. Windows). Possible strings include: -C<rpm>, C<deb>, C<ebuild>, C<pisi>, C<pacman>, C<pkgsrc>, C<apk>. +C<rpm>, C<deb>, C<ebuild>, C<pisi>, C<pacman>, C<pkgsrc>, C<apk>, +C<xbps>. Future versions of libguestfs may return other strings. Please read L<guestfs(3)/INSPECTION> for more details." }; @@ -1848,7 +1849,7 @@ a real packaging system (eg. Windows). 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>, C<apk>. +C<portage>, C<pisi>, C<pacman>, C<urpmi>, C<zypper>, C<apk>, C<xbps>. Future versions of libguestfs may return other strings. Please read L<guestfs(3)/INSPECTION> for more details." }; diff --git a/inspector/virt-inspector.rng b/inspector/virt-inspector.rng index c4c423c..dff46c5 100644 --- a/inspector/virt-inspector.rng +++ b/inspector/virt-inspector.rng @@ -126,6 +126,7 @@ <value>pisi</value> <value>pkgsrc</value> <value>rpm</value> + <value>xbps</value> <!-- "unknown" is intentionally left out --> </choice> </element> @@ -143,6 +144,7 @@ <value>portage</value> <value>up2date</value> <value>urpmi</value> + <value>xbps</value> <value>yum</value> <value>zypper</value> <!-- "unknown" is intentionally left out --> diff --git a/src/guestfs-internal.h b/src/guestfs-internal.h index 8a36ab7..03f1034 100644 --- a/src/guestfs-internal.h +++ b/src/guestfs-internal.h @@ -581,6 +581,7 @@ enum inspect_os_package_format { OS_PACKAGE_FORMAT_PISI, OS_PACKAGE_FORMAT_PKGSRC, OS_PACKAGE_FORMAT_APK, + OS_PACKAGE_FORMAT_XBPS, }; enum inspect_os_package_management { @@ -595,6 +596,7 @@ enum inspect_os_package_management { OS_PACKAGE_MANAGEMENT_ZYPPER, OS_PACKAGE_MANAGEMENT_DNF, OS_PACKAGE_MANAGEMENT_APK, + OS_PACKAGE_MANAGEMENT_XBPS, }; struct inspect_fs { diff --git a/src/inspect-apps.c b/src/inspect-apps.c index e53d87c..b8767c3 100644 --- a/src/inspect-apps.c +++ b/src/inspect-apps.c @@ -149,6 +149,7 @@ guestfs_impl_inspect_list_applications2 (guestfs_h *g, const char *root) case OS_PACKAGE_FORMAT_EBUILD: case OS_PACKAGE_FORMAT_PISI: case OS_PACKAGE_FORMAT_PKGSRC: + case OS_PACKAGE_FORMAT_XBPS: case OS_PACKAGE_FORMAT_UNKNOWN: ; /* nothing */ } diff --git a/src/inspect-fs.c b/src/inspect-fs.c index c718773..adda4ab 100644 --- a/src/inspect-fs.c +++ b/src/inspect-fs.c @@ -487,6 +487,10 @@ guestfs_int_check_package_format (guestfs_h *g, struct inspect_fs *fs) fs->package_format = OS_PACKAGE_FORMAT_APK; break; + case OS_DISTRO_VOID_LINUX: + fs->package_format = OS_PACKAGE_FORMAT_XBPS; + break; + case OS_DISTRO_SLACKWARE: case OS_DISTRO_TTYLINUX: case OS_DISTRO_COREOS: @@ -499,7 +503,6 @@ guestfs_int_check_package_format (guestfs_h *g, struct inspect_fs *fs) case OS_DISTRO_OPENBSD: case OS_DISTRO_FRUGALWARE: case OS_DISTRO_PLD_LINUX: - case OS_DISTRO_VOID_LINUX: case OS_DISTRO_UNKNOWN: fs->package_format = OS_PACKAGE_FORMAT_UNKNOWN; break; @@ -572,6 +575,10 @@ guestfs_int_check_package_management (guestfs_h *g, struct inspect_fs *fs) fs->package_management = OS_PACKAGE_MANAGEMENT_APK; break; + case OS_DISTRO_VOID_LINUX: + fs->package_management = OS_PACKAGE_MANAGEMENT_XBPS; + break; + case OS_DISTRO_SLACKWARE: case OS_DISTRO_TTYLINUX: case OS_DISTRO_COREOS: @@ -584,7 +591,6 @@ guestfs_int_check_package_management (guestfs_h *g, struct inspect_fs *fs) case OS_DISTRO_OPENBSD: case OS_DISTRO_FRUGALWARE: case OS_DISTRO_PLD_LINUX: - case OS_DISTRO_VOID_LINUX: case OS_DISTRO_UNKNOWN: fs->package_management = OS_PACKAGE_MANAGEMENT_UNKNOWN; break; diff --git a/src/inspect.c b/src/inspect.c index 29b4f85..9a60aa0 100644 --- a/src/inspect.c +++ b/src/inspect.c @@ -539,6 +539,7 @@ guestfs_impl_inspect_get_package_format (guestfs_h *g, const char *root) case OS_PACKAGE_FORMAT_PISI: ret = safe_strdup (g, "pisi"); break; case OS_PACKAGE_FORMAT_PKGSRC: ret = safe_strdup (g, "pkgsrc"); break; case OS_PACKAGE_FORMAT_APK: ret = safe_strdup (g, "apk"); break; + case OS_PACKAGE_FORMAT_XBPS: ret = safe_strdup (g, "xbps"); break; case OS_PACKAGE_FORMAT_UNKNOWN: ret = safe_strdup (g, "unknown"); break; @@ -567,6 +568,7 @@ guestfs_impl_inspect_get_package_management (guestfs_h *g, const char *root) 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_XBPS: ret = safe_strdup (g, "xbps"); 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: -- 2.5.5
Pino Toscano
2016-May-24 16:21 UTC
[Libguestfs] [PATCH 3/3] customize: add support for the xbps package manager
--- customize/customize_run.ml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/customize/customize_run.ml b/customize/customize_run.ml index 4b3e13c..c9d9d7d 100644 --- a/customize/customize_run.ml +++ b/customize/customize_run.ml @@ -114,6 +114,7 @@ exec >>%s 2>&1 | "pisi" -> sprintf "pisi it %s" quoted_args | "pacman" -> sprintf "pacman -S %s" quoted_args | "urpmi" -> sprintf "urpmi %s" quoted_args + | "xbps" -> sprintf "xbps-install -Sy %s" quoted_args | "yum" -> sprintf "yum -y install %s" quoted_args | "zypper" -> sprintf "zypper -n in -l %s" quoted_args @@ -141,6 +142,7 @@ exec >>%s 2>&1 | "pisi" -> "pisi upgrade" | "pacman" -> "pacman -Su" | "urpmi" -> "urpmi --auto-select" + | "xbps" -> "xbps-install -Suy" | "yum" -> "yum -y update" | "zypper" -> "zypper -n update -l" -- 2.5.5
Richard W.M. Jones
2016-May-24 16:25 UTC
Re: [Libguestfs] [PATCH 3/3] customize: add support for the xbps package manager
On Tue, May 24, 2016 at 06:21:59PM +0200, Pino Toscano wrote:> --- > customize/customize_run.ml | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/customize/customize_run.ml b/customize/customize_run.ml > index 4b3e13c..c9d9d7d 100644 > --- a/customize/customize_run.ml > +++ b/customize/customize_run.ml > @@ -114,6 +114,7 @@ exec >>%s 2>&1 > | "pisi" -> sprintf "pisi it %s" quoted_args > | "pacman" -> sprintf "pacman -S %s" quoted_args > | "urpmi" -> sprintf "urpmi %s" quoted_args > + | "xbps" -> sprintf "xbps-install -Sy %s" quoted_args > | "yum" -> sprintf "yum -y install %s" quoted_args > | "zypper" -> sprintf "zypper -n in -l %s" quoted_args > > @@ -141,6 +142,7 @@ exec >>%s 2>&1 > | "pisi" -> "pisi upgrade" > | "pacman" -> "pacman -Su" > | "urpmi" -> "urpmi --auto-select" > + | "xbps" -> "xbps-install -Suy" > | "yum" -> "yum -y update" > | "zypper" -> "zypper -n update -l" >ACK 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
Apparently Analagous Threads
- [PATCH] customize: use --noconfirm when installing Arch Linux packages
- [PATCH] customize: Add --uninstall operation.
- [PATCH 1/2] inspect: recognize the Alpine Linux distribution
- [PATCH 1/2] inspection: Set package manager to "unknown" if parsing major version failed (RHBZ#1332025).
- Re: [PATCH 2/2] customize: Improve the error messages when package manager is unknown or unsupported.