Date: Saturday, April 25, 2020 @ 23:49:09 Author: felixonmars Revision: 621204
upgpkg: haskell-ipynb 0.1-174: rebuild with base64-bytestring 1.1.0.0 Added: haskell-ipynb/trunk/base64-bytestring-1.1.patch Modified: haskell-ipynb/trunk/PKGBUILD -----------------------------+ PKGBUILD | 17 +++++-- base64-bytestring-1.1.patch | 99 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 111 insertions(+), 5 deletions(-) Modified: PKGBUILD =================================================================== --- PKGBUILD 2020-04-25 23:49:02 UTC (rev 621203) +++ PKGBUILD 2020-04-25 23:49:09 UTC (rev 621204) @@ -3,7 +3,7 @@ _hkgname=ipynb pkgname=haskell-ipynb pkgver=0.1 -pkgrel=173 +pkgrel=174 pkgdesc="Data structure for working with Jupyter notebooks (ipynb)" url="https://github.com/jgm/ipynb" license=('BSD') @@ -11,12 +11,19 @@ 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) -sha512sums=('8717dac6496905afc5e8735abc3b3a4a90b171253b035efa0751a6311b901caad563fdfeaa455987c1307d0532273ab80be37256562143db575f13c326843bf4') +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 @@ -34,7 +41,7 @@ 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" Added: base64-bytestring-1.1.patch =================================================================== --- base64-bytestring-1.1.patch (rev 0) +++ base64-bytestring-1.1.patch 2020-04-25 23:49:09 UTC (rev 621204) @@ -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
