Three more pieces of common code are moved under the common/
subdirectory. This is just code motion.
Note that windows.[ch] wasn't even being used by guestfish. That code
was only used in other virt tools.
---
Makefile.am | 6 +++++-
cat/Makefile.am | 22 ++++++++-------------
common/edit/Makefile.am | 35 ++++++++++++++++++++++++++++++++++
{fish => common/edit}/file-edit.c | 4 ++--
{fish => common/edit}/file-edit.h | 0
common/progress/Makefile.am | 37 ++++++++++++++++++++++++++++++++++++
{fish => common/progress}/progress.c | 0
{fish => common/progress}/progress.h | 0
common/windows/Makefile.am | 37 ++++++++++++++++++++++++++++++++++++
{fish => common/windows}/windows.c | 0
{fish => common/windows}/windows.h | 0
configure.ac | 3 +++
customize/Makefile.am | 6 +++---
docs/C_SOURCE_FILES | 12 ++++++------
docs/guestfs-hacking.pod | 13 +++++++++++++
edit/Makefile.am | 12 ++++--------
fish/Makefile.am | 9 ++++-----
mllib/Makefile.am | 4 ++--
po/POTFILES | 6 +++---
19 files changed, 162 insertions(+), 44 deletions(-)
create mode 100644 common/edit/Makefile.am
rename {fish => common/edit}/file-edit.c (100%)
rename {fish => common/edit}/file-edit.h (100%)
create mode 100644 common/progress/Makefile.am
rename {fish => common/progress}/progress.c (100%)
rename {fish => common/progress}/progress.h (100%)
create mode 100644 common/windows/Makefile.am
rename {fish => common/windows}/windows.c (100%)
rename {fish => common/windows}/windows.h (100%)
diff --git a/Makefile.am b/Makefile.am
index 604ca51..49aed47 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -89,7 +89,11 @@ SUBDIRS += tests/tsk
endif
# Common code used by the tools.
-SUBDIRS += common/visit common/options
+SUBDIRS += common/edit
+SUBDIRS += common/options
+SUBDIRS += common/progress
+SUBDIRS += common/visit
+SUBDIRS += common/windows
# libguestfs-test-tool
SUBDIRS += test-tool
diff --git a/cat/Makefile.am b/cat/Makefile.am
index 14d23b0..4b91719 100644
--- a/cat/Makefile.am
+++ b/cat/Makefile.am
@@ -32,12 +32,7 @@ EXTRA_DIST = \
bin_PROGRAMS = virt-cat virt-filesystems virt-log virt-ls virt-tail
-SHARED_SOURCE_FILES = \
- ../fish/windows.h \
- ../fish/windows.c
-
virt_cat_SOURCES = \
- $(SHARED_SOURCE_FILES) \
cat.c
virt_cat_CPPFLAGS = \
@@ -46,7 +41,7 @@ virt_cat_CPPFLAGS = \
-I$(top_srcdir)/common/utils -I$(top_builddir)/common/utils \
-I$(top_srcdir)/lib -I$(top_builddir)/lib \
-I$(top_srcdir)/common/options -I$(top_builddir)/common/options \
- -I$(top_srcdir)/fish \
+ -I$(top_srcdir)/common/windows -I$(top_builddir)/common/windows \
-I$(srcdir)/../gnulib/lib -I../gnulib/lib
virt_cat_CFLAGS = \
@@ -55,6 +50,7 @@ virt_cat_CFLAGS = \
virt_cat_LDADD = \
$(top_builddir)/common/options/liboptions.la \
+ $(top_builddir)/common/windows/libwindows.la \
$(top_builddir)/common/utils/libutils.la \
$(top_builddir)/lib/libguestfs.la \
$(LIBXML2_LIBS) \
@@ -63,7 +59,6 @@ virt_cat_LDADD = \
../gnulib/lib/libgnu.la
virt_filesystems_SOURCES = \
- $(SHARED_SOURCE_FILES) \
filesystems.c
virt_filesystems_CPPFLAGS = \
@@ -72,7 +67,7 @@ virt_filesystems_CPPFLAGS = \
-I$(top_srcdir)/common/utils -I$(top_builddir)/common/utils \
-I$(top_srcdir)/lib -I$(top_builddir)/lib \
-I$(top_srcdir)/common/options -I$(top_builddir)/common/options \
- -I$(top_srcdir)/fish \
+ -I$(top_srcdir)/common/windows -I$(top_builddir)/common/windows \
-I$(srcdir)/../gnulib/lib -I../gnulib/lib
virt_filesystems_CFLAGS = \
@@ -81,6 +76,7 @@ virt_filesystems_CFLAGS = \
virt_filesystems_LDADD = \
$(top_builddir)/common/options/liboptions.la \
+ $(top_builddir)/common/windows/libwindows.la \
$(top_builddir)/common/utils/libutils.la \
$(top_builddir)/lib/libguestfs.la \
$(LIBXML2_LIBS) \
@@ -89,7 +85,6 @@ virt_filesystems_LDADD = \
../gnulib/lib/libgnu.la
virt_log_SOURCES = \
- $(SHARED_SOURCE_FILES) \
log.c
virt_log_CPPFLAGS = \
@@ -98,7 +93,7 @@ virt_log_CPPFLAGS = \
-I$(top_srcdir)/common/utils -I$(top_builddir)/common/utils \
-I$(top_srcdir)/lib -I$(top_builddir)/lib \
-I$(top_srcdir)/common/options -I$(top_builddir)/common/options \
- -I$(top_srcdir)/fish \
+ -I$(top_srcdir)/common/windows -I$(top_builddir)/common/windows \
-I$(srcdir)/../gnulib/lib -I../gnulib/lib
virt_log_CFLAGS = \
@@ -115,7 +110,6 @@ virt_log_LDADD = \
../gnulib/lib/libgnu.la
virt_ls_SOURCES = \
- $(SHARED_SOURCE_FILES) \
ls.c
virt_ls_CPPFLAGS = \
@@ -125,7 +119,7 @@ virt_ls_CPPFLAGS = \
-I$(top_srcdir)/lib -I$(top_builddir)/lib \
-I$(top_srcdir)/common/visit \
-I$(top_srcdir)/common/options -I$(top_builddir)/common/options \
- -I$(top_srcdir)/fish \
+ -I$(top_srcdir)/common/windows -I$(top_builddir)/common/windows \
-I$(srcdir)/../gnulib/lib -I../gnulib/lib
virt_ls_CFLAGS = \
@@ -143,7 +137,6 @@ virt_ls_LDADD = \
../gnulib/lib/libgnu.la
virt_tail_SOURCES = \
- $(SHARED_SOURCE_FILES) \
tail.c
virt_tail_CPPFLAGS = \
@@ -152,7 +145,7 @@ virt_tail_CPPFLAGS = \
-I$(top_srcdir)/common/utils -I$(top_builddir)/common/utils \
-I$(top_srcdir)/lib -I$(top_builddir)/lib \
-I$(top_srcdir)/common/options -I$(top_builddir)/common/options \
- -I$(top_srcdir)/fish \
+ -I$(top_srcdir)/common/windows -I$(top_builddir)/common/windows \
-I$(srcdir)/../gnulib/lib -I../gnulib/lib
virt_tail_CFLAGS = \
@@ -161,6 +154,7 @@ virt_tail_CFLAGS = \
virt_tail_LDADD = \
$(top_builddir)/common/options/liboptions.la \
+ $(top_builddir)/common/windows/libwindows.la \
$(top_builddir)/common/utils/libutils.la \
$(top_builddir)/lib/libguestfs.la \
$(LIBXML2_LIBS) \
diff --git a/common/edit/Makefile.am b/common/edit/Makefile.am
new file mode 100644
index 0000000..592f6fc
--- /dev/null
+++ b/common/edit/Makefile.am
@@ -0,0 +1,35 @@
+# libguestfs
+# Copyright (C) 2009-2017 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+include $(top_srcdir)/subdir-rules.mk
+
+# libedit.la contains the common code used by virt-edit, guestfish
+# 'edit' command, virt-customize and virt-builder.
+noinst_LTLIBRARIES = libedit.la
+
+libedit_la_SOURCES = \
+ file-edit.c \
+ file-edit.h
+libedit_la_CPPFLAGS = \
+ -DGUESTFS_WARN_DEPRECATED=1 \
+ -I$(top_srcdir)/common/utils -I$(top_builddir)/common/utils \
+ -I$(top_srcdir)/lib -I$(top_builddir)/lib
+libedit_la_CFLAGS = \
+ $(WARN_CFLAGS) $(WERROR_CFLAGS)
+libedit_la_LIBADD = \
+ $(top_builddir)/common/utils/libutils.la \
+ $(top_builddir)/lib/libguestfs.la
diff --git a/fish/file-edit.c b/common/edit/file-edit.c
similarity index 100%
rename from fish/file-edit.c
rename to common/edit/file-edit.c
index e3bd7fe..a730011 100644
--- a/fish/file-edit.c
+++ b/common/edit/file-edit.c
@@ -27,8 +27,6 @@
#include <config.h>
-#include "file-edit.h"
-
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -45,6 +43,8 @@
#include "guestfs-internal-frontend.h"
+#include "file-edit.h"
+
static int do_download (guestfs_h *g, const char *filename, char **tempfile);
static int do_upload (guestfs_h *g, const char *filename, const char *tempfile,
const char *backup_extension);
diff --git a/fish/file-edit.h b/common/edit/file-edit.h
similarity index 100%
rename from fish/file-edit.h
rename to common/edit/file-edit.h
diff --git a/common/progress/Makefile.am b/common/progress/Makefile.am
new file mode 100644
index 0000000..afb03c8
--- /dev/null
+++ b/common/progress/Makefile.am
@@ -0,0 +1,37 @@
+# libguestfs
+# Copyright (C) 2009-2017 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+include $(top_srcdir)/subdir-rules.mk
+
+# libprogress.la contains common code for printing progress bars, used
+# by guestfish and other tools.
+noinst_LTLIBRARIES = libprogress.la
+
+libprogress_la_SOURCES = \
+ progress.c \
+ progress.h
+libprogress_la_CPPFLAGS = \
+ -DGUESTFS_WARN_DEPRECATED=1 \
+ -I$(top_srcdir)/common/utils -I$(top_builddir)/common/utils \
+ -I$(top_srcdir)/lib -I$(top_builddir)/lib
+libprogress_la_CFLAGS = \
+ $(WARN_CFLAGS) $(WERROR_CFLAGS) \
+ $(LIBTINFO_CFLAGS)
+libprogress_la_LIBADD = \
+ $(top_builddir)/common/utils/libutils.la \
+ $(top_builddir)/lib/libguestfs.la \
+ $(LIBTINFO_LIBS)
diff --git a/fish/progress.c b/common/progress/progress.c
similarity index 100%
rename from fish/progress.c
rename to common/progress/progress.c
diff --git a/fish/progress.h b/common/progress/progress.h
similarity index 100%
rename from fish/progress.h
rename to common/progress/progress.h
diff --git a/common/windows/Makefile.am b/common/windows/Makefile.am
new file mode 100644
index 0000000..043252b
--- /dev/null
+++ b/common/windows/Makefile.am
@@ -0,0 +1,37 @@
+# libguestfs
+# Copyright (C) 2009-2017 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+include $(top_srcdir)/subdir-rules.mk
+
+# libwindows.la contains common code for handling Windows drive
+# letters, which is used by virt-cat, virt-edit and virt-tail.
+noinst_LTLIBRARIES = libwindows.la
+
+libwindows_la_SOURCES = \
+ windows.c \
+ windows.h
+libwindows_la_CPPFLAGS = \
+ -DGUESTFS_WARN_DEPRECATED=1 \
+ -I$(top_srcdir)/common/utils -I$(top_builddir)/common/utils \
+ -I$(top_srcdir)/lib -I$(top_builddir)/lib \
+ -I$(top_srcdir)/gnulib/lib -I$(top_builddir)/gnulib/lib
+libwindows_la_CFLAGS = \
+ $(WARN_CFLAGS) $(WERROR_CFLAGS)
+libwindows_la_LIBADD = \
+ $(top_builddir)/common/utils/libutils.la \
+ $(top_builddir)/lib/libguestfs.la \
+ $(LTLIBINTL)
diff --git a/fish/windows.c b/common/windows/windows.c
similarity index 100%
rename from fish/windows.c
rename to common/windows/windows.c
diff --git a/fish/windows.h b/common/windows/windows.h
similarity index 100%
rename from fish/windows.h
rename to common/windows/windows.h
diff --git a/configure.ac b/configure.ac
index dbf5ce5..21a3961 100644
--- a/configure.ac
+++ b/configure.ac
@@ -181,10 +181,13 @@ AC_CONFIG_FILES([Makefile
builder/test-website/virt-builder/repos.d/libguestfs.conf
cat/Makefile
common/errnostring/Makefile
+ common/edit/Makefile
common/options/Makefile
+ common/progress/Makefile
common/protocol/Makefile
common/utils/Makefile
common/visit/Makefile
+ common/windows/Makefile
csharp/Makefile
customize/Makefile
daemon/Makefile
diff --git a/customize/Makefile.am b/customize/Makefile.am
index 5cc5c05..c7eed43 100644
--- a/customize/Makefile.am
+++ b/customize/Makefile.am
@@ -68,8 +68,8 @@ SOURCES_ML = \
customize_run.ml
SOURCES_C = \
- ../fish/file-edit.c \
- ../fish/file-edit.h \
+ ../common/edit/file-edit.c \
+ ../common/edit/file-edit.h \
crypt-c.c \
perl_edit-c.c
@@ -98,7 +98,7 @@ libcustomize_a_CPPFLAGS = \
-I$(shell $(OCAMLC) -where) \
-I$(top_srcdir)/common/utils \
-I$(top_srcdir)/lib \
- -I$(top_srcdir)/fish
+ -I$(top_srcdir)/common/edit
libcustomize_a_CFLAGS = \
$(WARN_CFLAGS) $(WERROR_CFLAGS) \
$(LIBVIRT_CFLAGS) \
diff --git a/docs/C_SOURCE_FILES b/docs/C_SOURCE_FILES
index 5c9478c..30293b6 100644
--- a/docs/C_SOURCE_FILES
+++ b/docs/C_SOURCE_FILES
@@ -11,6 +11,8 @@ cat/filesystems.c
cat/log.c
cat/ls.c
cat/tail.c
+common/edit/file-edit.c
+common/edit/file-edit.h
common/options/config.c
common/options/decrypt.c
common/options/display-options.c
@@ -22,6 +24,8 @@ common/options/options.c
common/options/options.h
common/options/uri.c
common/options/uri.h
+common/progress/progress.c
+common/progress/progress.h
common/utils/cleanup.c
common/utils/guestfs-internal-frontend-cleanups.h
common/utils/guestfs-internal-frontend.h
@@ -32,6 +36,8 @@ common/utils/uefi.c
common/utils/utils.c
common/visit/visit.c
common/visit/visit.h
+common/windows/windows.c
+common/windows/windows.h
customize/crypt-c.c
customize/dummy.c
customize/perl_edit-c.c
@@ -195,8 +201,6 @@ fish/entries-5.c
fish/entries-6.c
fish/event-names.c
fish/events.c
-fish/file-edit.c
-fish/file-edit.h
fish/fish-cmds.h
fish/fish.c
fish/fish.h
@@ -214,8 +218,6 @@ fish/prep-part.c
fish/prep.c
fish/prepopts.c
fish/prepopts.h
-fish/progress.c
-fish/progress.h
fish/rc.c
fish/reopen.c
fish/run-0.c
@@ -230,8 +232,6 @@ fish/setenv.c
fish/supported.c
fish/tilde.c
fish/time.c
-fish/windows.c
-fish/windows.h
format/format.c
fuse/guestmount.c
fuse/guestunmount.c
diff --git a/docs/guestfs-hacking.pod b/docs/guestfs-hacking.pod
index 1244cd6..c3084d6 100644
--- a/docs/guestfs-hacking.pod
+++ b/docs/guestfs-hacking.pod
@@ -83,6 +83,11 @@ subdirectory:
=over 4
+=item F<common/edit>
+
+Common code for interactively and non-interactively editing files
+within a libguestfs filesystem.
+
=item F<common/errnostring>
The communication protocol used between the library and the daemon
@@ -93,6 +98,10 @@ handled by this library.
Common options parsing for guestfish, guestmount and some virt tools.
+=item F<common/progress>
+
+Common code for printing progress bars.
+
=item F<common/protocol>
The XDR-based communication protocol used between the library
@@ -106,6 +115,10 @@ Various utility functions used throughout the library and tools.
Recursively visit a guestfs filesystem hierarchy.
+=item F<common/windows>
+
+Utility functions for handling Windows drive letters.
+
=back
=item F<contrib>
diff --git a/edit/Makefile.am b/edit/Makefile.am
index 317937b..f98e374 100644
--- a/edit/Makefile.am
+++ b/edit/Makefile.am
@@ -24,14 +24,7 @@ EXTRA_DIST = \
bin_PROGRAMS = virt-edit
-SHARED_SOURCE_FILES = \
- ../fish/file-edit.h \
- ../fish/file-edit.c \
- ../fish/windows.h \
- ../fish/windows.c
-
virt_edit_SOURCES = \
- $(SHARED_SOURCE_FILES) \
edit.c
virt_edit_CPPFLAGS = \
@@ -39,8 +32,9 @@ virt_edit_CPPFLAGS = \
-DLOCALEBASEDIR=\""$(datadir)/locale"\" \
-I$(top_srcdir)/common/utils -I$(top_builddir)/common/utils \
-I$(top_srcdir)/lib -I$(top_builddir)/lib \
+ -I$(top_srcdir)/common/edit -I$(top_builddir)/common/edit \
-I$(top_srcdir)/common/options -I$(top_builddir)/common/options \
- -I$(top_srcdir)/fish \
+ -I$(top_srcdir)/common/windows -I$(top_builddir)/common/windows \
-I$(srcdir)/../gnulib/lib -I../gnulib/lib
virt_edit_CFLAGS = \
@@ -48,7 +42,9 @@ virt_edit_CFLAGS = \
$(LIBXML2_CFLAGS)
virt_edit_LDADD = \
+ $(top_builddir)/common/edit/libedit.la \
$(top_builddir)/common/options/liboptions.la \
+ $(top_builddir)/common/windows/libwindows.la \
$(top_builddir)/common/utils/libutils.la \
$(top_builddir)/lib/libguestfs.la \
$(LIBXML2_LIBS) \
diff --git a/fish/Makefile.am b/fish/Makefile.am
index 3a50398..38409cb 100644
--- a/fish/Makefile.am
+++ b/fish/Makefile.am
@@ -77,8 +77,6 @@ guestfish_SOURCES = \
echo.c \
edit.c \
events.c \
- file-edit.c \
- file-edit.h \
fish.c \
fish.h \
glob.c \
@@ -93,8 +91,6 @@ guestfish_SOURCES = \
prep-fs.c \
prep-lv.c \
prep-boot.c \
- progress.h \
- progress.c \
rc.c \
reopen.c \
setenv.c \
@@ -122,7 +118,9 @@ guestfish_CPPFLAGS = \
-DLOCALEBASEDIR=\""$(datadir)/locale"\" \
-I$(top_srcdir)/common/utils -I$(top_builddir)/common/utils \
-I$(top_srcdir)/lib -I$(top_builddir)/lib \
+ -I$(top_srcdir)/common/edit -I$(top_builddir)/common/edit \
-I$(top_srcdir)/common/options -I$(top_builddir)/common/options \
+ -I$(top_srcdir)/common/progress -I$(top_builddir)/common/progress \
-I$(top_srcdir)/fish -I$(top_builddir)/fish \
-I$(srcdir)/../gnulib/lib -I../gnulib/lib
@@ -134,8 +132,9 @@ guestfish_CFLAGS = \
guestfish_LDADD = \
$(LIBCONFIG_LIBS) \
$(LIBREADLINE) \
- $(LIBTINFO_LIBS) \
+ $(top_builddir)/common/edit/libedit.la \
$(top_builddir)/common/options/liboptions.la \
+ $(top_builddir)/common/progress/libprogress.la \
$(top_builddir)/common/utils/libutils.la \
$(top_builddir)/lib/libguestfs.la \
$(LIBXML2_LIBS) \
diff --git a/mllib/Makefile.am b/mllib/Makefile.am
index 9cb244c..78fdf02 100644
--- a/mllib/Makefile.am
+++ b/mllib/Makefile.am
@@ -74,7 +74,7 @@ SOURCES_C = \
../common/options/decrypt.c \
../common/options/keys.c \
../common/options/uri.c \
- ../fish/progress.c \
+ ../common/progress/progress.c \
common_utils-c.c \
dev_t-c.c \
exit-c.c \
@@ -114,7 +114,7 @@ libmllib_a_CPPFLAGS = \
-I$(top_srcdir)/lib \
-I$(top_srcdir)/common/visit \
-I$(top_srcdir)/common/options \
- -I$(top_srcdir)/fish
+ -I$(top_srcdir)/common/progress
libmllib_a_CFLAGS = \
$(WARN_CFLAGS) $(WERROR_CFLAGS) \
$(LIBVIRT_CFLAGS) $(LIBXML2_CFLAGS) \
diff --git a/po/POTFILES b/po/POTFILES
index 5796a62..75a9799 100644
--- a/po/POTFILES
+++ b/po/POTFILES
@@ -10,6 +10,7 @@ cat/filesystems.c
cat/log.c
cat/ls.c
cat/tail.c
+common/edit/file-edit.c
common/errnostring/errnostring-gperf.c
common/errnostring/errnostring.c
common/options/config.c
@@ -20,12 +21,14 @@ common/options/inspect.c
common/options/keys.c
common/options/options.c
common/options/uri.c
+common/progress/progress.c
common/utils/cleanup.c
common/utils/structs-cleanup.c
common/utils/structs-print.c
common/utils/uefi.c
common/utils/utils.c
common/visit/visit.c
+common/windows/windows.c
customize/crypt-c.c
customize/dummy.c
customize/perl_edit-c.c
@@ -181,7 +184,6 @@ fish/entries-5.c
fish/entries-6.c
fish/event-names.c
fish/events.c
-fish/file-edit.c
fish/fish.c
fish/glob.c
fish/help.c
@@ -196,7 +198,6 @@ fish/prep-lv.c
fish/prep-part.c
fish/prep.c
fish/prepopts.c
-fish/progress.c
fish/rc.c
fish/reopen.c
fish/run-0.c
@@ -210,7 +211,6 @@ fish/setenv.c
fish/supported.c
fish/tilde.c
fish/time.c
-fish/windows.c
format/format.c
fuse/guestmount.c
fuse/guestunmount.c
--
2.9.3