Prechádzať zdrojové kódy

Dpkg::Shlibs::Symbol.pm: change handling of old-style wildcards

Really treat "*@version" like "(symver|optional)version" and don't care
if the diff output might not apply in that specific case. The difference
are minor anyway when you use that feature to maintain your symbols file.
Raphaël Hertzog 16 rokov pred
rodič
commit
e0fa135137

+ 12 - 14
scripts/Dpkg/Shlibs/Symbol.pm

@@ -157,23 +157,22 @@ sub initialize {
 	$type = 'alias-c++';
 	$type = 'alias-c++';
     }
     }
 
 
+    # Support old style wildcard syntax. That's basically a symver
+    # with an optional tag.
+    if ($self->get_symbolname() =~ /^\*@(.*)$/) {
+	$self->add_tag("symver") unless $self->has_tag("symver");
+	$self->add_tag("optional") unless $self->has_tag("optional");
+	$self->{symbol} = $1;
+    }
+
     if ($self->has_tag('symver')) {
     if ($self->has_tag('symver')) {
 	# Each symbol is matched against its version rather than full
 	# Each symbol is matched against its version rather than full
 	# name@version string.
 	# name@version string.
 	$type = (defined $type) ? 'generic' : 'alias-symver';
 	$type = (defined $type) ? 'generic' : 'alias-symver';
-    }
-    # Support old style wildcard syntax as well. That's basically a symver
-    # with implicit optional tag.
-    if ($self->get_symbolname() =~ /^\*@(.*)$/) {
-	error(_g("you can't use wildcards on unversioned symbols: %s"), $_) if $1 eq "Base";
-	# symver pattern needs symbol name to be its version. However, keeping
-	# dumping this as old style wildcard in the output.
-	unless (defined $self->{symbol_templ}) {
-	    $self->{symbol_templ} = $self->get_symbolname();
+	if ($self->get_symbolname() eq "Base") {
+	    error(_g("you can't use symver tag to catch unversioned symbols: %s"),
+	          $self->get_symbolspec(1));
 	}
 	}
-	$type = (defined $type) ? 'generic' : 'alias-symver';
-	$self->{symbol} = $1;
-	$self->{pattern}{old_wildcard} = 1;
     }
     }
 
 
     # As soon as regex is involved, we need to match each real
     # As soon as regex is involved, we need to match each real
@@ -270,8 +269,7 @@ sub equals {
 
 
 sub is_optional {
 sub is_optional {
     my $self = shift;
     my $self = shift;
-    return $self->has_tag("optional") ||
-           (exists $self->{pattern} && exists $self->{pattern}{old_wildcard});
+    return $self->has_tag("optional");
 }
 }
 
 
 sub is_arch_specific {
 sub is_arch_specific {

+ 10 - 4
scripts/t/200_Dpkg_Shlibs.t

@@ -13,7 +13,7 @@
 # You should have received a copy of the GNU General Public License
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
-use Test::More tests => 104;
+use Test::More tests => 106;
 use Cwd;
 use Cwd;
 use IO::String;
 use IO::String;
 
 
@@ -152,6 +152,7 @@ $sym = $sym_file_old->lookup_symbol('__nss_services_lookup@GLIBC_PRIVATE', ['lib
 is_deeply($sym, Dpkg::Shlibs::Symbol->new( 'symbol' => '__nss_services_lookup@GLIBC_PRIVATE',
 is_deeply($sym, Dpkg::Shlibs::Symbol->new( 'symbol' => '__nss_services_lookup@GLIBC_PRIVATE',
 		  'minver' => '2.3.6.wildcard', 'dep_id' => 0,
 		  'minver' => '2.3.6.wildcard', 'dep_id' => 0,
 		  'deprecated' => 0, 'depends' => '',
 		  'deprecated' => 0, 'depends' => '',
+		  'tags' => { 'symver' => undef,  optional => undef }, 'tagorder' => [ 'symver', 'optional' ],
 		  'soname' => 'libc.so.6', 'matching_pattern' => $pat ), 'wildcarded symbol');
 		  'soname' => 'libc.so.6', 'matching_pattern' => $pat ), 'wildcarded symbol');
 
 
 # Save -> Load test
 # Save -> Load test
@@ -457,9 +458,14 @@ ok ( $sym->get_pattern()->equals($sym_file->create_symbol('(c++|symver)SYMVER_1
 
 
 # Test old style wildcard support
 # Test old style wildcard support
 load_patterns_symbols();
 load_patterns_symbols();
-$pat = $sym_file->lookup_pattern($sym_file->create_symbol('*@SYMVEROPT_2 2'), ['libpatterns.so.1']);
-ok ( $pat->is_optional(), "Old style wildcard is optional");
-is ( $pat->get_alias_type(), "symver", "old style wildcard is a symver pattern" );
+$sym = $sym_file->create_symbol('*@SYMVEROPT_2 2');
+ok ( $sym->is_optional(), "Old style wildcard is optional");
+is ( $sym->get_alias_type(), "symver", "old style wildcard is a symver pattern" );
+is ( $sym->get_symbolname(), 'SYMVEROPT_2', "wildcard pattern got renamed" );
+
+$pat = $sym_file->lookup_pattern($sym_file->create_symbol('(symver|optional)SYMVEROPT_2 2'), ['libpatterns.so.1']);
+$sym->{symbol_templ} = $pat->{symbol_templ};
+is_deeply( $pat, $sym, "old style wildcard is the same as (symver|optional)" );
 
 
 # Get rid of all SymverOptional symbols
 # Get rid of all SymverOptional symbols
 foreach my $tmp (keys %{$obj->{dynsyms}}) {
 foreach my $tmp (keys %{$obj->{dynsyms}}) {

+ 1 - 1
scripts/t/200_Dpkg_Shlibs/patterns.symbols

@@ -1,7 +1,7 @@
 libpatterns.so.1 libpatterns1 #MINVER#
 libpatterns.so.1 libpatterns1 #MINVER#
- *@SYMVEROPT_2 2
  (c++|regex|optional)NSA::ClassA::Private(::.*)?@Base 1.private
  (c++|regex|optional)NSA::ClassA::Private(::.*)?@Base 1.private
  (c++)NSB::Symver::symver_method2()@SYMVER_1 1.method2
  (c++)NSB::Symver::symver_method2()@SYMVER_1 1.method2
+ (symver|optional)SYMVEROPT_2 2
  SYMVEROPT_2@SYMVEROPT_2 2
  SYMVEROPT_2@SYMVEROPT_2 2
  (c++|symver)SYMVER_1 1.generic
  (c++|symver)SYMVER_1 1.generic
  SYMVER_1@SYMVER_1 1
  SYMVER_1@SYMVER_1 1