Permalink
Browse files

Merge branch 'cabal-1.16'

  • Loading branch information...
tibbe committed Sep 8, 2012
2 parents 847a926 + c59cf49 commit aa5fc275ddce1bae76d68291fce02d62fd8922ec
@@ -76,8 +76,7 @@ import System.IO.Error (isDoesNotExistError)
import Distribution.Compat.Exception (catchIO)
import System.Directory
( getModificationTime, doesFileExist )
-import System.Time
- ( getClockTime, diffClockTimes, normalizeTimeDiff, TimeDiff(tdDay) )
+import Distribution.Compat.Time
getInstalledPackages :: Verbosity -> Compiler
@@ -196,13 +195,11 @@ readRepoIndex verbosity repo =
isOldThreshold = 15 --days
warnIfIndexIsOld indexFile = do
- indexTime <- getModificationTime indexFile
- currentTime <- getClockTime
- let diff = normalizeTimeDiff (diffClockTimes currentTime indexTime)
- when (tdDay diff >= isOldThreshold) $ case repoKind repo of
+ dt <- getFileAge indexFile
+ when (dt >= isOldThreshold) $ case repoKind repo of
Left remoteRepo -> warn verbosity $
"The package list for '" ++ remoteRepoName remoteRepo
- ++ "' is " ++ show (tdDay diff) ++ " days old.\nRun "
+ ++ "' is " ++ show dt ++ " days old.\nRun "
++ "'cabal update' to get the latest list of available packages."
Right _localRepo -> return ()
@@ -29,8 +29,6 @@ module Distribution.Client.JobControl (
import Control.Monad
import Control.Concurrent
import Control.Exception
-import Prelude hiding (catch)
-
data JobControl m a = JobControl {
spawnJob :: m a -> m (),
@@ -91,8 +91,7 @@ import Distribution.Compat.FilePerms
( setFileExecutable )
import System.Posix.Types
( FileMode )
-import System.Time
- ( ClockTime(..) )
+import Distribution.Compat.Time
import System.IO
( IOMode(ReadMode), openBinaryFile, hFileSize )
import System.IO.Unsafe (unsafeInterleaveIO)
@@ -123,8 +122,6 @@ extractTarGzFile dir expected tar = do
--
type FileSize = Int64
--- | The number of seconds since the UNIX epoch
-type EpochTime = Int64
type DevMajor = Int
type DevMinor = Int
type TypeCode = Char
@@ -927,8 +924,3 @@ recurseDirectories base (dir:dirs) = unsafeInterleaveIO $ do
ignore ['.'] = True
ignore ['.', '.'] = True
ignore _ = False
-
-getModTime :: FilePath -> IO EpochTime
-getModTime path = do
- (TOD s _) <- getModificationTime path
- return $! fromIntegral s
@@ -0,0 +1,37 @@
+{-# LANGUAGE CPP #-}
+module Distribution.Compat.Time where
+
+import Data.Int (Int64)
+import System.Directory (getModificationTime)
+
+#if MIN_VERSION_directory(1,2,0)
+import Data.Time.Clock.POSIX (utcTimeToPOSIXSeconds, posixDayLength)
+import Data.Time (getCurrentTime, diffUTCTime)
+#else
+import System.Time (ClockTime(..), getClockTime, diffClockTimes, normalizeTimeDiff, tdDay)
+#endif
+
+-- | The number of seconds since the UNIX epoch
+type EpochTime = Int64
+
+getModTime :: FilePath -> IO EpochTime
+getModTime path = do
+#if MIN_VERSION_directory(1,2,0)
+ (truncate . utcTimeToPOSIXSeconds) `fmap` getModificationTime path
+#else
+ (TOD s _) <- getModificationTime path
+ return $! fromIntegral s
+#endif
+
+-- | Return age of given file in days.
+getFileAge :: FilePath -> IO Int
+getFileAge file = do
+ t0 <- getModificationTime file
+#if MIN_VERSION_directory(1,2,0)
+ t1 <- getCurrentTime
+ let days = truncate $ (t1 `diffUTCTime` t0) / posixDayLength
+#else
+ t1 <- getClockTime
+ let days = (tdDay . normalizeTimeDiff) (t1 `diffClockTimes` t0)
+#endif
+ return days
View
@@ -47,16 +47,16 @@ PREFIX=${PREFIX:-${DEFAULT_PREFIX}}
# Versions of the packages to install.
# The version regex says what existing installed versions are ok.
-PARSEC_VER="3.1.2"; PARSEC_VER_REGEXP="[23]\." # == 2.* || == 3.*
-DEEPSEQ_VER="1.3.0.0"; DEEPSEQ_VER_REGEXP="1\.[1-9]\." # >= 1.1 && < 2
-TEXT_VER="0.11.2.0"; TEXT_VER_REGEXP="0\.([2-9]|(1[0-1]))\." # >= 0.2 && < 0.12
-NETWORK_VER="2.3.0.13"; NETWORK_VER_REGEXP="2\." # == 2.*
-CABAL_VER="1.14.0"; CABAL_VER_REGEXP="1\.(13\.3|14\.)" # >= 1.13.3 && < 1.15
+PARSEC_VER="3.1.3"; PARSEC_VER_REGEXP="[23]\." # == 2.* || == 3.*
+DEEPSEQ_VER="1.3.0.1"; DEEPSEQ_VER_REGEXP="1\.[1-9]\." # >= 1.1 && < 2
+TEXT_VER="0.11.2.3"; TEXT_VER_REGEXP="0\.([2-9]|(1[0-1]))\." # >= 0.2 && < 0.12
+NETWORK_VER="2.3.1.0"; NETWORK_VER_REGEXP="2\." # == 2.*
+CABAL_VER="1.16.0"; CABAL_VER_REGEXP="1\.(13\.3|1[4-7]\.)" # >= 1.13.3 && < 1.18
TRANS_VER="0.3.0.0"; TRANS_VER_REGEXP="0\.[23]\." # >= 0.2.* && < 0.4.*
-MTL_VER="2.1.1"; MTL_VER_REGEXP="[12]\." # == 1.* || == 2.*
-HTTP_VER="4000.2.3"; HTTP_VER_REGEXP="4000\.[012]\." # == 4000.0.* || 4000.1.* || 4000.2.*
+MTL_VER="2.1.2"; MTL_VER_REGEXP="[12]\." # == 1.* || == 2.*
+HTTP_VER="4000.2.4"; HTTP_VER_REGEXP="4000\.[012]\." # == 4000.0.* || 4000.1.* || 4000.2.*
ZLIB_VER="0.5.3.3"; ZLIB_VER_REGEXP="0\.[45]\." # == 0.4.* || == 0.5.*
-TIME_VER="1.4" TIME_VER_REGEXP="1\.[1234]\.?" # >= 1.1 && < 1.5
+TIME_VER="1.4.0.1" TIME_VER_REGEXP="1\.[1234]\.?" # >= 1.1 && < 1.5
RANDOM_VER="1.0.1.1" RANDOM_VER_REGEXP="1\.0\." # >= 1 && < 1.1
HACKAGE_URL="http://hackage.haskell.org/packages/archive"
@@ -138,6 +138,6 @@ Executable cabal
build-depends: Win32 >= 2 && < 3
cpp-options: -DWIN32
else
- build-depends: unix >= 1.0 && < 2.6
+ build-depends: unix >= 1.0 && < 2.7
extensions: CPP, ForeignFunctionInterface
c-sources: cbits/getnumcores.c

0 comments on commit aa5fc27

Please sign in to comment.