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/Propellor/Property/Chroot.hs') 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.3-2-g0d8e From 1a55d09b5452f07508d4624b632e9a54782dbee8 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 23 Oct 2015 01:27:22 -0400 Subject: export ChrootTarball and improve docs --- src/Propellor/Property/Chroot.hs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/Propellor/Property/Chroot.hs') diff --git a/src/Propellor/Property/Chroot.hs b/src/Propellor/Property/Chroot.hs index a0bbad35..d17edae7 100644 --- a/src/Propellor/Property/Chroot.hs +++ b/src/Propellor/Property/Chroot.hs @@ -4,6 +4,7 @@ module Propellor.Property.Chroot ( Chroot(..), ChrootBootstrapper(..), Debootstrapped(..), + ChrootTarball(..), debootstrapped, bootstrapped, provisioned, @@ -53,11 +54,12 @@ 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. +-- | Use this to bootstrap a chroot by extracting a tarball. -- --- 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. +-- The tarball is expected to contain 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 @@ -76,7 +78,7 @@ extractTarball target src = toProp . , src ] --- | Use to bootstrap a chroot with debootstrap. +-- | Use this to bootstrap a chroot with debootstrap. data Debootstrapped = Debootstrapped Debootstrap.DebootstrapConfig instance ChrootBootstrapper Debootstrapped where -- cgit v1.3-2-g0d8e