From d450f9fb12138b60e6b2310b349edb6462cd5729 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppi...@redhat.com> Date: Tue, 16 Feb 2016 08:58:35 +0100 Subject: Unbundle libbson
--- ....0-Use-system-libbson-library-if-possible.patch | 178 +++++++++++++++++++++ perl-MongoDB.spec | 27 +++- 2 files changed, 200 insertions(+), 5 deletions(-) create mode 100644 MongoDB-v0.708.4.0-Use-system-libbson-library-if-possible.patch diff --git a/MongoDB-v0.708.4.0-Use-system-libbson-library-if-possible.patch b/MongoDB-v0.708.4.0-Use-system-libbson-library-if-possible.patch new file mode 100644 index 0000000..439b6f5 --- /dev/null +++ b/MongoDB-v0.708.4.0-Use-system-libbson-library-if-possible.patch @@ -0,0 +1,178 @@ +From 7321c97598430437f919d748fd3a9d8ffab90d34 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppi...@redhat.com> +Date: Mon, 30 Mar 2015 15:20:33 +0200 +Subject: [PATCH] Use system libbson library if possible +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Signed-off-by: Petr Písař <ppi...@redhat.com> +--- + inc/Module/Install/PRIVATE/Mongo.pm | 85 +++++++++++++++++++++++++++---------- + perl_mongo.c | 12 +++++- + 2 files changed, 73 insertions(+), 24 deletions(-) + +diff --git a/inc/Module/Install/PRIVATE/Mongo.pm b/inc/Module/Install/PRIVATE/Mongo.pm +index 51d34e3..e099062 100644 +--- a/inc/Module/Install/PRIVATE/Mongo.pm ++++ b/inc/Module/Install/PRIVATE/Mongo.pm +@@ -56,8 +56,11 @@ END + sub mongo { + my ($self, @mongo_vars) = @_; + ++ my $inc = '-I.'; + my $ccflags = $self->makemaker_args->{CCFLAGS} || $Config{ccflags}; + $ccflags = "" unless defined $ccflags; ++ my $ldflags = $self->makemaker_args->{LDFLAGS}; ++ $ldflags = "" unless defined $ldflags; + + # MSWin32 requires newer gcc (if using gcc) + if ( $^O eq 'MSWin32' ) { +@@ -83,39 +86,49 @@ sub mongo { + $ccflags .= " -DMONGO_BIG_ENDIAN=1 "; + } + +- # needed to compile bson library +- $ccflags .= " -DBSON_COMPILATION "; +- +- my $conf = $self->configure_bson; +- +- if ($conf->{BSON_WITH_OID32_PT} || $conf->{BSON_WITH_OID64_PT}) { +- my $pthread = $^O eq 'solaris' ? " -pthreads " : " -pthread "; +- $ccflags .= $pthread; +- my $ldflags = $self->makemaker_args->{LDFLAGS}; +- $ldflags = "" unless defined $ldflags; +- $self->makemaker_args( LDFLAGS => "$ldflags $pthread" ); +- } ++ # Use system libbson if possible ++ my $conf = $self->check_system_bson; ++ my $bson_compilation = 1; ++ if ($conf->{found}) { ++ $bson_compilation = 0; ++ # I assume $conf->{cflags} contains -I only recognized by ++ # EU::MM's INC. Otherwise we should use ExtUtils::PkgConfig directly. ++ $inc .= ' ' . $conf->{cflags}; ++ # I assume $conf->{ldflags} contains -L and -l only recognized by ++ # EU::MM's LIBS. Otherwise we should use ExtUtils::PkgConfig directly. ++ $self->add_libs($conf->{ldflags}); ++ } else { ++ # needed to compile bson library ++ $inc .= ' -Ibson'; ++ $ccflags .= " -DBSON_COMPILATION "; ++ ++ $conf = $self->configure_bson; ++ ++ if ($conf->{BSON_WITH_OID32_PT} || $conf->{BSON_WITH_OID64_PT}) { ++ my $pthread = $^O eq 'solaris' ? " -pthreads " : " -pthread "; ++ $ccflags .= $pthread; ++ $ldflags .= $pthread; ++ } + +- if ( $conf->{BSON_HAVE_CLOCK_GETTIME} ) { +- my $libs = $self->makemaker_args->{LIBS}; +- $libs = [""] unless defined $libs; +- for my $part ( @$libs) { +- $part .= (length($part) ? " " : "") . "-lrt"; ++ if ( $conf->{BSON_HAVE_CLOCK_GETTIME} ) { ++ $self->add_libs("-lrt"); + } +- $self->makemaker_args->{LIBS} = $libs;; + } + + $self->makemaker_args( CCFLAGS => $ccflags ); + +- $self->xs_files; ++ $self->xs_files($bson_compilation); ++ ++ $self->makemaker_args( INC => $inc ); + +- $self->makemaker_args( INC => '-I. -Ibson -Iyajl' ); ++ # I think EU::MM ignores LDFLAGS ++ $self->makemaker_args( LDFLAGS => $ldflags ); + + return; + } + + sub xs_files { +- my ($self) = @_; ++ my ($self, $bson_compilation) = @_; + my (@clean, @OBJECT, %XS); + + for my $xs (<xs/*.xs>) { +@@ -127,7 +140,7 @@ sub xs_files { + push @clean, $o; + } + +- for my $c (<*.c>, <bson/*.c>, <yajl/*.c>) { ++ for my $c (<*.c>, ($bson_compilation ? (<bson/*.c>, <yajl/*.c>) : ())) { + (my $o = $c) =~ s/\.c$/\$(OBJ_EXT)/i; + + push @OBJECT, $o; +@@ -154,6 +167,34 @@ HERE + return; + } + ++sub add_libs { ++ my ($self, $new_libs) = @_; ++ ++ my $libs = $self->makemaker_args->{LIBS}; ++ $libs = [""] unless defined $libs; ++ for my $part ( @$libs) { ++ $part .= (length($part) ? " " : "") . "$new_libs"; ++ } ++ $self->makemaker_args->{LIBS} = $libs;; ++} ++ ++sub check_system_bson { ++ my ($self) = @_; ++ my %conf; ++ ++ my $ca = Config::AutoConf->new; ++ $ca->push_lang("C"); ++ if ($ca->pkg_config_package_flags('libbson-1.0')) { ++ $conf{found} = 1; ++ $conf{cflags} = $ca->_get_extra_compiler_flags; ++ $conf{ldflags} = $ca->_get_extra_linker_flags; ++ } else { ++ $conf{found} = 0; ++ } ++ ++ return \%conf; ++} ++ + # Quick and dirty autoconf substitute + sub configure_bson { + my ($self) = @_; +diff --git a/perl_mongo.c b/perl_mongo.c +index 72f4007..eb485a9 100644 +--- a/perl_mongo.c ++++ b/perl_mongo.c +@@ -1575,7 +1575,11 @@ static void serialize_binary(bson_t * bson, const char * key, bson_subtype_t sub + bson_append_binary(bson, key, -1, subtype, bytes, len); + } + +-void * mongo_renew(void * ptr, size_t size) ++void * mongo_renew(void * ptr, size_t size ++#ifndef BSON_COMPILATION ++ , void * ctx ++#endif ++ ) + { + Renew(ptr, size, char); + +@@ -1592,7 +1596,11 @@ void perl_mongo_sv_to_buffer(buffer * buf, SV *sv, AV *ids) + buf_len = buf->end - buf->start; + offset = buf->pos - buf->start; + +- writer = bson_writer_new((uint8_t **)&buf->start, &buf_len, offset, &mongo_renew); ++ writer = bson_writer_new((uint8_t **)&buf->start, &buf_len, offset, &mongo_renew ++#ifndef BSON_COMPILATION ++ , NULL ++#endif ++ ); + + bson_writer_begin(writer, &bson); + perl_mongo_sv_to_bson(bson, sv, ids); +-- +2.5.0 + diff --git a/perl-MongoDB.spec b/perl-MongoDB.spec index ee5a137..447251e 100644 --- a/perl-MongoDB.spec +++ b/perl-MongoDB.spec @@ -1,13 +1,21 @@ Name: perl-MongoDB Version: 0.708.4.0 -Release: 3%{?dist} +Release: 4%{?dist} Summary: A MongoDB Driver for Perl -# The distribution itself is under ASL 2.0 -# Various parts of the BSON and YAJL bits are under a combination -# of BSD, ISC and MIT licenses. -License: ASL 2.0 and BSD and ISC and MIT +## Installed: +# Other files: ASL 2.0 +## Not installed: +# bson/bson-stdint-win32.h: BSD +# bson/b64_ntop.h: MIT +# bson/bson-md5.c: zlib +# yajl: ISC +# inc/Module/Install/Compiler.pm: GPL+ or Artistic +# pstdint.h: BSD +License: ASL 2.0 URL: http://search.cpan.org/dist/MongoDB/ Source0: http://www.cpan.org/authors/id/M/MO/MONGODB/MongoDB-v%{version}.tar.gz +# Use system libbson if available <https://jira.mongodb.org/browse/PERL-521> +Patch0: MongoDB-v0.708.4.0-Use-system-libbson-library-if-possible.patch # Build BuildRequires: coreutils BuildRequires: findutils @@ -31,10 +39,12 @@ BuildRequires: perl(Path::Tiny) >= 0.052 BuildRequires: perl(strict) BuildRequires: perl(vars) BuildRequires: perl(warnings) +BuildRequires: sed # Disable tests on ARM because the server crashes (bug #1303864) %ifnarch %arm # Runtime BuildRequires: perl(Authen::SCRAM::Client) +BuildRequires: pkgconfig(libbson-1.0) BuildRequires: perl(boolean) BuildRequires: perl(Carp) BuildRequires: perl(Class::MOP::Class) @@ -89,6 +99,10 @@ The perl database access module for MongoDB. %prep %setup -q -n MongoDB-v%{version} +# Unbundle libbson +%patch0 -p1 +rm -r bson yajl +sed -i -e '/^bson\//d' -e '/^yajl\//d' MANIFEST %build perl Makefile.PL --ssl --sasl INSTALLDIRS=vendor OPTIMIZE="%{optflags}" NO_PACKLIST=1 @@ -124,6 +138,9 @@ exit $test_rc %{_mandir}/man3/* %changelog +* Tue Feb 16 2016 Petr Pisar <ppi...@redhat.com> - 0.708.4.0-4 +- Unbundle libbson + * Thu Feb 04 2016 Fedora Release Engineering <rel...@fedoraproject.org> - 0.708.4.0-3 - Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild -- cgit v0.11.2 http://pkgs.fedoraproject.org/cgit/perl-MongoDB.git/commit/?h=master&id=d450f9fb12138b60e6b2310b349edb6462cd5729 -- Fedora Extras Perl SIG http://www.fedoraproject.org/wiki/Extras/SIGs/Perl perl-devel mailing list perl-devel@lists.fedoraproject.org http://lists.fedoraproject.org/admin/lists/perl-devel@lists.fedoraproject.org