From 804622719b8a348bfdd32f427502e0529d50a8ed Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 1 Sep 2015 11:24:02 -0700 Subject: removal of chroot on disk image rebuild --- src/Propellor/Property/Chroot/Util.hs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/Propellor/Property/Chroot/Util.hs') 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 -- cgit v1.2.3