The following commit has been merged in the test-build branch:
commit 7ce363de30a37087e16621fc1b7e12516f1cd557
Merge: a6a593e37e89af719b9778a799c563ccd07d4736 
07efbb0889fcc6fab678ee727fc7c4013b163b53
Author: Raphael Hertzog <[EMAIL PROTECTED]>
Date:   Mon Dec 8 10:12:10 2008 +0100

    Merge branch 'master' into test-build

diff --combined ChangeLog
index 3a3a027,781ff56..c96d9a6
--- a/ChangeLog
+++ b/ChangeLog
@@@ -1,3 -1,14 +1,14 @@@
+ 2008-12-08  Modestas Vainius  <[EMAIL PROTECTED]>
+           Raphael Hertzog  <[EMAIL PROTECTED]>
+ 
+       * scripts/Dpkg/Shlibs/Objdump.pm (parse): Split into add_object()
+       and parse().
+       * scripts/Dpkg/Shlibs/SymbolFile.pm (merge_object_from_symfile):
+       New function to reintegrate symbols from previous symfiles.
+       * scripts/dpkg-shlibdeps.pl: Optimizes it by caching parsed
+       symbols files and objdump objects. This way neither of the
+       libraries or symbols files are parsed more than once.
+ 
  2008-12-05  Guillem Jover  <[EMAIL PROTECTED]>
  
        * lib/mlib.c: Remove <sys/wait.h> include.
@@@ -427,34 -438,6 +438,34 @@@
        * dselect/pkglist.cc (packagelist::addheading): Likewise.
        * dselect/pkgsublist.cc (packagelist::add): Likewise.
  
 +2008-12-01  Raphael Hertzog  <[EMAIL PROTECTED]>
 +
 +      * scripts/Dpkg/Source/Archive.pm (extract): Do not create the temp
 +      directory in the current directory but in the parent directory of
 +      the target directory. Otherwise the code would fail when called
 +      from a non-writable dir and rename could fail due to filesystem
 +      boundaries beetwen the current dir and the target one.
 +
 +2008-12-01  Modestas Vainius  <[EMAIL PROTECTED]>
 +
 +      * scripts/dpkg-shlibdeps.pl: Don't merge all dependency templates
 +      into the generated dependency when Build-Depends-Package is
 +      used in the symbols file. Instead simply modify the minimal
 +      version on any pre-existing dependency.
 +
 +2008-11-19  Raphael Hertzog  <[EMAIL PROTECTED]>
 +
 +      * scripts/Dpkg/Shlibs/Objdump.pm (parse_dynamic_symbol): Fix the
 +      regular expression to not require two space between alignment and
 +      symbol name.
 +      * scripts/t/200_Dpkg_Shlibs.t,
 +      scripts/t/200_Dpkg_Shlibs/objdump.ls: Add a non-regression test
 +      corresponding to the above case.
 +
 +2008-11-18  Guillem Jover  <[EMAIL PROTECTED]>
 +
 +      * configure.ac: Bump version to 1.14.24~.
 +
  2008-11-18  Guillem Jover  <[EMAIL PROTECTED]>
  
        * configure.ac: Release 1.14.23.
diff --combined debian/changelog
index 5914cf5,a8cb538..642c4be
--- a/debian/changelog
+++ b/debian/changelog
@@@ -86,6 -86,9 +86,9 @@@ dpkg (1.15.0) UNRELEASED; urgency=lo
    * Drop some unneeded lintian overrides.
    * Fix a chmod call in dpkg-source to not fail when POSIXLY_CORRECT is set.
      Closes: #506028
+   * Optimize dpkg-shlibdeps by caching parsed symbols files and
+     objdump objects. Thanks to Modestas Vainius <[EMAIL PROTECTED]> for the
+     patch. Closes: #503954
  
    [ Pierre Habouzit ]
    * Add a --query option to update-alternatives. Closes: #336091, #441904
