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.
(cherry picked from commit 5790f5bfaf)
This commit is contained in:
Richard W.M. Jones
2011-04-15 21:43:20 +01:00
parent 75419808cd
commit d642bef766
19 changed files with 79 additions and 490 deletions

View File

@@ -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.

28
README
View File

@@ -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
----------------------------------------------------------------------

View File

@@ -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

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -19,7 +19,6 @@ include $(top_srcdir)/subdir-rules.mk
EXTRA_DIST = \
README \
run-df-locally \
test-virt-df.sh \
virt-df.pod

View File

@@ -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);

View File

@@ -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 '<uuid>' > $@-t
../run $(builddir)/virt-inspector ../images/windows.img | \
fgrep -v '<uuid>' > $@-t
mv $@-t $@

View File

@@ -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);

View File

@@ -18,7 +18,6 @@
include $(top_srcdir)/subdir-rules.mk
EXTRA_DIST = \
run-rescue-locally \
virt-rescue.pod
CLEANFILES = stamp-virt-rescue.pod

View File

@@ -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);

View File

@@ -19,7 +19,6 @@ include $(top_srcdir)/subdir-rules.mk
EXTRA_DIST = \
$(SOURCES) \
run-resize-locally \
virt-resize.pod \
test-virt-resize.sh

View File

@@ -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);

42
run Executable file
View File

@@ -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 "$@"

View File

@@ -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 =

View File

@@ -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);

View File

@@ -26,7 +26,6 @@ tools = \
win-reg
EXTRA_DIST = \
run-locally \
$(tools:%=virt-%) \
test-virt-*.sh

View File

@@ -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);