Pino Toscano
2019-Feb-06 14:26 UTC
[Libguestfs] [PATCH 0/3] inspect: icon improvements for Mageia & *SUSE
See individual patches. Pino Toscano (3): inspect: bump size limit for Mageia guests inspect: factor out find_png helper function inspect: revamp icon extraction for *SUSE guests lib/inspect-icon.c | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) -- 2.20.1
Pino Toscano
2019-Feb-06 14:26 UTC
[Libguestfs] [PATCH 1/3] inspect: bump size limit for Mageia guests
Newer versions of the logo in Cauldron are almost 3K, so bump the limit to 10K for now. --- lib/inspect-icon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/inspect-icon.c b/lib/inspect-icon.c index 0edd3d1b0..c56d45295 100644 --- a/lib/inspect-icon.c +++ b/lib/inspect-icon.c @@ -344,7 +344,7 @@ icon_ubuntu (guestfs_h *g, size_t *size_r) static char * icon_mageia (guestfs_h *g, size_t *size_r) { - return get_png (g, MAGEIA_ICON, size_r, 2048); + return get_png (g, MAGEIA_ICON, size_r, 10240); } #define OPENSUSE_ICON "/usr/share/icons/hicolor/24x24/apps/distributor.png" -- 2.20.1
Pino Toscano
2019-Feb-06 14:26 UTC
[Libguestfs] [PATCH 2/3] inspect: factor out find_png helper function
Isolate the code for looking for a PNG file among a specified list from the icon_ubuntu implementation, and switch that function to it. This is just code refactoring, with no behaviour changes. --- lib/inspect-icon.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/lib/inspect-icon.c b/lib/inspect-icon.c index c56d45295..0cc8e92ad 100644 --- a/lib/inspect-icon.c +++ b/lib/inspect-icon.c @@ -245,6 +245,22 @@ get_png (guestfs_h *g, const char *filename, size_t *size_r, size_t max_size) return ret; } +static char * +find_png (guestfs_h *g, const char **filenames, size_t *size_r, size_t max_size) +{ + size_t i; + char *ret; + + for (i = 0; filenames[i] != NULL; ++i) { + ret = get_png (g, filenames[i], size_r, max_size); + if (ret == NULL) + return NULL; + if (ret != NOT_FOUND) + return ret; + } + return NOT_FOUND; +} + /* Return /etc/favicon.png (or \etc\favicon.png) if it exists and if * it has a reasonable size and format. */ @@ -326,17 +342,8 @@ icon_ubuntu (guestfs_h *g, size_t *size_r) "/usr/share/help/C/ubuntu-help/figures/ubuntu-logo.png", NULL }; - size_t i; - char *ret; - for (i = 0; icons[i] != NULL; ++i) { - ret = get_png (g, icons[i], size_r, 2048); - if (ret == NULL) - return NULL; - if (ret != NOT_FOUND) - return ret; - } - return NOT_FOUND; + return find_png (g, icons, size_r, 2048); } #define MAGEIA_ICON "/usr/share/icons/mageia.png" -- 2.20.1
Pino Toscano
2019-Feb-06 14:26 UTC
[Libguestfs] [PATCH 3/3] inspect: revamp icon extraction for *SUSE guests
Newer versions do not have the 24px distributor.png icon; OTOH they have the 48px version, so look for that one before the 24px one. Also, bump the size limit to 10K, as newer versions of the icon are bigger than 3K. --- lib/inspect-icon.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/inspect-icon.c b/lib/inspect-icon.c index 0cc8e92ad..623591aa6 100644 --- a/lib/inspect-icon.c +++ b/lib/inspect-icon.c @@ -354,12 +354,16 @@ icon_mageia (guestfs_h *g, size_t *size_r) return get_png (g, MAGEIA_ICON, size_r, 10240); } -#define OPENSUSE_ICON "/usr/share/icons/hicolor/24x24/apps/distributor.png" - static char * icon_opensuse (guestfs_h *g, size_t *size_r) { - return get_png (g, OPENSUSE_ICON, size_r, 2048); + const char *icons[] = { + "/usr/share/icons/hicolor/48x48/apps/distributor.png", + "/usr/share/icons/hicolor/24x24/apps/distributor.png", + NULL + }; + + return find_png (g, icons, size_r, 10240); } #if CAN_DO_CIRROS -- 2.20.1
Richard W.M. Jones
2019-Feb-06 16:04 UTC
Re: [Libguestfs] [PATCH 3/3] inspect: revamp icon extraction for *SUSE guests
On Wed, Feb 06, 2019 at 03:26:46PM +0100, Pino Toscano wrote:> Newer versions do not have the 24px distributor.png icon; OTOH they have > the 48px version, so look for that one before the 24px one. > > Also, bump the size limit to 10K, as newer versions of the icon are > bigger than 3K. > --- > lib/inspect-icon.c | 10 +++++++--- > 1 file changed, 7 insertions(+), 3 deletions(-) > > diff --git a/lib/inspect-icon.c b/lib/inspect-icon.c > index 0cc8e92ad..623591aa6 100644 > --- a/lib/inspect-icon.c > +++ b/lib/inspect-icon.c > @@ -354,12 +354,16 @@ icon_mageia (guestfs_h *g, size_t *size_r) > return get_png (g, MAGEIA_ICON, size_r, 10240); > } > > -#define OPENSUSE_ICON "/usr/share/icons/hicolor/24x24/apps/distributor.png" > - > static char * > icon_opensuse (guestfs_h *g, size_t *size_r) > { > - return get_png (g, OPENSUSE_ICON, size_r, 2048); > + const char *icons[] = { > + "/usr/share/icons/hicolor/48x48/apps/distributor.png", > + "/usr/share/icons/hicolor/24x24/apps/distributor.png", > + NULL > + }; > + > + return find_png (g, icons, size_r, 10240); > } > > #if CAN_DO_CIRROSACK series, thanks. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://people.redhat.com/~rjones/virt-top
Apparently Analagous Threads
- [PATCH 1/9] Partially fix --disable-erlang
- [PATCH 3/3] inspect: revamp icon extraction for *SUSE guests
- [PATCH] inspect: get icon of OpenMandriva guests
- [PATCH 0/3] library: improve handling of external tools
- [PATCH] inspect: get a better icon for ALT Linux guests (RHBZ#1433937)