Commit 11f8a6b2 authored by Valentin Reis's avatar Valentin Reis
Browse files

Should resolve TMPDIR issues

parent 55499ff0
Pipeline #5735 passed with stage
in 1 minute and 49 seconds
......@@ -233,30 +233,28 @@ sudoRemoveFile printer desc filePath = do
cleanSocket :: FilePath -> Shell ()
cleanSocket = sudoRemoveFile printWarning "socket"
socketList :: [FilePath]
socketList =
[ "/tmp/nrm-downstream-in"
, "/tmp/nrm-downstream-event"
, "/tmp/nrm-upstream-in"
, "/tmp/nrm-upstream-event"
]
setupSystem :: ArgsCommon -> Shell ()
setupSystem sa = do
doVerbose $ printInfo "Setting the nix-build environment up."
doVerbose $ printInfo "Cleaning sockets."
Prelude.mapM_
cleanSocket
[ "/tmp/nrm-downstream-in"
, "/tmp/nrm-downstream-event"
, "/tmp/nrm-upstream-in"
, "/tmp/nrm-upstream-event"
]
Prelude.mapM_ cleanSocket socketList
doVerbose $ printInfo "Setting up a cache directory:"
cachedir <- single
$ inproc "mktemp" ["-d", "/tmp/deletable-nix-cache-XXXX"] empty
export "XDG_CACHE_HOME" $ lineToText cachedir
doVerbose $ printInfo $ lineToText cachedir <> " exported to XDG_CACHE_HOME"
inproc "rm" ["-rf", "./nixtmpdir"] empty
inproc "mkdir" ["-p", "./nixtmpdir"] empty
export "TMPDIR" "./nixtmpdir/"
doVerbose $ printInfo $ lineToText cachedir <> " exported to XDG_CACHE_HOME"
liftIO $ createAndSetTMPDIR "./nixtmpdir"
vshell "sudo rm -rf result" empty >>= \case
ExitSuccess -> printInfo "removed ./result"
ExitFailure n ->
die ("Failed to remove ./result " <> repr n)
ExitSuccess -> printInfo "removed ./result"
ExitFailure n -> die ("Failed to remove ./result " <> repr n)
doVerbose $ printInfo "running nix-build for the containers attribute."
doVerbose $ printCommand $ "nix-build " <> pack
(unwords (nixArguments "containers" sa))
......@@ -283,6 +281,14 @@ setupSystem sa = do
vshell = verboseShell verbose
verbose = verbosity sa == Verbose
doVerbose = when verbose
createAndSetTMPDIR name = do
path <- (</> fromText name) <$> pwd
b <- testpath path
when b $ rmtree path
mkdir path
case toText path of
Right p -> export "TMPDIR" p
Left _ -> die "Path error when setting TMPDIR"
nixArguments :: String -> ArgsCommon -> [String]
nixArguments target ArgsCommon {..} =
......@@ -300,6 +306,7 @@ wrap :: NixCommand -> String -> ArgsCommon -> IO ()
wrap nixCommand target sa@ArgsCommon {..} = sh $ do
when (verbosity == Verbose) $ liftIO $ print sa
_ <- setupSystem sa
printf "toto"
printCommand $ pack nixc <> " " <> pack (unwords arglist)
liftIO (executeFile nixc True arglist Nothing)
where
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment