Some linux distributions don't package static lzma library. Allow
disabling it.
---
configure.ac | 14 +++++++++++++-
libvirt-sandbox/libvirt-sandbox-init-qemu.c | 12 ++++++++++++
2 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac
index 140fb8c..834a444 100644
--- a/configure.ac
+++ b/configure.ac
@@ -81,7 +81,14 @@ PKG_CHECK_MODULES(LIBVIRT_GLIB, libvirt-glib-1.0 >=
$LIBVIRT_GOBJECT_REQUIRED)
PKG_CHECK_MODULES(LIBVIRT_GOBJECT, libvirt-gobject-1.0 >= $LIBVIRT_GOBJECT_REQUIRED)
PKG_CHECK_MODULES(LIBVIRT_GCONFIG, libvirt-gconfig-1.0 >= $LIBVIRT_GCONFIG_REQUIRED)
PKG_CHECK_MODULES(ZLIB, zlib >= $ZLIB_REQUIRED)
-PKG_CHECK_MODULES(LZMA, liblzma >= $LZMA_REQUIRED)
+AC_ARG_WITH([lzma],
+ [AS_HELP_STRING([--with-lzma],
+ [add LZMA support @<:@default=yes@:>@])])
+m4_divert_text([DEFAULTS], [with_lzma=yes])
+
+if test "$with_lzma" = "yes" ; then
+ PKG_CHECK_MODULES(LZMA, liblzma >= $LZMA_REQUIRED)
+fi
LIBVIRT_SANDBOX_CAPNG
LIBVIRT_SANDBOX_GETTEXT
@@ -118,6 +125,11 @@ AC_MSG_NOTICE([])
AC_MSG_NOTICE([])
AC_MSG_NOTICE([ Libraries:])
AC_MSG_NOTICE([])
+if test "$with_lzma" != "no" ; then
+AC_MSG_NOTICE([ LZMA: $LZMA_CFLAGS $LZMA_LIBS])
+else
+AC_MSG_NOTICE([ LZMA: no])
+fi
AC_MSG_NOTICE([ GOBJECT: $GOBJECT_CFLAGS $GOBJECT_LIBS])
AC_MSG_NOTICE([ LIBVIRT_GOBJECT: $LIBVIRT_GOBJECT_CFLAGS $LIBVIRT_GOBJECT_LIBS])
AC_MSG_NOTICE([])
diff --git a/libvirt-sandbox/libvirt-sandbox-init-qemu.c
b/libvirt-sandbox/libvirt-sandbox-init-qemu.c
index 2c2c803..e91dbcf 100644
--- a/libvirt-sandbox/libvirt-sandbox-init-qemu.c
+++ b/libvirt-sandbox/libvirt-sandbox-init-qemu.c
@@ -42,7 +42,9 @@
#include <fcntl.h>
#include <sys/reboot.h>
#include <termios.h>
+#if WITH_LZMA
#include <lzma.h>
+#endif /* WITH_LZMA */
#include <zlib.h>
#define ATTR_UNUSED __attribute__((__unused__))
@@ -492,6 +494,7 @@ has_suffix(const char *filename, const char *ext)
offset[strlen(ext)] == '\0');
}
+#if WITH_LZMA
static char *
load_module_file_lzma(const char *filename, size_t *len)
{
@@ -548,6 +551,15 @@ load_module_file_lzma(const char *filename, size_t *len)
free(xzdata);
return data;
}
+#else
+static char *
+load_module_file_lzma(const char *filename, size_t *len)
+{
+ fprintf(stderr, "libvirt-sandbox-init-qemu: %s: "
+ "lzma support disabled, can't read module %s\n", __func__,
filename);
+ exit_poweroff();
+}
+#endif /* WITH_LZMA */
static char *
load_module_file_zlib(const char *filename, size_t *len)
--
2.1.4