]> git.deb.at Git - deb/packages.git/commitdiff
Reduce complexity during show_package by storing info in _all.db files
authorJeroen van Wolffelaar <jeroen@wolffelaar.nl>
Tue, 7 Feb 2006 14:41:04 +0000 (14:41 +0000)
committerJeroen van Wolffelaar <jeroen@wolffelaar.nl>
Tue, 7 Feb 2006 14:41:04 +0000 (14:41 +0000)
NUL-separated.
Also, lookup source packages by archive/suite, instead of version

bin/parse-packages
bin/parse-sources
cgi-bin/show_package.pl
lib/Packages/HTML.pm
lib/Packages/Page.pm

index 238a47b9ec9f5ffe50c751afe05e81c2e8d392fc..817f547e09d6c030259c583412e5971f11876b56 100755 (executable)
@@ -74,11 +74,9 @@ for my $archive (@ARCHIVES) {
                my $src_version = '';
                if ($data{'source'}) {
                        $src = $data{'source'};
-                       $src_version = $1
-                           if $src =~ s/\s+\((.*)\).*//; # strip version info
+                       $src =~ s/\s+.*//; # strip version info
                }
                $data{'source'} = $src;
-               $data{'source-version'} = $src_version if $src_version;
                my $descr = $data{'description'};
                my $did = undef;
                if (exists($descriptions{$descr})) {
@@ -117,8 +115,9 @@ for my $archive (@ARCHIVES) {
                        next if $key eq 'package' or $key eq 'version' or $key eq 'architecture'
                                or $key eq 'maintainer';
                        print STDERR "WARN: $key ($suite/$archive/$data{package}/$data{architecture}\n" unless defined $value;
-                       $data .= "$key: $value\n";
+                       $data .= "$key\00$value\00";
                }
+               $data =~ s/.$//s;
                $packages_all_db{"$data{'package'} $data{'architecture'} $data{'version'}"}
                        = $data;
        }
index e640b9d3dfae2581421f77cd6ba75caaa567fb7c..89f071d42d389bf77c4f05d997ddce019b0060ca 100755 (executable)
@@ -53,11 +53,14 @@ for my $archive (@ARCHIVES) {
                while (/^(\S+):\s*(.*)\s*$/mg) {
                        my ($key, $value) = ($1, $2);
                        $value =~ s/\377/\n /g;
-                       $data .= "$key: $value\n";
                        $key =~ tr [A-Z] [a-z];
                        $data{$key} = $value;
                }
                $source_names{$data{'package'}} = 1;
+               delete $data{'binary'};
+
+               $data{files} =~ s/\s*\n\s*/\01/sog;
+               $data{files} =~ s/^\01//sg;
 
                my $section = 'main';
                my $subsection = $data{section} || '-';
@@ -72,13 +75,13 @@ for my $archive (@ARCHIVES) {
                $sources_small{$data{'package'}} .=
                        "$archive $suite $section $subsection $data{'priority'} $data{'version'}\000";
 
-               $data{archive} = $archive;
                while (my ($key, $value) = each (%data)) {
-                   next if $key eq 'package' or $key eq 'version';
+                   next if $key eq 'package' or $key eq 'archive' or $key eq 'suite';
                    print STDERR "WARN: $key ($suite/$archive/$data{package}/$data{architecture}\n" unless defined $value;
-                   $data .= "$key: $value\n";
+                   $data .= "$key\00$value\00";
                }
-               $sources_all_db{"$data{'package'} $data{'version'}"}
+               $data =~ s/.$//so;
+               $sources_all_db{"$archive $suite $data{'package'}"}
                        = $data;
        }
 
index 0f3c48f6663b5592095320d2a672f124266ff516..445195d37e55192f280e3a52b43be6f2ce11266f 100755 (executable)
@@ -156,30 +156,19 @@ unless (@Packages::CGI::fatal_errors) {
                    my (undef, $archive, undef, $arch, $section, $subsection,
                        $priority, $version) = @$entry;
                    
-                   my $data = $packages_all{"$pkg $arch $version"};
-                   $page->merge_data($pkg, $version, $arch, $data) or debug( "Merging $pkg $arch $version FAILED", 2 );
+                   my %data = split /\000/, $packages_all{"$pkg $arch $version"};
+                   $data{package} = $pkg;
+                   $data{architecture} = $arch;
+                   $data{version} = $version;
+                   $page->merge_package(\%data) or debug( "Merging $pkg $arch $version FAILED", 2 );
                }
 
                $version = $page->{newest};
                my $source = $page->get_newest( 'source' );
-               my $source_version = $page->get_newest( 'source-version' )
-                   || $version;
-               debug( "find source package: source=$source (=$source_version)", 1);
-               my $src_data = $sources_all{"$source $source_version"};
-               unless ($src_data) { #fucking binNMUs
-                   my $versions = $page->get_versions;
-                   my $sources = $page->get_arch_field( 'source' );
-                   my $source_versions = $page->get_arch_field( 'source-version' );
-                   foreach (version_sort keys %$versions) {
-                       $source = $sources->{$versions->{$_}[0]};
-                       $source = $source_versions->{$versions->{$_}[0]}
-                       || $version;
-                       $src_data = $sources_all{"$source $source_version"};
-                       last if $src_data;
-                   }
-                   error( "couldn't find source package" ) unless $src_data;
-               }
-               $page->add_src_data( $source, $source_version, $src_data )
+               $archive = $page->get_newest( 'archive' );
+               debug( "find source package: source=$source", 1);
+               my $src_data = $sources_all{"$archive $suite $source"};
+               $page->add_src_data( $source, $src_data )
                    if $src_data;
 
                my $st1 = new Benchmark;
@@ -189,7 +178,6 @@ unless (@Packages::CGI::fatal_errors) {
                my $encodedpkg = uri_escape( $pkg );
                my ($v_str, $v_str_arch, $v_str_arr) = $page->get_version_string();
                my $did = $page->get_newest( 'description' );
-               $archive = $page->get_newest( 'archive' );
                $section = $page->get_newest( 'section' );
                $subsection = $page->get_newest( 'subsection' );
                my $filenames = $page->get_arch_field( 'filename' );
index a291a0028b6285d15e76880f35c9e1dfead4af1b..8d43b3be56d4cbf5e37851f5a88aa0da24e164e6 100644 (file)
@@ -136,7 +136,7 @@ sub pmoreinfo {
            $str .= gettext( "Not found" );
        } else {
            foreach( @$files ) {
-               my ($src_file_md5, $src_file_size, $src_file_name) = @$_;
+               my ($src_file_md5, $src_file_size, $src_file_name) = split /\s/o, $_;
                for ($page->get_newest('archive')) {
                    /security/o && do {
                        $str .= "<a href=\"$env->{security}/$src_dir/$src_file_name\">["; last };
index d57126ea4825674aba5c432f667fa90a0773f9e0..c44a099ffe9e7d19acab17c472e87ff60af84683 100644 (file)
@@ -33,22 +33,6 @@ sub new {
     return $self;
 }
 
-sub merge_data {
-    my ($self, $pkg, $version, $architecture, $data) = @_;
-
-    my %data = ( package => $pkg,
-                version => $version,
-                architecture => $architecture );
-    chomp($data);
-    while ($data =~ /^(\S+):\s*(.*)\s*$/mg) {
-       my ($key, $value) = ($1, $2);
-       $key =~ tr [A-Z] [a-z];
-       $data{$key} = $value;
-    }
-#      debug( "Merge package:\n".Dumper(\%data), 3 );
-    return $self->merge_package( \%data );
-}
-
 sub gettext { return $_[0]; }
 sub split_name_mail {
     my $string = shift;
@@ -68,26 +52,16 @@ sub split_name_mail {
 }
 
 sub add_src_data {
-    my ($self, $src, $version, $data) = @_;
-
-    chomp($data);
-    my %data = ();
-    $data =~ s/\n\s+/\377/g;
-    while ($data =~ /^(\S+):\s*(.*)\s*$/mog) {
-       my ($key, $value) = ($1, $2);
-       $key =~ tr [A-Z] [a-z];
-       $data{$key} = $value;
-    }
+    my ($self, $src, $data) = @_;
+
+    my %data = split /\00/o, $data;
 
     $self->{src}{package} = $src;
-    $self->{src}{version} = $version;
+    $self->{src}{version} = $data{version};
     if ($data{files}) {
-       $self->{src}{files} = [];
-        foreach my $sf ( split( /\377/, $data{files} ) ) {
-           next unless $sf;
-            # md5, size, name
-            push @{$self->{src}{files}}, [ split( /\s+/, $sf) ];
-        }
+       my @files = split /\01/so, $data{files};
+       $self->{src}{files} = \@files;
+       print @{$self->{src}{files}};
     }
     $self->{src}{directory} = $data{directory};
     my @uploaders;