Skip to content

Commit 8bfecbc

Browse files
geekosaurjuhp
authored andcommitted
support tar-0.7.0.0
Use the new functionality (which didn't make the changelog) when available; see #11131. This moves `createTarGzFile` to `Distribution.Client.Compat.Tar` with a re-export.
1 parent d9b0904 commit 8bfecbc

File tree

4 files changed

+21
-18
lines changed

4 files changed

+21
-18
lines changed

Cabal-tests/Cabal-tests.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ test-suite hackage-tests
155155
, base-orphans >=0.6 && <0.10
156156
, clock >=0.8 && <0.9
157157
, optparse-applicative >=0.13.2.0 && <0.19
158-
, tar >=0.5.0.3 && <0.7
158+
, tar >=0.5.0.3 && <0.8
159159
, tree-diff >=0.1 && <0.4
160160

161161
ghc-options: -Wall -rtsopts -threaded

cabal-install/cabal-install.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ library
250250
, process >= 1.2.3.0 && < 1.7
251251
, random >= 1.2 && < 1.4
252252
, stm >= 2.0 && < 2.6
253-
, tar >= 0.5.0.3 && < 0.7
253+
, tar >= 0.5.0.3 && < 0.8
254254
, time >= 1.5.0.1 && < 1.16
255255
, zlib >= 0.5.3 && < 0.8
256256
, hackage-security >= 0.6.2.0 && < 0.7

cabal-install/src/Distribution/Client/Compat/Tar.hs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
{- FOURMOLU_DISABLE -}
55
module Distribution.Client.Compat.Tar
66
( extractTarGzFile
7+
, createTarGzFile
78
#if MIN_VERSION_tar(0,6,0)
89
, Tar.Entry
910
, Tar.Entries
@@ -27,6 +28,7 @@ import qualified Codec.Archive.Tar.Check as Tar
2728
#else
2829
import qualified Codec.Archive.Tar.Entry as Tar
2930
#endif
31+
import qualified Codec.Compression.GZip as GZip
3032
import qualified Data.ByteString.Lazy as BS
3133
import qualified Distribution.Client.GZipUtils as GZipUtils
3234

@@ -65,4 +67,20 @@ extractTarGzFile dir expected tar =
6567
. Tar.read
6668
. GZipUtils.maybeDecompress
6769
=<< BS.readFile tar
70+
71+
createTarGzFile
72+
:: FilePath
73+
-- ^ Full Tarball path
74+
-> FilePath
75+
-- ^ Base directory
76+
-> FilePath
77+
-- ^ Directory to archive, relative to base dir
78+
-> IO ()
79+
createTarGzFile tar base dir =
80+
#if MIN_VERSION_tar(0,7,0)
81+
BS.writeFile tar . GZip.compress =<< Tar.write' =<< Tar.pack' base [dir]
82+
#else
83+
BS.writeFile tar . GZip.compress . Tar.write =<< Tar.pack base [dir]
84+
#endif
85+
6886
{- FOURMOLU_ENABLE -}

cabal-install/src/Distribution/Client/Tar.hs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
-- Reading, writing and manipulating \"@.tar@\" archive files.
1818
module Distribution.Client.Tar
1919
( -- * @tar.gz@ operations
20-
createTarGzFile
20+
TarComp.createTarGzFile
2121
, TarComp.extractTarGzFile
2222

2323
-- * Other local utils
@@ -34,8 +34,6 @@ import Prelude ()
3434

3535
import qualified Codec.Archive.Tar as Tar
3636
import qualified Codec.Archive.Tar.Entry as Tar
37-
import qualified Codec.Compression.GZip as GZip
38-
import qualified Data.ByteString.Lazy as BS
3937
import qualified Distribution.Client.Compat.Tar as TarComp
4038

4139
-- for foldEntries...
@@ -45,19 +43,6 @@ import Control.Exception (throw)
4543

4644
-- * High level operations
4745

48-
--
49-
50-
createTarGzFile
51-
:: FilePath
52-
-- ^ Full Tarball path
53-
-> FilePath
54-
-- ^ Base directory
55-
-> FilePath
56-
-- ^ Directory to archive, relative to base dir
57-
-> IO ()
58-
createTarGzFile tar base dir =
59-
BS.writeFile tar . GZip.compress . Tar.write =<< Tar.pack base [dir]
60-
6146
-- | Type code for the local build tree reference entry type. We don't use the
6247
-- symbolic link entry type because it allows only 100 ASCII characters for the
6348
-- path.

0 commit comments

Comments
 (0)