diff options
| author | Sean Whitton <spwhitton@spwhitton.name> | 2016-05-19 15:00:08 +0900 |
|---|---|---|
| committer | Sean Whitton <spwhitton@spwhitton.name> | 2016-05-19 15:00:08 +0900 |
| commit | 530d9f1b2bb1d740a4ca7404f0e885c64626a0e0 (patch) | |
| tree | 19ffd73da22b0a03cc601778611ae22c5bad7bb3 /src | |
| parent | 52d0cad8f09576f50479bfaaad9a03e725f7c77c (diff) | |
add Ccache.hs
Diffstat (limited to 'src')
| -rw-r--r-- | src/Propellor/Property/Ccache.hs | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/Propellor/Property/Ccache.hs b/src/Propellor/Property/Ccache.hs new file mode 100644 index 00000000..6ee796f0 --- /dev/null +++ b/src/Propellor/Property/Ccache.hs @@ -0,0 +1,39 @@ +-- | Maintainer: Sean Whitton <spwhitton@spwhitton.name> + +module Propellor.Property.Ccache where + +import Propellor.Base +import qualified Propellor.Property.File as File +import qualified Propellor.Property.Apt as Apt + +import Utility.FileMode +import System.Posix.Files + +-- | Configures a ccache in /var/cache for a group +-- +-- If you say +-- +-- > & (Group "foo") `Ccache.hasGroupCache` "4G" +-- +-- you instruct propellor to create a ccache in /var/cache/ccache-foo owned and +-- writeable by the foo group, with a maximum cache size of 4GB. See ccache(1) +-- for size specification. +hasGroupCache :: Group -> String -> RevertableProperty DebianLike UnixLike +group@(Group g) `hasGroupCache` size = (make `requires` installed) <!> delete + where + path = "/var/cache/ccache-" ++ g + make = check (not <$> doesDirectoryExist path) $ + propertyList ("ccache for " ++ g ++ " exists") $ props + & File.dirExists path + & File.ownerGroup path (User "root") group + & File.mode path (combineModes $ + readModes ++ executeModes + ++ [ownerWriteMode, groupWriteMode]) + & cmdProperty "ccache" ["--max-size", size] + `assume` MadeChange + delete = check (doesDirectoryExist path) $ + cmdProperty "rm" ["-r", path] `assume` MadeChange + `describe` ("ccache for " ++ g ++ " does not exist") + +installed :: Property DebianLike +installed = Apt.installed ["ccache"] |
