From 5790f5bfafb12cc2ed9365461bf66e0fdfde7150 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Fri, 15 Apr 2011 21:43:20 +0100 Subject: [PATCH] Remove ad-hoc run*locally scripts, replace with './run' Remove all the run*locally scripts and replace with a single top level ./run shell script. --- Makefile.am | 5 ++-- README | 28 +++++++++++++++++++++ cat/Makefile.am | 3 --- cat/run-cat-locally | 53 -------------------------------------- cat/run-filesystems-locally | 52 -------------------------------------- cat/run-ls-locally | 52 -------------------------------------- df/Makefile.am | 1 - df/run-df-locally | 52 -------------------------------------- inspector/Makefile.am | 10 ++++---- inspector/run-inspector-locally | 51 ------------------------------------- rescue/Makefile.am | 1 - rescue/run-rescue-locally | 52 -------------------------------------- resize/Makefile.am | 1 - resize/run-resize-locally | 53 -------------------------------------- run | 42 +++++++++++++++++++++++++++++++ test-tool/Makefile.am | 2 +- test-tool/run-test-tool-locally | 54 --------------------------------------- tools/Makefile.am | 1 - tools/run-locally | 56 ----------------------------------------- 19 files changed, 79 insertions(+), 490 deletions(-) delete mode 100755 cat/run-cat-locally delete mode 100755 cat/run-filesystems-locally delete mode 100755 cat/run-ls-locally delete mode 100755 df/run-df-locally delete mode 100755 inspector/run-inspector-locally delete mode 100755 rescue/run-rescue-locally delete mode 100755 resize/run-resize-locally create mode 100755 run delete mode 100755 test-tool/run-test-tool-locally delete mode 100755 tools/run-locally diff --git a/Makefile.am b/Makefile.am index 3d629e9..fcd190a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -105,7 +105,8 @@ EXTRA_DIST = \ autogen.sh \ bugs-in-changelog.sh \ update-bugs.sh \ - logo/fish.svg logo/fish.png + logo/fish.svg logo/fish.png \ + run # Recipes web page. html/recipes.html: $(wildcard recipes/*.sh) $(wildcard recipes/*.html) $(wildcard recipes/*.example) Makefile make-recipes.sh @@ -205,7 +206,7 @@ CLEANFILES = \ # is NOT a substitute for proper testing! quickcheck: - test-tool/run-test-tool-locally + ./run test-tool/libguestfs-test-tool # Make binary distribution. diff --git a/README b/README index 4abc045..3960b61 100644 --- a/README +++ b/README @@ -113,6 +113,34 @@ this command as root: make install +You can run the virt tools without needing to install, using the "run" +script in the top directory. This script sets up some environment +variables. For example: + + ./run ./inspector/virt-inspector [usual virt-inspector args ...] + +If you are already in the inspector/ subdirectory, then the following +command will also work: + + ../run ./virt-inspector [...] + +You can also make a symlink (note: NOT a hard link) from your $PATH to +the run script, eg: + + cd ~/bin + ln -s ~/libguestfs/run libguestfs-run + cd ~/libguestfs + libguestfs-run ./inspector/virt-inspector [...] + +You can also run the C programs under valgrind like this: + + ./run valgrind [valgrind opts...] ./cat/virt-cat [virt-cat opts...] + +This also works with sudo (eg. if you need root access for libvirt or +to access a block device): + + sudo ./run ./cat/virt-cat -d LinuxGuest /etc/passwd + qemu ---------------------------------------------------------------------- diff --git a/cat/Makefile.am b/cat/Makefile.am index d7bc7e8..a049a61 100644 --- a/cat/Makefile.am +++ b/cat/Makefile.am @@ -18,13 +18,10 @@ include $(top_srcdir)/subdir-rules.mk EXTRA_DIST = \ - run-cat-locally \ test-virt-cat.sh \ virt-cat.pod \ - run-filesystems-locally \ test-virt-filesystems.sh \ virt-filesystems.pod \ - run-ls-locally \ test-virt-ls.sh \ virt-ls.pod diff --git a/cat/run-cat-locally b/cat/run-cat-locally deleted file mode 100755 index 9467ad6..0000000 --- a/cat/run-cat-locally +++ /dev/null @@ -1,53 +0,0 @@ -#!/usr/bin/perl -# Copyright (C) 2009 Red Hat Inc. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -# This script sets up the environment so you can run virt-* tools in -# place without needing to do 'make install' first. You can also run -# the tools by creating a symlink to this script and putting it in -# your path. -# -# Use it like this: -# ./run-cat-locally [usual virt-cat args ...] - -use strict; -use warnings; - -use File::Basename qw(dirname); -use File::Spec; -use Cwd qw(abs_path); - -my $path = $0; -my $tool = "cat"; - -# Follow symlinks until we get to the real file -while(-l $path) { - my $link = readlink($path) or die "readlink: $path: $!"; - if(File::Spec->file_name_is_absolute($link)) { - $path = $link; - } else { - $path = File::Spec->catfile(dirname($path), $link); - } -} - -# Get the absolute path of the parent directory -$path = abs_path(dirname($path).'/..'); - -$ENV{LD_LIBRARY_PATH} = $path.'/src/.libs'; -$ENV{LIBGUESTFS_PATH} = $path.'/appliance'; - -#print (join " ", ("$path/$tool/virt-$tool", @ARGV), "\n"); -exec("$path/$tool/virt-$tool", @ARGV); diff --git a/cat/run-filesystems-locally b/cat/run-filesystems-locally deleted file mode 100755 index 316cc6d..0000000 --- a/cat/run-filesystems-locally +++ /dev/null @@ -1,52 +0,0 @@ -#!/usr/bin/perl -# Copyright (C) 2009 Red Hat Inc. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -# This script sets up the environment so you can run virt-* tools in -# place without needing to do 'make install' first. You can also run -# the tools by creating a symlink to this script and putting it in -# your path. -# -# Use it like this: -# ./run-filesystems-locally [usual virt-filesystems args ...] - -use strict; -use warnings; - -use File::Basename qw(dirname); -use File::Spec; -use Cwd qw(abs_path); - -my $path = $0; - -# Follow symlinks until we get to the real file -while(-l $path) { - my $link = readlink($path) or die "readlink: $path: $!"; - if(File::Spec->file_name_is_absolute($link)) { - $path = $link; - } else { - $path = File::Spec->catfile(dirname($path), $link); - } -} - -# Get the absolute path of the parent directory -$path = abs_path(dirname($path).'/..'); - -$ENV{LD_LIBRARY_PATH} = $path.'/src/.libs'; -$ENV{LIBGUESTFS_PATH} = $path.'/appliance'; - -#print (join " ", ("$path/cat/virt-filesystems", @ARGV), "\n"); -exec("$path/cat/virt-filesystems", @ARGV); diff --git a/cat/run-ls-locally b/cat/run-ls-locally deleted file mode 100755 index adc2cb6..0000000 --- a/cat/run-ls-locally +++ /dev/null @@ -1,52 +0,0 @@ -#!/usr/bin/perl -# Copyright (C) 2009 Red Hat Inc. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -# This script sets up the environment so you can run virt-* tools in -# place without needing to do 'make install' first. You can also run -# the tools by creating a symlink to this script and putting it in -# your path. -# -# Use it like this: -# ./run-ls-locally [usual virt-ls args ...] - -use strict; -use warnings; - -use File::Basename qw(dirname); -use File::Spec; -use Cwd qw(abs_path); - -my $path = $0; - -# Follow symlinks until we get to the real file -while(-l $path) { - my $link = readlink($path) or die "readlink: $path: $!"; - if(File::Spec->file_name_is_absolute($link)) { - $path = $link; - } else { - $path = File::Spec->catfile(dirname($path), $link); - } -} - -# Get the absolute path of the parent directory -$path = abs_path(dirname($path).'/..'); - -$ENV{LD_LIBRARY_PATH} = $path.'/src/.libs'; -$ENV{LIBGUESTFS_PATH} = $path.'/appliance'; - -#print (join " ", ("$path/cat/virt-ls", @ARGV), "\n"); -exec("$path/cat/virt-ls", @ARGV); diff --git a/df/Makefile.am b/df/Makefile.am index 81c190f..69c6140 100644 --- a/df/Makefile.am +++ b/df/Makefile.am @@ -19,7 +19,6 @@ include $(top_srcdir)/subdir-rules.mk EXTRA_DIST = \ README \ - run-df-locally \ test-virt-df.sh \ virt-df.pod diff --git a/df/run-df-locally b/df/run-df-locally deleted file mode 100755 index 2456ab5..0000000 --- a/df/run-df-locally +++ /dev/null @@ -1,52 +0,0 @@ -#!/usr/bin/perl -# Copyright (C) 2009 Red Hat Inc. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -# This script sets up the environment so you can run virt-* tools in -# place without needing to do 'make install' first. You can also run -# the tools by creating a symlink to this script and putting it in -# your path. -# -# Use it like this: -# ./run-df-locally [usual virt-df args ...] - -use strict; -use warnings; - -use File::Basename qw(dirname); -use File::Spec; -use Cwd qw(abs_path); - -my $path = $0; - -# Follow symlinks until we get to the real file -while(-l $path) { - my $link = readlink($path) or die "readlink: $path: $!"; - if(File::Spec->file_name_is_absolute($link)) { - $path = $link; - } else { - $path = File::Spec->catfile(dirname($path), $link); - } -} - -# Get the absolute path of the parent directory -$path = abs_path(dirname($path).'/..'); - -$ENV{LD_LIBRARY_PATH} = $path.'/src/.libs'; -$ENV{LIBGUESTFS_PATH} = $path.'/appliance'; - -#print (join " ", ("$path/df/virt-df", @ARGV), "\n"); -exec("$path/df/virt-df", @ARGV); diff --git a/inspector/Makefile.am b/inspector/Makefile.am index 435ba87..8024f98 100644 --- a/inspector/Makefile.am +++ b/inspector/Makefile.am @@ -33,7 +33,6 @@ EXAMPLE_XML = \ example-windows-xp-cd.xml EXTRA_DIST = \ - run-inspector-locally \ virt-inspector.pod CLEANFILES = stamp-virt-inspector.pod @@ -101,17 +100,18 @@ endif example-debian.xml: rm -f $@ $@-t - ./run-inspector-locally ../images/debian.img > $@-t + ../run $(builddir)/virt-inspector ../images/debian.img > $@-t mv $@-t $@ example-fedora.xml: rm -f $@ $@-t - ./run-inspector-locally ../images/fedora.img > $@-t + ../run $(builddir)/virt-inspector ../images/fedora.img > $@-t mv $@-t $@ example-ubuntu.xml: rm -f $@ $@-t - ./run-inspector-locally ../images/ubuntu.img > $@-t + ../run $(builddir)/virt-inspector ../images/ubuntu.img > $@-t mv $@-t $@ example-windows.xml: rm -f $@ $@-t - ./run-inspector-locally ../images/windows.img | fgrep -v '' > $@-t + ../run $(builddir)/virt-inspector ../images/windows.img | \ + fgrep -v '' > $@-t mv $@-t $@ diff --git a/inspector/run-inspector-locally b/inspector/run-inspector-locally deleted file mode 100755 index e5c9f4a..0000000 --- a/inspector/run-inspector-locally +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/perl -# libguestfs inspector -# Copyright (C) 2009 Red Hat Inc. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -# This script sets up the environment so you can run virt-inspector in place -# without needing to do 'make install' first. You can also run virt-inspector -# by creating a symlink to this script and putting it in your path. -# -# Use it like this: -# ./run-inspector-locally [usual virt-inspector args ...] - -use strict; -use warnings; - -use File::Basename qw(dirname); -use File::Spec; -use Cwd qw(abs_path); - -my $path = $0; - -# Follow symlinks until we get to the real file -while(-l $path) { - my $link = readlink($path) or die "readlink: $path: $!"; - if(File::Spec->file_name_is_absolute($link)) { - $path = $link; - } else { - $path = File::Spec->catfile(dirname($path), $link); - } -} - -# Get the absolute path of the parent directory -$path = abs_path(dirname($path).'/..'); - -$ENV{LD_LIBRARY_PATH} = $path.'/src/.libs'; -$ENV{LIBGUESTFS_PATH} = $path.'/appliance'; - -exec($path.'/inspector/virt-inspector', @ARGV); diff --git a/rescue/Makefile.am b/rescue/Makefile.am index a490341..0032a23 100644 --- a/rescue/Makefile.am +++ b/rescue/Makefile.am @@ -18,7 +18,6 @@ include $(top_srcdir)/subdir-rules.mk EXTRA_DIST = \ - run-rescue-locally \ virt-rescue.pod CLEANFILES = stamp-virt-rescue.pod diff --git a/rescue/run-rescue-locally b/rescue/run-rescue-locally deleted file mode 100755 index 95f3cc4..0000000 --- a/rescue/run-rescue-locally +++ /dev/null @@ -1,52 +0,0 @@ -#!/usr/bin/perl -# Copyright (C) 2009 Red Hat Inc. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -# This script sets up the environment so you can run virt-* tools in -# place without needing to do 'make install' first. You can also run -# the tools by creating a symlink to this script and putting it in -# your path. -# -# Use it like this: -# ./run-rescue-locally [usual virt-rescue args ...] - -use strict; -use warnings; - -use File::Basename qw(dirname); -use File::Spec; -use Cwd qw(abs_path); - -my $path = $0; - -# Follow symlinks until we get to the real file -while(-l $path) { - my $link = readlink($path) or die "readlink: $path: $!"; - if(File::Spec->file_name_is_absolute($link)) { - $path = $link; - } else { - $path = File::Spec->catfile(dirname($path), $link); - } -} - -# Get the absolute path of the parent directory -$path = abs_path(dirname($path).'/..'); - -$ENV{LD_LIBRARY_PATH} = $path.'/src/.libs'; -$ENV{LIBGUESTFS_PATH} = $path.'/appliance'; - -#print (join " ", ("$path/rescue/virt-rescue", @ARGV), "\n"); -exec("$path/rescue/virt-rescue", @ARGV); diff --git a/resize/Makefile.am b/resize/Makefile.am index 838c78d..f3e6aff 100644 --- a/resize/Makefile.am +++ b/resize/Makefile.am @@ -19,7 +19,6 @@ include $(top_srcdir)/subdir-rules.mk EXTRA_DIST = \ $(SOURCES) \ - run-resize-locally \ virt-resize.pod \ test-virt-resize.sh diff --git a/resize/run-resize-locally b/resize/run-resize-locally deleted file mode 100755 index 0d840dd..0000000 --- a/resize/run-resize-locally +++ /dev/null @@ -1,53 +0,0 @@ -#!/usr/bin/perl -# Copyright (C) 2009-2011 Red Hat Inc. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -# This script sets up the environment so you can run virt-* tools in -# place without needing to do 'make install' first. You can also run -# the tools by creating a symlink to this script and putting it in -# your path. -# -# Use it like this: -# ./run-resize-locally [usual virt-resize args ...] - -use strict; -use warnings; - -use File::Basename qw(dirname); -use File::Spec; -use Cwd qw(abs_path); - -my $path = $0; -my $tool = "resize"; - -# Follow symlinks until we get to the real file -while(-l $path) { - my $link = readlink($path) or die "readlink: $path: $!"; - if(File::Spec->file_name_is_absolute($link)) { - $path = $link; - } else { - $path = File::Spec->catfile(dirname($path), $link); - } -} - -# Get the absolute path of the parent directory -$path = abs_path(dirname($path).'/..'); - -$ENV{LD_LIBRARY_PATH} = $path.'/src/.libs'; -$ENV{LIBGUESTFS_PATH} = $path.'/appliance'; - -#print (join " ", ("$path/$tool/virt-$tool", @ARGV), "\n"); -exec("$path/$tool/virt-$tool", @ARGV); diff --git a/run b/run new file mode 100755 index 0000000..04152b1 --- /dev/null +++ b/run @@ -0,0 +1,42 @@ +#!/bin/bash - +# libguestfs 'run' programs locally script +# Copyright (C) 2011 Red Hat Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +#---------------------------------------------------------------------- + +# With this script you can run all the virt tools without needing to +# install them first. You just have to do for example: +# +# ./run ./inspector/virt-inspector [args ...] +# +# This works for any C, OCaml or Perl virt tools in the libguestfs +# distribution. Also you can make a symbolic link to this 'run' +# script from anywhere (eg. $HOME/bin/run) if you wish. + +#---------------------------------------------------------------------- + +# Find this script. +run=$(readlink -f "$0") +b=$(dirname "$run") + +# Set local environment relative to this script. +export LD_LIBRARY_PATH="$b/src/.libs" +export LIBGUESTFS_PATH="$b/appliance" +export PERL5LIB="$b/perl/blib/lib:$b/perl/blib/arch" + +# Run the program. +libtool --mode=execute "$@" diff --git a/test-tool/Makefile.am b/test-tool/Makefile.am index 5ce2164..1ed0820 100644 --- a/test-tool/Makefile.am +++ b/test-tool/Makefile.am @@ -17,7 +17,7 @@ include $(top_srcdir)/subdir-rules.mk -EXTRA_DIST = libguestfs-test-tool.pod run-test-tool-locally +EXTRA_DIST = libguestfs-test-tool.pod CLEANFILES = diff --git a/test-tool/run-test-tool-locally b/test-tool/run-test-tool-locally deleted file mode 100755 index 21df4c5..0000000 --- a/test-tool/run-test-tool-locally +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/perl -# Copyright (C) 2010-2011 Red Hat Inc. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -# This script sets up the environment so you can run -# libguestfs-test-tool in place without needing to do 'make install' -# first. You can also run the test tool by creating a symlink to this -# script and putting it in your path. -# -# Normal use is like this: -# ./run-test-tool-locally - -use strict; -use warnings; - -use File::Basename qw(dirname); -use File::Spec; -use Cwd qw(abs_path); - -my $path = $0; -my $tool = shift @ARGV; - -# Follow symlinks until we get to the real file -while(-l $path) { - my $link = readlink($path) or die "readlink: $path: $!"; - if(File::Spec->file_name_is_absolute($link)) { - $path = $link; - } else { - $path = File::Spec->catfile(dirname($path), $link); - } -} - -# Get the absolute path of the parent directory -$path = abs_path(dirname($path).'/..'); - -$ENV{LD_LIBRARY_PATH} = $path.'/src/.libs'; -$ENV{LIBGUESTFS_PATH} = $path.'/appliance'; - -exec("$path/test-tool/libguestfs-test-tool", - "$path/test-tool/libguestfs-test-tool", - @ARGV); diff --git a/tools/Makefile.am b/tools/Makefile.am index 806f244..6441333 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -26,7 +26,6 @@ tools = \ win-reg EXTRA_DIST = \ - run-locally \ $(tools:%=virt-%) \ test-virt-*.sh diff --git a/tools/run-locally b/tools/run-locally deleted file mode 100755 index cb3dca8..0000000 --- a/tools/run-locally +++ /dev/null @@ -1,56 +0,0 @@ -#!/usr/bin/perl -# Copyright (C) 2009 Red Hat Inc. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -# This script sets up the environment so you can run virt-* tools in -# place without needing to do 'make install' first. You can also run -# the tools by creating a symlink to this script and putting it in -# your path. -# -# Use it like this: -# ./run-locally tool [usual virt-tool args ...] -# eg: -# ./run-locally cat domname /etc/passwd - -use strict; -use warnings; - -use File::Basename qw(dirname); -use File::Spec; -use Cwd qw(abs_path); - -my $path = $0; -my $tool = shift @ARGV; - -# Follow symlinks until we get to the real file -while(-l $path) { - my $link = readlink($path) or die "readlink: $path: $!"; - if(File::Spec->file_name_is_absolute($link)) { - $path = $link; - } else { - $path = File::Spec->catfile(dirname($path), $link); - } -} - -# Get the absolute path of the parent directory -$path = abs_path(dirname($path).'/..'); - -$ENV{LD_LIBRARY_PATH} = $path.'/src/.libs'; -$ENV{LIBGUESTFS_PATH} = $path.'/appliance'; -$ENV{PERL5LIB} = $path.'/perl/blib/lib:'.$path.'/perl/blib/arch'; - -#print (join " ", ("$path/tools/virt-$tool", @ARGV), "\n"); -exec('perl', "$path/tools/virt-$tool", @ARGV); -- 1.8.3.1