summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJoey Hess2020-05-01 15:19:12 -0400
committerJoey Hess2020-05-01 15:21:37 -0400
commit72beed8697ca2816c84f8006e06aa10ea617f37a (patch)
tree397eede633bc1c9286b1b68bf04ed6d1a0398841 /src
parent20ffd4f3cc101818e6baac35e31193fad9b5266d (diff)
Apt.buildDepIn: Run build-dep command in a temporary directory, since it may sometimes not clean up all the files it creates.
Diffstat (limited to 'src')
-rw-r--r--src/Propellor/Property/Apt.hs16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/Propellor/Property/Apt.hs b/src/Propellor/Property/Apt.hs
index 4faf0984..2e7ccb04 100644
--- a/src/Propellor/Property/Apt.hs
+++ b/src/Propellor/Property/Apt.hs
@@ -16,6 +16,7 @@ import qualified Propellor.Property.File as File
import qualified Propellor.Property.Service as Service
import Propellor.Property.File (Line)
import Propellor.Types.Info
+import Utility.SafeCommand
data HostMirror = HostMirror Url
deriving (Eq, Show, Typeable)
@@ -308,11 +309,22 @@ buildDep ps = robustly $ go
-- in the specifed directory, with a dummy package also
-- installed so that autoRemove won't remove them.
buildDepIn :: FilePath -> Property DebianLike
-buildDepIn dir = cmdPropertyEnv "sh" ["-c", cmd] noninteractiveEnv
+buildDepIn dir = go
`changesFile` dpkgStatus
`requires` installedMin ["devscripts", "equivs"]
where
- cmd = "cd '" ++ dir ++ "' && mk-build-deps debian/control --install --tool 'apt-get -y --no-install-recommends' --remove"
+ -- mk-build-deps may leave files behind sometimes, eg on failure,
+ -- so run it in a temp directory, passing the path to the control
+ -- file
+ go :: UncheckedProperty DebianLike
+ go = unchecked $ property ("build-dep in " ++ dir) $ liftIO $
+ withTmpDir "build-dep" $ \tmpdir -> do
+ cmdResult <$> boolSystem' "mk-build-deps"
+ [ File $ dir </> "debian" </> "control"
+ , Param "--install"
+ , Param "--tool"
+ , Param "apt-get -y --no-install-recommends"
+ ] (\p -> p { cwd = Just tmpdir })
-- | The name of a package, a glob to match the names of packages, or a regexp
-- surrounded by slashes to match the names of packages. See