diff options
author | Daniel Gröber <dxld@darkboxed.org> | 2017-09-26 14:07:59 +0200 |
---|---|---|
committer | Daniel Gröber <dxld@darkboxed.org> | 2017-09-26 14:07:59 +0200 |
commit | 4b3571a6955c3a817f9b4ef7bcc273b916879a93 (patch) | |
tree | af2f0634cbc9f4ddf967c183de8137155ceb9e8f /CabalHelper/Compiletime | |
parent | 0e5511a9d58f47edb3790236391d75279553504e (diff) |
Refactor CH.C.Data to use 'unix' instead of 'time'
Diffstat (limited to 'CabalHelper/Compiletime')
-rw-r--r-- | CabalHelper/Compiletime/Data.hs | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/CabalHelper/Compiletime/Data.hs b/CabalHelper/Compiletime/Data.hs index 6b096d7..346c2a5 100644 --- a/CabalHelper/Compiletime/Data.hs +++ b/CabalHelper/Compiletime/Data.hs @@ -14,21 +14,22 @@ -- You should have received a copy of the GNU Affero General Public License -- along with this program. If not, see <http://www.gnu.org/licenses/>. -{-# LANGUAGE TemplateHaskell #-} +{-# LANGUAGE TemplateHaskell, ScopedTypeVariables #-} {-# OPTIONS_GHC -fforce-recomp #-} module CabalHelper.Compiletime.Data where import Control.Monad import Control.Monad.IO.Class import Data.Functor -import Data.Time.Clock -import Data.Time.Clock.POSIX import qualified Data.ByteString as BS import qualified Data.ByteString.UTF8 as UTF8 import Language.Haskell.TH import System.Directory import System.FilePath import System.IO.Temp +import System.Posix.Files +import System.Posix.Time +import System.Posix.Types import Prelude import CabalHelper.Compiletime.Compat.Environment @@ -49,20 +50,19 @@ withHelperSources mdir action = withDir mdir $ \dir -> do createDirectoryIfMissing True $ chdir </> "Runtime" createDirectoryIfMissing True $ chdir </> "Shared" - let modtime = read + let modtime :: EpochTime + modtime = fromIntegral $ (read :: String -> Integer) -- See https://reproducible-builds.org/specs/source-date-epoch/ $(runIO $ do - msde <- lookupEnv "SOURCE_DATE_EPOCH" - let parse :: String -> POSIXTime - parse = fromInteger . read - utctime <- getCurrentTime - return $ LitE . StringL $ show $ - maybe utctime (posixSecondsToUTCTime . parse) msde) + msde :: Maybe Integer + <- fmap read <$> lookupEnv "SOURCE_DATE_EPOCH" + (current_time :: Integer) <- round . toRational <$> epochTime + return $ LitE . StringL $ show $ maybe current_time id msde) liftIO $ forM_ sourceFiles $ \(fn, src) -> do let path = chdir </> fn BS.writeFile path $ UTF8.fromString src - setModificationTime path modtime + setFileTimes path modtime modtime action dir where |