[PATCH 1/2] golang: Fix for out-of-tree builds
by Hilko Bengen
---
configure.ac | 2 +-
golang/Makefile.am | 2 ++
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac
index 4e2bc65..9abec95 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1530,7 +1530,7 @@ AS_IF([test "x$enable_golang" != "xno"],[
AC_CHECK_PROG([GOLANG],[go],[go],[no])
AS_IF([test "x$GOLANG" != "xno"],[
AC_MSG_CHECKING([if $GOLANG is usable])
- AS_IF([$GOLANG run golang/config-test.go 2>&AS_MESSAGE_LOG_FD],[
+ AS_IF([$GOLANG run $srcdir/golang/config-test.go 2>&AS_MESSAGE_LOG_FD],[
AC_MSG_RESULT([yes])
# Substitute some golang environment.
diff --git a/golang/Makefile.am b/golang/Makefile.am
index a7dd1b2..a60c9ba 100644
--- a/golang/Makefile.am
+++ b/golang/Makefile.am
@@ -44,6 +44,7 @@ golangpkg_DATA = \
pkg/$(GOOS)_$(GOARCH)/$(pkg).a
pkg/$(GOOS)_$(GOARCH)/$(pkg).a: src/$(pkg)/guestfs.go
+ -[ $(srcdir) != $(builddir) ] && cp -rsu $(abs_srcdir)/src $(builddir)/src
$(top_builddir)/run $(GOLANG) install $(pkg)
golangsrc_DATA = $(source_files)
@@ -57,4 +58,5 @@ endif
CLEANFILES = *~ src/$(pkg)/*~
clean-local:
+ -[ $(srcdir) != $(builddir) ] && rm -rf $(builddir)/src
rm -rf pkg
--
1.8.5.1
10 years, 11 months
[PATCH] sysprep: remove some Pegasus files, like certs (RHBZ#1041552).
by Pino Toscano
---
sysprep/sysprep_operation_logfiles.ml | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/sysprep/sysprep_operation_logfiles.ml b/sysprep/sysprep_operation_logfiles.ml
index 3055ca4..2558af1 100644
--- a/sysprep/sysprep_operation_logfiles.ml
+++ b/sysprep/sysprep_operation_logfiles.ml
@@ -91,6 +91,13 @@ let globs = List.sort compare [
(* log file of ntp *)
"/var/log/ntpstats/*";
+
+ (* Pegasus certificates and other files *)
+ "/etc/Pegasus/*.cnf";
+ "/etc/Pegasus/*.crt";
+ "/etc/Pegasus/*.csr";
+ "/etc/Pegasus/*.pem";
+ "/etc/Pegasus/*.srl";
]
let globs_as_pod = String.concat "\n" (List.map ((^) " ") globs)
--
1.8.3.1
10 years, 11 months
[PATCH] sysprep: handle distro specific sysv scripts
by Olaf Hering
Currently firstboot would only work on redhat-based images.
Handle redhat-based, suse-based and debian guests, error out in case of an
unknown distro.
Update firstboot.sh:
- make sure scripts exists and can be executed
- add LSB header to avoid insserv warnings later on
- run script only if called with "start"
Update functions, pass only required options.
Signed-off-by: Olaf Hering <olaf(a)aepfle.de>
diff --git a/sysprep/firstboot.ml b/sysprep/firstboot.ml
index 97cd8a9..c5296a1 100644
--- a/sysprep/firstboot.ml
+++ b/sysprep/firstboot.ml
@@ -28,14 +28,35 @@ let firstboot_dir = "/usr/lib/virt-sysprep"
let firstboot_sh = sprintf "\
#!/bin/sh -
+### BEGIN INIT INFO
+# Provides: virt-sysprep
+# Required-Start: $null
+# Should-Start: $all
+# Required-Stop: $null
+# Should-Stop: $all
+# Default-Start: 2 3 5
+# Default-Stop: 0 1 6
+# Short-Description: Start scripts to run once at next boot
+# Description: Start scripts to run once at next boot
+# These scripts run the first time the guest boots,
+# and then are deleted. Output or errors from the scripts
+# are written to ~root/virt-sysprep-firstboot.log.
+### END INIT INFO
+
d=%s/scripts
logfile=~root/virt-sysprep-firstboot.log
-for f in $d/* ; do
- echo '=== Running' $f '===' >>$logfile
- $f >>$logfile 2>&1
- rm $f
-done
+if test \"$1\" = \"start\"
+then
+ for f in $d/* ; do
+ if test -x \"$f\"
+ then
+ echo '=== Running' $f '===' >>$logfile
+ $f >>$logfile 2>&1
+ rm -f $f
+ fi
+ done
+fi
" firstboot_dir
let firstboot_service = sprintf "\
@@ -56,7 +77,7 @@ WantedBy=default.target
let failed fs =
ksprintf (fun msg -> failwith (s_"firstboot: failed: " ^ msg)) fs
-let rec install_service g root =
+let rec install_service g distro =
g#mkdir_p firstboot_dir;
g#mkdir_p (sprintf "%s/scripts" firstboot_dir);
g#write (sprintf "%s/firstboot.sh" firstboot_dir) firstboot_sh;
@@ -64,18 +85,18 @@ let rec install_service g root =
(* systemd, else assume sysvinit *)
if g#is_dir "/etc/systemd" then
- install_systemd_service g root
+ install_systemd_service g
else
- install_sysvinit_service g root
+ install_sysvinit_service g distro
(* Install the systemd firstboot service, if not installed already. *)
-and install_systemd_service g root =
+and install_systemd_service g =
g#write (sprintf "%s/firstboot.service" firstboot_dir) firstboot_service;
g#mkdir_p "/etc/systemd/system/default.target.wants";
g#ln_sf (sprintf "%s/firstboot.service" firstboot_dir)
"/etc/systemd/system/default.target.wants"
-and install_sysvinit_service g root =
+and install_sysvinit_redhat g =
g#mkdir_p "/etc/rc.d/rc2.d";
g#mkdir_p "/etc/rc.d/rc3.d";
g#mkdir_p "/etc/rc.d/rc5.d";
@@ -86,12 +107,51 @@ and install_sysvinit_service g root =
g#ln_sf (sprintf "%s/firstboot.sh" firstboot_dir)
"/etc/rc.d/rc5.d/99virt-sysprep-firstboot"
+(* Make firstboot.sh look like a runlevel script to avoid insserv warnings. *)
+and install_sysvinit_suse g =
+ g#mkdir_p "/etc/init.d/rc2.d";
+ g#mkdir_p "/etc/init.d/rc3.d";
+ g#mkdir_p "/etc/init.d/rc5.d";
+ g#ln_sf (sprintf "%s/firstboot.sh" firstboot_dir)
+ "/etc/init.d/virt-sysprep-firstboot";
+ g#ln_sf "../virt-sysprep-firstboot"
+ "/etc/init.d/rc2.d/S99virt-sysprep-firstboot";
+ g#ln_sf "../virt-sysprep-firstboot"
+ "/etc/init.d/rc3.d/S99virt-sysprep-firstboot";
+ g#ln_sf "../virt-sysprep-firstboot"
+ "/etc/init.d/rc5.d/S99virt-sysprep-firstboot"
+
+and install_sysvinit_debian g =
+ g#mkdir_p "/etc/init.d";
+ g#mkdir_p "/etc/rc2.d";
+ g#mkdir_p "/etc/rc3.d";
+ g#mkdir_p "/etc/rc5.d";
+ g#ln_sf (sprintf "%s/firstboot.sh" firstboot_dir)
+ "/etc/init.d/virt-sysprep-firstboot";
+ g#ln_sf "/etc/init.d/virt-sysprep-firstboot"
+ "/etc/rc2.d/S99virt-sysprep-firstboot";
+ g#ln_sf "/etc/init.d/virt-sysprep-firstboot"
+ "/etc/rc3.d/S99virt-sysprep-firstboot";
+ g#ln_sf "/etc/init.d/virt-sysprep-firstboot"
+ "/etc/rc5.d/S99virt-sysprep-firstboot"
+
+and install_sysvinit_service g distro =
+ match distro with
+ | ("fedora"|"rhel"|"centos"|"scientificlinux"|"redhat-based") ->
+ install_sysvinit_redhat g
+ | ("opensuse"|"sles"|"suse-based") ->
+ install_sysvinit_suse g
+ | "debian" ->
+ install_sysvinit_debian g
+ | _ ->
+ failed "guest type %s is not supported" distro
+
let add_firstboot_script g root id content =
let typ = g#inspect_get_type root in
let distro = g#inspect_get_distro root in
match typ, distro with
| "linux", _ ->
- install_service g root;
+ install_service g distro;
let t = Int64.of_float (Unix.time ()) in
let r = string_random8 () in
let filename = sprintf "%s/scripts/%Ld-%s-%s" firstboot_dir t r id in
--
1.7.12
10 years, 11 months
[PATCH] daemon: mkfs: Use -I option to force mkfs.fat to write a filesystem over a whole device (RHBZ#1039995).
by Richard W.M. Jones
From: "Richard W.M. Jones" <rjones(a)redhat.com>
If you use virt-make-fs to create a partitionless FAT-formatted disk
image then currently you will get an error:
$ virt-make-fs --type=fat . /tmp/test.img
'mkfs' (create filesystem) operation failed.
Instead of 'fat', try 'vfat' (long filenames) or 'msdos' (short filenames).
mkfs: fat: /dev/sda: mkfs.fat: Device partition expected, not making filesystem on entire device '/dev/sda' (use -I to override) at /usr/bin/virt-make-fs line 508, <PIPE> line 1.
...propagated at /usr/bin/virt-make-fs line 518, <PIPE> line 1.
With this patch, the error goes away and partitionless disks can be
created.
---
daemon/mkfs.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/daemon/mkfs.c b/daemon/mkfs.c
index e753d9a..ee0e9d1 100644
--- a/daemon/mkfs.c
+++ b/daemon/mkfs.c
@@ -96,6 +96,11 @@ do_mkfs (const char *fstype, const char *device, int blocksize,
ADD_ARG (argv, i, "-O");
}
+ /* Force mkfs.fat to create a whole disk filesystem (RHBZ#1039995). */
+ if (STREQ (fstype, "fat") || STREQ (fstype, "vfat") ||
+ STREQ (fstype, "msdos"))
+ ADD_ARG (argv, i, "-I");
+
/* Process blocksize parameter if set. */
if (optargs_bitmask & GUESTFS_MKFS_BLOCKSIZE_BITMASK) {
if (blocksize <= 0 || !is_power_of_2 (blocksize)) {
--
1.8.3.1
10 years, 11 months
[PATCH 1/3] Fix manpage generation in out-of-tree builds
by Hilko Bengen
---
po-docs/ja/Makefile.am | 16 ++++++++--------
po-docs/uk/Makefile.am | 16 ++++++++--------
2 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/po-docs/ja/Makefile.am b/po-docs/ja/Makefile.am
index 820f91a..e954f04 100644
--- a/po-docs/ja/Makefile.am
+++ b/po-docs/ja/Makefile.am
@@ -92,9 +92,9 @@ guestfs.3: guestfs.pod guestfs-actions.pod guestfs-availability.pod guestfs-stru
--man $@ \
--section 3 \
--license LGPLv2+ \
- --insert guestfs-actions.pod:__ACTIONS__ \
- --insert guestfs-availability.pod:__AVAILABILITY__ \
- --insert guestfs-structs.pod:__STRUCTS__ \
+ --insert $(srcdir)/guestfs-actions.pod:__ACTIONS__ \
+ --insert $(srcdir)/guestfs-availability.pod:__AVAILABILITY__ \
+ --insert $(srcdir)/guestfs-structs.pod:__STRUCTS__ \
$<
guestfish.1: guestfish.pod guestfish-actions.pod guestfish-commands.pod guestfish-prepopts.pod
@@ -102,9 +102,9 @@ guestfish.1: guestfish.pod guestfish-actions.pod guestfish-commands.pod guestfis
--no-strict-checks \
--man $@ \
--license GPLv2+ \
- --insert guestfish-actions.pod:__ACTIONS__ \
- --insert guestfish-commands.pod:__FISH_COMMANDS__ \
- --insert guestfish-prepopts.pod:__PREPOPTS__ \
+ --insert $(srcdir)/guestfish-actions.pod:__ACTIONS__ \
+ --insert $(srcdir)/guestfish-commands.pod:__FISH_COMMANDS__ \
+ --insert $(srcdir)/guestfish-prepopts.pod:__PREPOPTS__ \
$<
virt-sysprep.1: virt-sysprep.pod sysprep-extra-options.pod sysprep-operations.pod
@@ -112,8 +112,8 @@ virt-sysprep.1: virt-sysprep.pod sysprep-extra-options.pod sysprep-operations.po
--no-strict-checks \
--man $@ \
--license GPLv2+ \
- --insert sysprep-extra-options.pod:__EXTRA_OPTIONS__ \
- --insert sysprep-operations.pod:__OPERATIONS__ \
+ --insert $(srcdir)/sysprep-extra-options.pod:__EXTRA_OPTIONS__ \
+ --insert $(srcdir)/sysprep-operations.pod:__OPERATIONS__ \
$<
%.1: %.pod
diff --git a/po-docs/uk/Makefile.am b/po-docs/uk/Makefile.am
index 820f91a..e954f04 100644
--- a/po-docs/uk/Makefile.am
+++ b/po-docs/uk/Makefile.am
@@ -92,9 +92,9 @@ guestfs.3: guestfs.pod guestfs-actions.pod guestfs-availability.pod guestfs-stru
--man $@ \
--section 3 \
--license LGPLv2+ \
- --insert guestfs-actions.pod:__ACTIONS__ \
- --insert guestfs-availability.pod:__AVAILABILITY__ \
- --insert guestfs-structs.pod:__STRUCTS__ \
+ --insert $(srcdir)/guestfs-actions.pod:__ACTIONS__ \
+ --insert $(srcdir)/guestfs-availability.pod:__AVAILABILITY__ \
+ --insert $(srcdir)/guestfs-structs.pod:__STRUCTS__ \
$<
guestfish.1: guestfish.pod guestfish-actions.pod guestfish-commands.pod guestfish-prepopts.pod
@@ -102,9 +102,9 @@ guestfish.1: guestfish.pod guestfish-actions.pod guestfish-commands.pod guestfis
--no-strict-checks \
--man $@ \
--license GPLv2+ \
- --insert guestfish-actions.pod:__ACTIONS__ \
- --insert guestfish-commands.pod:__FISH_COMMANDS__ \
- --insert guestfish-prepopts.pod:__PREPOPTS__ \
+ --insert $(srcdir)/guestfish-actions.pod:__ACTIONS__ \
+ --insert $(srcdir)/guestfish-commands.pod:__FISH_COMMANDS__ \
+ --insert $(srcdir)/guestfish-prepopts.pod:__PREPOPTS__ \
$<
virt-sysprep.1: virt-sysprep.pod sysprep-extra-options.pod sysprep-operations.pod
@@ -112,8 +112,8 @@ virt-sysprep.1: virt-sysprep.pod sysprep-extra-options.pod sysprep-operations.po
--no-strict-checks \
--man $@ \
--license GPLv2+ \
- --insert sysprep-extra-options.pod:__EXTRA_OPTIONS__ \
- --insert sysprep-operations.pod:__OPERATIONS__ \
+ --insert $(srcdir)/sysprep-extra-options.pod:__EXTRA_OPTIONS__ \
+ --insert $(srcdir)/sysprep-operations.pod:__OPERATIONS__ \
$<
%.1: %.pod
--
1.8.5.1
10 years, 11 months
[PATCH] lib: fix newline in error output
by Pino Toscano
See also RHBZ#923355.
---
src/actions-support.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/actions-support.c b/src/actions-support.c
index d0e3e67..00d8cdc 100644
--- a/src/actions-support.c
+++ b/src/actions-support.c
@@ -68,7 +68,7 @@ int
guestfs___check_appliance_up (guestfs_h *g, const char *caller)
{
if (g->state == CONFIG || g->state == LAUNCHING) {
- error (g, "%s: call launch before using this function\\n(in guestfish, don't forget to use the 'run' command)",
+ error (g, "%s: call launch before using this function\n(in guestfish, don't forget to use the 'run' command)",
caller);
return -1;
}
--
1.8.3.1
10 years, 11 months
Error in chunked encoding
by Chris Lalancette
Hello,
Oz is a program that does automated installation of virtual
machines. It is written in python and uses libguestfs pretty heavily
to manipulate ISOs and disks.
Someone reported an error against Oz here:
https://github.com/clalancette/oz/issues/140
There are some more details in the issue, but it essentially looks
like something happened during libguestfs tar_out:
RuntimeError: /dev/fd/13: error in chunked encoding
Has anyone seen this before? Any idea what this is about? If you
want to comment, I would appreciate it if you could comment in the
issue itself.
Thanks,
Chris
10 years, 11 months
[PATCH] sysprep: allow to specify globbing for --delete
by Pino Toscano
Adapt the globbing part from the old --remote-path work previously
proposed for sysprep [1], allowing --delete to perform globbing when
deleting paths.
[1] https://www.redhat.com/archives/libguestfs/2013-October/msg00045.html
---
sysprep/sysprep_operation_delete.ml | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/sysprep/sysprep_operation_delete.ml b/sysprep/sysprep_operation_delete.ml
index de78a87..59d5485 100644
--- a/sysprep/sysprep_operation_delete.ml
+++ b/sysprep/sysprep_operation_delete.ml
@@ -27,7 +27,9 @@ let add_paths path = paths := path :: !paths
let path_perform g root =
let paths = List.rev !paths in
- List.iter g#rm_rf paths;
+ if paths <> [] then (
+ List.iter (fun glob -> Array.iter g#rm_rf (g#glob_expand glob)) paths
+ );
[]
let op = {
--
1.8.3.1
10 years, 11 months