summaryrefslogtreecommitdiff
path: root/src/Propellor/Property/Chroot
diff options
context:
space:
mode:
authorJoey Hess2015-09-01 11:24:02 -0700
committerJoey Hess2015-09-01 11:24:02 -0700
commit804622719b8a348bfdd32f427502e0529d50a8ed (patch)
tree42a7c0be0541c177db996e03659f31cf1d86bb6d /src/Propellor/Property/Chroot
parente85a15d160005929a9d5ea5cb21c25751856c5ae (diff)
removal of chroot on disk image rebuild
Diffstat (limited to 'src/Propellor/Property/Chroot')
-rw-r--r--src/Propellor/Property/Chroot/Util.hs12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/Propellor/Property/Chroot/Util.hs b/src/Propellor/Property/Chroot/Util.hs
index 382fbab7..73cf094a 100644
--- a/src/Propellor/Property/Chroot/Util.hs
+++ b/src/Propellor/Property/Chroot/Util.hs
@@ -1,7 +1,11 @@
module Propellor.Property.Chroot.Util where
+import Propellor.Property.Mount
+
import Utility.Env
import Control.Applicative
+import Control.Monad
+import System.Directory
-- When chrooting, it's useful to ensure that PATH has all the standard
-- directories in it. This adds those directories to whatever PATH is
@@ -14,3 +18,11 @@ 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
+-- mounted within it.
+removeChroot :: FilePath -> IO ()
+removeChroot c = do
+ submnts <- mountPointsBelow c
+ forM_ submnts umountLazy
+ removeDirectoryRecursive c