[SCM] Debian Qt/KDE packaging tools branch, improved-gensymbols, updated. debian/0.5.3-27-g8436aa7
Modestas Vainius
modax at alioth.debian.org
Sun Jan 17 18:13:08 UTC 2010
The following commit has been merged in the improved-gensymbols branch:
commit ac1c80d7492e0da21cf3308f7d2a2a6198556a45
Author: Modestas Vainius <modestas at vainius.eu>
Date: Sun Jan 17 20:04:38 2010 +0200
`pkgkde-symbolshelper patch` is back.
---
symbolshelper/Debian/PkgKde/SymbolsHelper/Patch.pm | 86 ++++++++++++++++++
.../Debian/PkgKde/SymbolsHelper/Symbol.pm | 26 ++++++
.../Debian/PkgKde/SymbolsHelper/SymbolFile.pm | 96 --------------------
.../PkgKde/SymbolsHelper/SymbolFileCollection.pm | 96 --------------------
symbolshelper/pkgkde-symbolshelper | 53 ++++++++----
5 files changed, 148 insertions(+), 209 deletions(-)
diff --git a/symbolshelper/Debian/PkgKde/SymbolsHelper/Patch.pm b/symbolshelper/Debian/PkgKde/SymbolsHelper/Patch.pm
new file mode 100644
index 0000000..b221ab6
--- /dev/null
+++ b/symbolshelper/Debian/PkgKde/SymbolsHelper/Patch.pm
@@ -0,0 +1,86 @@
+package Debian::PkgKde::SymbolsHelper::Patch;
+
+use strict;
+use warnings;
+use base 'Exporter';
+
+use File::Temp qw();
+use IO::Handle;
+use Dpkg::ErrorHandling;
+
+our @EXPORT = qw(patch_symbolfile);
+
+sub patch_symbolfile {
+ my ($filename, $patchfh) = @_;
+
+ # Copy current symbol file to temporary location
+ my ($patchedfh, $patchedfn) = File::Temp::tempfile();
+ open(my $fh, "<", $filename) or
+ error("unable to open symbol file at '$filename'");
+ while (<$fh>) {
+ print $patchedfh $_;
+ }
+ $patchedfh->flush();
+ close $fh;
+ close $patchedfh;
+
+ # Extract needed patch from the stream and adapt it to our needs
+ # (filenames to patch).
+ my ($patchsrc, $patcharch);
+ my $is_patch;
+ my $sameline = 0;
+ while($sameline || ($_ = <$patchfh>)) {
+ $sameline = 0;
+ if (defined $is_patch) {
+ if (m/^(?:[+ -]|@@ )/) {
+ # Patch continues
+ print PATCH $_;
+ $is_patch++;
+ } else {
+ # Patch ended
+ if (close(PATCH)) {
+ # Successfully patched
+ $patchsrc = undef;
+ # $patcharch stays set
+ # $is_patch stays set
+ last;
+ } else {
+ # Failed to patch. continue searching for another patch
+ $sameline = 1;
+ $patchsrc = undef;
+ $patcharch = undef;
+ $is_patch = undef;
+ next;
+ }
+ }
+ } elsif (defined $patchsrc) {
+ if (m/^[+]{3}\s+\S+/) {
+ # Found the patch portion. Write the patch header
+ $is_patch = 0;
+ open(PATCH, "| patch --posix --force --quiet -r- -p0 >/dev/null 2>&1")
+ or die "Unable to execute `patch` program";
+ print PATCH "--- ", $patchedfn, "\n";
+ print PATCH "+++ ", $patchedfn, "\n";
+ } else {
+ $patchsrc = undef;
+ $patcharch = undef;
+ }
+ } elsif (m/^[-]{3}\s+(\S+)(?:\s+\((\S+)\s+(\S+)\))?/) {
+ $patchsrc = $1;
+ $patcharch = $2;
+ }
+ }
+ # In case patch continued to the end of file, close it
+ my $symfile;
+ if(($patchsrc && close(PATCH)) || $is_patch) {
+ # Patching was successful. Parse new SymbolFile and return it
+ my %opts;
+ $opts{file} = $patchedfn;
+ $opts{arch} = $patcharch if defined $patcharch;
+ $symfile = Debian::PkgKde::SymbolsHelper::SymbolFile->new(%opts);
+ }
+
+ unlink($patchedfn);
+ return $symfile;
+}
+
diff --git a/symbolshelper/Debian/PkgKde/SymbolsHelper/Symbol.pm b/symbolshelper/Debian/PkgKde/SymbolsHelper/Symbol.pm
index 9b42c14..b83d512 100644
--- a/symbolshelper/Debian/PkgKde/SymbolsHelper/Symbol.pm
+++ b/symbolshelper/Debian/PkgKde/SymbolsHelper/Symbol.pm
@@ -107,6 +107,13 @@ sub detect_cpp_templinst() {
return 0;
}
+sub mark_cpp_templinst_as_optional {
+ my $self = shift;
+ if (!$self->is_optional() && $self->detect_cpp_templinst()) {
+ $self->add_tag("optional", "templinst");
+ }
+}
+
# Upgrades symbol template to c++ alias converting
# substitutions as well. Returns upgraded template.
sub upgrade_templ_to_cpp_alias {
@@ -254,6 +261,13 @@ sub upgrade_templ_to_cpp_alias {
return $result;
}
+sub handle_virtual_table_symbol {
+ my $self = shift;
+ if ($self->get_symboltempl() =~ /^_ZT[Chv]/) {
+ $self->upgrade_templ_to_cpp_alias();
+ }
+}
+
sub set_min_version {
my ($self, $version, %opts) = @_;
@@ -275,4 +289,16 @@ sub normalize_min_version {
}
}
+sub handle_min_version {
+ my ($self, $version, %opts) = @_;
+
+ if (defined $version) {
+ if ($version) {
+ return $self->set_min_version($version, %opts);
+ } else {
+ return $self->normalize_min_version(%opts);
+ }
+ }
+}
+
1;
diff --git a/symbolshelper/Debian/PkgKde/SymbolsHelper/SymbolFile.pm b/symbolshelper/Debian/PkgKde/SymbolsHelper/SymbolFile.pm
index fda2776..46d2248 100644
--- a/symbolshelper/Debian/PkgKde/SymbolsHelper/SymbolFile.pm
+++ b/symbolshelper/Debian/PkgKde/SymbolsHelper/SymbolFile.pm
@@ -73,100 +73,4 @@ sub detect_standalone_substs {
}
}
-sub mark_cpp_templinst_as_optional {
- my $self = shift;
- foreach my $sym (grep { not $_->is_optional() } $self->get_symbols()) {
- if ($sym->detect_cpp_templinst()) {
- $sym->add_tag("optional", "templinst");
- }
- }
-}
-
-sub handle_virtual_table_symbols {
- my $self = shift;
- foreach my $sym (grep { $_->get_symboltempl() =~ /^_ZT[Chv]/ } $self->get_symbols()) {
- $sym->upgrade_templ_to_cpp_alias();
- }
-}
-
-sub merge_lost_symbols_to_template {
- my ($self, $origsymfile, $newsymfile) = @_;
- my $count = 0;
- # Note: $origsymfile should normally be result of $self->substitute()
-
- # Process symbols which are missing (lost) in $newsymfile
- for my $n ($newsymfile->get_lost_symbols($origsymfile)) {
- my $soname = $n->{soname};
- my $sym = $n->{name};
- my $origsyms = $origsymfile->{objects}{$soname}{syms};
- my $newsyms = $newsymfile->{objects}{$soname}{syms};
-
- my $mysym = (exists $origsyms->{$sym}{oldname}) ?
- $origsyms->{$sym}{oldname} : $sym;
- if (exists $newsyms->{$sym}) {
- $self->{objects}{$soname}{syms}{$mysym} = $newsyms->{$sym};
- } else {
- # Mark as missing
- $self->{objects}{$soname}{syms}{$mysym}{deprecated} = "LOST UNKNOWNVER";
- }
- $count++;
- }
- return $count;
-}
-
-sub get_new_symbols_as_symbfile {
- my ($self, $ref) = @_;
- my $deps = [ 'dummy dep' ];
-
- if (my @newsyms = $self->get_new_symbols($ref)) {
- my $newsymfile = new Debian::PkgKde::SymHelper::SymbFile();
- $newsymfile->clear();
-
- for my $n (@newsyms) {
- my $soname = $n->{soname};
- my $sym = $n->{name};
-
- $newsymfile->{objects}{$soname}{syms}{$sym} =
- $self->{objects}{$soname}{syms}{$sym};
- $newsymfile->{objects}{$soname}{deps} = $deps;
- }
- return $newsymfile;
- } else {
- return undef;
- }
-}
-
-sub merge_symbols_from_symbfile {
- my ($self, $symfile, $warn_about_collisions) = @_;
-
- while (my ($soname, $sonameobj) = each(%{$symfile->{objects}})) {
- my $mysyms = $self->{objects}{$soname}{syms};
- $mysyms = {} unless (defined $mysyms);
-
- while (my ($sym, $info) = each(%{$sonameobj->{syms}})) {
- if (exists $mysyms->{$sym}) {
- warning("$sym exists in both symfiles. Keeping the old one\n")
- if ($warn_about_collisions)
- } else {
- $mysyms->{$sym} = $info;
- }
- }
- $self->{objects}{$soname}{syms} = $mysyms;
- }
-}
-
-sub handle_min_version {
- my ($self, $version, %opts) = @_;
-
- foreach my $sym ($self->get_symbols()) {
- if (defined $version) {
- if ($version) {
- $sym->set_min_version($version, %opts);
- } else {
- $sym->normalize_min_version(%opts);
- }
- }
- }
-}
-
1;
diff --git a/symbolshelper/Debian/PkgKde/SymbolsHelper/SymbolFileCollection.pm b/symbolshelper/Debian/PkgKde/SymbolsHelper/SymbolFileCollection.pm
index b11a800..721f48a 100644
--- a/symbolshelper/Debian/PkgKde/SymbolsHelper/SymbolFileCollection.pm
+++ b/symbolshelper/Debian/PkgKde/SymbolsHelper/SymbolFileCollection.pm
@@ -189,100 +189,4 @@ sub create_template {
return $main_symfile;
}
-sub apply_patch_to_template {
- my ($self, $patchfh, $infile, $arch, $newminver) = @_;
-
- # Dump arch specific symbol file to temporary location
- my $archsymfile = $self->substitute($infile, $arch);
- my ($archfh, $archfn) = File::Temp::tempfile();
- $archsymfile->dump($archfh);
- close($archfh);
-
- # Adopt the patch to our needs (filename)
- my $file2patch;
- my $is_patch;
- my $sameline = 0;
- while($sameline || ($_ = <$patchfh>)) {
- $sameline = 0;
- if (defined $is_patch) {
- if (m/^(?:[+ -]|@@ )/) {
- # Patch continues
- print PATCH $_;
- $is_patch++;
- } else {
- # Patch ended
- if (!close(PATCH)) {
- # Continue searching for another patch
- $sameline = 1;
- $file2patch = undef;
- $is_patch = undef;
- next;
- } else {
- $file2patch = undef;
- # $is_patch stays set
- last;
- }
- }
- } elsif (defined $file2patch) {
- if (m/^[+]{3}\s+\S+/) {
- # Found the patch portion. Write the patch header
- $is_patch = 0;
- open(PATCH, "| patch -p0 >/dev/null 2>&1") or die "Unable to execute `patch` program";
- print PATCH "--- ", $archfn, "\n";
- print PATCH "+++ ", $archfn, "\n";
- } else {
- $file2patch = undef;
- }
- } elsif (m/^[-]{3}\s+(\S+)/) {
- $file2patch = $1;
- }
- }
- if(($file2patch && close(PATCH)) || $is_patch) {
- # Patching was successful. Reparse
- my $insymfile = new Debian::PkgKde::SymHelper::SymbFile($infile);
- my $newsymfile = new Debian::PkgKde::SymHelper::SymbFile($archfn);
-
- # Resync private symbols in newsymfile with archsymfile
- $newsymfile->resync_private_symbols($archsymfile);
-
- # Merge lost symbols
- if ($insymfile->merge_lost_symbols_to_template($archsymfile, $newsymfile)) {
- # Dump new MISSING symbols
- my $dummysymfile = new Debian::PkgKde::SymHelper::SymbFile();
- $dummysymfile->merge_lost_symbols_to_template($archsymfile, $newsymfile);
-
- info("-- Added new MISSING symbols --\n");
- while (my ($soname, $obj) = each %{$dummysymfile->{objects}}) {
- $obj->{deps} = [ 'dummy dep' ];
- }
- $dummysymfile->dump(*STDOUT, with_deprecated => 1);
- }
-
- # Now process new symbols. We need to create a template from them
- if (my $dummysymfile = $newsymfile->get_new_symbols_as_symbfile($archsymfile)) {
- $self->add_symbol_file($dummysymfile, $arch);
- $self->preprocess();
-
- # Handle min version
- $dummysymfile->handle_min_version($newminver, with_deprecated => 1);
-
- # Dump new symbols
- info("-- Added new symbols --\n");
- $dummysymfile->dump(*STDOUT, with_deprecated => 2);
-
- # Create a symbols template for our dummy file
- $dummysymfile = $self->create_template_standalone();
-
- # Finally, merge it to our $insymfile
- $insymfile->merge_symbols_from_symbfile($dummysymfile, 1);
- }
- unlink($archfn);
- return return $insymfile;
- } else {
- # Patching failed
- unlink($archfn);
- return undef;
- }
-}
-
1;
diff --git a/symbolshelper/pkgkde-symbolshelper b/symbolshelper/pkgkde-symbolshelper
index 6669ced..4e1eb39 100755
--- a/symbolshelper/pkgkde-symbolshelper
+++ b/symbolshelper/pkgkde-symbolshelper
@@ -56,8 +56,7 @@ use Dpkg::ErrorHandling;
use Dpkg::Arch qw(get_host_arch get_valid_arches);
use Debian::PkgKde::SymbolsHelper::SymbolFile;
use Debian::PkgKde::SymbolsHelper::SymbolFileCollection;
-
-my $handlers;
+use Debian::PkgKde::SymbolsHelper::Patch;
######## Option processing ##################
my $opt_out;
@@ -141,11 +140,11 @@ sub out_symfile {
return 0;
}
-sub print_symbol_list($$) {
- my ($list, $prefix) = @_;
- for my $item (@$list) {
- info(sprintf("%s%s %s\n", $prefix, $item->{soname}, $item->get_symbolname()));
- }
+sub tweak_symbol {
+ my $sym = shift;
+
+ $sym->handle_min_version($opt_version);
+ $sym->handle_virtual_table_symbol();
}
############### Subcommands ####################
@@ -191,8 +190,9 @@ sub subcommand_create {
$template = $symfiles->create_template();
}
- $template->handle_min_version($opt_version);
- $template->handle_virtual_table_symbols();
+ foreach my $sym ($template->get_symbols()) {
+ tweak_symbol($sym);
+ }
return out_symfile($template);
} else {
error("no properly named symbol files found in $opt_dir");
@@ -203,8 +203,6 @@ sub subcommand_create {
}
sub subcommand_patch {
- error("NOT IMPLEMENTED YET");
-
my $opt_diff;
my %opts = (
get_common_options("oipav"),
@@ -213,17 +211,38 @@ sub subcommand_patch {
if (GetOptions(%opts)) {
check_mandatory_options("i", "when package (-p) is not specified") unless ($opt_package);
unless ($opt_in) {
- $opt_in = "debian/$opt_package.symbols.in";
- error("symbol template file '$opt_in' was not found for package '$opt_package'") unless (-r $opt_in);
+ $opt_in = find_package_symbolfile_path($opt_package, $opt_arch);
+ error("symbol template file was not found for package '$opt_package'")
+ unless (defined $opt_in && -r $opt_in);
}
$opt_out = $opt_in if (!$opt_out && -w $opt_in);
-
$opt_diff = "-" unless ($opt_diff);
+
# Open patch
- open(DIFFINPUT, $opt_diff) or error("unable to open patch '$opt_diff' for reading");
- my $ret = out_symfile($handlers->apply_patch_to_template(*DIFFINPUT, $opt_in, $opt_arch, $opt_version));
+ open(DIFFINPUT, $opt_diff)
+ or error("unable to open patch '$opt_diff' for reading");
+
+ my $orig_symfile = Debian::PkgKde::SymbolsHelper::SymbolFile->new(
+ file => $opt_in, arch => $opt_arch);
+ my $patched_symfile = patch_symbolfile($opt_in, *DIFFINPUT);
+
+ # Read remaning $patchfh stream
+ if ($opt_diff eq "-") {
+ while (<DIFFINPUT>) {}
+ }
close(DIFFINPUT);
- return $ret;
+
+ error("supplied patch does not apply to the symbols file '$opt_in'")
+ unless defined $patched_symfile;
+
+ foreach my $info ($patched_symfile->get_new_symbols($orig_symfile)) {
+ # Retrieve real symbol instance
+ my $sym = $patched_symfile->{objects}{$info->{soname}}{syms}{$info->get_symbolname()};
+ tweak_symbol($sym);
+
+ info("NEW symbol: " . $sym->get_symbolspec(1));
+ }
+ return out_symfile($patched_symfile);
}
return 1;
}
--
Debian Qt/KDE packaging tools
More information about the pkg-kde-commits
mailing list