[arch-commits] Commit in haskell-ipynb/repos (3 files)

Felix Yan felixonmars at archlinux.org
Fri May 1 04:07:15 UTC 2020


    Date: Friday, May 1, 2020 @ 04:07:15
  Author: felixonmars
Revision: 623672

archrelease: copy trunk to community-staging-x86_64

Added:
  haskell-ipynb/repos/community-staging-x86_64/
  haskell-ipynb/repos/community-staging-x86_64/PKGBUILD
    (from rev 623671, haskell-ipynb/trunk/PKGBUILD)
  haskell-ipynb/repos/community-staging-x86_64/base64-bytestring-1.1.patch
    (from rev 623671, haskell-ipynb/trunk/base64-bytestring-1.1.patch)

-----------------------------+
 PKGBUILD                    |   50 +++++++++++++++++++++
 base64-bytestring-1.1.patch |   99 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 149 insertions(+)

Copied: haskell-ipynb/repos/community-staging-x86_64/PKGBUILD (from rev 623671, haskell-ipynb/trunk/PKGBUILD)
===================================================================
--- community-staging-x86_64/PKGBUILD	                        (rev 0)
+++ community-staging-x86_64/PKGBUILD	2020-05-01 04:07:15 UTC (rev 623672)
@@ -0,0 +1,50 @@
+# Maintainer: Felix Yan <felixonmars at archlinux.org>
+
+_hkgname=ipynb
+pkgname=haskell-ipynb
+pkgver=0.1
+pkgrel=175
+pkgdesc="Data structure for working with Jupyter notebooks (ipynb)"
+url="https://github.com/jgm/ipynb"
+license=('BSD')
+arch=('x86_64')
+depends=('ghc-libs' 'haskell-aeson' 'haskell-base64-bytestring' 'haskell-unordered-containers')
+makedepends=('ghc' 'haskell-aeson-diff' 'haskell-microlens' 'haskell-microlens-aeson'
+             'haskell-tasty' 'haskell-tasty-hunit' 'haskell-vector')
+source=(https://hackage.haskell.org/packages/archive/${_hkgname}/${pkgver}/${_hkgname}-${pkgver}.tar.gz
+        base64-bytestring-1.1.patch)
+sha512sums=('8717dac6496905afc5e8735abc3b3a4a90b171253b035efa0751a6311b901caad563fdfeaa455987c1307d0532273ab80be37256562143db575f13c326843bf4'
+            '705d0d71fb94d139c5e0ef8de9f72c15b9f3152e7417cacbf12519a4270e6ee6b1e4e929062337ada9a3d776741e95a2cafee79ebbe3ac038e5073ca94f14602')
+
+prepare() {
+    cd $_hkgname-$pkgver
+    patch -p1 -i ../base64-bytestring-1.1.patch
+}
+
+build() {
+    cd $_hkgname-$pkgver
+
+    runhaskell Setup configure -O --enable-shared --enable-executable-dynamic --disable-library-vanilla \
+        --prefix=/usr --docdir=/usr/share/doc/$pkgname --enable-tests \
+        --dynlibdir=/usr/lib --libsubdir=\$compiler/site-local/\$pkgid
+    runhaskell Setup build
+    runhaskell Setup register --gen-script
+    runhaskell Setup unregister --gen-script
+    sed -i -r -e "s|ghc-pkg.*update[^ ]* |&'--force' |" register.sh
+    sed -i -r -e "s|ghc-pkg.*unregister[^ ]* |&'--force' |" unregister.sh
+}
+
+check() {
+    cd $_hkgname-$pkgver
+    runhaskell Setup test
+}
+
+package() {
+    cd $_hkgname-$pkgver
+
+    install -D -m744 register.sh "$pkgdir"/usr/share/haskell/register/$pkgname.sh
+    install -D -m744 unregister.sh "$pkgdir"/usr/share/haskell/unregister/$pkgname.sh
+    runhaskell Setup copy --destdir="$pkgdir"
+    install -D -m644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
+    rm -f "$pkgdir"/usr/share/doc/$pkgname/LICENSE
+}

