summaryrefslogtreecommitdiff
path: root/src/Propellor/Property/Chroot.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Propellor/Property/Chroot.hs')
-rw-r--r--src/Propellor/Property/Chroot.hs24
1 files changed, 24 insertions, 0 deletions
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