summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Hess2020-06-18 14:38:20 -0400
committerJoey Hess2020-06-18 14:48:56 -0400
commitfe1e502f90faee1329fd27326de6b1bd191780fe (patch)
treeb0652928f4441f4b5a4aba6cde43e599ccd205b8
parentab130081933cb69322a3f0c73d903bfe16a9e20b (diff)
fix one more hardcoded dist/ path
Refactored the cabal exec code to reuse it here. Had to change the location of propellor.built too, so put it in the top of the propellor repo, rather than in dist. This seems like it could be simpler. Why does propellor need to symlink to propellor.built? Why not copy to a temp file, and atomically rename it to propellor? It seems possible that something could depend on it being a symlink, but I don't know what. Adding to my confusion, there's the comment about cp -pfRL and timestamp checking. What timestamp checking? The commit adding the comment didn't change anything else, and I can't find any now or then. This commit was sponsored by Jack Hill on Patreon.
-rw-r--r--.gitignore1
-rw-r--r--src/Propellor/Bootstrap.hs21
2 files changed, 13 insertions, 9 deletions
diff --git a/.gitignore b/.gitignore
index 4e1b918c..50258d53 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,5 @@
/propellor
+/propellor.built
dist/*
dist-newstyle/*
tags
diff --git a/src/Propellor/Bootstrap.hs b/src/Propellor/Bootstrap.hs
index 58ffa61b..7c1a3ea7 100644
--- a/src/Propellor/Bootstrap.hs
+++ b/src/Propellor/Bootstrap.hs
@@ -81,18 +81,21 @@ buildCommand bs = intercalate " && " (go (getBuilder bs))
go Cabal =
[ "cabal configure"
, "cabal build -j1 propellor-config"
- , intercalate "; "
- [ "if [ -d dist-newstyle ]"
- , "then ln -sf $(cabal exec -- sh -c 'command -v propellor-config') propellor"
- , "else ln -sf dist/build/propellor-config/propellor-config propellor"
- , "fi"
- ]
+ , "ln -sf" `commandCabalBuildTo` "propellor"
]
go Stack =
[ "stack build :propellor-config"
, "ln -sf $(stack path --dist-dir)/build/propellor-config/propellor-config propellor"
]
+commandCabalBuildTo :: ShellCommand -> FilePath -> ShellCommand
+commandCabalBuildTo cmd dest = intercalate "; "
+ [ "if [ -d dist-newstyle ]"
+ , "then " ++ cmd ++ " $(cabal exec -- sh -c 'command -v propellor-config') " ++ shellEscape dest
+ , "else " ++ cmd ++ " dist/build/propellor-config/propellor-config " ++ shellEscape dest
+ , "fi"
+ ]
+
-- Check if all dependencies are installed; if not, run the depsCommand.
checkDepsCommand :: Bootstrapper -> Maybe System -> ShellCommand
checkDepsCommand bs sys = go (getBuilder bs)
@@ -273,14 +276,14 @@ cabalBuild msys = do
-- or breaking the symlink.
--
-- Need cp -pfRL to make build timestamp checking work.
- unlessM (boolSystem "cp" [Param "-pfRL", Param cabalbuiltbin, Param (tmpfor safetycopy)]) $
+ let cpcmd = "cp -pfRL" `commandCabalBuildTo` tmpfor safetycopy
+ unlessM (boolSystem "sh" [Param "-c", Param cpcmd]) $
error "cp of binary failed"
rename (tmpfor safetycopy) safetycopy
symlinkPropellorBin safetycopy
return True
where
- cabalbuiltbin = "dist/build/propellor-config/propellor-config"
- safetycopy = cabalbuiltbin ++ ".built"
+ safetycopy = "propellor.built"
cabal_configure = ifM (cabal ["configure"])
( do
writeFile "configured" ""