@@@ -97,21 -100,6 +100,21 @@@
  
   -- Guillem Jover <[EMAIL PROTECTED]>  Tue, 29 Jul 2008 02:34:59 +0300
  
 +dpkg (1.14.24) UNRELEASED; urgency=low
 +
 +  [ Raphael Hertzog ]
 +  * Fix parsing of objdump output (by dpkg-shlibdeps) in a special case where
 +    the symbol name is separated only with a single space. Closes: #506139
 +  * Fix dpkg-shlibdeps behaviour when Build-Depends-Package is used in the
 +    symbols file. It was merging all dependency templates into the generated
 +    dependency instead of simply modifying the minimal version. Thanks to
 +    Modestas Vainius <[EMAIL PROTECTED]>. Closes: #507346
 +  * Fix dpkg-source to correctly extract a source package even when called
 +    from a non-writable directory when a target directory has been specified
 +    on the command line. Closes: #507217, #507219
 +
 + -- Guillem Jover <[EMAIL PROTECTED]>  Tue, 18 Nov 2008 12:40:33 +0200
 +
  dpkg (1.14.23) unstable; urgency=low
  
    [ Raphael Hertzog ]
@@@ -146,7 -134,6 +149,7 @@@
    * Romanian (Eddy Petrișor).
    * Slovak (Ivan Masár). Closes: #506024
    * Spanish (Javier Fernandez-Sanguino). Closes: #505836
 +  * Swedish (Peter Krefting).
  
    [ Updated scripts translations ]
    * Fix typo in Russian. Closes: #499736
diff --combined scripts/Dpkg/Shlibs/Objdump.pm
index 7d15388,411821f..b5cf7c9
--- a/scripts/Dpkg/Shlibs/Objdump.pm
+++ b/scripts/Dpkg/Shlibs/Objdump.pm
@@@ -30,10 -30,8 +30,8 @@@ sub new 
      return $self;
  }
  
