On Wed, 28 May 2014 21:24:43 +0100, Daniel Lintott wrote: > For a while I couldn't figure this out as the bundled files don't match > any of the files in libsnappy-dev, because the version included is > actually csnappy from [1] > [1] https://github.com/zeevt/csnappy
D'oh! Thanks for the clarification. > Which leaves two options... > > a) Use the bundled version of csnappy > b) Package csnappy for Debian Obviously b) would be better, and then libcsnappy could also be used for libsereal-{en,de}coder-perl. In the light of https://github.com/Sereal/Sereal/issues/47#issuecomment-50531205 I'm just a bit skeptical ... Maybe Compress::Snappy (and Sereal::*) could use the packaged original libsnappy? I quickly played around a bit, and with the attached patch, libcompress-snappy-perl builds and passes the tests. Maybe someone who speaks C/CS could make something out of it ... Cheers, gregor -- .''`. Homepage: http://info.comodo.priv.at/ - OpenPGP key 0xBB3A68018649AA06 : :' : Debian GNU/Linux user, admin, and developer - http://www.debian.org/ `. `' Member of VIBE!AT & SPI, fellow of the Free Software Foundation Europe `- NP: Bob Dylan: Highlands
diff --git a/debian/control b/debian/control index 36e5e76..04b34c8 100644 --- a/debian/control +++ b/debian/control @@ -4,6 +4,7 @@ Priority: optional Maintainer: Debian Perl Group <pkg-perl-maintain...@lists.alioth.debian.org> Uploaders: Alejandro Garrido Mota <alejan...@debian.org> Build-Depends: debhelper (>= 9.20120312), + libsnappy-dev, perl Standards-Version: 3.9.4 Vcs-Browser: http://anonscm.debian.org/gitweb/?p=pkg-perl/packages/libcompress-snappy-perl.git diff --git a/debian/patches/libsnappy.patch b/debian/patches/libsnappy.patch new file mode 100644 index 0000000..8bbbef2 --- /dev/null +++ b/debian/patches/libsnappy.patch @@ -0,0 +1,95 @@ +--- a/Snappy.xs ++++ b/Snappy.xs +@@ -7,8 +7,7 @@ + #define NEED_sv_2pvbyte + #include "ppport.h" + +-#include "src/csnappy_compress.c" +-#include "src/csnappy_decompress.c" ++#include <snappy-c.h> + + MODULE = Compress::Snappy PACKAGE = Compress::Snappy + +@@ -20,8 +19,7 @@ + PREINIT: + char *src, *dest; + STRLEN src_len; +- uint32_t dest_len; +- void *working_memory; ++ size_t dest_len; + CODE: + if (SvROK(sv) && ! SvAMAGIC(sv)) + sv = SvRV(sv); +@@ -30,19 +28,14 @@ + src = SvPVbyte(sv, src_len); + if (! src_len) + XSRETURN_NO; +- dest_len = csnappy_max_compressed_length(src_len); ++ dest_len = snappy_max_compressed_length(src_len); + if (! dest_len) + XSRETURN_UNDEF; +- Newx(working_memory, CSNAPPY_WORKMEM_BYTES, void *); +- if (! working_memory) +- XSRETURN_UNDEF; + RETVAL = newSV(dest_len); + dest = SvPVX(RETVAL); + if (! dest) + XSRETURN_UNDEF; +- csnappy_compress(src, src_len, dest, &dest_len, working_memory, +- CSNAPPY_WORKMEM_BYTES_POWER_OF_TWO); +- Safefree(working_memory); ++ snappy_compress(src, src_len, dest, &dest_len); + SvCUR_set(RETVAL, dest_len); + SvPOK_on(RETVAL); + OUTPUT: +@@ -56,7 +49,7 @@ + PREINIT: + char *src, *dest; + STRLEN src_len; +- uint32_t dest_len; ++ size_t dest_len; + int header_len; + CODE: + PERL_UNUSED_VAR(ix); /* -W */ +@@ -67,14 +60,14 @@ + src = SvPVbyte(sv, src_len); + if (! src_len) + XSRETURN_NO; +- header_len = csnappy_get_uncompressed_length(src, src_len, &dest_len); ++ header_len = snappy_uncompressed_length(src, src_len, &dest_len); + if (0 > header_len || ! dest_len) + XSRETURN_UNDEF; + RETVAL = newSV(dest_len); + dest = SvPVX(RETVAL); + if (! dest) + XSRETURN_UNDEF; +- if (csnappy_decompress_noheader(src + header_len, src_len - header_len, ++ if (snappy_uncompress(src + header_len, src_len - header_len, + dest, &dest_len)) + XSRETURN_UNDEF; + SvCUR_set(RETVAL, dest_len); +--- a/Makefile.PL ++++ b/Makefile.PL +@@ -5,10 +5,9 @@ + use lib qw(inc); + use Devel::CheckLib; + +-my $ctz = check_lib( +- lib => 'c', +- function => 'return (__builtin_ctzll(0x100000000LL) != 32);' +-) ? '-DHAVE_BUILTIN_CTZ' : ''; ++my $snappy = check_lib( ++ lib => 'snappy' ++) ? '-lsnappy' : ''; + + my %conf = ( + NAME => 'Compress::Snappy', +@@ -27,7 +26,7 @@ + }, + }, + +- DEFINE => $ctz, ++ LIBS => [ $snappy ], + + dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', }, + clean => { FILES => 'Compress-Snappy-*' }, diff --git a/debian/patches/series b/debian/patches/series new file mode 100644 index 0000000..e259574 --- /dev/null +++ b/debian/patches/series @@ -0,0 +1 @@ +libsnappy.patch
signature.asc
Description: Digital Signature