summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2012-03-07 15:07:37 +0000
committerRichard W.M. Jones <rjones@redhat.com>2012-03-08 18:14:28 +0000
commit435d5f176f5db1663cb5e3e853f96a23918ee4a9 (patch)
treec5425db7a2085b8f6b4aa35ebb71c2678989deb0 /src
parent7cdc5af8535635eed3840a9e18324e417ba9e9de (diff)
downloadlibguestfs-435d5f176f5db1663cb5e3e853f96a23918ee4a9.tar.gz
libguestfs-435d5f176f5db1663cb5e3e853f96a23918ee4a9.tar.xz
libguestfs-435d5f176f5db1663cb5e3e853f96a23918ee4a9.zip
build: Make netpbm and icoutils into proper optional dependencies.
Netpbm and icoutils (wrestool) have always been dependencies. Since they are not always present, make these into optional dependencies (which they were, sort of, before). Also document these dependencies in the README file. (cherry picked from commit 2c9c0525ebda105f37e6a6eea2307db4cb2f0a73)
Diffstat (limited to 'src')
-rw-r--r--src/inspect_icon.c22
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.
*/