diff options
| author | Joey Hess <joeyh@joeyh.name> | 2015-09-25 09:36:58 -0400 |
|---|---|---|
| committer | Joey Hess <joeyh@joeyh.name> | 2015-09-25 09:36:58 -0400 |
| commit | 1cc81cf92d98d71b115ddae0b19c2657fa5bb2bc (patch) | |
| tree | e4d6aeaa9a8dc35adc9620af9f0feef35e0df677 /src/Propellor/Bootstrap.hs | |
| parent | 86b7feb9e7879cf418efd77e832f06cae20a4109 (diff) | |
| parent | cd44c61aa104f2d36b9834b143296b74b33e226f (diff) | |
Merge branch 'joeyconfig'
Diffstat (limited to 'src/Propellor/Bootstrap.hs')
| -rw-r--r-- | src/Propellor/Bootstrap.hs | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/Propellor/Bootstrap.hs b/src/Propellor/Bootstrap.hs index 6812b4ab..089def51 100644 --- a/src/Propellor/Bootstrap.hs +++ b/src/Propellor/Bootstrap.hs @@ -104,9 +104,24 @@ build = catchBoolIO $ do void $ cabal ["configure"] unlessM (cabal ["build"]) $ error "cabal build failed" - nukeFile "propellor" - createSymbolicLink "dist/build/propellor-config/propellor-config" "propellor" + -- For safety against eg power loss in the middle of the build, + -- make a copy of the binary, and move it into place atomically. + -- This ensures that the propellor symlink only ever points at + -- a binary that is fully built. Also, avoid ever removing + -- or breaking the symlink. + -- + -- Need cp -a to make build timestamp checking work. + unlessM (boolSystem "cp" [Param "-a", Param cabalbuiltbin, Param (tmpfor safetycopy)]) $ + error "cp of binary failed" + rename (tmpfor safetycopy) safetycopy + createSymbolicLink safetycopy (tmpfor dest) + rename (tmpfor dest) dest return True + where + dest = "propellor" + cabalbuiltbin = "dist/build/propellor-config/propellor-config" + safetycopy = cabalbuiltbin ++ ".built" + tmpfor f = f ++ ".propellortmp" make :: FilePath -> [FilePath] -> IO Bool -> IO () make dest srcs builder = do |
