From: Jeroen van Wolffelaar Date: Tue, 7 Feb 2006 14:41:04 +0000 (+0000) Subject: Reduce complexity during show_package by storing info in _all.db files X-Git-Tag: switch-to-templates~160 X-Git-Url: https://git.deb.at/?a=commitdiff_plain;h=9f26e8bcb912da43661983f13714c3e56f406007;p=deb%2Fpackages.git Reduce complexity during show_package by storing info in _all.db files NUL-separated. Also, lookup source packages by archive/suite, instead of version --- diff --git a/bin/parse-packages b/bin/parse-packages index 238a47b..817f547 100755 --- a/bin/parse-packages +++ b/bin/parse-packages @@ -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; } diff --git a/bin/parse-sources b/bin/parse-sources index e640b9d..89f071d 100755 --- a/bin/parse-sources +++ b/bin/parse-sources @@ -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; } diff --git a/cgi-bin/show_package.pl b/cgi-bin/show_package.pl index 0f3c48f..445195d 100755 --- a/cgi-bin/show_package.pl +++ b/cgi-bin/show_package.pl @@ -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' ); diff --git a/lib/Packages/HTML.pm b/lib/Packages/HTML.pm index a291a00..8d43b3b 100644 --- a/lib/Packages/HTML.pm +++ b/lib/Packages/HTML.pm @@ -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 .= "{security}/$src_dir/$src_file_name\">["; last }; diff --git a/lib/Packages/Page.pm b/lib/Packages/Page.pm index d57126e..c44a099 100644 --- a/lib/Packages/Page.pm +++ b/lib/Packages/Page.pm @@ -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;