tar 0.3 support without CPP

This commit is contained in:
Michael Snoyman 2012-11-25 08:59:59 +02:00
parent 5697fdd417
commit 8ab54e67ac
2 changed files with 3 additions and 12 deletions

View File

@ -1,4 +1,3 @@
{-# LANGUAGE CPP #-}
module Stackage.LoadDatabase where
import qualified Codec.Archive.Tar as Tar
@ -44,11 +43,7 @@ loadPackageDB core deps = do
lbs <- L.readFile tarName
addEntries mempty $ Tar.read lbs
where
#if MIN_VERSION_tar(0, 4, 0)
addEntries _ (Tar.Fail e) = throwIO e
#else
addEntries _ (Tar.Fail e) = error e
#endif
addEntries _ (Tar.Fail e) = error $ show e
addEntries db Tar.Done = return db
addEntries db (Tar.Next e es) = addEntry db e >>= flip addEntries es

View File

@ -1,4 +1,3 @@
{-# LANGUAGE CPP #-}
module Stackage.Tarballs
( makeTarballs
) where
@ -27,11 +26,8 @@ makeTarballs ii = do
createDirectoryIfMissing True $ takeDirectory extraTar
L.writeFile extraTar $ Tar.write extraEntries
where
#if MIN_VERSION_tar(0, 4, 0)
loop _ _ (Tar.Fail err) = throwIO err
#else
loop _ _ (Tar.Fail err) = error err
#endif
-- Using "error . show" for compatibility with tar 0.3 and 0.4
loop _ _ (Tar.Fail err) = error $ show err
loop stable extra Tar.Done = return (stable [], extra [])
loop stable extra (Tar.Next e es) =
loop stable' extra' es