Implement the "tgz" output format, i.e. "tar" compressed as gzip.
This was implemented in diskimage-builder upstream as
commit da41ee6012b064aa6901c871a1104a3a3933117e.
---
dib/Makefile.am | 1 +
dib/output_format_tgz.ml | 35 +++++++++++++++++++++++++++++++++++
dib/virt-dib.pod | 4 ++++
3 files changed, 40 insertions(+)
create mode 100644 dib/output_format_tgz.ml
diff --git a/dib/Makefile.am b/dib/Makefile.am
index 42b7a5c..470fb52 100644
--- a/dib/Makefile.am
+++ b/dib/Makefile.am
@@ -32,6 +32,7 @@ formats = \
qcow2 \
raw \
tar \
+ tgz \
vhd
SOURCES_ML = \
diff --git a/dib/output_format_tgz.ml b/dib/output_format_tgz.ml
new file mode 100644
index 0000000..a74a4a6
--- /dev/null
+++ b/dib/output_format_tgz.ml
@@ -0,0 +1,35 @@
+(* virt-dib
+ * Copyright (C) 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.
+ *)
+
+open Common_utils
+open Common_gettext.Gettext
+
+open Output_format
+
+let tgz_run_fs (g : Guestfs.guestfs) filename _ =
+ message (f_"Compressing the image as tar.gz");
+ g#tar_out ~excludes:[| "./sys/*"; "./proc/*" |]
~compress:"gzip"
+ "/" filename
+
+let fmt = {
+ defaults with
+ name = "tgz";
+ run_on_filesystem = Some tgz_run_fs;
+}
+
+let () = register_format fmt
diff --git a/dib/virt-dib.pod b/dib/virt-dib.pod
index fe61ca7..2786050 100644
--- a/dib/virt-dib.pod
+++ b/dib/virt-dib.pod
@@ -216,6 +216,10 @@ Raw disk format.
An uncompressed tarball.
+=item C<tgz>
+
+A tarball compressed with gzip.
+
=item C<vhd>
C<Virtual Hard Disk> disk image. This output format requires
--
2.9.3