Implement the "squash" output format, i.e. a squashfs compressed filesystem. This was implemented in diskimage-builder upstream as commit 9d13084c4183b63587e1f5e4b03395a8df6538f6. --- dib/Makefile.am | 1 + dib/output_format_squashfs.ml | 39 +++++++++++++++++++++++++++++++++++++++ dib/utils.ml | 1 + dib/virt-dib.pod | 6 ++++++ 4 files changed, 47 insertions(+) create mode 100644 dib/output_format_squashfs.ml diff --git a/dib/Makefile.am b/dib/Makefile.am index 470fb52..6780ee2 100644 --- a/dib/Makefile.am +++ b/dib/Makefile.am @@ -31,6 +31,7 @@ formats = \ docker \ qcow2 \ raw \ + squashfs \ tar \ tgz \ vhd diff --git a/dib/output_format_squashfs.ml b/dib/output_format_squashfs.ml new file mode 100644 index 0000000..333e711 --- /dev/null +++ b/dib/output_format_squashfs.ml @@ -0,0 +1,39 @@ +(* 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 squashfs_check (g : Guestfs.guestfs) = + g#available [| "squashfs" |] + +let squashfs_run_fs (g : Guestfs.guestfs) filename _ = + message (f_"Compressing the image as squashfs"); + g#mksquashfs ~excludes:[| "sys/*"; "proc/*"; "dev/*" |] ~compress:"xz" + "/" filename + +let fmt = { + defaults with + name = "squashfs"; + check_appliance_prerequisites = Some squashfs_check; + run_on_filesystem = Some squashfs_run_fs; +} + +let () = register_format fmt diff --git a/dib/utils.ml b/dib/utils.ml index 3775a41..da5e738 100644 --- a/dib/utils.ml +++ b/dib/utils.ml @@ -33,6 +33,7 @@ let current_arch () = | arch -> arch let output_filename image_name = function + | "squashfs" -> image_name ^ ".squash" | fmt -> image_name ^ "." ^ fmt let log_filename () = diff --git a/dib/virt-dib.pod b/dib/virt-dib.pod index 2786050..7083e78 100644 --- a/dib/virt-dib.pod +++ b/dib/virt-dib.pod @@ -212,6 +212,12 @@ QEMU's qcow2. Raw disk format. +=item C<squashfs> + +An squashfs filesystem, compressed with XZ. This output format +requires the C<squashfs> feature; see also +L<guestfs(3)/AVAILABILITY>. + =item C<tar> An uncompressed tarball. -- 2.9.3