- sub parse {
-     my ($self, $file) = @_;
-     my $obj = Dpkg::Shlibs::Objdump::Object->new($file);
- 
+ sub add_object {
+     my ($self, $obj) = @_;
      my $id = $obj->get_id;
      if ($id) {
        $self->{objects}{$id} = $obj;
@@@ -41,6 -39,12 +39,12 @@@
      return $id;
  }
  
+ sub parse {
+     my ($self, $file) = @_;
+     my $obj = Dpkg::Shlibs::Objdump::Object->new($file);
+ 
+     return $self->add_object($obj);
+ }
  
  sub locate_symbol {
      my ($self, $name) = @_;
@@@ -55,12 -59,17 +59,17 @@@
  
  sub get_object {
      my ($self, $objid) = @_;
-     if (exists $self->{objects}{$objid}) {
+     if ($self->has_object($objid)) {
        return $self->{objects}{$objid};
      }
      return undef;
  }
  
+ sub has_object {
+     my ($self, $objid) = @_;
+     return exists $self->{objects}{$objid};
+ }
+ 
  {
      my %format; # Cache of result
      sub get_format {
@@@ -259,7 -268,7 +268,7 @@@ sub _parse 
  sub parse_dynamic_symbol {
      my ($self, $line) = @_;
      my $vis_re = '(\.protected|\.hidden|\.internal|0x\S+)';
 -    if ($line =~ /^[0-9a-f]+ 
(.{7})\s+(\S+)\s+[0-9a-f]+\s+(\S+)?(?:(?:\s+$vis_re)?\s+(\S+))/) {
 +    if ($line =~ /^[0-9a-f]+ 
(.{7})\s+(\S+)\s+[0-9a-f]+(?:\s+(\S+))?(?:\s+$vis_re)?\s+(\S+)/) {
  
        my ($flags, $sect, $ver, $vis, $name) = ($1, $2, $3, $4, $5);
  
diff --combined scripts/dpkg-shlibdeps.pl
index e4c643c,068074d..609bf73
--- a/scripts/dpkg-shlibdeps.pl
+++ b/scripts/dpkg-shlibdeps.pl
@@@ -131,6 -131,11 +131,11 @@@ my %global_soname_notfound
  my %global_soname_used;
  my %global_soname_needed;
  
+ # Symfile and objdump caches
+ my %symfile_cache;
+ my %objdump_cache;
+ my %symfile_has_soname_cache;
+ 
  my $cur_field;
  foreach my $file (keys %exec) {
      $cur_field = $exec{$file};
@@@ -193,17 -198,21 +198,21 @@@
  
        # Load symbols/shlibs files from packages providing libraries
        foreach my $pkg (@{$file2pkg->{$lib}}) {
-           my $dpkg_symfile;
+           my $symfile_path;
            if ($packagetype eq "deb") {
                # Use fine-grained dependencies only on real deb
-               $dpkg_symfile = find_symbols_file($pkg, $soname, $lib);
-               if (defined $dpkg_symfile) {
-                   # Load symbol information
-                   print "Using symbols file $dpkg_symfile for $soname\n" if 
$debug;
-                   $symfile->load($dpkg_symfile);
-               }
-           }
-           if (defined($dpkg_symfile) && $symfile->has_object($soname)) {
+               $symfile_path = find_symbols_file($pkg, $soname, $lib);
+             }
+             if (defined($symfile_path)) {
+                 # Load symbol information
+                 print "Using symbols file $symfile_path for $soname\n" if 
$debug;
+                 unless (exists $symfile_cache{$symfile_path}) {
+                     $symfile_cache{$symfile_path} =
+                         Dpkg::Shlibs::SymbolFile->new($symfile_path);
+                 }
+                 
$symfile->merge_object_from_symfile($symfile_cache{$symfile_path}, $soname);
+             }
+           if (defined($symfile_path) && $symfile->has_object($soname)) {
                # Initialize dependencies with the smallest minimal version
                  # of all symbols (unversioned dependency is not ok as the
                  # library might not have always been available in the
@@@ -217,13 -226,17 +226,17 @@@
                }
            } else {
                # No symbol file found, fall back to standard shlibs
-               my $id = $dumplibs_wo_symfile->parse($lib);
+                 print "Using shlibs+objdump for $soname (file $lib)\n" if 
$debug;
+                 unless (exists $objdump_cache{$lib}) {
+                     $objdump_cache{$lib} = 
Dpkg::Shlibs::Objdump::Object->new($lib);
+                 }
+                 my $libobj = $objdump_cache{$lib};
+                 my $id = $dumplibs_wo_symfile->add_object($libobj);
                if (($id ne $soname) and ($id ne $lib)) {
                    warning(_g("%s has an unexpected SONAME (%s)"), $lib, $id);
                    $alt_soname{$id} = $soname;
                }
                push @soname_wo_symfile, $soname;
-               my $libobj = $dumplibs_wo_symfile->get_object($id);
                # Only try to generate a dependency for libraries with a SONAME
                if ($libobj->is_public_library() and not
                    add_shlibs_dep($soname, $pkg, $lib)) {
@@@ -341,7 -354,7 +354,7 @@@
            my $minver = get_min_version_from_deps($build_deps, $dev_pkg);
            if (defined $minver) {
                foreach my $dep ($symfile->get_dependencies($soname)) {
 -                  update_dependency_version($dep, $minver);
 +                  update_dependency_version($dep, $minver, 1);
                }
            }
        }
@@@ -539,7 -552,7 +552,7 @@@ sub get_min_version_from_deps 
  }
  
  sub update_dependency_version {
 -    my ($dep, $minver) = @_;
 +    my ($dep, $minver, $existing_only) = @_;
      return if not defined($minver);
      foreach my $subdep (split /\s*,\s*/, $dep) {
        if (exists $dependencies{$cur_field}{$subdep} and
@@@ -551,7 -564,7 +564,7 @@@
            {
                $dependencies{$cur_field}{$subdep} = $minver;
            }
 -      } else {
 +      } elsif (!$existing_only) {
            $dependencies{$cur_field}{$subdep} = $minver;
        }
      }
@@@ -672,6 -685,11 +685,11 @@@ sub find_symbols_file 
  
  sub symfile_has_soname {
      my ($file, $soname) = @_;
+ 
+     if (exists $symfile_has_soname_cache{$file}{$soname}) {
+         return $symfile_has_soname_cache{$file}{$soname};
+     }
+ 
      open(SYM_FILE, "<", $file) ||
          syserr(_g("cannot open file %s"), $file);
      my $result = 0;
@@@ -682,6 -700,7 +700,7 @@@
        }
      }
      close(SYM_FILE);
+     $symfile_has_soname_cache{$file}{$soname} = $result;
      return $result;
  }
  

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to