diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/inspect_icon.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/inspect_icon.c b/src/inspect_icon.c index 5c3628ab..aa6e44a0 100644 --- a/src/inspect_icon.c +++ b/src/inspect_icon.c @@ -33,6 +33,12 @@ #include "guestfs-internal-actions.h" #include "guestfs_protocol.h" +/* External tools are required for some icon types. Check we have them. */ +#if defined(WRESTOOL) && defined(BMPTOPNM) && defined(PNMTOPNG) && \ + defined(PAMCUT) +#define CAN_DO_WINDOWS 1 +#endif + static int read_whole_file (guestfs_h *g, const char *filename, char **data_r, size_t *size_r); /* All these icon_*() functions return the same way. One of: @@ -56,7 +62,9 @@ static char *icon_debian (guestfs_h *g, struct inspect_fs *fs, size_t *size_r); static char *icon_ubuntu (guestfs_h *g, struct inspect_fs *fs, size_t *size_r); static char *icon_mageia (guestfs_h *g, struct inspect_fs *fs, size_t *size_r); static char *icon_opensuse (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 /* Dummy static object. */ static char *NOT_FOUND = (char *) "not_found"; @@ -158,11 +166,13 @@ guestfs__inspect_get_icon (guestfs_h *g, const char *root, size_t *size_r, break; case OS_TYPE_WINDOWS: +#if CAN_DO_WINDOWS /* We don't know how to get high quality icons from a Windows guest, * so disable this if high quality was specified. */ if (!highquality) r = icon_windows (g, fs, &size); +#endif break; case OS_TYPE_FREEBSD: @@ -325,6 +335,8 @@ icon_opensuse (guestfs_h *g, struct inspect_fs *fs, size_t *size_r) return get_png (g, fs, OPENSUSE_ICON, size_r, 2048); } +#if CAN_DO_WINDOWS + /* Windows, as usual, has to be much more complicated and stupid than * anything else. * @@ -352,8 +364,8 @@ icon_windows_xp (guestfs_h *g, struct inspect_fs *fs, const char *explorer, pngfile = safe_asprintf (g, "%s/windows-xp-icon.png", g->tmpdir); cmd = safe_asprintf (g, - "wrestool -x --type=2 --name=143 %s | " - "bmptopnm | pnmtopng > %s", + WRESTOOL " -x --type=2 --name=143 %s | " + BMPTOPNM " | " PNMTOPNG " > %s", explorer, pngfile); r = system (cmd); if (r == -1 || WEXITSTATUS (r) != 0) { @@ -387,8 +399,8 @@ icon_windows_7 (guestfs_h *g, struct inspect_fs *fs, const char *explorer, pngfile = safe_asprintf (g, "%s/windows-7-icon.png", g->tmpdir); cmd = safe_asprintf (g, - "wrestool -x --type=2 --name=6801 %s | " - "bmptopnm | pamcut -bottom 54 | pnmtopng > %s", + WRESTOOL " -x --type=2 --name=6801 %s | " + BMPTOPNM " | " PAMCUT " -bottom 54 | " PNMTOPNG " > %s", explorer, pngfile); r = system (cmd); if (r == -1 || WEXITSTATUS (r) != 0) { @@ -450,6 +462,8 @@ icon_windows (guestfs_h *g, struct inspect_fs *fs, size_t *size_r) return ret; } +#endif /* CAN_DO_WINDOWS */ + /* Read the whole file into a memory buffer and return it. The file * should be a regular, local, trusted file. */ |
