packages feed

shake-bindist (empty) → 0.1.0.0

raw patch · 5 files changed

+164/−0 lines, 5 filesdep +archive-libarchivedep +archive-sigdep +archive-tar

Dependencies added: archive-libarchive, archive-sig, archive-tar, base, bytestring, bz2, lzlib, shake, zlib, zstd

Files

+ CHANGELOG.md view
@@ -0,0 +1,5 @@+# shake-bindist++## 0.1.0.0++Initial release
+ LICENSE view
@@ -0,0 +1,11 @@+Copyright Vanessa McHale (c) 2020++Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:++1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.++2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.++3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ README.md view
@@ -0,0 +1,10 @@+# shake-bindist++Like [shake-pack](https://hackage.haskell.org/package/shake-pack-0.2.0).++## Use++This package has two backends; by default it uses+[tar](http://hackage.haskell.org/package/tar) but if the `pure` flag is+disabled it will be built with the+[libarchive](http://hackage.haskell.org/package/libarchive) backend.
+ shake-bindist.cabal view
@@ -0,0 +1,61 @@+cabal-version:   2.0+name:            shake-bindist+version:         0.1.0.0+license:         BSD3+license-file:    LICENSE+copyright:       Copyright: (c) 2020 Vanessa McHale+maintainer:      vamchale@gmail.com+author:          Vanessa McHale+synopsis:        Rules for binary distributions+description:     Pack files into a binary distribution+category:        Shake, Compression, Archive+build-type:      Simple+extra-doc-files:+    README.md+    CHANGELOG.md++source-repository head+    type:     darcs+    location: https://hub.darcs.net/vmchale/shake-bindist++flag development+    description: Enable `-Werror`+    default:     False+    manual:      True++flag pure+    description: Use tar library++library+    exposed-modules:  Development.Shake.BinDist+    hs-source-dirs:   src+    default-language: Haskell2010+    ghc-options:      -Wall+    build-depends:+        base >=4.3 && <5,+        shake -any,+        lzlib >=0.3.2.0,+        zstd -any,+        bytestring -any,+        archive-sig >=0.2.0.0,+        bz2,+        zlib++    if flag(pure)+        build-depends: archive-tar >=0.2.0.0+        mixins:        archive-tar (Archive.Tar as Archive)++    else+        build-depends: archive-libarchive >=0.2.0.0+        mixins:        archive-libarchive (Archive.FFI as Archive)++    if flag(development)+        ghc-options: -Werror++    if impl(ghc >=8.0)+        ghc-options:+            -Wincomplete-uni-patterns -Wincomplete-record-updates+            -Wredundant-constraints -Widentities++    if impl(ghc >=8.4)+        ghc-options: -Wmissing-export-lists
+ src/Development/Shake/BinDist.hs view
@@ -0,0 +1,77 @@+module Development.Shake.BinDist ( -- * Rules+                                   tarLzip+                                 , tarZstd+                                 , tarBz2+                                 , tarGz+                                   -- * Actions+                                 , tarLzipA+                                 , tarZstdA+                                 , tarBz2A+                                 , tarGzA+                                 ) where++import           Archive                     (packFiles)+import qualified Codec.Compression.BZip      as Bz2+import qualified Codec.Compression.GZip      as GZip+import qualified Codec.Compression.Zstd.Lazy as Zstd+import qualified Codec.Lzip                  as Lzip+import qualified Data.ByteString.Lazy        as BSL+import           Development.Shake           hiding (action)++tarGenericA :: String -- ^ Rule name+            -> (BSL.ByteString -> BSL.ByteString) -- ^ Compression function+            -> [FilePath] -- ^ Files to pack up+            -> FilePath -- ^ File name of resultant tarball+            -> Action ()+tarGenericA rn f fps tar = do+    need fps+    traced rn $ BSL.writeFile tar =<< f <$> packFiles fps++mkRule :: (a -> FilePath -> Action ()) -> a -> FilePattern -> Rules ()+mkRule action x pat =+    pat %> \out ->+        action x out++-- | The [lzip](http://www.nongnu.org/lzip/lzip.html) format is suitable for+-- archiving.+--+-- Note that 'tarLzip' doesn't stream in memory; the others do.+tarLzip :: [FilePath] -- ^ Files to pack up+        -> FilePattern -- ^ Resultant tarball+        -> Rules ()+tarLzip = mkRule tarLzipA++tarZstd :: [FilePath] -- ^ Files to pack up+        -> FilePattern -- ^ Resultant tarball+        -> Rules ()+tarZstd = mkRule tarZstdA++tarGz :: [FilePath] -- ^ Files to pack up+      -> FilePattern -- ^ Resultant tarball+      -> Rules ()+tarGz = mkRule tarGzA++tarBz2 :: [FilePath] -- ^ Files to pack up+      -> FilePattern -- ^ Resultant tarball+      -> Rules ()+tarBz2 = mkRule tarBz2A++tarLzipA :: [FilePath] -- ^ Files to pack up+         -> FilePath -- ^ File name of resultant tarball+         -> Action ()+tarLzipA = tarGenericA "tar-lzip" Lzip.compressBest++tarZstdA :: [FilePath] -- ^ Files to pack up+         -> FilePath -- ^ File name of resultant tarball+         -> Action ()+tarZstdA = tarGenericA "tar-zstd" (Zstd.compress Zstd.maxCLevel)++tarGzA :: [FilePath] -- ^ Files to pack up+         -> FilePath -- ^ File name of resultant tarball+         -> Action ()+tarGzA = tarGenericA "tar-gz" GZip.compress++tarBz2A :: [FilePath] -- ^ Files to pack up+         -> FilePath -- ^ File name of resultant tarball+         -> Action ()+tarBz2A = tarGenericA "tar-bz2" Bz2.compress