From c1bd2c3e742dc5a37e4a673822a4588d1c211c37 Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Thu, 2 Feb 2017 13:34:13 +0100 Subject: [PATCH] dib: add tgz output format 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 42b7a5cdf..470fb52a8 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 000000000..a74a4a6e2 --- /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 fe61ca7f7..278605015 100644 --- a/dib/virt-dib.pod +++ b/dib/virt-dib.pod @@ -216,6 +216,10 @@ Raw disk format. An uncompressed tarball. +=item C + +A tarball compressed with gzip. + =item C C disk image. This output format requires