From f526a166fe3e8a28c9fcac3ffc8e6be967d678ff Mon Sep 17 00:00:00 2001 From: David Bremner Date: Sat, 3 Mar 2012 15:23:40 -0400 Subject: Introduce a btparse_api_version note and use it in definine the SONAME. Most linux distributions require a versioned SONAME for all libraries in /usr/lib. This provides such an SONAME by defining the version in Build.PL. We also provide a symlink with unversioned name to make the linking of binaries to the shared library transparent. Arguably this should be defined in the C source of btparse, but since the version is taken from the perl module, this alternative is maybe more acceptable; it is certainly simpler than parsing another file in Build.PL. Gbp-Pq: Name 0001-Introduce-a-btparse_api_version-note-and-use-it-in-d.patch --- Build.PL | 4 ++++ inc/MyBuilder.pm | 23 ++++++++++++++++++----- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/Build.PL b/Build.PL index 75d0b33..18d3ecd 100644 --- a/Build.PL +++ b/Build.PL @@ -103,6 +103,10 @@ else { $hdrdir =~ s!/[^/]+/?$!/include! } $builder->notes( 'btparse_version' => $version ); +# +# this should be increased everytime there is a non-upward compatible +# change the library ABI. +$builder->notes( 'btparse_api_version' => 2 ); $builder->notes( 'lib_path' => $libdir ); $builder->add_build_element('usrlib'); $builder->install_path( 'usrlib' => $libdir ); diff --git a/inc/MyBuilder.pm b/inc/MyBuilder.pm index 8c6f6f9..2725565 100644 --- a/inc/MyBuilder.pm +++ b/inc/MyBuilder.pm @@ -15,7 +15,7 @@ use ExtUtils::Mkbootstrap; use File::Spec::Functions qw.catdir catfile.; use File::Path qw.mkpath.; -use Cwd 'abs_path'; +use Cwd; my @EXTRA_FLAGS = (); my @BINARIES = qw(biblex bibparse dumpnames); @@ -334,9 +334,14 @@ sub ACTION_create_library { my $libbuilder = $self->notes('libbuilder'); + my $APIVERSION = $self->notes('btparse_api_version'); my $LIBEXT = $libbuilder->{libext}; - print STDERR "\n** Creating libbtparse$LIBEXT\n"; + my $symlink_exists = eval { symlink("",""); 1 }; + + my $SONAME= $symlink_exists ? "libbtparse$LIBEXT.$APIVERSION" : "libbtparse$LIBEXT"; + + print STDERR "\n** Creating $SONAME\n"; my @modules = qw:init input bibtex err scan error lex_auxiliary parse_auxiliary bibtex_ast sym @@ -346,15 +351,15 @@ sub ACTION_create_library { my @objects = map { "btparse/src/$_.o" } @modules; my $libpath = $self->notes('lib_path'); - $libpath = catfile($libpath, "libbtparse$LIBEXT"); - my $libfile = "btparse/src/libbtparse$LIBEXT"; + $libpath = catfile($libpath, $SONAME); + my $libfile = "btparse/src/$SONAME"; my $extra_linker_flags = ""; if ($^O =~ /darwin/) { my $abs_path = abs_path($libfile); $extra_linker_flags = "-install_name $abs_path"; } elsif ($LIBEXT eq ".so") { - $extra_linker_flags = "-Wl,-soname,libbtparse$LIBEXT"; + $extra_linker_flags = "-Wl,-soname,$SONAME"; } if (!$self->up_to_date(\@objects, $libfile)) { @@ -364,6 +369,14 @@ sub ACTION_create_library { extra_linker_flags => $extra_linker_flags); } + if ($symlink_exists) { + my $olddir = getcwd; + chdir ("btparse/src"); + unlink("libbtparse$LIBEXT"); + symlink ($SONAME, "libbtparse$LIBEXT") or die("$!"); + chdir ($olddir); + } + my $libdir = catdir($self->blib, 'usrlib'); mkpath( $libdir, 0, 0777 ) unless -d $libdir; -- cgit v1.2.3 From 417469a8caa47cc4a201a7cecb246afbab2eab3c Mon Sep 17 00:00:00 2001 From: David Bremner Date: Sat, 3 Mar 2012 20:33:47 -0400 Subject: disable rpath if installing into /usr/lib rpath isn't needed then, and setting has some undesirable side-effects, the more obvious being that it prevents relocating the libraries in the files system. Gbp-Pq: Name 0002-disable-rpath-if-installing-into-usr-lib.patch --- inc/MyBuilder.pm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/inc/MyBuilder.pm b/inc/MyBuilder.pm index 2725565..949aec2 100644 --- a/inc/MyBuilder.pm +++ b/inc/MyBuilder.pm @@ -224,8 +224,14 @@ sub ACTION_create_binaries { print STDERR "\n** Creating binaries (",join(", ", map { $_.$EXEEXT } @BINARIES), ")\n"; + my $rpath_arg = ''; + + if ( ($^O !~ /darwin/) && $btparselibdir ne "/usr/lib") { + $rpath_arg = "-Wl,-R${btparselibdir}"; + } + my $extra_linker_flags = sprintf("-Lbtparse/src %s -lbtparse ", - ($^O !~ /darwin/)?"-Wl,-R${btparselibdir}":""); + $rpath_arg); my @toinstall; -- cgit v1.2.3 From 6ea8dc68bc9e93bdab63ec69ec6968a2a5164bc6 Mon Sep 17 00:00:00 2001 From: gregor herrmann Date: Wed, 17 Jul 2019 15:27:53 -0300 Subject: make sure we don't run ldconfig Origin: vendor Forwarded: not-needed Last-Update: 2016-07-09 Gbp-Pq: Name 0003-no-ldconfig.patch --- inc/MyBuilder.pm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/inc/MyBuilder.pm b/inc/MyBuilder.pm index 949aec2..7597bdc 100644 --- a/inc/MyBuilder.pm +++ b/inc/MyBuilder.pm @@ -52,10 +52,10 @@ sub ACTION_install { $self->install_path( 'usrlib' => $usrlib ); } $self->SUPER::ACTION_install; - if ($^O =~ /linux/ && $ENV{USER} eq 'root') { - my $linux = Config::AutoConf->check_prog("ldconfig"); - system $linux if (-x $linux); - } +# if ($^O =~ /linux/ && $ENV{USER} eq 'root') { +# my $linux = Config::AutoConf->check_prog("ldconfig"); +# system $linux if (-x $linux); +# } if ($^O =~ /(?:linux|bsd|sun|sol|dragonfly|hpux|irix|darwin|gnu)/ && $usrlib !~ m!^/usr(/local)?/lib/?$!) -- cgit v1.2.3 From 86177ffdb4909b1065ad86cc07f46e0ca9d6b311 Mon Sep 17 00:00:00 2001 From: gregor herrmann Date: Wed, 17 Jul 2019 15:27:53 -0300 Subject: install manpages into section 3 Origin: vendor Forwarded: no Last-Update: 2019-07-16 Gbp-Pq: Name 0004-manpage-section.patch --- inc/MyBuilder.pm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/inc/MyBuilder.pm b/inc/MyBuilder.pm index 7597bdc..6e17718 100644 --- a/inc/MyBuilder.pm +++ b/inc/MyBuilder.pm @@ -177,18 +177,18 @@ sub ACTION_create_manpages { my $version = $self->notes('btparse_version'); for my $pod (@$pods) { my $man = $pod; - $man =~ s!.pod!.1!; + $man =~ s!.pod!.3!; $man =~ s!btparse/doc!blib/bindoc!; ## FIXME - path next if $self->up_to_date($pod, $man); ## FIXME - `pod2man --section=1 --center="btparse" --release="btparse, version $version" $pod $man`; + `pod2man --section=3 --center="btparse" --release="btparse, version $version" $pod $man`; } my $pod = 'btool_faq.pod'; - my $man = catfile('blib','bindoc','btool_faq.1'); + my $man = catfile('blib','bindoc','btool_faq.3'); unless ($self->up_to_date($pod, $man)) { ## FIXME - `pod2man --section=1 --center="btparse" --release="btparse, version $version" $pod $man`; + `pod2man --section=3 --center="btparse" --release="btparse, version $version" $pod $man`; } } -- cgit v1.2.3 From 547fc932d28d0a76133c1354978c8b098f28165b Mon Sep 17 00:00:00 2001 From: gregor herrmann Date: Wed, 17 Jul 2019 15:27:53 -0300 Subject: add LDFLAGS when linking the .so Origin: vendor Forwarded: no Last-Update: 2019-07-16 Gbp-Pq: Name 0005-hardening-flags.patch --- inc/MyBuilder.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/inc/MyBuilder.pm b/inc/MyBuilder.pm index 6e17718..d1f7a70 100644 --- a/inc/MyBuilder.pm +++ b/inc/MyBuilder.pm @@ -208,7 +208,7 @@ sub ACTION_create_objects { $object =~ s/\.c/.o/; next if $self->up_to_date($file, $object); $cbuilder->compile(object_file => $object, - extra_compiler_flags=>["-D_FORTIFY_SOURCE=1",@EXTRA_FLAGS], + extra_compiler_flags=>[@EXTRA_FLAGS], source => $file, include_dirs => ["btparse/src"]); } @@ -365,7 +365,7 @@ sub ACTION_create_library { my $abs_path = abs_path($libfile); $extra_linker_flags = "-install_name $abs_path"; } elsif ($LIBEXT eq ".so") { - $extra_linker_flags = "-Wl,-soname,$SONAME"; + $extra_linker_flags = "-Wl,-soname,$SONAME $ENV{LDFLAGS}"; } if (!$self->up_to_date(\@objects, $libfile)) { -- cgit v1.2.3 From 955161d8f6b280cce5e6cd4c2693a11c6ac090d4 Mon Sep 17 00:00:00 2001 From: gregor herrmann Date: Wed, 17 Jul 2019 15:27:53 -0300 Subject: don't install into /usr/lib64 even if it exists Origin: vendor Bug-Debian: https://bugs.debian.org/905594 Forwarded: not-needed Last-Update: 2019-07-16 Gbp-Pq: Name 0006-no-lib64.patch --- Build.PL | 1 + 1 file changed, 1 insertion(+) diff --git a/Build.PL b/Build.PL index 18d3ecd..1b20844 100644 --- a/Build.PL +++ b/Build.PL @@ -65,6 +65,7 @@ my $builder = MyBuilder->new( ## HACK HACK HACK HACK my $libdir = $builder->install_destination("bin"); +$libdir =~ s/\bbin\b/lib/; # ignores the lib64 hackery later my $hdrdir = undef; if ( $^O =~ /mswin32/i ) { $libdir = undef; -- cgit v1.2.3