forked from pool/libguestfs
- bsc#1195415 - libguestfs: consider dropping build requirement on
systemd-sysvinit libguestfs.spec OBS-URL: https://build.opensuse.org/package/show/Virtualization/libguestfs?expand=0&rev=493
This commit is contained in:
parent
434f46da61
commit
6dd3989061
416
0001-Introduce-a-wrapper-around-xmlParseURI.patch
Normal file
416
0001-Introduce-a-wrapper-around-xmlParseURI.patch
Normal file
@ -0,0 +1,416 @@
|
||||
From 66dbffd38377abeb64144990421e52293613840a Mon Sep 17 00:00:00 2001
|
||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||
Date: Thu, 15 Feb 2018 15:55:35 +0000
|
||||
Subject: [PATCH 1/3] Introduce a wrapper around xmlParseURI.
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
We only use xmlParseURI to parse our own "homebrew" URIs, for example
|
||||
the ones used by guestfish --add or virt-v2v. Unfortunately
|
||||
xmlParseURI cannot handle URIs with spaces or other non-RFC-compliant
|
||||
characters so simple commands like these fail:
|
||||
|
||||
$ guestfish -a 'ssh://example.com/virtual machine.img'
|
||||
guestfish: --add: could not parse URI 'ssh://example.com/virtual machine.img'
|
||||
|
||||
$ guestfish -a 'ssh://example.com/バーチャルマシン.img'
|
||||
guestfish: --add: could not parse URI 'ssh://example.com/バーチャルマシン.img'
|
||||
|
||||
This is a usability problem. However since these are not expected to
|
||||
be generic RFC-compliant URIs we can perform the required
|
||||
percent-escaping ourselves instead of demanding that the user does
|
||||
this.
|
||||
|
||||
Note that the wrapper function should not be used on real URLs or
|
||||
libvirt URLs.
|
||||
---
|
||||
common/mlxml/Makefile.am | 1 +
|
||||
common/mlxml/xml-c.c | 45 +++++++++--
|
||||
common/mlxml/xml.ml | 1 +
|
||||
common/mlxml/xml.mli | 4 +
|
||||
common/options/uri.c | 5 +-
|
||||
common/utils/Makefile.am | 2 +
|
||||
common/utils/libxml2-utils.c | 178 +++++++++++++++++++++++++++++++++++++++++++
|
||||
common/utils/libxml2-utils.h | 27 +++++++
|
||||
10 files changed, 258 insertions(+), 18 deletions(-)
|
||||
create mode 100644 common/utils/libxml2-utils.c
|
||||
create mode 100644 common/utils/libxml2-utils.h
|
||||
|
||||
Index: libguestfs-1.44.2/common/mlxml/Makefile.am
|
||||
===================================================================
|
||||
--- libguestfs-1.44.2.orig/common/mlxml/Makefile.am
|
||||
+++ libguestfs-1.44.2/common/mlxml/Makefile.am
|
||||
@@ -54,6 +54,7 @@ libmlxml_a_CPPFLAGS = \
|
||||
-I. \
|
||||
-I$(top_builddir) \
|
||||
-I$(top_srcdir)/gnulib/lib -I$(top_builddir)/gnulib/lib \
|
||||
+ -I$(top_srcdir)/common/utils -I$(top_builddir)/common/utils \
|
||||
-I$(shell $(OCAMLC) -where)
|
||||
libmlxml_a_CFLAGS = \
|
||||
$(WARN_CFLAGS) $(WERROR_CFLAGS) \
|
||||
Index: libguestfs-1.44.2/common/mlxml/xml-c.c
|
||||
===================================================================
|
||||
--- libguestfs-1.44.2.orig/common/mlxml/xml-c.c
|
||||
+++ libguestfs-1.44.2/common/mlxml/xml-c.c
|
||||
@@ -27,17 +27,21 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
+#include <errno.h>
|
||||
|
||||
#include <caml/alloc.h>
|
||||
#include <caml/custom.h>
|
||||
#include <caml/fail.h>
|
||||
#include <caml/memory.h>
|
||||
#include <caml/mlvalues.h>
|
||||
+#include <caml/unixsupport.h>
|
||||
|
||||
#include <libxml/xpath.h>
|
||||
#include <libxml/xpathInternals.h>
|
||||
#include <libxml/uri.h>
|
||||
|
||||
+#include "libxml2-utils.h"
|
||||
+
|
||||
#pragma GCC diagnostic ignored "-Wmissing-prototypes"
|
||||
|
||||
/* Replacement if caml_alloc_initialized_string is missing, added
|
||||
@@ -438,16 +442,11 @@ mllib_xml_doc_get_root_element (value do
|
||||
}
|
||||
}
|
||||
|
||||
-value
|
||||
-mllib_xml_parse_uri (value strv)
|
||||
+static value
|
||||
+Val_uri (xmlURIPtr uri)
|
||||
{
|
||||
- CAMLparam1 (strv);
|
||||
+ CAMLparam0 ();
|
||||
CAMLlocal3 (rv, sv, ov);
|
||||
- xmlURIPtr uri;
|
||||
-
|
||||
- uri = xmlParseURI (String_val (strv));
|
||||
- if (uri == NULL)
|
||||
- caml_invalid_argument ("parse_uri: unable to parse URI");
|
||||
|
||||
rv = caml_alloc_tuple (9);
|
||||
|
||||
@@ -526,7 +525,37 @@ mllib_xml_parse_uri (value strv)
|
||||
else ov = Val_int (0);
|
||||
Store_field (rv, 8, ov);
|
||||
|
||||
+ CAMLreturn (rv);
|
||||
+}
|
||||
+
|
||||
+value
|
||||
+mllib_xml_parse_uri (value strv)
|
||||
+{
|
||||
+ CAMLparam1 (strv);
|
||||
+ CAMLlocal1 (rv);
|
||||
+ xmlURIPtr uri;
|
||||
+
|
||||
+ uri = xmlParseURI (String_val (strv));
|
||||
+ if (uri == NULL)
|
||||
+ caml_invalid_argument ("parse_uri: unable to parse URI");
|
||||
+
|
||||
+ rv = Val_uri (uri);
|
||||
xmlFreeURI (uri);
|
||||
+ CAMLreturn (rv);
|
||||
+}
|
||||
|
||||
+value
|
||||
+mllib_xml_parse_nonstandard_uri (value strv)
|
||||
+{
|
||||
+ CAMLparam1 (strv);
|
||||
+ CAMLlocal1 (rv);
|
||||
+ xmlURIPtr uri;
|
||||
+
|
||||
+ uri = guestfs_int_parse_nonstandard_uri (String_val (strv));
|
||||
+ if (uri == NULL)
|
||||
+ unix_error (errno, (char *) "Xml.parse_uri", strv);
|
||||
+
|
||||
+ rv = Val_uri (uri);
|
||||
+ xmlFreeURI (uri);
|
||||
CAMLreturn (rv);
|
||||
}
|
||||
Index: libguestfs-1.44.2/common/mlxml/xml.ml
|
||||
===================================================================
|
||||
--- libguestfs-1.44.2.orig/common/mlxml/xml.ml
|
||||
+++ libguestfs-1.44.2/common/mlxml/xml.ml
|
||||
@@ -162,3 +162,4 @@ type uri = {
|
||||
}
|
||||
|
||||
external parse_uri : string -> uri = "mllib_xml_parse_uri"
|
||||
+external parse_nonstandard_uri : string -> uri = "mllib_xml_parse_nonstandard_uri"
|
||||
Index: libguestfs-1.44.2/common/mlxml/xml.mli
|
||||
===================================================================
|
||||
--- libguestfs-1.44.2.orig/common/mlxml/xml.mli
|
||||
+++ libguestfs-1.44.2/common/mlxml/xml.mli
|
||||
@@ -115,3 +115,7 @@ val parse_uri : string -> uri
|
||||
Note this is different from the {!URI} module which is specialized
|
||||
for parsing the [-a] parameter on the command line. This function
|
||||
exposes the full [xmlParseURI] interface. *)
|
||||
+
|
||||
+val parse_nonstandard_uri : string -> uri
|
||||
+(** Similar to {!parse_uri} but only for use with our non-standard
|
||||
+ URIs. See [guestfs_int_parse_nonstandard_uri] in [common/utils]. *)
|
||||
Index: libguestfs-1.44.2/common/options/uri.c
|
||||
===================================================================
|
||||
--- libguestfs-1.44.2.orig/common/options/uri.c
|
||||
+++ libguestfs-1.44.2/common/options/uri.c
|
||||
@@ -38,6 +38,7 @@
|
||||
|
||||
#include "guestfs.h"
|
||||
#include "guestfs-utils.h"
|
||||
+#include "libxml2-utils.h"
|
||||
#include "uri.h"
|
||||
|
||||
static int is_uri (const char *arg);
|
||||
@@ -114,9 +115,9 @@ parse (const char *arg, char **path_ret,
|
||||
CLEANUP_FREE char *socket = NULL;
|
||||
char *path;
|
||||
|
||||
- uri = xmlParseURI (arg);
|
||||
+ uri = guestfs_int_parse_nonstandard_uri (arg);
|
||||
if (!uri) {
|
||||
- fprintf (stderr, _("%s: --add: could not parse URI ‘%s’\n"),
|
||||
+ fprintf (stderr, _("%s: --add: could not parse URI ‘%s’: %m\n"),
|
||||
getprogname (), arg);
|
||||
return -1;
|
||||
}
|
||||
Index: libguestfs-1.44.2/common/utils/Makefile.am
|
||||
===================================================================
|
||||
--- libguestfs-1.44.2.orig/common/utils/Makefile.am
|
||||
+++ libguestfs-1.44.2/common/utils/Makefile.am
|
||||
@@ -29,12 +29,15 @@ libutils_la_SOURCES = \
|
||||
libxml2-writer-macros.h \
|
||||
pcre2-cleanups.c \
|
||||
stringlists-utils.c \
|
||||
+ libxml2-utils.c \
|
||||
+ libxml2-utils.h \
|
||||
utils.c
|
||||
libutils_la_CPPFLAGS = \
|
||||
-DGUESTFS_NO_DEPRECATED=1 \
|
||||
-DGUESTFS_PRIVATE=1 \
|
||||
-I$(top_srcdir)/gnulib/lib -I$(top_builddir)/gnulib/lib \
|
||||
- -I$(top_srcdir)/lib -I$(top_builddir)/lib
|
||||
+ -I$(top_srcdir)/lib -I$(top_builddir)/lib \
|
||||
+ -I$(top_builddir)/include
|
||||
libutils_la_CFLAGS = \
|
||||
$(WARN_CFLAGS) $(WERROR_CFLAGS) \
|
||||
$(GCC_VISIBILITY_HIDDEN) \
|
||||
Index: libguestfs-1.44.2/common/utils/libxml2-utils.c
|
||||
===================================================================
|
||||
--- /dev/null
|
||||
+++ libguestfs-1.44.2/common/utils/libxml2-utils.c
|
||||
@@ -0,0 +1,178 @@
|
||||
+/* libguestfs
|
||||
+ * Copyright (C) 2017 Red Hat Inc.
|
||||
+ *
|
||||
+ * This library is free software; you can redistribute it and/or
|
||||
+ * modify it under the terms of the GNU Lesser General Public
|
||||
+ * License as published by the Free Software Foundation; either
|
||||
+ * version 2 of the License, or (at your option) any later version.
|
||||
+ *
|
||||
+ * This library is distributed in the hope that it will be useful,
|
||||
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
+ * Lesser General Public License for more details.
|
||||
+ *
|
||||
+ * You should have received a copy of the GNU Lesser General Public
|
||||
+ * License along with this library; if not, write to the Free Software
|
||||
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
+ */
|
||||
+
|
||||
+/**
|
||||
+ * Utility functions using libxml2.
|
||||
+ *
|
||||
+ * These functions these I<must not> call internal library functions
|
||||
+ * such as C<safe_*>, C<error> or C<perrorf>, or any C<guestfs_int_*>.
|
||||
+ */
|
||||
+
|
||||
+#include <config.h>
|
||||
+
|
||||
+#include <stdio.h>
|
||||
+#include <stdlib.h>
|
||||
+#include <string.h>
|
||||
+#include <errno.h>
|
||||
+#include <locale.h>
|
||||
+#include <langinfo.h>
|
||||
+#include <iconv.h>
|
||||
+
|
||||
+#include <libxml/uri.h>
|
||||
+
|
||||
+#include "c-ctype.h"
|
||||
+
|
||||
+/* NB: MUST NOT include "guestfs-internal.h". */
|
||||
+#include "guestfs.h"
|
||||
+#include "guestfs-utils.h"
|
||||
+#include "libxml2-utils.h"
|
||||
+
|
||||
+static char *local_string_to_utf8 (/* const */ char *input);
|
||||
+
|
||||
+/**
|
||||
+ * This is a wrapper around C<xmlParseURI>. That function cannot
|
||||
+ * handle spaces and some non-ASCII characters found in URIs. This
|
||||
+ * wrapper URI-encodes those before calling C<xmlParseURI> and returns
|
||||
+ * the URI structure.
|
||||
+ *
|
||||
+ * This function should B<only> be called for the URIs that libguestfs
|
||||
+ * has invented, for things like guestfish I<--add> and virt-v2v.
|
||||
+ *
|
||||
+ * For real URIs or libvirt URIs this may cause corruption in corner
|
||||
+ * cases. (See L<https://news.ycombinator.com/item?id=11673058>
|
||||
+ * describing some of the complexity involved in dealing with real
|
||||
+ * URI).
|
||||
+ *
|
||||
+ * On error, returns C<NULL> and sets C<errno> appropriately.
|
||||
+ *
|
||||
+ * Caller must call C<xmlFreeURI> on the returned structure or use the
|
||||
+ * C<CLEANUP_XMLFREEURI> cleanup macro.
|
||||
+ */
|
||||
+xmlURIPtr
|
||||
+guestfs_int_parse_nonstandard_uri (const char *arg)
|
||||
+{
|
||||
+ CLEANUP_FREE char *uri = NULL;
|
||||
+ CLEANUP_FREE char *escaped_uri = NULL;
|
||||
+ static const char hexdigit[] = "0123456789abcdef";
|
||||
+ size_t i, j, len;
|
||||
+ xmlURIPtr ret;
|
||||
+
|
||||
+ /* Convert the string to UTF-8. */
|
||||
+ uri = local_string_to_utf8 ((char *) arg);
|
||||
+ if (uri == NULL)
|
||||
+ return NULL;
|
||||
+
|
||||
+ /* Since we know the URI is in well-formed UTF-8 we can iterate over
|
||||
+ * the bytes to do the escaping. The output of this will never be
|
||||
+ * more than 3 times larger (each byte might be rewritten as ‘%XX’).
|
||||
+ */
|
||||
+ len = strlen (uri);
|
||||
+ escaped_uri = malloc (3*len + 1);
|
||||
+ if (escaped_uri == NULL)
|
||||
+ return NULL;
|
||||
+
|
||||
+ for (i = j = 0; i < strlen (uri); ++i) {
|
||||
+ /* See RFC 3986 appendix A. Note this leaves existing %-encoded
|
||||
+ * escapes alone.
|
||||
+ */
|
||||
+ if (c_isalnum (uri[i]) ||
|
||||
+ strchr ("%-._~:/?#[]@!$&'()*+,;=", uri[i]) != NULL)
|
||||
+ escaped_uri[j++] = uri[i];
|
||||
+ else {
|
||||
+ escaped_uri[j++] = '%';
|
||||
+ escaped_uri[j++] = hexdigit [(((unsigned char) uri[i]) >> 4) & 0xf];
|
||||
+ escaped_uri[j++] = hexdigit [((unsigned char) uri[i]) & 0xf];
|
||||
+ }
|
||||
+ }
|
||||
+ escaped_uri[j++] = '\0';
|
||||
+
|
||||
+ /* libxml2 xmlParseURI does not reliably set errno, so it's likely
|
||||
+ * best to ignore whatever errno is returned and overwrite it with
|
||||
+ * EINVAL.
|
||||
+ */
|
||||
+ ret = xmlParseURI (escaped_uri);
|
||||
+ if (ret == NULL) {
|
||||
+ errno = EINVAL;
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+/* Would be const, but the interface to iconv is not const-correct on
|
||||
+ * all platforms. The input string is not touched.
|
||||
+ */
|
||||
+static char *
|
||||
+local_string_to_utf8 (/* const */ char *input)
|
||||
+{
|
||||
+ iconv_t ic;
|
||||
+ size_t len, inlen, outlen, outalloc, r, prev;
|
||||
+ int err;
|
||||
+ char *out, *inp, *outp;
|
||||
+
|
||||
+ /* Convert from input locale to UTF-8. */
|
||||
+ ic = iconv_open ("UTF-8", nl_langinfo (CODESET));
|
||||
+ if (ic == (iconv_t) -1)
|
||||
+ return NULL;
|
||||
+
|
||||
+ len = strlen (input);
|
||||
+ outalloc = len; /* Initial guess. */
|
||||
+
|
||||
+ again:
|
||||
+ inlen = len;
|
||||
+ outlen = outalloc;
|
||||
+ out = malloc (outlen + 1);
|
||||
+ if (out == NULL) {
|
||||
+ err = errno;
|
||||
+ iconv_close (ic);
|
||||
+ errno = err;
|
||||
+ return NULL;
|
||||
+ }
|
||||
+ inp = input;
|
||||
+ outp = out;
|
||||
+
|
||||
+ r = iconv (ic, (char **) &inp, &inlen, &outp, &outlen);
|
||||
+ if (r == (size_t) -1) {
|
||||
+ if (errno == E2BIG) {
|
||||
+ err = errno;
|
||||
+ prev = outalloc;
|
||||
+ /* Try again with a larger output buffer. */
|
||||
+ free (out);
|
||||
+ outalloc *= 2;
|
||||
+ if (outalloc < prev) {
|
||||
+ iconv_close (ic);
|
||||
+ errno = err;
|
||||
+ return NULL;
|
||||
+ }
|
||||
+ goto again;
|
||||
+ }
|
||||
+ else {
|
||||
+ /* Else some other conversion failure, eg. EILSEQ, EINVAL. */
|
||||
+ err = errno;
|
||||
+ iconv_close (ic);
|
||||
+ free (out);
|
||||
+ errno = err;
|
||||
+ return NULL;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ *outp = '\0';
|
||||
+ iconv_close (ic);
|
||||
+
|
||||
+ return out;
|
||||
+}
|
||||
Index: libguestfs-1.44.2/common/utils/libxml2-utils.h
|
||||
===================================================================
|
||||
--- /dev/null
|
||||
+++ libguestfs-1.44.2/common/utils/libxml2-utils.h
|
||||
@@ -0,0 +1,27 @@
|
||||
+/* libguestfs
|
||||
+ * Copyright (C) 2017 Red Hat Inc.
|
||||
+ *
|
||||
+ * This library is free software; you can redistribute it and/or
|
||||
+ * modify it under the terms of the GNU Lesser General Public
|
||||
+ * License as published by the Free Software Foundation; either
|
||||
+ * version 2 of the License, or (at your option) any later version.
|
||||
+ *
|
||||
+ * This library is distributed in the hope that it will be useful,
|
||||
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
+ * Lesser General Public License for more details.
|
||||
+ *
|
||||
+ * You should have received a copy of the GNU Lesser General Public
|
||||
+ * License along with this library; if not, write to the Free Software
|
||||
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
+ */
|
||||
+
|
||||
+#ifndef GUESTFS_LIBXML2_UTILS_H_
|
||||
+#define GUESTFS_LIBXML2_UTILS_H_
|
||||
+
|
||||
+#include <libxml/uri.h>
|
||||
+
|
||||
+/* libxml2-utils.c */
|
||||
+extern xmlURIPtr guestfs_int_parse_nonstandard_uri (const char *uri);
|
||||
+
|
||||
+#endif /* GUESTFS_LIBXML2_UTILS_H_ */
|
222
0002-common-extract-UTF-8-conversion-function.patch
Normal file
222
0002-common-extract-UTF-8-conversion-function.patch
Normal file
@ -0,0 +1,222 @@
|
||||
From 10d1eacdac98575d0d8ce81bc04d74b12bf43cab Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?C=C3=A9dric=20Bosdonnat?= <cbosdonnat@suse.com>
|
||||
Date: Thu, 15 Feb 2018 17:38:19 +0100
|
||||
Subject: [PATCH 2/3] common: extract UTF-8 conversion function
|
||||
|
||||
libxml2-utils.c local_string_to_utf8() function could easily be reused
|
||||
in other places. This commit extracts it with a new parameter to allow
|
||||
giving the encoding of the input string and publishes it in
|
||||
guestfs-utils.h as guestfs_int_string_to_utf8()
|
||||
---
|
||||
common/utils/guestfs-utils.h | 11 +++++++
|
||||
common/utils/libxml2-utils.c | 69 +-------------------------------------------
|
||||
common/utils/utils.c | 64 ++++++++++++++++++++++++++++++++++++++++
|
||||
3 files changed, 76 insertions(+), 68 deletions(-)
|
||||
|
||||
Index: libguestfs-1.43.1/common/utils/guestfs-utils.h
|
||||
===================================================================
|
||||
--- libguestfs-1.43.1.orig/common/utils/guestfs-utils.h
|
||||
+++ libguestfs-1.43.1/common/utils/guestfs-utils.h
|
||||
@@ -33,6 +33,7 @@
|
||||
#define GUESTFS_UTILS_H_
|
||||
|
||||
#include <stdbool.h>
|
||||
+#include <langinfo.h>
|
||||
|
||||
#include "guestfs-internal-all.h"
|
||||
#include "cleanups.h"
|
||||
@@ -68,6 +69,17 @@ extern int guestfs_int_is_sock (int64_t
|
||||
extern char *guestfs_int_full_path (const char *dir, const char *name);
|
||||
extern void guestfs_int_hexdump (const void *data, size_t len, FILE *fp);
|
||||
|
||||
+extern char *guestfs_int_string_to_utf8 (/* const */ char *input, const char *encoding);
|
||||
+
|
||||
+/* Would be const, but the interface to iconv is not const-correct on
|
||||
+ * all platforms. The input string is not touched.
|
||||
+ */
|
||||
+static inline char *
|
||||
+guestfs_int_local_string_to_utf8 (/* const */ char *input)
|
||||
+{
|
||||
+ return guestfs_int_string_to_utf8 (input, nl_langinfo (CODESET));
|
||||
+}
|
||||
+
|
||||
/* Not all language bindings know how to deal with Pointer arguments.
|
||||
* Those that don't will use this macro which complains noisily and
|
||||
* returns NULL.
|
||||
Index: libguestfs-1.43.1/common/utils/libxml2-utils.c
|
||||
===================================================================
|
||||
--- libguestfs-1.43.1.orig/common/utils/libxml2-utils.c
|
||||
+++ libguestfs-1.43.1/common/utils/libxml2-utils.c
|
||||
@@ -30,8 +30,6 @@
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <locale.h>
|
||||
-#include <langinfo.h>
|
||||
-#include <iconv.h>
|
||||
|
||||
#include <libxml/uri.h>
|
||||
|
||||
@@ -42,8 +40,6 @@
|
||||
#include "guestfs-utils.h"
|
||||
#include "libxml2-utils.h"
|
||||
|
||||
-static char *local_string_to_utf8 (/* const */ char *input);
|
||||
-
|
||||
/**
|
||||
* This is a wrapper around C<xmlParseURI>. That function cannot
|
||||
* handle spaces and some non-ASCII characters found in URIs. This
|
||||
@@ -73,7 +69,7 @@ guestfs_int_parse_nonstandard_uri (const
|
||||
xmlURIPtr ret;
|
||||
|
||||
/* Convert the string to UTF-8. */
|
||||
- uri = local_string_to_utf8 ((char *) arg);
|
||||
+ uri = guestfs_int_local_string_to_utf8 ((char *) arg);
|
||||
if (uri == NULL)
|
||||
return NULL;
|
||||
|
||||
@@ -113,66 +109,3 @@ guestfs_int_parse_nonstandard_uri (const
|
||||
|
||||
return ret;
|
||||
}
|
||||
-
|
||||
-/* Would be const, but the interface to iconv is not const-correct on
|
||||
- * all platforms. The input string is not touched.
|
||||
- */
|
||||
-static char *
|
||||
-local_string_to_utf8 (/* const */ char *input)
|
||||
-{
|
||||
- iconv_t ic;
|
||||
- size_t len, inlen, outlen, outalloc, r, prev;
|
||||
- int err;
|
||||
- char *out, *inp, *outp;
|
||||
-
|
||||
- /* Convert from input locale to UTF-8. */
|
||||
- ic = iconv_open ("UTF-8", nl_langinfo (CODESET));
|
||||
- if (ic == (iconv_t) -1)
|
||||
- return NULL;
|
||||
-
|
||||
- len = strlen (input);
|
||||
- outalloc = len; /* Initial guess. */
|
||||
-
|
||||
- again:
|
||||
- inlen = len;
|
||||
- outlen = outalloc;
|
||||
- out = malloc (outlen + 1);
|
||||
- if (out == NULL) {
|
||||
- err = errno;
|
||||
- iconv_close (ic);
|
||||
- errno = err;
|
||||
- return NULL;
|
||||
- }
|
||||
- inp = input;
|
||||
- outp = out;
|
||||
-
|
||||
- r = iconv (ic, (char **) &inp, &inlen, &outp, &outlen);
|
||||
- if (r == (size_t) -1) {
|
||||
- if (errno == E2BIG) {
|
||||
- err = errno;
|
||||
- prev = outalloc;
|
||||
- /* Try again with a larger output buffer. */
|
||||
- free (out);
|
||||
- outalloc *= 2;
|
||||
- if (outalloc < prev) {
|
||||
- iconv_close (ic);
|
||||
- errno = err;
|
||||
- return NULL;
|
||||
- }
|
||||
- goto again;
|
||||
- }
|
||||
- else {
|
||||
- /* Else some other conversion failure, eg. EILSEQ, EINVAL. */
|
||||
- err = errno;
|
||||
- iconv_close (ic);
|
||||
- free (out);
|
||||
- errno = err;
|
||||
- return NULL;
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- *outp = '\0';
|
||||
- iconv_close (ic);
|
||||
-
|
||||
- return out;
|
||||
-}
|
||||
Index: libguestfs-1.43.1/common/utils/utils.c
|
||||
===================================================================
|
||||
--- libguestfs-1.43.1.orig/common/utils/utils.c
|
||||
+++ libguestfs-1.43.1/common/utils/utils.c
|
||||
@@ -35,6 +35,7 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
#include <libintl.h>
|
||||
+#include <iconv.h>
|
||||
|
||||
/* NB: MUST NOT require linking to gnulib, because that will break the
|
||||
* Python 'sdist' which includes a copy of this file. It's OK to
|
||||
@@ -640,3 +641,66 @@ guestfs_int_hexdump (const void *data, s
|
||||
fprintf (fp, "|\n");
|
||||
}
|
||||
}
|
||||
+
|
||||
+/* Would be const, but the interface to iconv is not const-correct on
|
||||
+ * all platforms. The input string is not touched.
|
||||
+ */
|
||||
+char *
|
||||
+guestfs_int_string_to_utf8 (/* const */ char *input, const char *encoding)
|
||||
+{
|
||||
+ iconv_t ic;
|
||||
+ size_t len, inlen, outlen, outalloc, r, prev;
|
||||
+ int err;
|
||||
+ char *out, *inp, *outp;
|
||||
+
|
||||
+ /* Convert from input encoding to UTF-8. */
|
||||
+ ic = iconv_open ("UTF-8", encoding);
|
||||
+ if (ic == (iconv_t) -1)
|
||||
+ return NULL;
|
||||
+
|
||||
+ len = strlen (input);
|
||||
+ outalloc = len; /* Initial guess. */
|
||||
+
|
||||
+ again:
|
||||
+ inlen = len;
|
||||
+ outlen = outalloc;
|
||||
+ out = malloc (outlen + 1);
|
||||
+ if (out == NULL) {
|
||||
+ err = errno;
|
||||
+ iconv_close (ic);
|
||||
+ errno = err;
|
||||
+ return NULL;
|
||||
+ }
|
||||
+ inp = input;
|
||||
+ outp = out;
|
||||
+
|
||||
+ r = iconv (ic, (char **) &inp, &inlen, &outp, &outlen);
|
||||
+ if (r == (size_t) -1) {
|
||||
+ if (errno == E2BIG) {
|
||||
+ err = errno;
|
||||
+ prev = outalloc;
|
||||
+ /* Try again with a larger output buffer. */
|
||||
+ free (out);
|
||||
+ outalloc *= 2;
|
||||
+ if (outalloc < prev) {
|
||||
+ iconv_close (ic);
|
||||
+ errno = err;
|
||||
+ return NULL;
|
||||
+ }
|
||||
+ goto again;
|
||||
+ }
|
||||
+ else {
|
||||
+ /* Else some other conversion failure, eg. EILSEQ, EINVAL. */
|
||||
+ err = errno;
|
||||
+ iconv_close (ic);
|
||||
+ free (out);
|
||||
+ errno = err;
|
||||
+ return NULL;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ *outp = '\0';
|
||||
+ iconv_close (ic);
|
||||
+
|
||||
+ return out;
|
||||
+}
|
129
0003-inspector-rpm-summary-and-description-may-not-be-utf.patch
Normal file
129
0003-inspector-rpm-summary-and-description-may-not-be-utf.patch
Normal file
@ -0,0 +1,129 @@
|
||||
From 2a20ad737e4682b9f304b6c3ba6116f4cc195541 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?C=C3=A9dric=20Bosdonnat?= <cbosdonnat@suse.com>
|
||||
Date: Wed, 14 Feb 2018 10:21:42 +0100
|
||||
Subject: [PATCH 3/3] inspector: rpm summary and description may not be utf-8
|
||||
|
||||
The application inspection code assumes the data in the RPM database
|
||||
are encoded in UTF-8. However this is not always the case.
|
||||
|
||||
As a basic workaround, try to parse the string to UTF-8 and if that
|
||||
fails, try converting it from latin-1.
|
||||
---
|
||||
inspector/expected-fedora.img.xml | 4 ++++
|
||||
lib/inspect-apps.c | 30 +++++++++++++++++++++++----
|
||||
test-data/phony-guests/fedora-packages.db.txt | 4 ++--
|
||||
3 files changed, 32 insertions(+), 6 deletions(-)
|
||||
|
||||
Index: libguestfs-1.42.0/inspector/expected-fedora.img.xml
|
||||
===================================================================
|
||||
--- libguestfs-1.42.0.orig/inspector/expected-fedora.img.xml
|
||||
+++ libguestfs-1.42.0/inspector/expected-fedora.img.xml
|
||||
@@ -34,12 +34,16 @@
|
||||
<version>1.0</version>
|
||||
<release>1.fc14</release>
|
||||
<arch>x86_64</arch>
|
||||
+ <summary>summary with ö</summary>
|
||||
+ <description>description with ö</description>
|
||||
</application>
|
||||
<application>
|
||||
<name>test2</name>
|
||||
<version>2.0</version>
|
||||
<release>2.fc14</release>
|
||||
<arch>x86_64</arch>
|
||||
+ <summary>summary with ö</summary>
|
||||
+ <description>description with ö</description>
|
||||
</application>
|
||||
<application>
|
||||
<name>test3</name>
|
||||
Index: libguestfs-1.42.0/lib/inspect-apps.c
|
||||
===================================================================
|
||||
--- libguestfs-1.42.0.orig/lib/inspect-apps.c
|
||||
+++ libguestfs-1.42.0/lib/inspect-apps.c
|
||||
@@ -22,6 +22,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
+#include <iconv.h>
|
||||
|
||||
#ifdef HAVE_ENDIAN_H
|
||||
#include <endian.h>
|
||||
@@ -43,6 +44,7 @@
|
||||
#include "guestfs.h"
|
||||
#include "guestfs-internal.h"
|
||||
#include "guestfs-internal-actions.h"
|
||||
+#include "guestfs-utils.h"
|
||||
#include "structs-cleanups.h"
|
||||
|
||||
/* Some limits on what the inspection code will read, for safety. */
|
||||
@@ -266,7 +268,7 @@ get_rpm_header_tag (guestfs_h *g, const
|
||||
/* This function parses the RPM header structure to pull out various
|
||||
* tag strings (version, release, arch, etc.). For more detail on the
|
||||
* header format, see:
|
||||
- * http://www.rpm.org/max-rpm/s1-rpm-file-format-rpm-file-format.html#S2-RPM-FILE-FORMAT-HEADER
|
||||
+ * http://rpm.org/devel_doc/file_format.html#24-header-format
|
||||
*/
|
||||
|
||||
/* The minimum header size that makes sense here is 24 bytes. Four
|
||||
@@ -316,6 +318,20 @@ struct read_package_data {
|
||||
struct guestfs_application2_list *apps;
|
||||
};
|
||||
|
||||
+static char *
|
||||
+to_utf8 (guestfs_h *g, char *input)
|
||||
+{
|
||||
+ char *out = NULL;
|
||||
+
|
||||
+ out = guestfs_int_string_to_utf8 (input, "UTF-8");
|
||||
+ if (!out) {
|
||||
+ out = guestfs_int_string_to_utf8 (input, "ISO-8859-1");
|
||||
+ perrorf (g, "Not an UTF-8 or latin-1 string: '%s'", input);
|
||||
+ }
|
||||
+
|
||||
+ return out;
|
||||
+}
|
||||
+
|
||||
static int
|
||||
read_package (guestfs_h *g,
|
||||
const unsigned char *key, size_t keylen,
|
||||
@@ -326,7 +342,7 @@ read_package (guestfs_h *g,
|
||||
struct rpm_name nkey, *entry;
|
||||
CLEANUP_FREE char *version = NULL, *release = NULL,
|
||||
*epoch_str = NULL, *arch = NULL, *url = NULL, *summary = NULL,
|
||||
- *description = NULL;
|
||||
+ *description = NULL, *summary_raw = NULL, *description_raw = NULL;
|
||||
int32_t epoch;
|
||||
|
||||
/* This function reads one (key, value) pair from the Packages
|
||||
@@ -357,8 +373,14 @@ read_package (guestfs_h *g,
|
||||
epoch_str = get_rpm_header_tag (g, value, valuelen, RPMTAG_EPOCH, 'i');
|
||||
arch = get_rpm_header_tag (g, value, valuelen, RPMTAG_ARCH, 's');
|
||||
url = get_rpm_header_tag (g, value, valuelen, RPMTAG_URL, 's');
|
||||
- summary = get_rpm_header_tag (g, value, valuelen, RPMTAG_SUMMARY, 's');
|
||||
- description = get_rpm_header_tag (g, value, valuelen, RPMTAG_DESCRIPTION, 's');
|
||||
+ summary_raw = get_rpm_header_tag (g, value, valuelen, RPMTAG_SUMMARY, 's');
|
||||
+ description_raw = get_rpm_header_tag (g, value, valuelen, RPMTAG_DESCRIPTION, 's');
|
||||
+
|
||||
+ /* Try (not too hard) to get UTF-8 */
|
||||
+ if (summary_raw)
|
||||
+ summary = to_utf8 (g, summary_raw);
|
||||
+ if (description_raw)
|
||||
+ description = to_utf8 (g, description_raw);
|
||||
|
||||
/* The epoch is stored as big-endian integer. */
|
||||
if (epoch_str)
|
||||
Index: libguestfs-1.42.0/test-data/phony-guests/fedora-packages.db.txt
|
||||
===================================================================
|
||||
--- libguestfs-1.42.0.orig/test-data/phony-guests/fedora-packages.db.txt
|
||||
+++ libguestfs-1.42.0/test-data/phony-guests/fedora-packages.db.txt
|
||||
@@ -5,9 +5,9 @@ h_nelem=3
|
||||
db_pagesize=4096
|
||||
HEADER=END
|
||||
\01\00\00\00
|
||||
- \00\00\00\03\00\00\00\11\00\00\03\e9\00\00\00\00\00\00\00\00\00\00\00\00\00\00\03\ea\00\00\00\00\00\00\00\04\00\00\00\00\00\00\03\fe\00\00\00\00\00\00\00\0b\00\00\00\001.0\001.fc14\00x86_64\00
|
||||
+ \00\00\00\05\00\00\00\33\00\00\03\e9\00\00\00\00\00\00\00\00\00\00\00\00\00\00\03\ea\00\00\00\00\00\00\00\04\00\00\00\00\00\00\03\fe\00\00\00\00\00\00\00\0b\00\00\00\00\00\00\03\ec\00\00\00\00\00\00\00\12\00\00\00\00\00\00\03\ed\00\00\00\00\00\00\00\21\00\00\00\001.0\001.fc14\00x86_64\00summary with \f6\00description with \f6\00
|
||||
\02\00\00\00
|
||||
- \00\00\00\03\00\00\00\11\00\00\03\e9\00\00\00\00\00\00\00\00\00\00\00\00\00\00\03\ea\00\00\00\00\00\00\00\04\00\00\00\00\00\00\03\fe\00\00\00\00\00\00\00\0b\00\00\00\002.0\002.fc14\00x86_64\00
|
||||
+ \00\00\00\05\00\00\00\35\00\00\03\e9\00\00\00\00\00\00\00\00\00\00\00\00\00\00\03\ea\00\00\00\00\00\00\00\04\00\00\00\00\00\00\03\fe\00\00\00\00\00\00\00\0b\00\00\00\00\00\00\03\ec\00\00\00\00\00\00\00\12\00\00\00\00\00\00\03\ed\00\00\00\00\00\00\00\22\00\00\00\002.0\002.fc14\00x86_64\00summary with \c3\b6\00description with \c3\b6\00
|
||||
\03\00\00\00
|
||||
\00\00\00\03\00\00\00\11\00\00\03\e9\00\00\00\00\00\00\00\00\00\00\00\00\00\00\03\ea\00\00\00\00\00\00\00\04\00\00\00\00\00\00\03\fe\00\00\00\00\00\00\00\0b\00\00\00\003.0\003.fc14\00x86_64\00
|
||||
DATA=END
|
42
489b14b7-ocaml-examples-Link-examples-to-gnulib.patch
Normal file
42
489b14b7-ocaml-examples-Link-examples-to-gnulib.patch
Normal file
@ -0,0 +1,42 @@
|
||||
Subject: ocaml/examples: Link examples to gnulib
|
||||
From: Richard W.M. Jones rjones@redhat.com Sat Sep 11 09:36:08 2021 +0100
|
||||
Date: Sat Sep 11 09:36:08 2021 +0100:
|
||||
Git: 489b14b75e5f30010d8a8c8d3a10ecc52b629563
|
||||
|
||||
It's unclear why exactly the OCaml library is using replacement
|
||||
symbols, but it is so we need gnulib. Note this only applies in the
|
||||
stable-1.44 branch since upstream we have finally got rid of gnulib,
|
||||
because of exactly these kinds of problems that it causes everyone.
|
||||
|
||||
ocamlfind ocamlopt -cclib -L../../lib/.libs -package unix -linkpkg \
|
||||
-warn-error A -I .. mlguestfs.cmxa create_disk.ml -o create_disk
|
||||
../libmlguestfs.a(libguestfsocaml_a-guestfs-c.o): In function `guestfs_finalize':
|
||||
/home/rjones/d/libguestfs-1.44/ocaml/guestfs-c.c:86: undefined reference to `rpl_free'
|
||||
/home/rjones/d/libguestfs-1.44/ocaml/guestfs-c.c:88: undefined reference to `rpl_free'
|
||||
../libmlguestfs.a(libguestfsocaml_a-guestfs-c.o): In function `guestfs_int_ocaml_set_event_callback':
|
||||
/home/rjones/d/libguestfs-1.44/ocaml/guestfs-c.c:239: undefined reference to `rpl_free'
|
||||
../libmlguestfs.a(libguestfsocaml_a-guestfs-c.o): In function `guestfs_int_ocaml_delete_event_callback':
|
||||
/home/rjones/d/libguestfs-1.44/ocaml/guestfs-c.c:266: undefined reference to `rpl_free'
|
||||
../libmlguestfs.a(libguestfsocaml_a-guestfs-c.o): In function `guestfs_int_ocaml_event_to_string':
|
||||
/home/rjones/d/libguestfs-1.44/ocaml/guestfs-c.c:290: undefined reference to `rpl_free'
|
||||
../libmlguestfs.a(libguestfsocaml_a-guestfs-c-actions.o):/home/rjones/d/libguestfs-1.44/ocaml/guestfs-c-actions.c:1188: more undefined references to `rpl_free' follow
|
||||
collect2: error: ld returned 1 exit status
|
||||
File "caml_startup", line 1:
|
||||
Error: Error during linking
|
||||
make[2]: *** [Makefile:2272: create_disk] Error 2
|
||||
|
||||
diff --git a/ocaml/examples/Makefile.am b/ocaml/examples/Makefile.am
|
||||
index 19cbebdf9..d8c3dd4c5 100644
|
||||
--- a/ocaml/examples/Makefile.am
|
||||
+++ b/ocaml/examples/Makefile.am
|
||||
@@ -48,7 +48,9 @@ if HAVE_OCAML
|
||||
|
||||
noinst_SCRIPTS = create_disk debug_logging inspect_vm
|
||||
|
||||
-OCAMLFINDFLAGS = -cclib -L$(top_builddir)/lib/.libs
|
||||
+OCAMLFINDFLAGS = \
|
||||
+ -cclib -L$(top_builddir)/lib/.libs \
|
||||
+ -cclib -L$(top_builddir)/gnulib/lib/.libs -cclib -lgnu
|
||||
|
||||
if HAVE_OCAMLOPT
|
||||
create_disk: create_disk.ml
|
@ -0,0 +1,27 @@
|
||||
Subject: m4/guestfs-ocaml.m4: Fix deprecated warning format
|
||||
From: Richard W.M. Jones rjones@redhat.com Tue Oct 5 20:51:19 2021 +0100
|
||||
Date: Tue Oct 5 21:08:07 2021 +0100:
|
||||
Git: 63c9cd933af75ca759fa2f2bbdbb07a699df5b30
|
||||
|
||||
In OCaml 4.13:
|
||||
|
||||
Alert ocaml_deprecated_cli: Setting a warning with a sequence of lowercase or uppercase letters,
|
||||
like 'CDEFLMPSUVYZX', is deprecated.
|
||||
Use the equivalent signed form: +C+D+E+F+L+M+P+S+U+V+Y+Z+X+52-3.
|
||||
|
||||
(cherry picked from
|
||||
guestfs-tools commit fa4f59e1d99c08d7e0bae2a7cb54f254a6506d67)
|
||||
|
||||
diff --git a/m4/guestfs-ocaml.m4 b/m4/guestfs-ocaml.m4
|
||||
index 4b8a44dee..d7f9462ea 100644
|
||||
--- a/m4/guestfs-ocaml.m4
|
||||
+++ b/m4/guestfs-ocaml.m4
|
||||
@@ -232,7 +232,7 @@ EOF
|
||||
])
|
||||
|
||||
dnl Flags we want to pass to every OCaml compiler call.
|
||||
-OCAML_WARN_ERROR="-warn-error CDEFLMPSUVYZX+52-3"
|
||||
+OCAML_WARN_ERROR="-warn-error +C+D+E+F+L+M+P+S+U+V+Y+Z+X+52-3"
|
||||
AC_SUBST([OCAML_WARN_ERROR])
|
||||
OCAML_FLAGS="-g -annot $safe_string_option"
|
||||
AC_SUBST([OCAML_FLAGS])
|
@ -0,0 +1,55 @@
|
||||
Subject: customize, resize, sparsify, sysprep: Link explicitly with pthread
|
||||
From: Richard W.M. Jones rjones@redhat.com Thu Mar 4 11:57:44 2021 +0000
|
||||
Date: Sat Sep 11 09:42:12 2021 +0100:
|
||||
Git: 68a02c2f6c7b4243ecb298c0d9539f0fc51a52ce
|
||||
|
||||
Cherry picked from guestfs-tools commit 87543dad61.
|
||||
|
||||
diff --git a/customize/Makefile.am b/customize/Makefile.am
|
||||
index c926687b3..fb418d7bf 100644
|
||||
--- a/customize/Makefile.am
|
||||
+++ b/customize/Makefile.am
|
||||
@@ -169,6 +169,7 @@ OCAMLLINKFLAGS = \
|
||||
$(LINK_CUSTOM_OCAMLC_ONLY)
|
||||
|
||||
OCAMLCLIBS = \
|
||||
+ -pthread -lpthread \
|
||||
-lutils \
|
||||
$(LIBTINFO_LIBS) \
|
||||
$(LIBCRYPT_LIBS) \
|
||||
diff --git a/resize/Makefile.am b/resize/Makefile.am
|
||||
index fa88cc634..936d2b05e 100644
|
||||
--- a/resize/Makefile.am
|
||||
+++ b/resize/Makefile.am
|
||||
@@ -72,6 +72,7 @@ OCAMLPACKAGES += -package gettext-stub
|
||||
endif
|
||||
|
||||
OCAMLCLIBS = \
|
||||
+ -pthread -lpthread \
|
||||
-lprogress \
|
||||
-lutils \
|
||||
$(LIBTINFO_LIBS) \
|
||||
diff --git a/sparsify/Makefile.am b/sparsify/Makefile.am
|
||||
index fa964e8af..4d1af85d6 100644
|
||||
--- a/sparsify/Makefile.am
|
||||
+++ b/sparsify/Makefile.am
|
||||
@@ -80,6 +80,7 @@ OCAMLPACKAGES += -package gettext-stub
|
||||
endif
|
||||
|
||||
OCAMLCLIBS = \
|
||||
+ -pthread -lpthread \
|
||||
-lprogress \
|
||||
-lutils \
|
||||
$(LIBTINFO_LIBS) \
|
||||
diff --git a/sysprep/Makefile.am b/sysprep/Makefile.am
|
||||
index 69bb92820..250c74913 100644
|
||||
--- a/sysprep/Makefile.am
|
||||
+++ b/sysprep/Makefile.am
|
||||
@@ -129,6 +129,7 @@ OCAMLPACKAGES += -package gettext-stub
|
||||
endif
|
||||
|
||||
OCAMLCLIBS = \
|
||||
+ -pthread -lpthread \
|
||||
-lvisit \
|
||||
-lstructs \
|
||||
-lutils \
|
@ -0,0 +1,31 @@
|
||||
Subject: appliance: enable bash's Process Substitution feature
|
||||
From: Olaf Hering olaf@aepfle.de Wed Sep 15 12:20:42 2021 +0200
|
||||
Date: Wed Sep 15 12:37:08 2021 +0100:
|
||||
Git: 9db0c98c99090e601d856c6795544f6967e6155f
|
||||
|
||||
bash can read input from a spawned process, and even provide input to
|
||||
such process. This feature relies on /dev/fd/ being present. In the
|
||||
past udev silently created this symlink, so this bash feature worked
|
||||
more or less by accident. With recent systemd versions, such as 246
|
||||
which is included in Leap 15.3, the symlink is not created anymore. As
|
||||
a result scripts, such as /sbin/dhclient-script, fail to work
|
||||
properly.
|
||||
|
||||
This symlink should have been created in version 1 of this variant of /init.
|
||||
|
||||
https://bugzilla.opensuse.org/show_bug.cgi?id=1190501
|
||||
|
||||
Signed-off-by: Olaf Hering <olaf@aepfle.de>
|
||||
|
||||
diff --git a/appliance/init b/appliance/init
|
||||
index b1c4d09ea..cdc39c3b9 100755
|
||||
--- a/appliance/init
|
||||
+++ b/appliance/init
|
||||
@@ -72,6 +72,7 @@ fi
|
||||
|
||||
# devtmpfs is required since udev 176
|
||||
mount -t devtmpfs /dev /dev
|
||||
+ln -s /proc/self/fd /dev/fd
|
||||
mkdir -p /dev/pts
|
||||
mount -t devpts /dev/pts /dev/pts
|
||||
mkdir -p /dev/shm
|
3
Pod-Simple-3.23.tar.xz
Normal file
3
Pod-Simple-3.23.tar.xz
Normal file
@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:fab3872d3f424cec65995cf5decda99cb04f85aae654b1e199ec659bdbef0ab0
|
||||
size 185608
|
23
a4930f5f-customize-Suppress-OCaml-warning.patch
Normal file
23
a4930f5f-customize-Suppress-OCaml-warning.patch
Normal file
@ -0,0 +1,23 @@
|
||||
Subject: customize: Suppress OCaml warning
|
||||
From: Richard W.M. Jones rjones@redhat.com Tue Oct 5 20:53:25 2021 +0100
|
||||
Date: Tue Oct 5 20:53:25 2021 +0100:
|
||||
Git: a4930f5fad82e5358d565b8cf3610970e9646259
|
||||
|
||||
In OCaml 4.13:
|
||||
|
||||
File "perl_edit.ml", line 30, characters 2-13:
|
||||
30 | c_edit_file (verbose ()) g (Guestfs.c_pointer g) file expr
|
||||
^^^^^^^^^^^
|
||||
Error (warning 6 [labels-omitted]): label verbose was omitted in the application of this function.
|
||||
|
||||
--- a/m4/guestfs-ocaml.m4
|
||||
+++ b/m4/guestfs-ocaml.m4
|
||||
@@ -232,7 +232,7 @@ EOF
|
||||
])
|
||||
|
||||
dnl Flags we want to pass to every OCaml compiler call.
|
||||
-OCAML_WARN_ERROR="-warn-error +C+D+E+F+L+M+P+S+U+V+Y+Z+X+52-3"
|
||||
+OCAML_WARN_ERROR="-warn-error +C+D+E+F+L+M+P+S+U+V+Y+Z+X+52-3-6"
|
||||
AC_SUBST([OCAML_WARN_ERROR])
|
||||
OCAML_FLAGS="-g -annot $safe_string_option"
|
||||
AC_SUBST([OCAML_FLAGS])
|
26
appliance.patch
Normal file
26
appliance.patch
Normal file
@ -0,0 +1,26 @@
|
||||
Index: libguestfs-1.44.2/appliance/init
|
||||
===================================================================
|
||||
--- libguestfs-1.44.2.orig/appliance/init
|
||||
+++ libguestfs-1.44.2/appliance/init
|
||||
@@ -122,8 +122,10 @@ if test "$guestfs_network" = 1; then
|
||||
rm -f /etc/dhcp/dhclient-enter-hooks.d/resolved
|
||||
if dhclient --version >/dev/null 2>&1; then
|
||||
dhclient $iface
|
||||
- else
|
||||
+ elif dhcpcd --version ; then
|
||||
dhcpcd $iface
|
||||
+ elif busybox udhcpc --help ; then
|
||||
+ busybox udhcpc --quit -v
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -240,7 +242,8 @@ else
|
||||
echo "Note: The contents of / (root) are the rescue appliance."
|
||||
if ! test -d "/sysroot/dev"; then
|
||||
echo "You have to mount the guest’s partitions under /sysroot"
|
||||
- echo "before you can examine them."
|
||||
+ echo "before you can examine them. A helper script for that exists:"
|
||||
+ echo "mount-rootfs-and-chroot.sh /dev/sda2"
|
||||
else
|
||||
echo "Use 'cd /sysroot' or 'chroot /sysroot' to see guest filesystems."
|
||||
fi
|
29
c0de4de9-appliance-add-reboot-and-netconfig-for-SUSE.patch
Normal file
29
c0de4de9-appliance-add-reboot-and-netconfig-for-SUSE.patch
Normal file
@ -0,0 +1,29 @@
|
||||
Subject: appliance: add reboot and netconfig for SUSE
|
||||
From: Olaf Hering olaf@aepfle.de Tue Sep 14 17:57:43 2021 +0200
|
||||
Date: Tue Sep 14 20:49:02 2021 +0100:
|
||||
Git: c0de4de9029c3e483f738a0f80a2c5066c6532db
|
||||
|
||||
systemd-sysvinit contains the reboot command, which is used to
|
||||
properly stop the VM. This was required by other packages, and as a
|
||||
result always available. Since Leap 15.3 it will not be installed, and
|
||||
as a result the VM will just panic because /init died.
|
||||
|
||||
If the appliance is started with --network, dhclient will run
|
||||
/usr/sbin/dhclient-script, which in turn may call /sbin/netconfig to
|
||||
update /etc/resolv.conf. Install sysconfig-netconfig to make sure DNS
|
||||
resolving actually works.
|
||||
|
||||
Signed-off-by: Olaf Hering <olaf@aepfle.de>
|
||||
|
||||
--- a/appliance/packagelist.in
|
||||
+++ b/appliance/packagelist.in
|
||||
@@ -133,7 +133,9 @@ ifelse(SUSE,1,
|
||||
ntfs-3g
|
||||
reiserfs
|
||||
squashfs
|
||||
+ sysconfig-netconfig
|
||||
systemd
|
||||
+ systemd-sysvinit
|
||||
vim
|
||||
xz
|
||||
)
|
26
e26cfa44-daemon-Build-with--pthread.patch
Normal file
26
e26cfa44-daemon-Build-with--pthread.patch
Normal file
@ -0,0 +1,26 @@
|
||||
Subject: daemon: Build with -pthread
|
||||
From: Richard W.M. Jones rjones@redhat.com Sat Sep 11 09:27:17 2021 +0100
|
||||
Date: Sat Sep 11 09:27:17 2021 +0100:
|
||||
Git: e26cfa445a1947503a03c55d8d65263530747062
|
||||
|
||||
The daemon failed to link with glibc < 2.34 because we didn't include
|
||||
the separate pthread library. Adding -pthread fixes this.
|
||||
|
||||
Note this change was also make upstream in commit 733d2182b6 ("Remove
|
||||
the tools.") although I think either by accident or unrelated.
|
||||
|
||||
Reported-by: Toolybird
|
||||
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2003326
|
||||
|
||||
diff --git a/daemon/Makefile.am b/daemon/Makefile.am
|
||||
index 86aa920e8..b670bb1e2 100644
|
||||
--- a/daemon/Makefile.am
|
||||
+++ b/daemon/Makefile.am
|
||||
@@ -255,6 +255,7 @@ guestfsd_CPPFLAGS = \
|
||||
-I$(top_srcdir)/common/utils \
|
||||
-I$(top_builddir)/common/utils
|
||||
guestfsd_CFLAGS = \
|
||||
+ -pthread \
|
||||
$(WARN_CFLAGS) $(WERROR_CFLAGS) \
|
||||
$(RPC_CFLAGS) \
|
||||
$(AUGEAS_CFLAGS) \
|
@ -0,0 +1,77 @@
|
||||
Subject: appliance: reorder mounting of special filesystems in init
|
||||
From: Olaf Hering olaf@aepfle.de Wed Sep 15 12:58:23 2021 +0200
|
||||
Date: Wed Sep 15 12:37:08 2021 +0100:
|
||||
Git: f47e0bb6725434778384cf79ba3b08610f8c3796
|
||||
|
||||
Make sure proc and dev are available early.
|
||||
No change in behavior intended.
|
||||
|
||||
Signed-off-by: Olaf Hering <olaf@aepfle.de>
|
||||
|
||||
diff --git a/appliance/init b/appliance/init
|
||||
index cdc39c3b9..7076821d2 100755
|
||||
--- a/appliance/init
|
||||
+++ b/appliance/init
|
||||
@@ -27,12 +27,12 @@ for d in /lib64 /lib; do
|
||||
fi
|
||||
done
|
||||
|
||||
-mkdir -p /sysroot
|
||||
-
|
||||
-# Mount /proc.
|
||||
-if [ ! -d /proc ]; then rm -f /proc; fi
|
||||
-mkdir -p /proc
|
||||
+mkdir -p /proc /sys
|
||||
mount -t proc /proc /proc
|
||||
+mount -t sysfs /sys /sys
|
||||
+# devtmpfs is required since udev 176
|
||||
+mount -t devtmpfs /dev /dev
|
||||
+ln -s /proc/self/fd /dev/fd
|
||||
|
||||
# Parse the kernel command line early (must be after /proc is mounted).
|
||||
cmdline=$(</proc/cmdline)
|
||||
@@ -54,34 +54,28 @@ if [[ $cmdline == *guestfs_boot_analysis=1* ]]; then
|
||||
guestfs_boot_analysis=1
|
||||
fi
|
||||
|
||||
-# Mount the other special filesystems.
|
||||
-if [ ! -d /sys ]; then rm -f /sys; fi
|
||||
-mkdir -p /sys
|
||||
-mount -t sysfs /sys /sys
|
||||
+mkdir -p /dev/pts /dev/shm
|
||||
+mount -t devpts /dev/pts /dev/pts
|
||||
+mount -t tmpfs -o mode=1777 shmfs /dev/shm
|
||||
+
|
||||
+mkdir -p /sysroot
|
||||
+
|
||||
# taken from initramfs-tools/init --Hilko Bengen
|
||||
mkdir -p /run
|
||||
mount -t tmpfs -o "nosuid,size=20%,mode=0755" tmpfs /run
|
||||
mkdir -p /run/lock
|
||||
ln -s ../run/lock /var/lock
|
||||
|
||||
+if [[ $cmdline == *selinux=1* ]]; then
|
||||
+ mount -t selinuxfs none /sys/fs/selinux
|
||||
+fi
|
||||
+
|
||||
# On Fedora 23, util-linux creates /etc/mtab in %post .. stupid
|
||||
# and e2fsprogs fails if the link doesn't exist .. stupid stupid
|
||||
if ! test -e /etc/mtab; then
|
||||
ln -s /proc/mounts /etc/mtab
|
||||
fi
|
||||
|
||||
-# devtmpfs is required since udev 176
|
||||
-mount -t devtmpfs /dev /dev
|
||||
-ln -s /proc/self/fd /dev/fd
|
||||
-mkdir -p /dev/pts
|
||||
-mount -t devpts /dev/pts /dev/pts
|
||||
-mkdir -p /dev/shm
|
||||
-mount -t tmpfs -o mode=1777 shmfs /dev/shm
|
||||
-
|
||||
-if [[ $cmdline == *selinux=1* ]]; then
|
||||
- mount -t selinuxfs none /sys/fs/selinux
|
||||
-fi
|
||||
-
|
||||
# Static nodes must happen before udev is started.
|
||||
|
||||
# Set up kmod static-nodes (RHBZ#1011907).
|
@ -1,6 +0,0 @@
|
||||
# Guestfish colour prompts. See PROMPT in guestfish(1).
|
||||
GUESTFISH_PS1='\[\e[1;32m\]><fs>\[\e[0;31m\] '
|
||||
GUESTFISH_OUTPUT='\e[0m'
|
||||
GUESTFISH_RESTORE="$GUESTFISH_OUTPUT"
|
||||
GUESTFISH_INIT='\e[1;34m'
|
||||
export GUESTFISH_PS1 GUESTFISH_OUTPUT GUESTFISH_RESTORE GUESTFISH_INIT
|
3
libguestfs-1.44.2.tar.gz
Normal file
3
libguestfs-1.44.2.tar.gz
Normal file
@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:6ea0cd73eb6e5186b14ae48139f16f8701866ad8fb4954dea9c3e4aaa79a1bb9
|
||||
size 23854577
|
17
libguestfs-1.44.2.tar.gz.sig
Normal file
17
libguestfs-1.44.2.tar.gz.sig
Normal file
@ -0,0 +1,17 @@
|
||||
-----BEGIN PGP SIGNATURE-----
|
||||
|
||||
iQJFBAABCAAvFiEE93dPsa0HSn6Mh2fqkXOPc+G3aKAFAmE3zKERHHJpY2hAYW5u
|
||||
ZXhpYS5vcmcACgkQkXOPc+G3aKBGyRAAiV+CFfaAi06iqJ6H9YTfNOB/wK6XPPmu
|
||||
DG+sLCXBVR/YYe93Myt/T+6+6U9Ue7d1BTGQ6UhHc/E8IbnFPWNi/8tdQSL9W+Nm
|
||||
KEkfZNDROnnO1vHX8nR/rAuwdcDCHZR5suh58K8TvY/1+i362zNFxY/YMFujExK5
|
||||
z4kCcP9GjEECoPgvu/RtOJm9YrRdbF0QzF9Fu7ZqhQFbaMkCJg9IDB/mSz5t/mWE
|
||||
e08rHqwqYsygBCfHCX9lALhNWQO0x/WX2QZrgbcIgMijgWrmTq5czTwkWGPG/CMO
|
||||
+8tkyF6r1HKHtpz1UsIXsHflOCVk0f0twTncYYltifecZq2sR9UODLBgRPMaTSYa
|
||||
TLz2jcuSd98yFmkSORr8JNIOGyX8jatFLQT85PqsDZ7MIIilMTT27rYQkY5/EJcN
|
||||
Yetn3mc+hsbXYjk/eCeZvPVnkD98JQaOlW3+lybTkdS9HWNc3lzaS1M64OSYOzMo
|
||||
PQL9OAm+ScLzQvvefCKGcLVUGoRvmcabvkg8buYRZb2WuM2uY+xHsLWGWLROxAwa
|
||||
cI9N+bvD1qyDoze3yjti0WWwBDxCYG/Wz/bJpuwawDx60VEyFUARyk4182nCz2E/
|
||||
PE+t2z0xLYsbj3bT1grI+Ay8EJEP0u6R88PO7CW7l2jZUYpZNHyFlOCgyG3nB1LF
|
||||
u4tbE+OLPyA=
|
||||
=06k/
|
||||
-----END PGP SIGNATURE-----
|
@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:fe1f6318a4166e6201268a8ceda331433ab7bf91ede9766d04ab30165c534f9e
|
||||
size 18505340
|
@ -1,17 +0,0 @@
|
||||
-----BEGIN PGP SIGNATURE-----
|
||||
|
||||
iQJFBAABCAAvFiEE93dPsa0HSn6Mh2fqkXOPc+G3aKAFAmGyO9wRHHJpY2hAYW5u
|
||||
ZXhpYS5vcmcACgkQkXOPc+G3aKBl+RAAoxqpUWTEiXxwyWWhW0IotI5xyEdyrkL6
|
||||
+po1pqtEXzcFeCHX+lB86C9nkolmFEDfz1wnlNVbz1La35Zdkw1gCD96Fx3/s4xl
|
||||
s7pZ9073FauSo4IjseWAPcFj3SF4aEeK8xvpOQaq+rcA3Zmg5vZJCqW0xnEGqeCO
|
||||
UTgmKPgmg2NJaUnUq7TRI8AxNDElD+MetV+olywjJG2QETSFP65ZwdppT8fUZvl/
|
||||
W4s38gvHAGLQgKZL7MudQXTDUkGD7rThr3IKGQP8UJGr+IpR4MxxkkDAndeb37ps
|
||||
6b+s3popuJRwXaSw7gPPGut5jfdJNBJ5KIYqxxWu+fmRTkXD+qoDR1AuJLZlCO7E
|
||||
Yp9X9rTZh55wZk8NetG0XNDkyoBqJoBkoL3h5wvHOTOoYX4KfjL5YxHbjuhMJ3O1
|
||||
O0JiwtrqmkQ3c4HzmMJEBctj3ZuhdL5d+MJH7VtTjKy95FJlmEGPRa1DYoaeW6lv
|
||||
tVE/zEv6dsy1dpzVgMM/lugTTs2NRwNhLo843OpVCQjZfDk0fEOcWo+0sW0tca05
|
||||
EdnocDI8bAW98dLAla6RJwMvBaD6Y/RtutMDO9AY7hVFDeIc1bYBHPtvDSYwd9ul
|
||||
hB849Q3dtdEeVk3+5rsxZllXowltnfe4KxvkII4NHJVHp5uZZruHHF4pNvKmAFD1
|
||||
B9VPVX4vIgw=
|
||||
=UAq6
|
||||
-----END PGP SIGNATURE-----
|
@ -1,58 +1,9 @@
|
||||
-------------------------------------------------------------------
|
||||
Mon Dec 20 16:36:24 MST 2021 - carnold@suse.com
|
||||
Mon Feb 7 15:23:07 MST 2022 - carnold@suse.com
|
||||
|
||||
- Update to version 1.46.1
|
||||
* This release has moved many virt tools like virt-builder,
|
||||
virt-cat, virt-customize, virt-df, etc. to the guestfs-tools
|
||||
project. This makes libguestfs a bit easier to build and manage.
|
||||
* The build now uses and requires PCRE2 (instead of PCRE).
|
||||
* This version requires libvirt ≥ 7.1.0, if libvirt is enabled.
|
||||
* gnulib is no longer bundled with libguestfs, making builds from
|
||||
git much simpler.
|
||||
* Perl Sys::Virt (libvirt bindings for Perl) are no longer
|
||||
required by libguestfs.
|
||||
* The code has been compiled with both LTO and GCC -fanalyzer and
|
||||
many bugs and warnings fixed.
|
||||
* Various fixes for qemu 6.1.
|
||||
* Update appliance packages on SUSE and several other improvements
|
||||
to the init script (Olaf Hering).
|
||||
* We now use the qemu / libvirt feature -cpu max to select the
|
||||
best CPU to run the appliance.
|
||||
* When passing the appliance filesystem UUID to supermin we now
|
||||
read it directly out of the appliance instead of using the
|
||||
file(1) program. This is more reliable.
|
||||
* The qemu -enable-fips option is no longer used. It was not
|
||||
needed and has been deprecated by qemu.
|
||||
* We no longer use qemu's sga (Serial Graphics Adapter) option
|
||||
ROM, instead using the equivalent seabios feature.
|
||||
* Various bug fixes
|
||||
- Dropped scripts and patches
|
||||
Pod-Simple-3.23.tar.xz
|
||||
libguestfs.test.simple.create-opensuse-guest-crypt-on-lvm.sh
|
||||
libguestfs.test.simple.create-opensuse-guest.sh
|
||||
libguestfs.test.simple.create-sles12-guest-crypt-on-lvm.sh
|
||||
libguestfs.test.simple.create-sles12-guest.sh
|
||||
libguestfs.test.simple.run-libugestfs-test-tool.sh
|
||||
0001-Introduce-a-wrapper-around-xmlParseURI.patch
|
||||
0002-common-extract-UTF-8-conversion-function.patch
|
||||
0003-inspector-rpm-summary-and-description-may-not-be-utf.patch
|
||||
489b14b7-ocaml-examples-Link-examples-to-gnulib.patch
|
||||
63c9cd93-m4-guestfs-ocaml.m4-Fix-deprecated-warning-format.patch
|
||||
68a02c2f-customize--resize--sparsify--sysprep-Link-explicitly-with-pthread.patch
|
||||
9db0c98c-appliance-enable-bashs-Process-Substitution-feature.patch
|
||||
a4930f5f-customize-Suppress-OCaml-warning.patch
|
||||
c0de4de9-appliance-add-reboot-and-netconfig-for-SUSE.patch
|
||||
e26cfa44-daemon-Build-with--pthread.patch
|
||||
f47e0bb6-appliance-reorder-mounting-of-special-filesystems-in-init.patch
|
||||
appliance.patch
|
||||
libguestfs.env.patch
|
||||
makefile-ocaml-find-guestfs.patch
|
||||
netconfig.patch
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue Dec 14 14:14:14 UTC 2021 - ohering@suse.de
|
||||
|
||||
- Add python-rpm-macros (bsc#1180125)
|
||||
- bsc#1195415 - libguestfs: consider dropping build requirement on
|
||||
systemd-sysvinit
|
||||
libguestfs.spec
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue Oct 26 20:44:52 MDT 2021 - carnold@suse.com
|
||||
|
32
libguestfs.env.patch
Normal file
32
libguestfs.env.patch
Normal file
@ -0,0 +1,32 @@
|
||||
--- a/tools/virt-list-filesystems
|
||||
+++ b/tools/virt-list-filesystems
|
||||
@@ -1,4 +1,4 @@
|
||||
-#!/usr/bin/env perl
|
||||
+#!/usr/bin/perl
|
||||
# virt-list-filesystems
|
||||
# Copyright (C) 2009-2020 Red Hat Inc.
|
||||
#
|
||||
--- a/tools/virt-list-partitions
|
||||
+++ b/tools/virt-list-partitions
|
||||
@@ -1,4 +1,4 @@
|
||||
-#!/usr/bin/env perl
|
||||
+#!/usr/bin/perl
|
||||
# virt-list-partitions
|
||||
# Copyright (C) 2010 Red Hat Inc.
|
||||
#
|
||||
--- a/tools/virt-tar
|
||||
+++ b/tools/virt-tar
|
||||
@@ -1,4 +1,4 @@
|
||||
-#!/usr/bin/env perl
|
||||
+#!/usr/bin/perl
|
||||
# virt-tar
|
||||
# Copyright (C) 2009-2020 Red Hat Inc.
|
||||
#
|
||||
--- a/tools/virt-win-reg
|
||||
+++ b/tools/virt-win-reg
|
||||
@@ -1,4 +1,4 @@
|
||||
-#!/usr/bin/env perl
|
||||
+#!/usr/bin/perl
|
||||
# virt-win-reg
|
||||
# Copyright (C) 2010 Red Hat Inc.
|
||||
#
|
1190
libguestfs.spec
1190
libguestfs.spec
File diff suppressed because it is too large
Load Diff
333
libguestfs.test.simple.create-opensuse-guest-crypt-on-lvm.sh
Normal file
333
libguestfs.test.simple.create-opensuse-guest-crypt-on-lvm.sh
Normal file
@ -0,0 +1,333 @@
|
||||
#!/bin/bash
|
||||
# Create an openSUSE image with lvm on dm-crypt partition
|
||||
#
|
||||
# Theory of operation:
|
||||
# This script uses zypper from the host to resolve dependencies
|
||||
# for zypper which runs within the appliance. If zypper on the host
|
||||
# is too old, it will be unable to handle repo data from 13.1:
|
||||
# http://lists.opensuse.org/zypp-devel/2013-11/msg00000.html
|
||||
# "[zypp-devel] Package conflicting with itself"
|
||||
# For this reason zypper from 12.3 can be used to install the pattern
|
||||
# of the final repo.
|
||||
# First the dependencies of zypper are resolved, the required packages
|
||||
# are downloaded and extracted with unrpm. Now the guest is started and
|
||||
# the partitions in the diskimage are prepared. Then the extracted
|
||||
# package content is copied into the guest. Once that is done zypper
|
||||
# inside the guest will install the base pattern and a few extra packages.
|
||||
# Finally the bootloader grub is configured. Once all that is done
|
||||
# kvm is started. If all goes well a login prompt appears.
|
||||
# The password for the crypted partition is "123456".
|
||||
# The password for root is "root".
|
||||
# The guest has also network access to the outside.
|
||||
#
|
||||
# Expected runtime: ca. 200 seconds
|
||||
# Requires at least 1.24.5 because this includes the required crypt modules
|
||||
#
|
||||
# Expected output:
|
||||
# guest should start
|
||||
# no "obvious" errors should be shown during the disk operation
|
||||
# at the end kvm is started with the generated disk image
|
||||
# login should be possible
|
||||
#
|
||||
set -e
|
||||
unset LANG
|
||||
unset ${!LC_*}
|
||||
cpus=`grep -Ec 'cpu[0-9]' /proc/stat || echo 1`
|
||||
|
||||
output_diskimage=/dev/shm/$LOGNAME/testcase.img
|
||||
final_repo=http://download.opensuse.org/distribution/13.1/repo/oss/
|
||||
initial_repo=http://download.opensuse.org/distribution/12.3/repo/oss/
|
||||
force=false
|
||||
guest_zypper_in__pattern_name="base"
|
||||
guest_zypper_in__package_list="
|
||||
grub
|
||||
less
|
||||
master-boot-code
|
||||
nfs-utils
|
||||
parted
|
||||
vim
|
||||
"
|
||||
guest_root_password="root"
|
||||
guest_crypt_password="123456"
|
||||
diskname_inside_vm=/dev/sda
|
||||
|
||||
case "$0" in
|
||||
/*) progname="$0" ;;
|
||||
*) progname="$PWD/$0" ;;
|
||||
esac
|
||||
|
||||
_exit() {
|
||||
echo "Exiting '$0 $*'."
|
||||
exit 1
|
||||
}
|
||||
|
||||
_unrpm() {
|
||||
CPIO_OPTS="--extract --unconditional --preserve-modification-time --make-directories --extract-over-symlinks"
|
||||
FILES="$@"
|
||||
for f in $FILES; do
|
||||
echo -ne "$f:\t"
|
||||
rpm2cpio $f | cpio ${CPIO_OPTS}
|
||||
done
|
||||
}
|
||||
|
||||
until test $# -lt 1
|
||||
do
|
||||
case "$1" in
|
||||
--unrpm) shift ; _unrpm "$@" ; exit 0 ;;
|
||||
-n) diskname_inside_vm="$2" ; shift ;;
|
||||
-o) output_diskimage="$2" ; shift ;;
|
||||
-R) initial_repo="$2" ; shift ;;
|
||||
-r) final_repo="$2" ; shift ;;
|
||||
-f) force=true ;;
|
||||
-x) set -x ;;
|
||||
*) echo "Unknown option '$1'" ; exit 1 ;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
if test -z "${initial_repo}"
|
||||
then
|
||||
echo "URL to initial repo required. Wrong -R option."
|
||||
_exit
|
||||
fi
|
||||
if test -z "${final_repo}"
|
||||
then
|
||||
echo "URL to final repo required. Wrong -r option."
|
||||
_exit
|
||||
fi
|
||||
if test -z "${output_diskimage}"
|
||||
then
|
||||
echo "Filename for temporary disk image required. Wrong -o option."
|
||||
_exit
|
||||
fi
|
||||
if test -e "${output_diskimage}"
|
||||
then
|
||||
if test "${force}" = "false"
|
||||
then
|
||||
echo "Output diskimage '${output_diskimage}' exists."
|
||||
echo "It will not be overwritten. Option '-f' exists to force overwrite."
|
||||
_exit
|
||||
fi
|
||||
fi
|
||||
zypper --version
|
||||
cpio --version
|
||||
guestfish --version
|
||||
kvm="qemu-system-`uname -m`"
|
||||
if $kvm --version
|
||||
then
|
||||
: good
|
||||
else
|
||||
kvm="qemu-kvm"
|
||||
if $kvm --version
|
||||
then
|
||||
:
|
||||
else
|
||||
echo "No qemu-kvm found."
|
||||
_exit
|
||||
fi
|
||||
fi
|
||||
guestfish_version="`guestfish --version | awk '{print \$2}'`"
|
||||
case "${guestfish_version}" in
|
||||
1.20*) _exit ;;
|
||||
1.21*) _exit ;;
|
||||
1.22*) _exit ;;
|
||||
1.23*) _exit ;;
|
||||
1.24.[0-4]) _exit ;;
|
||||
*) ;;
|
||||
esac
|
||||
|
||||
mkdir -vp "${output_diskimage%/*}"
|
||||
td=`mktemp -d --tmpdir=/dev/shm/${LOGNAME}`
|
||||
tf=`mktemp --tmpdir=/dev/shm/${LOGNAME}`
|
||||
_exit() {
|
||||
rm -rf "$tf"
|
||||
rm -rf "$td"
|
||||
}
|
||||
trap _exit EXIT
|
||||
dir_repo=${td}/repos.d
|
||||
dir_root=${td}/root
|
||||
dir_cache=${td}/cache
|
||||
mkdir -vp \
|
||||
${dir_root} \
|
||||
${dir_cache} \
|
||||
${dir_repo}
|
||||
cat > ${tf} <<EOF
|
||||
[main]
|
||||
reposdir = ${dir_repo}
|
||||
EOF
|
||||
cat > ${dir_repo}/tmp.repo <<EOF
|
||||
[tmp]
|
||||
name=tmp
|
||||
enabled=1
|
||||
autorefresh=1
|
||||
keeppackages=0
|
||||
baseurl=${initial_repo}
|
||||
EOF
|
||||
packages="
|
||||
curl
|
||||
zypper
|
||||
"
|
||||
head ${dir_repo}/tmp.repo ${tf}
|
||||
zypper \
|
||||
--verbose \
|
||||
--verbose \
|
||||
--config ${tf} \
|
||||
--root ${dir_root} \
|
||||
--reposd-dir ${dir_repo} \
|
||||
--cache-dir ${dir_cache} \
|
||||
--gpg-auto-import-keys \
|
||||
--no-gpg-checks \
|
||||
--non-interactive \
|
||||
lr -d
|
||||
zypper \
|
||||
--verbose \
|
||||
--verbose \
|
||||
--config ${tf} \
|
||||
--root ${dir_root} \
|
||||
--reposd-dir ${dir_repo} \
|
||||
--cache-dir ${dir_cache} \
|
||||
--gpg-auto-import-keys \
|
||||
--no-gpg-checks \
|
||||
--non-interactive \
|
||||
install \
|
||||
--auto-agree-with-licenses \
|
||||
--no-recommends \
|
||||
--dry-run \
|
||||
--download-only \
|
||||
${packages}
|
||||
cd ${dir_root}
|
||||
find ${dir_cache} -xdev -name "*.rpm" -print0 | sort -z | xargs -0 -n 1 -P ${cpus} bash "${progname}" --unrpm
|
||||
mkdir -vp etc/zypp/repos.d
|
||||
grep -w search /etc/resolv.conf >> etc/resolv.conf
|
||||
echo nameserver 169.254.2.3 >> etc/resolv.conf
|
||||
grep -w root /etc/passwd > etc/passwd
|
||||
grep -w root /etc/group > etc/group
|
||||
echo 'root::15209::::::' > etc/shadow
|
||||
cat > etc/fstab <<EOF
|
||||
LABEL=SWAP swap swap defaults 0 0
|
||||
LABEL=ROOT / ext4 noatime 1 2
|
||||
EOF
|
||||
mkdir -p boot/grub
|
||||
cat > etc/grub.conf <<EOF
|
||||
setup --stage2=/boot/grub/stage2 --force-lba (hd0,1) (hd0,1)
|
||||
quit
|
||||
EOF
|
||||
echo "(hd0) ${diskname_inside_vm}" > boot/grub/device.map
|
||||
cat > boot/grub/menu.lst <<EOF
|
||||
serial --unit=0 --speed=115200
|
||||
terminal --timeout=10 console serial
|
||||
title ${0} $*
|
||||
kernel /boot/vmlinuz panic=9 quiet video=800x600
|
||||
initrd /boot/initrd
|
||||
EOF
|
||||
du -sm .
|
||||
find ${dir_cache} -xdev -name "*.rpm" -delete
|
||||
(
|
||||
echo "${guest_crypt_password}"
|
||||
echo "${guest_crypt_password}"
|
||||
) | \
|
||||
guestfish \
|
||||
-x \
|
||||
--keys-from-stdin \
|
||||
\
|
||||
sparse ${output_diskimage} 2048M : \
|
||||
set-smp 2 : \
|
||||
set-memsize 1024 : \
|
||||
set-network true : \
|
||||
run : \
|
||||
list-devices : \
|
||||
part-init ${diskname_inside_vm} mbr : \
|
||||
part-add ${diskname_inside_vm} primary 1 $(( ((1024*1024)* 256)/512 - 1)) : \
|
||||
part-add ${diskname_inside_vm} primary $(( ((1024*1024)* 256)/512 )) $(( ((1024*1024)*1024)/512 - 1)) : \
|
||||
part-add ${diskname_inside_vm} primary $(( ((1024*1024)*1024)/512 )) $(( ((1024*1024)*1555)/512 - 1)) : \
|
||||
part-add ${diskname_inside_vm} primary $(( ((1024*1024)*1555)/512 )) $(( ((1024*1024)*2024)/512 - 1)) : \
|
||||
part-list ${diskname_inside_vm} : \
|
||||
mkswap-opts ${diskname_inside_vm}1 label:SWAP : \
|
||||
mke2fs ${diskname_inside_vm}2 label:ROOT fstype:ext4 blocksize:1024 : \
|
||||
pvcreate ${diskname_inside_vm}3 : \
|
||||
vgcreate uncrypted ${diskname_inside_vm}3 : \
|
||||
luks-format ${diskname_inside_vm}4 0 : \
|
||||
luks-open ${diskname_inside_vm}4 crypt_part4 : \
|
||||
pvcreate /dev/mapper/crypt_part4 : \
|
||||
vgcreate crypted /dev/mapper/crypt_part4 : \
|
||||
lvcreate-free root uncrypted 50 : \
|
||||
lvcreate-free work uncrypted 50 : \
|
||||
lvcreate-free home crypted 50 : \
|
||||
lvcreate-free mail crypted 50 : \
|
||||
list-devices : \
|
||||
list-partitions : \
|
||||
pvs-full : \
|
||||
vgs-full : \
|
||||
lvs-full : \
|
||||
mke2fs /dev/uncrypted/root label:LV_ROOT fstype:ext4 blocksize:1024 : \
|
||||
mke2fs /dev/uncrypted/work label:LV_WORK fstype:ext4 blocksize:1024 : \
|
||||
mke2fs /dev/crypted/home label:LV_HOME fstype:ext4 blocksize:1024 : \
|
||||
mke2fs /dev/crypted/mail label:LV_MAIL fstype:ext4 blocksize:1024 : \
|
||||
part-set-bootable ${diskname_inside_vm} 2 true : \
|
||||
list-filesystems : \
|
||||
swapon-label SWAP : \
|
||||
mount-options discard ${diskname_inside_vm}2 / : \
|
||||
set-verbose false : \
|
||||
copy-in `echo *` / : \
|
||||
set-verbose true : \
|
||||
command /sbin/ldconfig : \
|
||||
cat /etc/resolv.conf : \
|
||||
command "ip a" : \
|
||||
command "curl google.com" : \
|
||||
command "zypper help" : \
|
||||
command "zypper -v -v ar -c -K -f ${final_repo} tmp" : \
|
||||
sh "(set -x -e ; z_in='zypper -v -v --gpg-auto-import-keys --no-gpg-checks --non-interactive in --auto-agree-with-licenses --no-recommends' ; \$z_in -t pattern ${guest_zypper_in__pattern_name} ; chkstat --set /etc/permissions /etc/permissions.easy ; echo root:${guest_root_password} | chpasswd ; \$z_in `eval echo ${guest_zypper_in__package_list}` ) 2>&1 " : \
|
||||
sh "depmod -a \$(get_kernel_version /boot/vmlinuz) ; mkinitrd -B" : \
|
||||
sh "dd if=/usr/lib/boot/MBR of=${diskname_inside_vm}" : \
|
||||
sh "cp --verbose --sparse=never --remove-destination --target-directory=/boot/grub /usr/lib/grub/*" : \
|
||||
sh "grub --batch --verbose < /etc/grub.conf" : \
|
||||
sh "echo crypt_part4 ${diskname_inside_vm}4 none luks,timeout=0 >> /etc/crypttab" : \
|
||||
mkdir /LV_ROOT : \
|
||||
sh "echo LABEL=LV_ROOT /LV_ROOT ext4 noatime 1 2 >> /etc/fstab" : \
|
||||
mkdir /LV_WORK : \
|
||||
sh "echo LABEL=LV_WORK /LV_WORK ext4 noatime 1 2 >> /etc/fstab" : \
|
||||
mkdir /LV_HOME : \
|
||||
sh "echo LABEL=LV_HOME /LV_HOME ext4 noatime 1 2 >> /etc/fstab" : \
|
||||
mkdir /LV_MAIL : \
|
||||
sh "echo LABEL=LV_MAIL /LV_MAIL ext4 noatime 1 2 >> /etc/fstab" : \
|
||||
sh "echo BOOTPROTO='dhcp' >> /etc/sysconfig/network/ifcfg-eth0" : \
|
||||
sh "echo STARTMODE='auto' >> /etc/sysconfig/network/ifcfg-eth0" : \
|
||||
sh "echo 'Password for User root is: ${guest_root_password}' >> /etc/issue" : \
|
||||
cat /etc/fstab : \
|
||||
quit
|
||||
ls -lhsS "${output_diskimage}"
|
||||
|
||||
: ${diskname_inside_vm}
|
||||
case "${diskname_inside_vm}" in
|
||||
*vda*)
|
||||
qemu_drive_options="
|
||||
-drive file=${output_diskimage},cache=writeback,id=hd0,if=none \
|
||||
-device virtio-blk-pci,drive=hd0 \
|
||||
"
|
||||
;;
|
||||
*sda*)
|
||||
qemu_drive_options="
|
||||
-device virtio-scsi-pci,id=scsi \
|
||||
-drive file=${output_diskimage},cache=unsafe,format=raw,id=hd0,if=none \
|
||||
-device scsi-hd,drive=hd0 \
|
||||
"
|
||||
;;
|
||||
*)
|
||||
echo "${diskname_inside_vm} not handled"
|
||||
_exit
|
||||
esac
|
||||
$kvm -enable-kvm \
|
||||
-global virtio-blk-pci.scsi=off \
|
||||
-enable-fips \
|
||||
-machine accel=kvm:tcg \
|
||||
-cpu host,+kvmclock \
|
||||
-m 500 \
|
||||
-no-reboot \
|
||||
-no-hpet \
|
||||
${qemu_drive_options} \
|
||||
-device virtio-serial-pci \
|
||||
-serial stdio \
|
||||
-device sga \
|
||||
-netdev user,id=usernet,net=169.254.0.0/16 \
|
||||
-device virtio-net-pci,netdev=usernet
|
||||
|
||||
exit 0
|
288
libguestfs.test.simple.create-opensuse-guest.sh
Normal file
288
libguestfs.test.simple.create-opensuse-guest.sh
Normal file
@ -0,0 +1,288 @@
|
||||
#!/bin/bash
|
||||
# Create an openSUSE image with just enough packages to allow boot to login prompt
|
||||
#
|
||||
# Theory of operation:
|
||||
# This script uses zypper from the host to resolve dependencies
|
||||
# for zypper which runs within the appliance. If zypper on the host
|
||||
# is too old, it will be unable to handle repo data from 13.1:
|
||||
# http://lists.opensuse.org/zypp-devel/2013-11/msg00000.html
|
||||
# "[zypp-devel] Package conflicting with itself"
|
||||
# For this reason zypper from 12.3 can be used to install the pattern
|
||||
# of the final repo.
|
||||
# First the dependencies of zypper are resolved, the required packages
|
||||
# are downloaded and extracted with unrpm. Now the guest is started and
|
||||
# the partitions in the diskimage are prepared. Then the extracted
|
||||
# package content is copied into the guest. Once that is done zypper
|
||||
# inside the guest will install the base pattern and a few extra packages.
|
||||
# Finally the bootloader grub is configured. Once all that is done
|
||||
# kvm is started. If all goes well a login prompt appears.
|
||||
# The password for root is "root".
|
||||
# The guest has also network access to the outside.
|
||||
#
|
||||
# Expected runtime: ca. 180 seconds
|
||||
#
|
||||
# Expected output:
|
||||
# guest should start
|
||||
# no "obvious" errors should be shown during the disk operation
|
||||
# at the end kvm is started with the generated disk image
|
||||
# login should be possible
|
||||
#
|
||||
set -e
|
||||
unset LANG
|
||||
unset ${!LC_*}
|
||||
cpus=`grep -Ec 'cpu[0-9]' /proc/stat || echo 1`
|
||||
|
||||
output_diskimage=/dev/shm/$LOGNAME/testcase.img
|
||||
final_repo=http://download.opensuse.org/distribution/13.1/repo/oss/
|
||||
initial_repo=http://download.opensuse.org/distribution/12.3/repo/oss/
|
||||
force=false
|
||||
guest_zypper_in__pattern_name="base"
|
||||
guest_zypper_in__package_list="
|
||||
grub
|
||||
less
|
||||
master-boot-code
|
||||
nfs-utils
|
||||
parted
|
||||
vim
|
||||
"
|
||||
guest_root_password="root"
|
||||
diskname_inside_vm=/dev/sda
|
||||
|
||||
case "$0" in
|
||||
/*) progname="$0" ;;
|
||||
*) progname="$PWD/$0" ;;
|
||||
esac
|
||||
|
||||
_exit() {
|
||||
echo "Exiting '$0 $*'."
|
||||
exit 1
|
||||
}
|
||||
|
||||
_unrpm() {
|
||||
CPIO_OPTS="--extract --unconditional --preserve-modification-time --make-directories --extract-over-symlinks"
|
||||
FILES="$@"
|
||||
for f in $FILES; do
|
||||
echo -ne "$f:\t"
|
||||
rpm2cpio $f | cpio ${CPIO_OPTS}
|
||||
done
|
||||
}
|
||||
|
||||
until test $# -lt 1
|
||||
do
|
||||
case "$1" in
|
||||
--unrpm) shift ; _unrpm "$@" ; exit 0 ;;
|
||||
-n) diskname_inside_vm="$2" ; shift ;;
|
||||
-o) output_diskimage="$2" ; shift ;;
|
||||
-R) initial_repo="$2" ; shift ;;
|
||||
-r) final_repo="$2" ; shift ;;
|
||||
-f) force=true ;;
|
||||
-x) set -x ;;
|
||||
*) echo "Unknown option '$1'" ; exit 1 ;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
if test -z "${initial_repo}"
|
||||
then
|
||||
echo "URL to initial repo required. Wrong -R option."
|
||||
_exit
|
||||
fi
|
||||
if test -z "${final_repo}"
|
||||
then
|
||||
echo "URL to final repo required. Wrong -r option."
|
||||
_exit
|
||||
fi
|
||||
if test -z "${output_diskimage}"
|
||||
then
|
||||
echo "Filename for temporary disk image required. Wrong -o option."
|
||||
_exit
|
||||
fi
|
||||
if test -e "${output_diskimage}"
|
||||
then
|
||||
if test "${force}" = "false"
|
||||
then
|
||||
echo "Output diskimage '${output_diskimage}' exists."
|
||||
echo "It will not be overwritten. Option '-f' exists to force overwrite."
|
||||
_exit
|
||||
fi
|
||||
fi
|
||||
zypper --version
|
||||
cpio --version
|
||||
guestfish --version
|
||||
kvm="qemu-system-`uname -m`"
|
||||
if $kvm --version
|
||||
then
|
||||
: good
|
||||
else
|
||||
kvm="qemu-kvm"
|
||||
if $kvm --version
|
||||
then
|
||||
:
|
||||
else
|
||||
echo "No qemu-kvm found."
|
||||
_exit
|
||||
fi
|
||||
fi
|
||||
|
||||
mkdir -vp "${output_diskimage%/*}"
|
||||
td=`mktemp -d --tmpdir=/dev/shm/${LOGNAME}`
|
||||
tf=`mktemp --tmpdir=/dev/shm/${LOGNAME}`
|
||||
_exit() {
|
||||
rm -rf "$tf"
|
||||
rm -rf "$td"
|
||||
}
|
||||
trap _exit EXIT
|
||||
dir_repo=${td}/repos.d
|
||||
dir_root=${td}/root
|
||||
dir_cache=${td}/cache
|
||||
mkdir -vp \
|
||||
${dir_root} \
|
||||
${dir_cache} \
|
||||
${dir_repo}
|
||||
cat > ${tf} <<EOF
|
||||
[main]
|
||||
reposdir = ${dir_repo}
|
||||
EOF
|
||||
cat > ${dir_repo}/tmp.repo <<EOF
|
||||
[tmp]
|
||||
name=tmp
|
||||
enabled=1
|
||||
autorefresh=1
|
||||
keeppackages=0
|
||||
baseurl=${initial_repo}
|
||||
EOF
|
||||
packages="
|
||||
curl
|
||||
zypper
|
||||
"
|
||||
head ${dir_repo}/tmp.repo ${tf}
|
||||
zypper \
|
||||
--verbose \
|
||||
--verbose \
|
||||
--config ${tf} \
|
||||
--root ${dir_root} \
|
||||
--reposd-dir ${dir_repo} \
|
||||
--cache-dir ${dir_cache} \
|
||||
--gpg-auto-import-keys \
|
||||
--no-gpg-checks \
|
||||
--non-interactive \
|
||||
lr -d
|
||||
zypper \
|
||||
--verbose \
|
||||
--verbose \
|
||||
--config ${tf} \
|
||||
--root ${dir_root} \
|
||||
--reposd-dir ${dir_repo} \
|
||||
--cache-dir ${dir_cache} \
|
||||
--gpg-auto-import-keys \
|
||||
--no-gpg-checks \
|
||||
--non-interactive \
|
||||
install \
|
||||
--auto-agree-with-licenses \
|
||||
--no-recommends \
|
||||
--dry-run \
|
||||
--download-only \
|
||||
${packages}
|
||||
cd ${dir_root}
|
||||
find ${dir_cache} -xdev -name "*.rpm" -print0 | sort -z | xargs -0 -n 1 -P ${cpus} bash "${progname}" --unrpm
|
||||
mkdir -vp etc/zypp/repos.d
|
||||
grep -w search /etc/resolv.conf >> etc/resolv.conf
|
||||
echo nameserver 169.254.2.3 >> etc/resolv.conf
|
||||
grep -w root /etc/passwd > etc/passwd
|
||||
grep -w root /etc/group > etc/group
|
||||
echo 'root::15209::::::' > etc/shadow
|
||||
cat > etc/fstab <<EOF
|
||||
LABEL=SWAP swap swap defaults 0 0
|
||||
LABEL=ROOT / ext4 noatime 1 2
|
||||
EOF
|
||||
mkdir -p boot/grub
|
||||
cat > etc/grub.conf <<EOF
|
||||
setup --stage2=/boot/grub/stage2 --force-lba (hd0,1) (hd0,1)
|
||||
quit
|
||||
EOF
|
||||
echo "(hd0) ${diskname_inside_vm}" > boot/grub/device.map
|
||||
cat > boot/grub/menu.lst <<EOF
|
||||
serial --unit=0 --speed=115200
|
||||
terminal --timeout=10 console serial
|
||||
title ${0} $*
|
||||
kernel /boot/vmlinuz panic=9 quiet video=800x600
|
||||
initrd /boot/initrd
|
||||
EOF
|
||||
du -sm .
|
||||
find ${dir_cache} -xdev -name "*.rpm" -delete
|
||||
guestfish \
|
||||
-x \
|
||||
\
|
||||
sparse ${output_diskimage} 1024M : \
|
||||
set-smp 2 : \
|
||||
set-memsize 1024 : \
|
||||
set-network true : \
|
||||
run : \
|
||||
list-devices : \
|
||||
part-init ${diskname_inside_vm} mbr : \
|
||||
part-add ${diskname_inside_vm} primary 1 $(( ((1024*1024)* 256)/512 - 1)) : \
|
||||
part-add ${diskname_inside_vm} primary $(( ((1024*1024)* 256)/512 )) $(( ((1024*1024)*1024)/512 - 1)) : \
|
||||
part-list ${diskname_inside_vm} : \
|
||||
mkswap-opts ${diskname_inside_vm}1 label:SWAP : \
|
||||
mke2fs ${diskname_inside_vm}2 label:ROOT fstype:ext4 blocksize:1024 : \
|
||||
list-devices : \
|
||||
list-partitions : \
|
||||
part-set-bootable ${diskname_inside_vm} 2 true : \
|
||||
list-filesystems : \
|
||||
swapon-label SWAP : \
|
||||
mount-options discard ${diskname_inside_vm}2 / : \
|
||||
set-verbose false : \
|
||||
copy-in `echo *` / : \
|
||||
set-verbose true : \
|
||||
command /sbin/ldconfig : \
|
||||
cat /etc/resolv.conf : \
|
||||
command "ip a" : \
|
||||
command "curl google.com" : \
|
||||
command "zypper help" : \
|
||||
command "zypper -v -v ar -c -K -f ${final_repo} tmp" : \
|
||||
sh "(set -x -e ; z_in='zypper -v -v --gpg-auto-import-keys --no-gpg-checks --non-interactive in --auto-agree-with-licenses --no-recommends' ; \$z_in -t pattern ${guest_zypper_in__pattern_name} ; chkstat --set /etc/permissions /etc/permissions.easy ; echo root:${guest_root_password} | chpasswd ; \$z_in `eval echo ${guest_zypper_in__package_list}` ) 2>&1 " : \
|
||||
sh "depmod -a \$(get_kernel_version /boot/vmlinuz) ; mkinitrd -B" : \
|
||||
sh "dd if=/usr/lib/boot/MBR of=${diskname_inside_vm}" : \
|
||||
sh "cp --verbose --sparse=never --remove-destination --target-directory=/boot/grub /usr/lib/grub/*" : \
|
||||
sh "grub --batch --verbose < /etc/grub.conf" : \
|
||||
sh "echo BOOTPROTO='dhcp' >> /etc/sysconfig/network/ifcfg-eth0" : \
|
||||
sh "echo STARTMODE='auto' >> /etc/sysconfig/network/ifcfg-eth0" : \
|
||||
sh "echo 'Password for User root is: ${guest_root_password}' >> /etc/issue" : \
|
||||
cat /etc/fstab : \
|
||||
quit
|
||||
ls -lhsS "${output_diskimage}"
|
||||
|
||||
: ${diskname_inside_vm}
|
||||
case "${diskname_inside_vm}" in
|
||||
*vda*)
|
||||
qemu_drive_options="
|
||||
-drive file=${output_diskimage},cache=writeback,id=hd0,if=none \
|
||||
-device virtio-blk-pci,drive=hd0 \
|
||||
"
|
||||
;;
|
||||
*sda*)
|
||||
qemu_drive_options="
|
||||
-device virtio-scsi-pci,id=scsi \
|
||||
-drive file=${output_diskimage},cache=unsafe,format=raw,id=hd0,if=none \
|
||||
-device scsi-hd,drive=hd0 \
|
||||
"
|
||||
;;
|
||||
*)
|
||||
echo "${diskname_inside_vm} not handled"
|
||||
_exit
|
||||
esac
|
||||
$kvm -enable-kvm \
|
||||
-global virtio-blk-pci.scsi=off \
|
||||
-enable-fips \
|
||||
-machine accel=kvm:tcg \
|
||||
-cpu host,+kvmclock \
|
||||
-m 500 \
|
||||
-no-reboot \
|
||||
-no-hpet \
|
||||
${qemu_drive_options} \
|
||||
-device virtio-serial-pci \
|
||||
-serial stdio \
|
||||
-device sga \
|
||||
-netdev user,id=usernet,net=169.254.0.0/16 \
|
||||
-device virtio-net-pci,netdev=usernet
|
||||
|
||||
exit 0
|
326
libguestfs.test.simple.create-sles12-guest-crypt-on-lvm.sh
Normal file
326
libguestfs.test.simple.create-sles12-guest-crypt-on-lvm.sh
Normal file
@ -0,0 +1,326 @@
|
||||
#!/bin/bash
|
||||
# Create an openSUSE image with lvm on dm-crypt partition
|
||||
#
|
||||
# Theory of operation:
|
||||
# This script uses zypper from the host to resolve dependencies
|
||||
# for zypper which runs within the appliance. If zypper on the host
|
||||
# is too old, it will be unable to handle repo data from 13.1:
|
||||
# http://lists.opensuse.org/zypp-devel/2013-11/msg00000.html
|
||||
# "[zypp-devel] Package conflicting with itself"
|
||||
# For this reason zypper from 12.3 can be used to install the pattern
|
||||
# of the final repo.
|
||||
# First the dependencies of zypper are resolved, the required packages
|
||||
# are downloaded and extracted with unrpm. Now the guest is started and
|
||||
# the partitions in the diskimage are prepared. Then the extracted
|
||||
# package content is copied into the guest. Once that is done zypper
|
||||
# inside the guest will install the base pattern and a few extra packages.
|
||||
# Finally the bootloader grub is configured. Once all that is done
|
||||
# kvm is started. If all goes well a login prompt appears.
|
||||
# The password for the crypted partition is "123456".
|
||||
# The password for root is "root".
|
||||
# The guest has also network access to the outside.
|
||||
#
|
||||
# Expected runtime: ca. 200 seconds
|
||||
# Requires at least 1.24.5 because this includes the required crypt modules
|
||||
#
|
||||
# Expected output:
|
||||
# guest should start
|
||||
# no "obvious" errors should be shown during the disk operation
|
||||
# at the end kvm is started with the generated disk image
|
||||
# login should be possible
|
||||
#
|
||||
set -e
|
||||
unset LANG
|
||||
unset ${!LC_*}
|
||||
cpus=`grep -Ec 'cpu[0-9]' /proc/stat || echo 1`
|
||||
|
||||
output_diskimage=/dev/shm/$LOGNAME/testcase.img
|
||||
final_repo=http://dist.suse.de/install/SLP/SLE-12-Server-LATEST/x86_64/DVD1
|
||||
initial_repo=http://dist.suse.de/install/SLP/SLE-12-Server-LATEST/x86_64/DVD1
|
||||
force=false
|
||||
guest_zypper_in__pattern_name="base"
|
||||
guest_zypper_in__package_list="
|
||||
grub2
|
||||
kernel-default
|
||||
less
|
||||
master-boot-code
|
||||
nfs-utils
|
||||
parted
|
||||
vim
|
||||
"
|
||||
guest_root_password="root"
|
||||
guest_crypt_password="123456"
|
||||
diskname_inside_vm=/dev/sda
|
||||
|
||||
case "$0" in
|
||||
/*) progname="$0" ;;
|
||||
*) progname="$PWD/$0" ;;
|
||||
esac
|
||||
|
||||
_exit() {
|
||||
echo "Exiting '$0 $*'."
|
||||
exit 1
|
||||
}
|
||||
|
||||
_unrpm() {
|
||||
CPIO_OPTS="--extract --unconditional --preserve-modification-time --make-directories --extract-over-symlinks"
|
||||
FILES="$@"
|
||||
for f in $FILES; do
|
||||
echo -ne "$f:\t"
|
||||
rpm2cpio $f | cpio ${CPIO_OPTS}
|
||||
done
|
||||
}
|
||||
|
||||
until test $# -lt 1
|
||||
do
|
||||
case "$1" in
|
||||
--unrpm) shift ; _unrpm "$@" ; exit 0 ;;
|
||||
-n) diskname_inside_vm="$2" ; shift ;;
|
||||
-o) output_diskimage="$2" ; shift ;;
|
||||
-R) initial_repo="$2" ; shift ;;
|
||||
-r) final_repo="$2" ; shift ;;
|
||||
-f) force=true ;;
|
||||
-x) set -x ;;
|
||||
*) echo "Unknown option '$1'" ; exit 1 ;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
if test -z "${initial_repo}"
|
||||
then
|
||||
echo "URL to initial repo required. Wrong -R option."
|
||||
_exit
|
||||
fi
|
||||
if test -z "${final_repo}"
|
||||
then
|
||||
echo "URL to final repo required. Wrong -r option."
|
||||
_exit
|
||||
fi
|
||||
if test -z "${output_diskimage}"
|
||||
then
|
||||
echo "Filename for temporary disk image required. Wrong -o option."
|
||||
_exit
|
||||
fi
|
||||
if test -e "${output_diskimage}"
|
||||
then
|
||||
if test "${force}" = "false"
|
||||
then
|
||||
echo "Output diskimage '${output_diskimage}' exists."
|
||||
echo "It will not be overwritten. Option '-f' exists to force overwrite."
|
||||
_exit
|
||||
fi
|
||||
fi
|
||||
zypper --version
|
||||
cpio --version
|
||||
guestfish --version
|
||||
kvm="qemu-system-`uname -m`"
|
||||
if $kvm --version
|
||||
then
|
||||
: good
|
||||
else
|
||||
kvm="qemu-kvm"
|
||||
if $kvm --version
|
||||
then
|
||||
:
|
||||
else
|
||||
echo "No qemu-kvm found."
|
||||
_exit
|
||||
fi
|
||||
fi
|
||||
guestfish_version="`guestfish --version | awk '{print \$2}'`"
|
||||
case "${guestfish_version}" in
|
||||
1.20*) _exit ;;
|
||||
1.21*) _exit ;;
|
||||
1.22*) _exit ;;
|
||||
1.23*) _exit ;;
|
||||
1.24.[0-4]) _exit ;;
|
||||
*) ;;
|
||||
esac
|
||||
|
||||
mkdir -vp "${output_diskimage%/*}"
|
||||
td=`mktemp -d --tmpdir=/dev/shm/${LOGNAME}`
|
||||
tf=`mktemp --tmpdir=/dev/shm/${LOGNAME}`
|
||||
_exit() {
|
||||
rm -rf "$tf"
|
||||
rm -rf "$td"
|
||||
}
|
||||
trap _exit EXIT
|
||||
dir_repo=${td}/repos.d
|
||||
dir_root=${td}/root
|
||||
dir_cache=${td}/cache
|
||||
mkdir -vp \
|
||||
${dir_root} \
|
||||
${dir_cache} \
|
||||
${dir_repo}
|
||||
cat > ${tf} <<EOF
|
||||
[main]
|
||||
reposdir = ${dir_repo}
|
||||
EOF
|
||||
cat > ${dir_repo}/tmp.repo <<EOF
|
||||
[tmp]
|
||||
name=tmp
|
||||
enabled=1
|
||||
autorefresh=1
|
||||
keeppackages=0
|
||||
baseurl=${initial_repo}
|
||||
EOF
|
||||
packages="
|
||||
curl
|
||||
iproute2
|
||||
zypper
|
||||
"
|
||||
head ${dir_repo}/tmp.repo ${tf}
|
||||
zypper \
|
||||
--verbose \
|
||||
--verbose \
|
||||
--config ${tf} \
|
||||
--root ${dir_root} \
|
||||
--reposd-dir ${dir_repo} \
|
||||
--cache-dir ${dir_cache} \
|
||||
--gpg-auto-import-keys \
|
||||
--no-gpg-checks \
|
||||
--non-interactive \
|
||||
lr -d
|
||||
zypper \
|
||||
--verbose \
|
||||
--verbose \
|
||||
--config ${tf} \
|
||||
--root ${dir_root} \
|
||||
--reposd-dir ${dir_repo} \
|
||||
--cache-dir ${dir_cache} \
|
||||
--gpg-auto-import-keys \
|
||||
--no-gpg-checks \
|
||||
--non-interactive \
|
||||
install \
|
||||
--auto-agree-with-licenses \
|
||||
--no-recommends \
|
||||
--dry-run \
|
||||
--download-only \
|
||||
${packages}
|
||||
cd ${dir_root}
|
||||
find ${dir_cache} -xdev -name "*.rpm" -print0 | sort -z | xargs -0 -n 1 -P ${cpus} bash "${progname}" --unrpm
|
||||
mkdir -vp etc/zypp/repos.d
|
||||
grep -w search /etc/resolv.conf >> etc/resolv.conf
|
||||
echo nameserver 169.254.2.3 >> etc/resolv.conf
|
||||
grep -w root /etc/passwd > etc/passwd
|
||||
grep -w root /etc/group > etc/group
|
||||
echo 'root::15209::::::' > etc/shadow
|
||||
cat > etc/fstab <<EOF
|
||||
LABEL=SWAP swap swap defaults 0 0
|
||||
LABEL=ROOT / ext4 noatime 1 2
|
||||
EOF
|
||||
du -sm .
|
||||
find ${dir_cache} -xdev -name "*.rpm" -delete
|
||||
(
|
||||
echo "${guest_crypt_password}"
|
||||
echo "${guest_crypt_password}"
|
||||
) | \
|
||||
guestfish \
|
||||
-x \
|
||||
--keys-from-stdin \
|
||||
\
|
||||
sparse ${output_diskimage} 2048M : \
|
||||
set-smp 2 : \
|
||||
set-memsize 1024 : \
|
||||
set-network true : \
|
||||
run : \
|
||||
list-devices : \
|
||||
part-init ${diskname_inside_vm} mbr : \
|
||||
part-add ${diskname_inside_vm} primary 1 $(( ((1024*1024)* 64)/512 - 1)) : \
|
||||
part-add ${diskname_inside_vm} primary $(( ((1024*1024)* 64)/512 )) $(( ((1024*1024)*1024)/512 - 1)) : \
|
||||
part-add ${diskname_inside_vm} primary $(( ((1024*1024)*1024)/512 )) $(( ((1024*1024)*1555)/512 - 1)) : \
|
||||
part-add ${diskname_inside_vm} primary $(( ((1024*1024)*1555)/512 )) $(( ((1024*1024)*2024)/512 - 1)) : \
|
||||
part-list ${diskname_inside_vm} : \
|
||||
mkswap-opts ${diskname_inside_vm}1 label:SWAP : \
|
||||
mke2fs ${diskname_inside_vm}2 label:ROOT fstype:ext4 blocksize:1024 : \
|
||||
pvcreate ${diskname_inside_vm}3 : \
|
||||
vgcreate uncrypted ${diskname_inside_vm}3 : \
|
||||
luks-format ${diskname_inside_vm}4 0 : \
|
||||
luks-open ${diskname_inside_vm}4 crypt_part4 : \
|
||||
pvcreate /dev/mapper/crypt_part4 : \
|
||||
vgcreate crypted /dev/mapper/crypt_part4 : \
|
||||
lvcreate-free root uncrypted 50 : \
|
||||
lvcreate-free work uncrypted 50 : \
|
||||
lvcreate-free home crypted 50 : \
|
||||
lvcreate-free mail crypted 50 : \
|
||||
list-devices : \
|
||||
list-partitions : \
|
||||
pvs-full : \
|
||||
vgs-full : \
|
||||
lvs-full : \
|
||||
mke2fs /dev/uncrypted/root label:LV_ROOT fstype:ext4 blocksize:1024 : \
|
||||
mke2fs /dev/uncrypted/work label:LV_WORK fstype:ext4 blocksize:1024 : \
|
||||
mke2fs /dev/crypted/home label:LV_HOME fstype:ext4 blocksize:1024 : \
|
||||
mke2fs /dev/crypted/mail label:LV_MAIL fstype:ext4 blocksize:1024 : \
|
||||
part-set-bootable ${diskname_inside_vm} 2 true : \
|
||||
list-filesystems : \
|
||||
swapon-label SWAP : \
|
||||
mount-options discard ${diskname_inside_vm}2 / : \
|
||||
set-verbose false : \
|
||||
copy-in `echo *` / : \
|
||||
set-verbose true : \
|
||||
command /sbin/ldconfig : \
|
||||
cat /etc/resolv.conf : \
|
||||
command "ip a" : \
|
||||
command "curl google.com" : \
|
||||
command "zypper help" : \
|
||||
command "zypper -v -v ar -c -K -f ${final_repo} tmp" : \
|
||||
sh "(set -x -e ; z_in='zypper -v -v --gpg-auto-import-keys --no-gpg-checks --non-interactive in --auto-agree-with-licenses --no-recommends' ; \$z_in -t pattern ${guest_zypper_in__pattern_name} ; chkstat --set /etc/permissions /etc/permissions.easy ; echo root:${guest_root_password} | chpasswd ; \$z_in `eval echo ${guest_zypper_in__package_list}` ) 2>&1 " : \
|
||||
sh "depmod -a \$(get_kernel_version /boot/vmlinuz) ; mkinitrd -B" : \
|
||||
sh "dd if=/usr/lib/boot/MBR of=${diskname_inside_vm}" : \
|
||||
sh "echo GRUB_DISABLE_OS_PROBER=true >> /etc/default/grub " : \
|
||||
sh "echo GRUB_DISABLE_LINUX_RECOVERY=true >> /etc/default/grub " : \
|
||||
sh "echo GRUB_CMDLINE_LINUX_DEFAULT=\'quiet panic=9 video=800x600 \' >> /etc/default/grub " : \
|
||||
sh "grub2-mkconfig > /boot/grub2/grub.cfg " : \
|
||||
sh "grub2-install --force --verbose ${diskname_inside_vm}2 " : \
|
||||
sh "echo crypt_part4 ${diskname_inside_vm}4 none luks,timeout=0 >> /etc/crypttab" : \
|
||||
mkdir /LV_ROOT : \
|
||||
sh "echo LABEL=LV_ROOT /LV_ROOT ext4 noatime 1 2 >> /etc/fstab" : \
|
||||
mkdir /LV_WORK : \
|
||||
sh "echo LABEL=LV_WORK /LV_WORK ext4 noatime 1 2 >> /etc/fstab" : \
|
||||
mkdir /LV_HOME : \
|
||||
sh "echo LABEL=LV_HOME /LV_HOME ext4 noatime 1 2 >> /etc/fstab" : \
|
||||
mkdir /LV_MAIL : \
|
||||
sh "echo LABEL=LV_MAIL /LV_MAIL ext4 noatime 1 2 >> /etc/fstab" : \
|
||||
sh "echo BOOTPROTO='dhcp' >> /etc/sysconfig/network/ifcfg-eth0" : \
|
||||
sh "echo STARTMODE='auto' >> /etc/sysconfig/network/ifcfg-eth0" : \
|
||||
sh "echo 'Password for User root is: ${guest_root_password}' >> /etc/issue" : \
|
||||
sh "echo >> /etc/issue" : \
|
||||
cat /etc/fstab : \
|
||||
quit
|
||||
ls -lhsS "${output_diskimage}"
|
||||
|
||||
: ${diskname_inside_vm}
|
||||
case "${diskname_inside_vm}" in
|
||||
*vda*)
|
||||
qemu_drive_options="
|
||||
-drive file=${output_diskimage},cache=writeback,id=hd0,if=none \
|
||||
-device virtio-blk-pci,drive=hd0 \
|
||||
"
|
||||
;;
|
||||
*sda*)
|
||||
qemu_drive_options="
|
||||
-device virtio-scsi-pci,id=scsi \
|
||||
-drive file=${output_diskimage},cache=unsafe,format=raw,id=hd0,if=none \
|
||||
-device scsi-hd,drive=hd0 \
|
||||
"
|
||||
;;
|
||||
*)
|
||||
echo "${diskname_inside_vm} not handled"
|
||||
_exit
|
||||
esac
|
||||
$kvm -enable-kvm \
|
||||
-global virtio-blk-pci.scsi=off \
|
||||
-enable-fips \
|
||||
-machine accel=kvm:tcg \
|
||||
-cpu host,+kvmclock \
|
||||
-m 500 \
|
||||
-no-reboot \
|
||||
-no-hpet \
|
||||
${qemu_drive_options} \
|
||||
-device virtio-serial-pci \
|
||||
-serial stdio \
|
||||
-device VGA \
|
||||
-netdev user,id=usernet,net=169.254.0.0/16 \
|
||||
-device virtio-net-pci,netdev=usernet
|
||||
|
||||
exit 0
|
281
libguestfs.test.simple.create-sles12-guest.sh
Normal file
281
libguestfs.test.simple.create-sles12-guest.sh
Normal file
@ -0,0 +1,281 @@
|
||||
#!/bin/bash
|
||||
# Create an openSUSE image with just enough packages to allow boot to login prompt
|
||||
#
|
||||
# Theory of operation:
|
||||
# This script uses zypper from the host to resolve dependencies
|
||||
# for zypper which runs within the appliance. If zypper on the host
|
||||
# is too old, it will be unable to handle repo data from 13.1:
|
||||
# http://lists.opensuse.org/zypp-devel/2013-11/msg00000.html
|
||||
# "[zypp-devel] Package conflicting with itself"
|
||||
# For this reason zypper from 12.3 can be used to install the pattern
|
||||
# of the final repo.
|
||||
# First the dependencies of zypper are resolved, the required packages
|
||||
# are downloaded and extracted with unrpm. Now the guest is started and
|
||||
# the partitions in the diskimage are prepared. Then the extracted
|
||||
# package content is copied into the guest. Once that is done zypper
|
||||
# inside the guest will install the base pattern and a few extra packages.
|
||||
# Finally the bootloader grub is configured. Once all that is done
|
||||
# kvm is started. If all goes well a login prompt appears.
|
||||
# The password for root is "root".
|
||||
# The guest has also network access to the outside.
|
||||
#
|
||||
# Expected runtime: ca. 180 seconds
|
||||
#
|
||||
# Expected output:
|
||||
# guest should start
|
||||
# no "obvious" errors should be shown during the disk operation
|
||||
# at the end kvm is started with the generated disk image
|
||||
# login should be possible
|
||||
#
|
||||
set -e
|
||||
unset LANG
|
||||
unset ${!LC_*}
|
||||
cpus=`grep -Ec 'cpu[0-9]' /proc/stat || echo 1`
|
||||
|
||||
output_diskimage=/dev/shm/$LOGNAME/testcase.img
|
||||
final_repo=http://dist.suse.de/install/SLP/SLE-12-Server-LATEST/x86_64/DVD1
|
||||
initial_repo=http://dist.suse.de/install/SLP/SLE-12-Server-LATEST/x86_64/DVD1
|
||||
force=false
|
||||
guest_zypper_in__pattern_name="base"
|
||||
guest_zypper_in__package_list="
|
||||
grub2
|
||||
kernel-default
|
||||
less
|
||||
master-boot-code
|
||||
nfs-utils
|
||||
parted
|
||||
vim
|
||||
"
|
||||
guest_root_password="root"
|
||||
diskname_inside_vm=/dev/sda
|
||||
|
||||
case "$0" in
|
||||
/*) progname="$0" ;;
|
||||
*) progname="$PWD/$0" ;;
|
||||
esac
|
||||
|
||||
_exit() {
|
||||
echo "Exiting '$0 $*'."
|
||||
exit 1
|
||||
}
|
||||
|
||||
_unrpm() {
|
||||
CPIO_OPTS="--extract --unconditional --preserve-modification-time --make-directories --extract-over-symlinks"
|
||||
FILES="$@"
|
||||
for f in $FILES; do
|
||||
echo -ne "$f:\t"
|
||||
rpm2cpio $f | cpio ${CPIO_OPTS}
|
||||
done
|
||||
}
|
||||
|
||||
until test $# -lt 1
|
||||
do
|
||||
case "$1" in
|
||||
--unrpm) shift ; _unrpm "$@" ; exit 0 ;;
|
||||
-n) diskname_inside_vm="$2" ; shift ;;
|
||||
-o) output_diskimage="$2" ; shift ;;
|
||||
-R) initial_repo="$2" ; shift ;;
|
||||
-r) final_repo="$2" ; shift ;;
|
||||
-f) force=true ;;
|
||||
-x) set -x ;;
|
||||
*) echo "Unknown option '$1'" ; exit 1 ;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
if test -z "${initial_repo}"
|
||||
then
|
||||
echo "URL to initial repo required. Wrong -R option."
|
||||
_exit
|
||||
fi
|
||||
if test -z "${final_repo}"
|
||||
then
|
||||
echo "URL to final repo required. Wrong -r option."
|
||||
_exit
|
||||
fi
|
||||
if test -z "${output_diskimage}"
|
||||
then
|
||||
echo "Filename for temporary disk image required. Wrong -o option."
|
||||
_exit
|
||||
fi
|
||||
if test -e "${output_diskimage}"
|
||||
then
|
||||
if test "${force}" = "false"
|
||||
then
|
||||
echo "Output diskimage '${output_diskimage}' exists."
|
||||
echo "It will not be overwritten. Option '-f' exists to force overwrite."
|
||||
_exit
|
||||
fi
|
||||
fi
|
||||
zypper --version
|
||||
cpio --version
|
||||
guestfish --version
|
||||
kvm="qemu-system-`uname -m`"
|
||||
if $kvm --version
|
||||
then
|
||||
: good
|
||||
else
|
||||
kvm="qemu-kvm"
|
||||
if $kvm --version
|
||||
then
|
||||
:
|
||||
else
|
||||
echo "No qemu-kvm found."
|
||||
_exit
|
||||
fi
|
||||
fi
|
||||
|
||||
mkdir -vp "${output_diskimage%/*}"
|
||||
td=`mktemp -d --tmpdir=/dev/shm/${LOGNAME}`
|
||||
tf=`mktemp --tmpdir=/dev/shm/${LOGNAME}`
|
||||
_exit() {
|
||||
rm -rf "$tf"
|
||||
rm -rf "$td"
|
||||
}
|
||||
trap _exit EXIT
|
||||
dir_repo=${td}/repos.d
|
||||
dir_root=${td}/root
|
||||
dir_cache=${td}/cache
|
||||
mkdir -vp \
|
||||
${dir_root} \
|
||||
${dir_cache} \
|
||||
${dir_repo}
|
||||
cat > ${tf} <<EOF
|
||||
[main]
|
||||
reposdir = ${dir_repo}
|
||||
EOF
|
||||
cat > ${dir_repo}/tmp.repo <<EOF
|
||||
[tmp]
|
||||
name=tmp
|
||||
enabled=1
|
||||
autorefresh=1
|
||||
keeppackages=0
|
||||
baseurl=${initial_repo}
|
||||
EOF
|
||||
packages="
|
||||
curl
|
||||
iproute2
|
||||
zypper
|
||||
"
|
||||
head ${dir_repo}/tmp.repo ${tf}
|
||||
zypper \
|
||||
--verbose \
|
||||
--verbose \
|
||||
--config ${tf} \
|
||||
--root ${dir_root} \
|
||||
--reposd-dir ${dir_repo} \
|
||||
--cache-dir ${dir_cache} \
|
||||
--gpg-auto-import-keys \
|
||||
--no-gpg-checks \
|
||||
--non-interactive \
|
||||
lr -d
|
||||
zypper \
|
||||
--verbose \
|
||||
--verbose \
|
||||
--config ${tf} \
|
||||
--root ${dir_root} \
|
||||
--reposd-dir ${dir_repo} \
|
||||
--cache-dir ${dir_cache} \
|
||||
--gpg-auto-import-keys \
|
||||
--no-gpg-checks \
|
||||
--non-interactive \
|
||||
install \
|
||||
--auto-agree-with-licenses \
|
||||
--no-recommends \
|
||||
--dry-run \
|
||||
--download-only \
|
||||
${packages}
|
||||
cd ${dir_root}
|
||||
find ${dir_cache} -xdev -name "*.rpm" -print0 | sort -z | xargs -0 -n 1 -P ${cpus} bash "${progname}" --unrpm
|
||||
mkdir -vp etc/zypp/repos.d
|
||||
grep -w search /etc/resolv.conf >> etc/resolv.conf
|
||||
echo nameserver 169.254.2.3 >> etc/resolv.conf
|
||||
grep -w root /etc/passwd > etc/passwd
|
||||
grep -w root /etc/group > etc/group
|
||||
echo 'root::15209::::::' > etc/shadow
|
||||
cat > etc/fstab <<EOF
|
||||
LABEL=SWAP swap swap defaults 0 0
|
||||
LABEL=ROOT / ext4 noatime 1 2
|
||||
EOF
|
||||
du -sm .
|
||||
find ${dir_cache} -xdev -name "*.rpm" -delete
|
||||
guestfish \
|
||||
-x \
|
||||
\
|
||||
sparse ${output_diskimage} 1024M : \
|
||||
set-smp 2 : \
|
||||
set-memsize 1024 : \
|
||||
set-network true : \
|
||||
run : \
|
||||
list-devices : \
|
||||
part-init ${diskname_inside_vm} mbr : \
|
||||
part-add ${diskname_inside_vm} primary 1 $(( ((1024*1024)* 64)/512 - 1)) : \
|
||||
part-add ${diskname_inside_vm} primary $(( ((1024*1024)* 64)/512 )) $(( ((1024*1024)*1024)/512 - 1)) : \
|
||||
part-list ${diskname_inside_vm} : \
|
||||
mkswap-opts ${diskname_inside_vm}1 label:SWAP : \
|
||||
mke2fs ${diskname_inside_vm}2 label:ROOT fstype:ext4 blocksize:1024 : \
|
||||
list-devices : \
|
||||
list-partitions : \
|
||||
part-set-bootable ${diskname_inside_vm} 2 true : \
|
||||
list-filesystems : \
|
||||
swapon-label SWAP : \
|
||||
mount-options noatime ${diskname_inside_vm}2 / : \
|
||||
set-verbose false : \
|
||||
copy-in `echo *` / : \
|
||||
set-verbose true : \
|
||||
command /sbin/ldconfig : \
|
||||
cat /etc/resolv.conf : \
|
||||
command "ip a" : \
|
||||
command "curl google.com" : \
|
||||
command "zypper help" : \
|
||||
command "zypper -v -v ar -c -K -f ${final_repo} tmp" : \
|
||||
sh "(set -x -e ; z_in='zypper -v -v --gpg-auto-import-keys --no-gpg-checks --non-interactive in --auto-agree-with-licenses --no-recommends ' ; \$z_in -t pattern ${guest_zypper_in__pattern_name} ; chkstat --set /etc/permissions /etc/permissions.easy ; echo root:${guest_root_password} | chpasswd ; \$z_in `eval echo ${guest_zypper_in__package_list}` ) < /dev/null &>/dev/kmsg " : \
|
||||
sh "depmod -a \$(get_kernel_version /boot/vmlinuz) ; mkinitrd -B" : \
|
||||
sh "dd if=/usr/lib/boot/MBR of=${diskname_inside_vm}" : \
|
||||
sh "echo GRUB_DISABLE_OS_PROBER=true >> /etc/default/grub " : \
|
||||
sh "echo GRUB_DISABLE_LINUX_RECOVERY=true >> /etc/default/grub " : \
|
||||
sh "echo GRUB_CMDLINE_LINUX_DEFAULT=\'quiet panic=9 video=800x600 \' >> /etc/default/grub " : \
|
||||
sh "grub2-mkconfig > /boot/grub2/grub.cfg " : \
|
||||
sh "grub2-install --force --verbose ${diskname_inside_vm}2 " : \
|
||||
sh "echo BOOTPROTO='dhcp' >> /etc/sysconfig/network/ifcfg-eth0" : \
|
||||
sh "echo STARTMODE='auto' >> /etc/sysconfig/network/ifcfg-eth0" : \
|
||||
sh "echo 'Password for User root is: ${guest_root_password}' >> /etc/issue" : \
|
||||
sh "echo >> /etc/issue" : \
|
||||
cat /etc/fstab : \
|
||||
quit
|
||||
ls -lhsS "${output_diskimage}"
|
||||
|
||||
: ${diskname_inside_vm}
|
||||
case "${diskname_inside_vm}" in
|
||||
*vda*)
|
||||
qemu_drive_options="
|
||||
-drive file=${output_diskimage},cache=writeback,id=hd0,if=none \
|
||||
-device virtio-blk-pci,drive=hd0 \
|
||||
"
|
||||
;;
|
||||
*sda*)
|
||||
qemu_drive_options="
|
||||
-device virtio-scsi-pci,id=scsi \
|
||||
-drive file=${output_diskimage},cache=unsafe,format=raw,id=hd0,if=none \
|
||||
-device scsi-hd,drive=hd0 \
|
||||
"
|
||||
;;
|
||||
*)
|
||||
echo "${diskname_inside_vm} not handled"
|
||||
_exit
|
||||
esac
|
||||
$kvm -enable-kvm \
|
||||
-global virtio-blk-pci.scsi=off \
|
||||
-enable-fips \
|
||||
-machine accel=kvm:tcg \
|
||||
-cpu host,+kvmclock \
|
||||
-m 500 \
|
||||
-no-reboot \
|
||||
-no-hpet \
|
||||
${qemu_drive_options} \
|
||||
-device virtio-serial-pci \
|
||||
-serial stdio \
|
||||
-device VGA \
|
||||
-netdev user,id=usernet,net=169.254.0.0/16 \
|
||||
-device virtio-net-pci,netdev=usernet
|
||||
|
||||
exit 0
|
26
libguestfs.test.simple.run-libugestfs-test-tool.sh
Normal file
26
libguestfs.test.simple.run-libugestfs-test-tool.sh
Normal file
@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
# libguestfs-test-tool starts its temporary guest using a dummy disk image
|
||||
# It creates a partition, a filesystem, mounts it and touches a file
|
||||
# Once it is done the dummy image is removed again
|
||||
# Per default it runs in --verbose mode, and our version trace the API calls
|
||||
#
|
||||
# Expected runtime: ca. 10 seconds
|
||||
#
|
||||
# Expected output:
|
||||
# guest should start
|
||||
# no "obvious" errors should be shown during the disk operation
|
||||
# Somewhere at the end of the verbose output lines like this are expected:
|
||||
# ...
|
||||
# libguestfs: trace: touch "/hello"
|
||||
# ...
|
||||
# libguestfs: trace: touch = 0
|
||||
#
|
||||
#
|
||||
set -x
|
||||
set -e
|
||||
unset LANG
|
||||
unset ${!LC_*}
|
||||
cpus=`grep -Ec 'cpu[0-9]' /proc/stat || echo 1`
|
||||
|
||||
libguestfs-test-tool -V
|
||||
time libguestfs-test-tool
|
44
makefile-ocaml-find-guestfs.patch
Normal file
44
makefile-ocaml-find-guestfs.patch
Normal file
@ -0,0 +1,44 @@
|
||||
--- libguestfs-1.44.2/common/mlprogress/Makefile.am.orig 2021-09-14 10:01:16.710596638 -0600
|
||||
+++ libguestfs-1.44.2/common/mlprogress/Makefile.am 2021-09-14 10:01:25.526596848 -0600
|
||||
@@ -67,7 +67,7 @@ BOBJECTS = $(SOURCES_ML:.ml=.cmo)
|
||||
XOBJECTS = $(BOBJECTS:.cmo=.cmx)
|
||||
|
||||
OCAMLPACKAGES = \
|
||||
- -package str,unix,guestfs \
|
||||
+ -package str,unix \
|
||||
-I $(top_builddir)/common/utils/.libs \
|
||||
-I $(top_builddir)/ocaml \
|
||||
-I $(builddir)
|
||||
--- libguestfs-1.44.2/common/mlvisit/Makefile.am.orig 2021-09-14 10:37:51.790648944 -0600
|
||||
+++ libguestfs-1.44.2/common/mlvisit/Makefile.am 2021-09-14 10:44:53.878659002 -0600
|
||||
@@ -68,7 +68,7 @@ BOBJECTS = $(SOURCES_ML:.ml=.cmo)
|
||||
XOBJECTS = $(BOBJECTS:.cmo=.cmx)
|
||||
|
||||
OCAMLPACKAGES = \
|
||||
- -package str,unix,guestfs \
|
||||
+ -package str,unix \
|
||||
-I $(top_builddir)/common/mlutils \
|
||||
-I $(top_builddir)/ocaml \
|
||||
-I $(top_builddir)/common/utils/.libs \
|
||||
--- libguestfs-1.44.2/common/mltools/Makefile.am.orig 2021-09-14 10:38:03.082649213 -0600
|
||||
+++ libguestfs-1.44.2/common/mltools/Makefile.am 2021-09-14 10:45:08.230659344 -0600
|
||||
@@ -114,7 +114,7 @@ BOBJECTS = $(SOURCES_ML:.ml=.cmo)
|
||||
XOBJECTS = $(BOBJECTS:.cmo=.cmx)
|
||||
|
||||
OCAMLPACKAGES = \
|
||||
- -package str,unix,guestfs \
|
||||
+ -package str,unix \
|
||||
-I $(top_builddir)/common/utils/.libs \
|
||||
-I $(top_builddir)/gnulib/lib/.libs \
|
||||
-I $(top_builddir)/ocaml \
|
||||
--- libguestfs-1.44.2/common/mlcustomize/Makefile.am.orig 2021-09-14 10:44:24.598658304 -0600
|
||||
+++ libguestfs-1.44.2/common/mlcustomize/Makefile.am 2021-09-14 10:44:35.654658567 -0600
|
||||
@@ -82,7 +82,7 @@ BOBJECTS = $(SOURCES_ML:.ml=.cmo)
|
||||
XOBJECTS = $(BOBJECTS:.cmo=.cmx)
|
||||
|
||||
OCAMLPACKAGES = \
|
||||
- -package str,unix,guestfs \
|
||||
+ -package str,unix \
|
||||
-I $(top_builddir)/common/utils/.libs \
|
||||
-I $(top_builddir)/ocaml \
|
||||
-I $(top_builddir)/common/mlstdutils \
|
12
netconfig.patch
Normal file
12
netconfig.patch
Normal file
@ -0,0 +1,12 @@
|
||||
Index: libguestfs-1.44.2/appliance/packagelist.in
|
||||
===================================================================
|
||||
--- libguestfs-1.44.2.orig/appliance/packagelist.in
|
||||
+++ libguestfs-1.44.2/appliance/packagelist.in
|
||||
@@ -118,6 +118,7 @@ ifelse(SUSE,1,
|
||||
dnl It seems no other augeas package depends on it.
|
||||
augeas-lenses
|
||||
btrfsprogs
|
||||
+ busybox
|
||||
cdrkit-cdrtools-compat
|
||||
cryptsetup
|
||||
dhcpcd
|
Loading…
Reference in New Issue
Block a user