From 221b71fd6321ae35c5fc0f1bdd3ac216596a2fe0 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 18 Jun 2020 14:53:03 -0400 Subject: simplify update of propellor bin propellor won't be a symlink to propellor.built, instead the latter is renamed over the former, atomically. If something somehow depends on propellor being a symlink, this will break it, but I don't think anything should. --- src/Propellor/Bootstrap.hs | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/Propellor/Bootstrap.hs b/src/Propellor/Bootstrap.hs index 7c1a3ea7..6aa5720c 100644 --- a/src/Propellor/Bootstrap.hs +++ b/src/Propellor/Bootstrap.hs @@ -269,21 +269,14 @@ cabalBuild msys = do unlessM cabal_build $ unlessM (cabal_configure <&&> cabal_build) $ error "cabal build failed" - -- 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 -pfRL to make build timestamp checking work. - let cpcmd = "cp -pfRL" `commandCabalBuildTo` tmpfor safetycopy + -- Make a copy of the binary, and move it into place atomically. + let safetycopy = "propellor.built" + let cpcmd = "cp -pfL" `commandCabalBuildTo` safetycopy unlessM (boolSystem "sh" [Param "-c", Param cpcmd]) $ error "cp of binary failed" - rename (tmpfor safetycopy) safetycopy - symlinkPropellorBin safetycopy + rename safetycopy "propellor" return True where - safetycopy = "propellor.built" cabal_configure = ifM (cabal ["configure"]) ( do writeFile "configured" "" -- cgit v1.2.3