From 62aaba85c7ff40d44fa2101b05e6577dee7d0184 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Tue, 20 Oct 2015 23:52:27 -0400 Subject: chroot: add a ChrootTarball chroot type This extracts a minimal tarball into a target directory. (cherry picked from commit 33ac6c1c4bb2581d6f5a27254e52956e5a257326) --- src/Propellor/Property/Chroot.hs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src') diff --git a/src/Propellor/Property/Chroot.hs b/src/Propellor/Property/Chroot.hs index 7ec2010c..a0bbad35 100644 --- a/src/Propellor/Property/Chroot.hs +++ b/src/Propellor/Property/Chroot.hs @@ -22,6 +22,7 @@ import Propellor.Types.Info import Propellor.Property.Chroot.Util import qualified Propellor.Property.Debootstrap as Debootstrap import qualified Propellor.Property.Systemd.Core as Systemd +import qualified Propellor.Property.File as File import qualified Propellor.Shim as Shim import Propellor.Property.Mount @@ -52,6 +53,29 @@ class ChrootBootstrapper b where -- If the operating System is not supported, return Nothing. buildchroot :: b -> System -> FilePath -> Maybe (Property HasInfo) +-- | Use to extract a tarball with a filesystem image. +-- +-- The filesystem image is expected to be a root directory (no top-level +-- directory, also known as a "tarbomb"). It may be optionally compressed with +-- any format `tar` knows how to detect automatically. +data ChrootTarball = ChrootTarball FilePath + +instance ChrootBootstrapper ChrootTarball where + buildchroot (ChrootTarball tb) _ loc = Just $ extractTarball loc tb + +extractTarball :: FilePath -> FilePath -> Property HasInfo +extractTarball target src = toProp . + check (unpopulated target) $ + cmdProperty "tar" params + `requires` File.dirExists target + where + params = + [ "-C" + , target + , "-xf" + , src + ] + -- | Use to bootstrap a chroot with debootstrap. data Debootstrapped = Debootstrapped Debootstrap.DebootstrapConfig -- cgit v1.2.3