From 05d35eb568e74deafc936e6735171291410b5f0b Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 20 Oct 2015 12:01:59 -0400 Subject: Chroot: Converted to use a ChrootBootstrapper type class So other ways to bootstrap chroots can easily be added in separate modules. (API change) --- src/Propellor/Property/Chroot/Util.hs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/Propellor/Property/Chroot') diff --git a/src/Propellor/Property/Chroot/Util.hs b/src/Propellor/Property/Chroot/Util.hs index ea0df780..3ebda28f 100644 --- a/src/Propellor/Property/Chroot/Util.hs +++ b/src/Propellor/Property/Chroot/Util.hs @@ -2,11 +2,14 @@ module Propellor.Property.Chroot.Util where import Propellor.Property.Mount +import Utility.Exception import Utility.Env +import Utility.Directory + import Control.Applicative import System.Directory --- When chrooting, it's useful to ensure that PATH has all the standard +-- | When chrooting, it's useful to ensure that PATH has all the standard -- directories in it. This adds those directories to whatever PATH is -- already set. standardPathEnv :: IO [(String, String)] @@ -18,9 +21,13 @@ standardPathEnv = do stdPATH :: String stdPATH = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" --- Removes the contents of a chroot. First, unmounts any filesystems +-- | Removes the contents of a chroot. First, unmounts any filesystems -- mounted within it. removeChroot :: FilePath -> IO () removeChroot c = do unmountBelow c removeDirectoryRecursive c + +-- | Returns true if a chroot directory is empty. +unpopulated :: FilePath -> IO Bool +unpopulated d = null <$> catchDefaultIO [] (dirContents d) -- cgit v1.2.3