Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Compiling against directory-1.2.0.0 #1033

Closed
wants to merge 1 commit into from

3 participants

@ktvoelker

I was working on getting some sort of cabal-install installed on top of my brand-new ghc-7.6.1. I ended up going with HEAD...but I found a problem when compiling against directory-1.2.0.0. The return type of getModificationTime changed from ClockTime (from the old-time package) to UTCTime (from the time package).

I don't know what the procedure is for this sort of thing...but the code works for me, so hopefully it's useful to everyone else.

@ktvoelker ktvoelker Build against directory-1.2.0.0
The return type of getModificationTime changed
from ClockTime (from the old-time package) to
UTCTime (from the time package).
acd2784
@ktvoelker

It just occurred to me to look at the outstanding pull requests, and I guess this one is redundant given #1003.

@sol
sol commented

@ktvoelker I think your way of calculating the diff is nicer. I now do it your way in #1003.

@tibbe
Owner

I ended up merging #1003 instead. Thanks though!

@tibbe tibbe closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 8, 2012
  1. @ktvoelker

    Build against directory-1.2.0.0

    ktvoelker authored
    The return type of getModificationTime changed
    from ClockTime (from the old-time package) to
    UTCTime (from the time package).
This page is out of date. Refresh to see the latest.
View
15 cabal-install/Distribution/Client/IndexUtils.hs
@@ -76,8 +76,10 @@ import System.IO.Error (isDoesNotExistError)
import Distribution.Compat.Exception (catchIO)
import System.Directory
( getModificationTime, doesFileExist )
-import System.Time
- ( getClockTime, diffClockTimes, normalizeTimeDiff, TimeDiff(tdDay) )
+import Data.Time.Clock
+ ( getCurrentTime, diffUTCTime )
+import Data.Time.Clock.POSIX
+ ( posixDayLength )
getInstalledPackages :: Verbosity -> Compiler
@@ -194,15 +196,16 @@ readRepoIndex verbosity repo =
return mempty
else ioError e
+ isOldThreshold :: Integer
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
+ currentTime <- getCurrentTime
+ let diff = truncate $ diffUTCTime currentTime indexTime / posixDayLength
+ when (diff >= isOldThreshold) $ case repoKind repo of
Left remoteRepo -> warn verbosity $
"The package list for '" ++ remoteRepoName remoteRepo
- ++ "' is " ++ show (tdDay diff) ++ " days old.\nRun "
+ ++ "' is " ++ show diff ++ " days old.\nRun "
++ "'cabal update' to get the latest list of available packages."
Right _localRepo -> return ()
View
8 cabal-install/Distribution/Client/Tar.hs
@@ -91,8 +91,8 @@ import Distribution.Compat.FilePerms
( setFileExecutable )
import System.Posix.Types
( FileMode )
-import System.Time
- ( ClockTime(..) )
+import Data.Time.Clock.POSIX
+ ( utcTimeToPOSIXSeconds )
import System.IO
( IOMode(ReadMode), openBinaryFile, hFileSize )
import System.IO.Unsafe (unsafeInterleaveIO)
@@ -930,5 +930,5 @@ recurseDirectories base (dir:dirs) = unsafeInterleaveIO $ do
getModTime :: FilePath -> IO EpochTime
getModTime path = do
- (TOD s _) <- getModificationTime path
- return $! fromIntegral s
+ utc <- getModificationTime path
+ return $! round $ utcTimeToPOSIXSeconds utc
View
4 cabal-install/cabal-install.cabal
@@ -122,7 +122,7 @@ Executable cabal
else
build-depends: base >= 3,
process >= 1 && < 1.2,
- directory >= 1 && < 1.3,
+ directory >= 1.2 && < 1.3,
pretty >= 1 && < 1.2,
random >= 1 && < 1.1,
containers >= 0.1 && < 0.6,
@@ -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
Something went wrong with that request. Please try again.