--- /dev/null
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+EAPI=5
+
+# ebuild generated by hackport 0.4.6.9999
+
+CABAL_FEATURES="lib profile haddock hoogle hscolour test-suite"
+inherit haskell-cabal
+
+DESCRIPTION="A client library for the D-Bus IPC system"
+HOMEPAGE="https://john-millikin.com/software/haskell-dbus/"
+SRC_URI="mirror://hackage/packages/archive/${PN}/${PV}/${P}.tar.gz"
+
+LICENSE="GPL-3"
+SLOT="0/${PV}"
+KEYWORDS="~alpha ~amd64 ~ia64 ~ppc ~ppc64 ~sparc ~x86"
+IUSE=""
+
+RDEPEND=">=dev-haskell/cereal-0.3.4:=[profile?]
+ >=dev-haskell/libxml-sax-0.7:=[profile?] <dev-haskell/libxml-sax-0.8:=[profile?]
+ >=dev-haskell/network-2.2.3:=[profile?]
+ >=dev-haskell/parsec-2.0:=[profile?] <dev-haskell/parsec-3.2:=[profile?]
+ >=dev-haskell/random-1.0:=[profile?] <dev-haskell/random-2.0:=[profile?]
+ >=dev-haskell/text-0.11.1.5:=[profile?]
+ >=dev-haskell/transformers-0.2:=[profile?]
+ >=dev-haskell/vector-0.7:=[profile?] <dev-haskell/vector-0.12:=[profile?]
+ >=dev-haskell/xml-types-0.3:=[profile?] <dev-haskell/xml-types-0.4:=[profile?]
+ >=dev-lang/ghc-7.4.1:=
+"
+DEPEND="${RDEPEND}
+ >=dev-haskell/cabal-1.8
+ test? ( >=dev-haskell/chell-0.4 <dev-haskell/chell-0.5
+ >=dev-haskell/chell-quickcheck-0.2 <dev-haskell/chell-quickcheck-0.3
+ >=dev-haskell/quickcheck-2.4 )
+"
+
+src_prepare() {
+ epatch "${FILESDIR}"/${P}-cereal-0.5.patch
+
+ cabal_chdeps \
+ 'cereal >= 0.3.4 && < 0.5' 'cereal >= 0.3.4'
+}
--- /dev/null
+diff --git a/lib/DBus/Transport.hs b/lib/DBus/Transport.hs
+index 8c50ab9..9517212 100644
+--- a/lib/DBus/Transport.hs
++++ b/lib/DBus/Transport.hs
+@@ -42,3 +42,5 @@ import qualified Data.ByteString
+ import Data.ByteString (ByteString)
++import qualified Data.ByteString.Lazy as BL
+ import qualified Data.Map as Map
++import qualified Data.Monoid as M
+ import Data.Typeable (Typeable)
+@@ -49,3 +51,3 @@ import qualified System.Info
+
+-import qualified Data.Serialize.Builder as Builder
++import qualified Data.ByteString.Builder as Builder
+
+@@ -151,3 +153,3 @@ instance Transport SocketTransport where
+ recvLoop :: Socket -> Int -> IO ByteString
+-recvLoop s = loop Builder.empty where
++recvLoop s = loop M.mempty where
+ chunkSize = 4096
+@@ -156,3 +158,3 @@ recvLoop s = loop Builder.empty where
+ chunk <- recv s chunkSize
+- let builder = Builder.append acc (Builder.fromByteString chunk)
++ let builder = M.mappend acc (Builder.byteString chunk)
+ loop builder (n - Data.ByteString.length chunk)
+@@ -163,8 +165,8 @@ recvLoop s = loop Builder.empty where
+ -- Return what we've got so far.
+- 0 -> return (Builder.toByteString acc)
++ 0 -> return (BL.toStrict $ Builder.toLazyByteString acc)
+
+ len -> do
+- let builder = Builder.append acc (Builder.fromByteString chunk)
++ let builder = M.mappend acc (Builder.byteString chunk)
+ if len == n
+- then return (Builder.toByteString builder)
++ then return (BL.toStrict $ Builder.toLazyByteString builder)
+ else loop builder (n - Data.ByteString.length chunk)
+diff --git a/lib/DBus/Wire.hs b/lib/DBus/Wire.hs
+index 43ae315..09bf8bd 100644
+--- a/lib/DBus/Wire.hs
++++ b/lib/DBus/Wire.hs
+@@ -34,2 +34,3 @@ import qualified Data.ByteString.Char8
+ import Data.Int (Int16, Int32, Int64)
++import qualified Data.ByteString.Lazy as BL
+ import qualified Data.Map
+@@ -37,2 +38,3 @@ import Data.Map (Map)
+ import Data.Maybe (fromJust, listToMaybe, fromMaybe)
++import qualified Data.Monoid as M
+ import Data.Text (Text)
+@@ -45,3 +47,3 @@ import System.Posix.Types (Fd(..))
+
+-import qualified Data.Serialize.Builder as Builder
++import qualified Data.ByteString.Builder as Builder
+ import qualified Data.Serialize.Get as Get
+@@ -180,3 +182,3 @@ appendB :: Word64 -> Builder.Builder -> Marshal ()
+ appendB size bytes = Wire (\_ (MarshalState builder count) -> let
+- builder' = Builder.append builder bytes
++ builder' = M.mappend builder bytes
+ count' = count + size
+@@ -187,3 +189,3 @@ appendS bytes = appendB
+ (fromIntegral (Data.ByteString.length bytes))
+- (Builder.fromByteString bytes)
++ (Builder.byteString bytes)
+
+@@ -275,3 +277,3 @@ unmarshalGet count be le = do
+ marshalWord8 :: Word8 -> Marshal ()
+-marshalWord8 x = appendB 1 (Builder.singleton x)
++marshalWord8 x = appendB 1 (Builder.word8 x)
+
+@@ -282,4 +284,4 @@ marshalWord16 :: Word16 -> Marshal ()
+ marshalWord16 = marshalBuilder 2
+- Builder.putWord16be
+- Builder.putWord16le
++ Builder.word16BE
++ Builder.word16LE
+
+@@ -287,4 +289,4 @@ marshalWord32 :: Word32 -> Marshal ()
+ marshalWord32 = marshalBuilder 4
+- Builder.putWord32be
+- Builder.putWord32le
++ Builder.word32BE
++ Builder.word32LE
+
+@@ -292,4 +294,4 @@ marshalWord64 :: Word64 -> Marshal ()
+ marshalWord64 = marshalBuilder 8
+- Builder.putWord64be
+- Builder.putWord64le
++ Builder.word64BE
++ Builder.word64LE
+
+@@ -441,6 +443,6 @@ getArrayBytes itemType vs = do
+
+- putState (MarshalState Builder.empty afterPadding)
++ putState (MarshalState M.mempty afterPadding)
+ (MarshalState itemBuilder _) <- Data.Vector.mapM_ marshal vs >> getState
+
+- let itemBytes = Builder.toByteString itemBuilder
++ let itemBytes = BL.toStrict $ Builder.toLazyByteString itemBuilder
+ paddingSize = fromIntegral (afterPadding - afterLength)
+@@ -568,3 +570,3 @@ marshalMessage e serial msg = runMarshal where
+ marshal (toValue (encodeEndianness e))
+- let bodyBytes = Builder.toByteString bodyBytesB
++ let bodyBytes = BL.toStrict $ Builder.toLazyByteString bodyBytesB
+ marshalHeader msg serial sig (fromIntegral (Data.ByteString.length bodyBytes))
+@@ -573,6 +575,6 @@ marshalMessage e serial msg = runMarshal where
+ checkMaximumSize
+- emptyState = MarshalState Builder.empty 0
++ emptyState = MarshalState M.mempty 0
+ runMarshal = case unWire marshaler e emptyState of
+ WireRL err -> Left (MarshalError err)
+- WireRR _ (MarshalState builder _) -> Right (Builder.toByteString builder)
++ WireRR _ (MarshalState builder _) -> Right (BL.toStrict $ Builder.toLazyByteString builder)
+