cmdProperty' renamed to cmdPropertyEnv to make way for a new, more generic cmdProperty' (API change)

This commit is contained in:
Joey Hess 2015-05-07 12:16:48 -04:00
parent 53a084632c
commit 63ccccb1bb
3 changed files with 23 additions and 7 deletions

7
debian/changelog vendored
View File

@ -1,3 +1,10 @@
propellor (2.5.0) UNRELEASED; urgency=medium
* cmdProperty' renamed to cmdPropertyEnv to make way for a new,
more generic cmdProperty' (API change)
-- Joey Hess <id@joeyh.name> Thu, 07 May 2015 12:08:34 -0400
propellor (2.4.0) unstable; urgency=medium
* Propellor no longer supports Debian wheezy (oldstable).

View File

@ -109,7 +109,7 @@ setSourcesListD ls basename = f `File.hasContent` ls `onChange` update
f = "/etc/apt/sources.list.d/" ++ basename ++ ".list"
runApt :: [String] -> Property NoInfo
runApt ps = cmdProperty' "apt-get" ps noninteractiveEnv
runApt ps = cmdPropertyEnv "apt-get" ps noninteractiveEnv
noninteractiveEnv :: [(String, String)]
noninteractiveEnv =
@ -170,7 +170,7 @@ buildDep ps = robustly go
buildDepIn :: FilePath -> Property NoInfo
buildDepIn dir = go `requires` installedMin ["devscripts", "equivs"]
where
go = cmdProperty' "sh" ["-c", "cd '" ++ dir ++ "' && mk-build-deps debian/control --install --tool 'apt-get -y --no-install-recommends' --remove"]
go = cmdPropertyEnv "sh" ["-c", "cd '" ++ dir ++ "' && mk-build-deps debian/control --install --tool 'apt-get -y --no-install-recommends' --remove"]
noninteractiveEnv
-- | Package installation may fail becuse the archive has changed.
@ -251,7 +251,7 @@ reConfigure package vals = reconfigure `requires` setselections
forM_ vals $ \(tmpl, tmpltype, value) ->
hPutStrLn h $ unwords [package, tmpl, tmpltype, value]
hClose h
reconfigure = cmdProperty' "dpkg-reconfigure" ["-fnone", package] noninteractiveEnv
reconfigure = cmdPropertyEnv "dpkg-reconfigure" ["-fnone", package] noninteractiveEnv
-- | Ensures that a service is installed and running.
--

View File

@ -3,6 +3,7 @@
module Propellor.Property.Cmd (
cmdProperty,
cmdProperty',
cmdPropertyEnv,
scriptProperty,
userScriptProperty,
) where
@ -10,6 +11,7 @@ module Propellor.Property.Cmd (
import Control.Applicative
import Data.List
import "mtl" Control.Monad.Reader
import System.Process (CreateProcess)
import Propellor.Types
import Propellor.Property
@ -20,12 +22,19 @@ import Utility.Env
--
-- The command must exit 0 on success.
cmdProperty :: String -> [String] -> Property NoInfo
cmdProperty cmd params = cmdProperty' cmd params []
cmdProperty cmd params = cmdProperty' cmd params id
cmdProperty' :: String -> [String] -> (CreateProcess -> CreateProcess) -> Property NoInfo
cmdProperty' cmd params mkprocess = property desc $ liftIO $ do
toResult <$> boolSystem' cmd (map Param params) mkprocess
where
desc = unwords $ cmd : params
-- | A property that can be satisfied by running a command,
-- with added environment.
cmdProperty' :: String -> [String] -> [(String, String)] -> Property NoInfo
cmdProperty' cmd params env = property desc $ liftIO $ do
-- with added environment variables in addition to the standard
-- environment.
cmdPropertyEnv :: String -> [String] -> [(String, String)] -> Property NoInfo
cmdPropertyEnv cmd params env = property desc $ liftIO $ do
env' <- addEntries env <$> getEnvironment
toResult <$> boolSystemEnv cmd (map Param params) (Just env')
where