Copied: haskell-ipynb/repos/community-staging-x86_64/base64-bytestring-1.1.patch (from rev 623671, haskell-ipynb/trunk/base64-bytestring-1.1.patch)
===================================================================
--- community-staging-x86_64/base64-bytestring-1.1.patch	                        (rev 0)
+++ community-staging-x86_64/base64-bytestring-1.1.patch	2020-05-01 04:07:15 UTC (rev 623672)
@@ -0,0 +1,99 @@
+--- ipynb-0.1/test/roundtrip.hs.orig	2020-04-26 07:02:19.792033245 +0800
++++ ipynb-0.1/test/roundtrip.hs	2020-04-26 07:02:34.438786334 +0800
+@@ -49,7 +49,7 @@
+        case Base64.decode (TE.encodeUtf8 (T.filter (/='\n') t)) of
+             Left _  -> String t  -- textual
+             Right b -> String $
+-              TE.decodeUtf8 . Base64.joinWith "\n" 76 . Base64.encode $ b
++              TE.decodeUtf8 . joinWith "\n" 76 . Base64.encode $ b
+      go v = v
+
+ rtTest :: FilePath -> TestTree
+--- ipynb-0.1/src/Data/Ipynb.hs.orig	2020-04-26 07:00:34.408032416 +0800
++++ ipynb-0.1/src/Data/Ipynb.hs	2020-04-26 07:47:18.956882066 +0800
+@@ -1,3 +1,4 @@
++{-# LANGUAGE BangPatterns               #-}
+ {-# LANGUAGE CPP                        #-}
+ {-# LANGUAGE DeriveGeneric              #-}
+ {-# LANGUAGE FlexibleContexts           #-}
+@@ -38,13 +39,17 @@
+                   , MimeData(..)
+                   , MimeBundle(..)
+                   , breakLines
++                  , joinWith
+                   )
+ where
+ import Control.Applicative ((<|>))
++import Control.Exception (assert)
+ import Control.Monad (when)
+ import Data.Aeson as Aeson
+ import qualified Data.Aeson.Types as Aeson
+ import Data.ByteString (ByteString)
++import qualified Data.ByteString as B
++import Data.ByteString.Internal
+ import qualified Data.ByteString.Base64 as Base64
+ import Data.Char (isSpace)
+ import qualified Data.HashMap.Strict as HM
+@@ -54,6 +59,8 @@
+ import Data.Text (Text)
+ import qualified Data.Text as T
+ import qualified Data.Text.Encoding as TE
++import Foreign.ForeignPtr (withForeignPtr)
++import Foreign.Ptr (minusPtr, plusPtr)
+ import GHC.Generics
+ import Prelude
+ #if MIN_VERSION_base(4,11,0)
+@@ -480,10 +487,52 @@
+             Left _  -> return (mt, TextualData t)
+             Right b -> return (mt, BinaryData b)
+ 
++-- | Efficiently intersperse a terminator string into another at
++-- regular intervals, and terminate the input with it.
++--
++-- Examples:
++--
++-- > joinWith "|" 2 "----" = "--|--|"
++--
++-- > joinWith "\r\n" 3 "foobarbaz" = "foo\r\nbar\r\nbaz\r\n"
++-- > joinWith "x" 3 "fo" = "fox"
++joinWith :: ByteString  -- ^ String to intersperse and end with
++         -> Int         -- ^ Interval at which to intersperse, in bytes
++         -> ByteString  -- ^ String to transform
++         -> ByteString
++joinWith brk@(PS bfp boff blen) every' bs@(PS sfp soff slen)
++    | every' <= 0 = error "invalid interval"
++    | blen <= 0  = bs
++    | B.null bs = brk
++    | otherwise =
++  unsafeCreate dlen $ \dptr ->
++    withForeignPtr bfp $ \bptr -> do
++      withForeignPtr sfp $ \sptr -> do
++          let bp = bptr `plusPtr` boff
++              sp0 = sptr `plusPtr` soff
++              sEnd = sp0 `plusPtr` slen
++              dLast = dptr `plusPtr` dlen
++              loop !dp !sp !written
++                  | dp == dLast = return ()
++                  | otherwise = do
++                let chunkSize = min every (sEnd `minusPtr` sp)
++                memcpy dp sp (fromIntegral chunkSize)
++                let dp' = dp `plusPtr` chunkSize
++                memcpy dp' bp (fromIntegral blen)
++                let written' = written + chunkSize + blen
++                assert (written' <= dlen) $
++                  loop (dp' `plusPtr` blen) (sp `plusPtr` chunkSize) written'
++          loop dptr sp0 0
++  where dlast = slen + blen * numBreaks
++        every = min slen every'
++        dlen | rmndr > 0   = dlast + blen
++             | otherwise   = dlast
++        (numBreaks, rmndr) = slen `divMod` every
++
+ instance ToJSON MimeBundle where
+   toJSON (MimeBundle m) =
+     let mimeBundleToValue (BinaryData bs) =
+-          toJSON $ TE.decodeUtf8 . Base64.joinWith "\n" 76 . Base64.encode $ bs
++          toJSON $ TE.decodeUtf8 . joinWith "\n" 76 . Base64.encode $ bs
+         mimeBundleToValue (JsonData v) = v
+         mimeBundleToValue (TextualData t) = toJSON (breakLines t)
+     in  toJSON $ M.map mimeBundleToValue m


More information about the arch-commits mailing list