From 530d9f1b2bb1d740a4ca7404f0e885c64626a0e0 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Thu, 19 May 2016 15:00:08 +0900 Subject: add Ccache.hs --- src/Propellor/Property/Ccache.hs | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/Propellor/Property/Ccache.hs 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 + +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"] -- cgit v1.2.3