[SCM] Debian Qt/KDE packaging tools branch, master, updated. debian/0.5.3-68-gcaa8c01
Modestas Vainius
modax at alioth.debian.org
Sun Jan 31 18:33:00 UTC 2010
The following commit has been merged in the master branch:
commit 9a83e8613742b14320763c475025e01b35cf1dd7
Author: Modestas Vainius <modestas at vainius.eu>
Date: Sun Jan 31 14:31:31 2010 +0200
Make subst detection much safer.
* Detected subst is verified on all arches before assuming that it is correct.
* Previous subst is preserved if it validates on all aches.
* Posibility to detect "very similar" substs due to above.
* If the group still does not verify after subst detection, regroup by name and
emit a warning about possibly unknown subst.
---
.../Debian/PkgKde/SymbolsHelper/String.pm | 9 ++
symbolshelper/Debian/PkgKde/SymbolsHelper/Subst.pm | 15 +++-
.../Debian/PkgKde/SymbolsHelper/Substs.pm | 2 +-
.../PkgKde/SymbolsHelper/Substs/TypeSubst.pm | 79 +++++++++++++++--
.../PkgKde/SymbolsHelper/SymbolFileCollection.pm | 93 ++++++++++++++------
5 files changed, 162 insertions(+), 36 deletions(-)
diff --git a/symbolshelper/Debian/PkgKde/SymbolsHelper/String.pm b/symbolshelper/Debian/PkgKde/SymbolsHelper/String.pm
index 7800938..477f34b 100644
--- a/symbolshelper/Debian/PkgKde/SymbolsHelper/String.pm
+++ b/symbolshelper/Debian/PkgKde/SymbolsHelper/String.pm
@@ -77,6 +77,15 @@ sub get_string {
return shift()->{str};
}
+sub has_string2 {
+ return exists shift()->{str2};
+}
+
+sub get_string2_char {
+ my ($self, $index) = @_;
+ return $self->{str2}->[$index];
+}
+
sub get_string2 {
my $self = shift;
if (defined $self->{str2}) {
diff --git a/symbolshelper/Debian/PkgKde/SymbolsHelper/Subst.pm b/symbolshelper/Debian/PkgKde/SymbolsHelper/Subst.pm
index 01262ad..749c0c0 100644
--- a/symbolshelper/Debian/PkgKde/SymbolsHelper/Subst.pm
+++ b/symbolshelper/Debian/PkgKde/SymbolsHelper/Subst.pm
@@ -54,10 +54,23 @@ sub neutralize {
return undef;
}
+# Hinted neutralize where $hint is an already "detected"
+# SymbolsHelper::String
+# my ($self, $rawname, $hint) = @_;
+sub hinted_neutralize {
+ return undef;
+}
+
# Detect if the substitution can be applied to a bunch of
# arch specific raw names.
+# my ($self, $rawname, $arch, $arch_rawnames) = @_;
sub detect {
- my ($self, $rawname, $arch, $arch_rawnames) = @_;
+ return 0;
+}
+
+# Verifies if the subst is correct at $pos
+# my ($self, $pos, $arch_rawnames) = @_;
+sub verify_at {
return undef;
}
diff --git a/symbolshelper/Debian/PkgKde/SymbolsHelper/Substs.pm b/symbolshelper/Debian/PkgKde/SymbolsHelper/Substs.pm
index efb2c42..1738bc5 100644
--- a/symbolshelper/Debian/PkgKde/SymbolsHelper/Substs.pm
+++ b/symbolshelper/Debian/PkgKde/SymbolsHelper/Substs.pm
@@ -29,7 +29,7 @@ our @STANDALONE_SUBSTS = (
"${NS}::VirtTable"->new(),
);
-our @TYPE_SUBSTS = (
+our @TYPE_SUBSTS = (
"${NS}::TypeSubst::size_t"->new(),
"${NS}::TypeSubst::ssize_t"->new(),
"${NS}::TypeSubst::int64_t"->new(),
diff --git a/symbolshelper/Debian/PkgKde/SymbolsHelper/Substs/TypeSubst.pm b/symbolshelper/Debian/PkgKde/SymbolsHelper/Substs/TypeSubst.pm
index 1ee7957..310a596 100644
--- a/symbolshelper/Debian/PkgKde/SymbolsHelper/Substs/TypeSubst.pm
+++ b/symbolshelper/Debian/PkgKde/SymbolsHelper/Substs/TypeSubst.pm
@@ -19,6 +19,8 @@ use strict;
use warnings;
use base 'Debian::PkgKde::SymbolsHelper::Subst';
+use Debian::PkgKde::SymbolsHelper::Substs;
+
sub new {
my $class = shift;
my $self = $class->SUPER::new(@_);
@@ -54,6 +56,21 @@ sub neutralize {
return ($ret) ? $rawname : undef;
}
+sub hinted_neutralize {
+ my ($self, $rawname, $hint) = @_;
+ my $hintstr = $hint->{str2};
+ my $ret = 1;
+ my $l = $self->{'length'};
+
+ for (my $i = 0; $i < @$hintstr; $i++) {
+ if (defined $hintstr->[$i] && $hintstr->[$i] eq $self->{substvar}) {
+ $rawname->substr($i, $l, $self->{types}->[0]);
+ $ret = 1;
+ }
+ }
+ return ($ret) ? $rawname : undef;
+}
+
sub detect {
my ($self, $rawname, $arch, $arch_rawnames) = @_;
@@ -71,19 +88,55 @@ sub detect {
}
}
- return undef unless defined $s2;
+ return 0 unless defined $s2;
- # Verify subst and replace them with types[0] and substvar
+ # Verify subst and replace it with types[0] and substvar
my $ret = 0;
- my $pos = 0;
- while (($pos = index($s1, $t1, $pos)) != -1) {
+ search_next: for (my $pos = 0; ($pos = index($s1, $t1, $pos)) != -1; $pos++) {
+ # Verify on the selected $a2
if ($t2 eq substr($s2, $pos, $l)) {
- $rawname->substr($pos, $l, $self->{types}->[0], $self->{substvar});
- $ret = 1;
+ # Maybe subst is already there?
+ if ($rawname->has_string2() &&
+ (my $char = $rawname->get_string2_char($pos)))
+ {
+ if ($char eq $self->{substvar}) {
+ # Nothing to do
+ $ret = 1;
+ $pos += $l-1;
+ next search_next;
+ } elsif ($char =~ /^{(.*)}$/) {
+ # Another subst. Verify it
+ # NOTE: %SUBSTS won't work here due to recursive "use"
+ my $othersubst = $Debian::PkgKde::SymbolsHelper::Substs::SUBSTS{$1};
+ if (defined $othersubst && $othersubst->verify_at($pos, $arch_rawnames)) {
+ $ret = 1;
+ next search_next;
+ }
+ }
+ }
+ # Now verify detection on other arches
+ if ($self->verify_at($pos, $arch_rawnames)) {
+ $rawname->substr($pos, $l, $self->{types}->[0], $self->{substvar});
+ $ret = 1;
+ $pos += $l-1;
+ }
}
- $pos += $l;
}
- return ($ret) ? $rawname : undef;
+ return $ret;
+}
+
+sub verify_at {
+ my ($self, $pos, $arch_rawnames) = @_;
+ my $l = $self->{'length'};
+ my $verified = 1;
+ foreach my $a (keys %$arch_rawnames) {
+ my $t = $self->expand($a);
+ if ($t ne substr($arch_rawnames->{$a}, $pos, $l)) {
+ $verified = 0;
+ last;
+ }
+ }
+ return $verified;
}
# Operates on %l% etc. same length types that cannot be present in demanged
@@ -200,6 +253,16 @@ sub neutralize {
return $self->{private}->neutralize(@_);
}
+sub hinted_neutralize {
+ my $self = shift;
+ return $self->{private}->hinted_neutralize(@_);
+}
+
+sub verify_at {
+ my $self = shift;
+ return $self->{private}->verify_at(@_);
+}
+
package Debian::PkgKde::SymbolsHelper::Substs::TypeSubst::size_t;
use strict;
diff --git a/symbolshelper/Debian/PkgKde/SymbolsHelper/SymbolFileCollection.pm b/symbolshelper/Debian/PkgKde/SymbolsHelper/SymbolFileCollection.pm
index 5d23360..c94c015 100644
--- a/symbolshelper/Debian/PkgKde/SymbolsHelper/SymbolFileCollection.pm
+++ b/symbolshelper/Debian/PkgKde/SymbolsHelper/SymbolFileCollection.pm
@@ -147,6 +147,18 @@ sub calc_group_name {
return $str->get_string();
}
+sub get_symbols_regrouped_by_name {
+ my ($self, $group) = @_;
+ my $byname = $group->regroup_by_name();
+ my @byname;
+ foreach my $grp (sort values %$byname) {
+ if (my $sym = $grp->calc_properties($self)) {
+ push @byname, $sym;
+ }
+ }
+ return sort { $a->get_symboltempl() cmp $b->get_symboltempl() } @byname;
+}
+
# Create a new template from the collection of symbol files
sub create_template {
my ($self, %opts) = @_;
@@ -257,36 +269,46 @@ sub create_template {
# Take care of ambiguous groups
if ($group->is_ambiguous()) {
- my $byname = $group->regroup_by_name();
- my @byname;
- foreach my $grp (values %$byname) {
- if (my $sym = $grp->calc_properties($self)) {
- push @byname, $sym->get_symbolspec(1);
- $template->add_symbol($soname, $sym);
- }
- }
- if (@byname) {
+ if (my @byname = $self->get_symbols_regrouped_by_name($group)) {
+ $template->add_symbol($soname, $_) foreach @byname;
info("ambiguous symbols for subst detection (%s). Processed by name:\n" .
- " %s", "$groupname/$soname", join("\n ", @byname));
+ " %s", "$groupname/$soname",
+ join("\n ", map { $_->get_symbolspec(1) } @byname));
}
next;
}
# Calculate properties and detect substs.
if (my $sym = $group->calc_properties($self)) {
# Then detect substs (we need two or more arch specific symbols for that)
- if ($group->get_arches() > 1) {
+ my $substs_ok = 0;
+ if (scalar($group->get_arches()) > 1 && ! $group->are_symbols_equal()) {
my $substs_arch = ($group->has_symbol($orig_arch)) ?
$orig_arch : ($group->get_arches())[0];
-
if ($group->detect_substs($substs_arch)) {
- my $substs_sym = $group->get_symbol($substs_arch);
- $sym->add_tag("subst");
- $sym->reset_h_name($substs_sym->get_h_name());
+ my $substs_sym = $group->get_symbol($substs_arch);
+ $sym->add_tag("subst");
+ $sym->reset_h_name($substs_sym->get_h_name());
+ $substs_ok = $group->verify_substs();
}
+ } else {
+ $substs_ok = 1;
}
- # Finally add to template
- $template->add_symbol($soname, $sym);
+ if ($substs_ok) {
+ # Finally add to template
+ $template->add_symbol($soname, $sym);
+ } else {
+ # Substitutions do not verify. Regroup by name what remains
+ foreach my $sym ($group->get_symbols()) {
+ $sym->resync_name_with_h_name();
+ }
+ if (my @byname = $self->get_symbols_regrouped_by_name($group)) {
+ $template->add_symbol($soname, $_) foreach @byname;
+ info("possible incomplete subst detection (%s). Processed by name:\n" .
+ " %s", "$groupname/$soname",
+ join("\n ", map { $_->get_symbolspec(1) } @byname));
+ }
+ }
}
}
}
@@ -337,6 +359,11 @@ sub get_arches {
return keys %{$self->{arches}};
}
+sub get_symbols {
+ my $self = shift;
+ return values %{$self->{arches}};
+}
+
sub get_result {
my $self = shift;
return $self->{result};
@@ -412,16 +439,31 @@ sub regroup_by_name {
sub are_symbols_equal {
my $self = shift;
my @arches = $self->get_arches();
- my $name = $self->get_symbol(shift @arches);
+ my $name;
+
+ $name = ($self->get_symbol()) ?
+ $self->get_symbol() : $self->get_symbol(shift @arches);
+ $name = $name->get_symbolname();
foreach my $arch (@arches) {
if ($self->get_symbol($arch)->get_symbolname() ne $name) {
- $name = undef;
- last;
+ return 0;
}
}
- return $name;
+ return 1;
}
+# Verify if all substs have been replaced (i.e. hint-neutralized)
+sub verify_substs {
+ my $self = shift;
+ my @arches = $self->get_arches();
+ my $str = $self->get_symbol(shift @arches)->get_h_name()->get_string();
+ foreach my $arch (@arches) {
+ if ($self->get_symbol($arch)->get_h_name()->get_string() ne $str) {
+ return 0;
+ }
+ }
+ return 1;
+}
# Calculate group properties and instantiates 'result'. At the moment, this
# method will take care of arch tags and deprecated status. "Result" symbol is
@@ -602,19 +644,18 @@ sub detect_substs {
my %h_names = map { $_ => $self->get_symbol($_)->get_h_name() } $self->get_arches();
my $h_name = $h_names{$main_arch};
- delete $h_names{$main_arch};
- my @substs;
+ my $detected = 0;
foreach my $subst (@{$self->{substs}}) {
if ($subst->detect($h_name, $main_arch, \%h_names)) {
- push @substs, $subst;
+ $detected++;
# Make other h_names arch independent with regard to this handler.
foreach my $arch (keys %h_names) {
- $subst->neutralize($h_names{$arch}, $arch);
+ $subst->hinted_neutralize($h_names{$arch}, $h_name);
}
}
}
- return @substs;
+ return $detected;
}
1;
--
Debian Qt/KDE packaging tools
More information about the pkg-kde-commits
mailing list