[Libguestfs] [PATCH 3/3] Add 'virt-rescue' command.
Jim Meyering
jim at meyering.net
Wed Sep 23 10:36:34 UTC 2009
Richard W.M. Jones wrote:
...
> Subject: [PATCH 3/3] Add 'virt-rescue' command.
>
> This command runs a "rescue appliance" against a virtual machine
> or disk image. This is useful for making ad-hoc interactive
...
> diff --git a/rescue/Makefile.am b/rescue/Makefile.am
...
> +if HAVE_RESCUE
> +
> +man_MANS = virt-rescue.1
I have a vague memory that recent automake generates
better rules if you spell the above like this:
dist_man1_MANS = virt-rescue.1
> +noinst_DATA = @top_builddir@/html/virt-rescue.1.html
IMHO, it's better to avoid automake's obsolescent @VAR@ notation.
Instead, use $(VAR). There's even a syntax-check rule for this,
but it's currently disabled.
> +virt-rescue.1: virt-rescue.pl
> + $(POD2MAN) \
> + --section 1 \
> + -c "Virtualization Support" \
> + --release "$(PACKAGE_NAME)-$(PACKAGE_VERSION)" \
> + $< > $@
Don't redirect directly to $@, in case the command fails
without removing the incomplete result. This idiom ensures
that it is updated atomically:
$< > $@-t && mv $@-t $@
> + at top_builddir@/html/virt-rescue.1.html: virt-rescue.pl
> + mkdir -p @top_builddir@/html
> + cd @top_builddir@ && pod2html \
> + --css 'pod.css' \
> + --title 'virt-rescue, run a rescue shell on a virtual machine' \
> + --htmldir html \
> + --outfile html/virt-rescue.1.html \
> + rescue/$<
> +
> +install-data-hook:
> + mkdir -p $(DESTDIR)$(bindir)
> + install -m 0755 virt-rescue.pl $(DESTDIR)$(bindir)/virt-rescue
> +
> +endif
> diff --git a/rescue/run-rescue-locally b/rescue/run-rescue-locally
...
> +my $path = $0;
> +
> +# Follow symlinks until we get to the real file
> +while(-l $path) {
> + my $link = readlink($path);
You'll want to handle the case in which readlink fails
and returns "undef".
> + if(File::Spec->file_name_is_absolute($link)) {
> + $path = $link;
> + } else {
> + $path = File::Spec->catfile(dirname($path), $link);
> + }
More information about the Libguestfs
mailing list