Move virt tools (virt-cat, virt-edit etc) into tools/ subdirectory.

This moves the tool programs into a single directory:
  cat/* -> tools/virt-cat
  df/* -> tools/virt-df
  edit/* -> tools/virt-edit
  rescue/* -> tools/virt-rescue

This in itself simplifies the build process because we only need
one Makefile and one copy of 'run-locally'.

'run-*-locally' has become just 'run-locally' and takes an extra
parameter which is the name of the tool, eg:
  run-locally cat [virt-cat params...]

virt-inspector stays in its own directory, because this contains
more than just a single Perl script.
This commit is contained in:
Richard Jones
2009-10-19 10:18:46 +01:00
parent 854f8e0d56
commit 945b6e0a08
17 changed files with 46 additions and 360 deletions

5
.gitignore vendored
View File

@@ -23,7 +23,6 @@ capitests/test*.img
capitests/tests
capitests/tests.c
capitests/test*.tmp
cat/virt-cat.1
ChangeLog
*.class
*.cma
@@ -47,8 +46,6 @@ daemon/names.c
daemon/stubs.c
depcomp
.deps
df/virt-df.1
edit/virt-edit.1
emptydisk
examples/hello
examples/to-xml
@@ -179,7 +176,6 @@ python/guestfs.py
python/guestfs-py.c
python/guestfs.pyc
regressions/test1.img
rescue/virt-rescue.1
ruby/bindtests.rb
ruby/ext/guestfs/extconf.h
ruby/ext/guestfs/_guestfs.c
@@ -201,6 +197,7 @@ stamp-h1
test-tool/libguestfs-test-tool.1
test-tool/libguestfs-test-tool
test-tool/libguestfs-test-tool-helper
tools/virt-*.1
/GNUmakefile
/maint.mk
/build-aux

18
HACKING
View File

@@ -68,9 +68,6 @@ Directories
appliance/
The qemu appliance, build scripts and so on.
cat/
The virt-cat tool.
capitests/
Automated tests of the C API.
@@ -80,12 +77,6 @@ contrib/
daemon/
The daemon that runs inside the guest and carries out actions.
df/
The virt-df tool.
edit/
The virt-edit tool.
examples/
The examples.
@@ -125,12 +116,15 @@ python/
regressions/
Regression tests.
rescue/
The virt-rescue tool.
ruby/
Ruby bindings.
tools/
Command line tools like virt-cat, virt-df, virt-edit and more.
In versions <= 1.0.73 these were all in separate directories
like cat/, df/, edit/, but since then we moved them all into
one directory to simplify builds.
src/
Source code to the C library.
Also contains the crucial generator program.

View File

@@ -26,9 +26,14 @@ SUBDIRS = gnulib/lib src daemon appliance fish po examples images \
if HAVE_PERL
SUBDIRS += perl
endif
if HAVE_INSPECTOR
SUBDIRS += inspector
endif
if HAVE_TOOLS
SUBDIRS += tools
endif
if HAVE_OCAML
SUBDIRS += ocaml ocaml/examples
endif
@@ -44,18 +49,6 @@ endif
if HAVE_HASKELL
SUBDIRS += haskell
endif
if HAVE_DF
SUBDIRS += df
endif
if HAVE_CAT
SUBDIRS += cat
endif
if HAVE_RESCUE
SUBDIRS += rescue
endif
if HAVE_EDIT
SUBDIRS += edit
endif
EXTRA_DIST = \
guestfs.pod guestfs-actions.pod guestfs-structs.pod \

View File

@@ -1,52 +0,0 @@
#!/usr/bin/perl
# virt-cat
# 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-cat in place
# without needing to do 'make install' first. You can also run virt-cat
# 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;
# 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';
exec('perl', $path.'/cat/virt-cat', @ARGV);

View File

@@ -675,18 +675,12 @@ for pm in Pod::Usage Getopt::Long Sys::Virt Data::Dumper XML::Writer Locale::Tex
fi
done
if test "x$missing_perl_modules" = "xyes"; then
AC_MSG_WARN([some Perl modules required to compile virt-cat, virt-df, virt-edit, virt-inspector and virt-rescue are missing])
AC_MSG_WARN([some Perl modules required to compile virt-inspector and the other virt-* tools are missing])
fi
AM_CONDITIONAL([HAVE_CAT],
[test "x$PERL" != "xno" -a "x$missing_perl_modules" != "xyes"])
AM_CONDITIONAL([HAVE_DF],
[test "x$PERL" != "xno" -a "x$missing_perl_modules" != "xyes"])
AM_CONDITIONAL([HAVE_EDIT],
[test "x$PERL" != "xno" -a "x$missing_perl_modules" != "xyes"])
AM_CONDITIONAL([HAVE_INSPECTOR],
[test "x$PERL" != "xno" -a "x$missing_perl_modules" != "xyes"])
AM_CONDITIONAL([HAVE_RESCUE],
AM_CONDITIONAL([HAVE_TOOLS],
[test "x$PERL" != "xno" -a "x$missing_perl_modules" != "xyes"])
dnl Library versioning.
@@ -723,11 +717,8 @@ AC_CONFIG_FILES([Makefile
ruby/Makefile ruby/Rakefile
java/Makefile
haskell/Makefile
cat/Makefile
df/Makefile
edit/Makefile
inspector/Makefile
rescue/Makefile
tools/Makefile
libguestfs.pc
gnulib/lib/Makefile
gnulib/tests/Makefile
@@ -755,16 +746,10 @@ echo -n "Java bindings ....................... "
if test "x$HAVE_JAVA_TRUE" = "x"; then echo "yes"; else echo "no"; fi
echo -n "Haskell bindings .................... "
if test "x$HAVE_HASKELL" = "x"; then echo "yes"; else echo "no"; fi
echo -n "virt-cat ............................ "
if test "x$HAVE_CAT" = "x"; then echo "yes"; else echo "no"; fi
echo -n "virt-df ............................. "
if test "x$HAVE_DF" = "x"; then echo "yes"; else echo "no"; fi
echo -n "virt-edit ........................... "
if test "x$HAVE_EDIT" = "x"; then echo "yes"; else echo "no"; fi
echo -n "virt-inspector ...................... "
if test "x$HAVE_INSPECTOR" = "x"; then echo "yes"; else echo "no"; fi
echo -n "virt-rescue ......................... "
if test "x$HAVE_RESCUE" = "x"; then echo "yes"; else echo "no"; fi
echo -n "virt-* tools ........................ "
if test "x$HAVE_TOOLS" = "x"; then echo "yes"; else echo "no"; fi
echo "supermin appliance .................. $enable_supermin"
echo
echo "If any optional component is configured 'no' when you expected 'yes'"

View File

@@ -1,45 +0,0 @@
# libguestfs virt-df
# 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.
EXTRA_DIST = \
run-df-locally \
virt-df
if HAVE_DF
bin_SCRIPTS = virt-df
man_MANS = virt-df.1
noinst_DATA = $(top_builddir)/html/virt-df.1.html
virt-df.1: virt-df
$(POD2MAN) \
--section 1 \
-c "Virtualization Support" \
--release "$(PACKAGE_NAME)-$(PACKAGE_VERSION)" \
$< > $@-t && mv $@-t $@
$(top_builddir)/html/virt-df.1.html: virt-df
mkdir -p $(top_builddir)/html
cd $(top_builddir) && pod2html \
--css 'pod.css' \
--title 'virt-df, display free space on virtual filesystems' \
--htmldir html \
--outfile html/virt-df.1.html \
df/$<
endif

View File

@@ -1,52 +0,0 @@
#!/usr/bin/perl
# virt-df
# 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-df in place
# without needing to do 'make install' first. You can also run virt-df
# 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';
$ENV{PERL5LIB} = $path.'/perl/blib/lib:'.$path.'/perl/blib/arch';
exec('perl', $path.'/df/virt-df', @ARGV);

View File

@@ -1,45 +0,0 @@
# libguestfs virt-edit
# 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.
EXTRA_DIST = \
run-edit-locally \
virt-edit
if HAVE_EDIT
bin_SCRIPTS = virt-edit
man_MANS = virt-edit.1
noinst_DATA = $(top_builddir)/html/virt-edit.1.html
virt-edit.1: virt-edit
$(POD2MAN) \
--section 1 \
-c "Virtualization Support" \
--release "$(PACKAGE_NAME)-$(PACKAGE_VERSION)" \
$< > $@-t && mv $@-t $@
$(top_builddir)/html/virt-edit.1.html: virt-edit
mkdir -p $(top_builddir)/html
cd $(top_builddir) && pod2html \
--css 'pod.css' \
--title 'virt-edit, edit a file in a virtual machine' \
--htmldir html \
--outfile html/virt-edit.1.html \
edit/$<
endif

View File

@@ -1,52 +0,0 @@
#!/usr/bin/perl
# virt-edit
# 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-edit in place
# without needing to do 'make install' first. You can also run virt-edit
# by creating a symlink to this script and putting it in your path.
#
# Use it like this:
# ./run-edit-locally [usual virt-edit 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';
$ENV{PERL5LIB} = $path.'/perl/blib/lib:'.$path.'/perl/blib/arch';
exec('perl', $path.'/edit/virt-edit', @ARGV);

View File

@@ -1,4 +1,3 @@
cat/virt-cat
daemon/augeas.c
daemon/blockdev.c
daemon/checksum.c
@@ -55,8 +54,6 @@ daemon/wc.c
daemon/xattr.c
daemon/zero.c
daemon/zerofree.c
df/virt-df
edit/virt-edit
fish/alloc.c
fish/cmds.c
fish/completion.c
@@ -81,10 +78,13 @@ perl/lib/Sys/Guestfs.pm
perl/lib/Sys/Guestfs/Lib.pm
python/guestfs-py.c
regressions/test-noexec-stack.pl
rescue/virt-rescue
ruby/ext/guestfs/_guestfs.c
src/guestfs-actions.c
src/guestfs-bindtests.c
src/guestfs.c
test-tool/helper.c
test-tool/test-tool.c
tools/virt-cat
tools/virt-df
tools/virt-edit
tools/virt-rescue

View File

@@ -1,45 +0,0 @@
# libguestfs virt-rescue
# 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.
EXTRA_DIST = \
run-rescue-locally \
virt-rescue
if HAVE_RESCUE
bin_SCRIPTS = virt-rescue
man_MANS = virt-rescue.1
noinst_DATA = $(top_builddir)/html/virt-rescue.1.html
virt-rescue.1: virt-rescue
$(POD2MAN) \
--section 1 \
-c "Virtualization Support" \
--release "$(PACKAGE_NAME)-$(PACKAGE_VERSION)" \
$< > $@-t && mv $@-t $@
$(top_builddir)/html/virt-rescue.1.html: virt-rescue
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/$<
endif

View File

@@ -1,4 +1,4 @@
# libguestfs virt-cat
# libguestfs virt-* tools
# Copyright (C) 2009 Red Hat Inc.
#
# This program is free software; you can redistribute it and/or modify
@@ -15,31 +15,36 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
tools = cat df edit rescue
EXTRA_DIST = \
run-cat-locally \
virt-cat
run-locally \
$(tools:%=virt-%)
if HAVE_CAT
if HAVE_TOOLS
bin_SCRIPTS = virt-cat
man_MANS = virt-cat.1
bin_SCRIPTS = $(tools:%=virt-%)
noinst_DATA = $(top_builddir)/html/virt-cat.1.html
# XXX Bug in automake? If you list virt-cat.1 explicitly, then it
# builds and installs the man pages. However if this is removed,
# then the man pages are neither built nor installed.
man_MANS = virt-cat.1 $(patsubst %,virt-%.1,$(filter-out cat,$(tools)))
virt-cat.1: virt-cat
noinst_DATA = $(tools:%=$(top_builddir)/html/virt-%.1.html)
virt-%.1: virt-%
$(POD2MAN) \
--section 1 \
-c "Virtualization Support" \
--release "$(PACKAGE_NAME)-$(PACKAGE_VERSION)" \
$< > $@-t && mv $@-t $@
$(top_builddir)/html/virt-cat.1.html: virt-cat
$(top_builddir)/html/virt-%.1.html: virt-%
mkdir -p $(top_builddir)/html
cd $(top_builddir) && pod2html \
--css 'pod.css' \
--title 'virt-cat, display a file in a virtual machine' \
--htmldir html \
--outfile html/virt-cat.1.html \
cat/$<
--outfile html/$<.1.html \
tools/$<
endif

View File

@@ -1,5 +1,4 @@
#!/usr/bin/perl
# virt-rescue
# Copyright (C) 2009 Red Hat Inc.
#
# This program is free software; you can redistribute it and/or modify
@@ -16,13 +15,15 @@
# 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-rescue in
# 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
# virt-rescue by creating a symlink to this script and putting it in
# 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 ...]
# ./run-locally tool [usual virt-tool args ...]
# eg:
# ./run-locally cat domname /etc/passwd
use strict;
use warnings;
@@ -32,6 +33,7 @@ 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) {
@@ -50,4 +52,5 @@ $ENV{LD_LIBRARY_PATH} = $path.'/src/.libs';
$ENV{LIBGUESTFS_PATH} = $path.'/appliance';
$ENV{PERL5LIB} = $path.'/perl/blib/lib:'.$path.'/perl/blib/arch';
exec('perl', $path.'/rescue/virt-rescue', @ARGV);
print (join " ", ("$path/tools/virt-$tool", @ARGV), "\n");
exec('perl', "$path/tools/virt-$tool", @ARGV);