From b01975957189785370251bd09802e3b61f8fd03f Mon Sep 17 00:00:00 2001 From: Don Armstrong Date: Sat, 9 Jun 2007 16:10:47 -0700 Subject: [PATCH] - Implement versioning aware archiving support (closes: #419693) --- Debbugs/Config.pm | 20 ++++++---- Debbugs/Packages.pm | 93 ++++++++++++++++++++++++--------------------- Debbugs/Status.pm | 37 +++++++++++++++--- debian/changelog | 1 + 4 files changed, 94 insertions(+), 57 deletions(-) diff --git a/Debbugs/Config.pm b/Debbugs/Config.pm index 9134718..6b8639f 100644 --- a/Debbugs/Config.pm +++ b/Debbugs/Config.pm @@ -450,39 +450,43 @@ set_default(\%config,'version_packages_dir',$config{spool_dir}.'/../versions/pkg =item version_time_index Location of the version/time index file. Defaults to -spool_dir/../versions/idx/versions_time.idx +spool_dir/../versions/idx/versions_time.idx if spool_dir/../versions +exists; otherwise defaults to undef. =cut -set_default(\%config,'version_time_index',$config{spool_dir}.'../versions/idx/versions_time.idx'); +set_default(\%config,'version_time_index', -d $config{spool_dir}.'/../versions' ? $config{spool_dir}.'/../versions/indices/versions_time.idx' : undef); =item version_index Location of the version index file. Defaults to -spool_dir/../versions/idx/versions.idx +spool_dir/../versions/indices/versions.idx if spool_dir/../versions +exists; otherwise defaults to undef. =cut -set_default(\%config,'version_index',$config{spool_dir}.'../versions/idx/versions.idx'); +set_default(\%config,'version_index',-d $config{spool_dir}.'/../versions' ? $config{spool_dir}.'/../versions/indices/versions.idx' : undef); =item binary_source_map Location of the binary -> source map. Defaults to -spool_dir/../versions/idx/binsrc.idx +spool_dir/../versions/indices/bin2src.idx if spool_dir/../versions +exists; otherwise defaults to undef. =cut -set_default(\%config,'binary_source_map',$config{spool_dir}.'../versions/idx/binsrc.idx'); +set_default(\%config,'binary_source_map',-d $config{spool_dir}.'/../versions' ? $config{spool_dir}.'/../versions/indices/binsrc.idx' : undef); =item source_binary_map Location of the source -> binary map. Defaults to -spool_dir/../versions/idx/srcbin.idx +spool_dir/../versions/indices/src2bin.idx if spool_dir/../versions +exists; otherwise defaults to undef. =cut -set_default(\%config,'source_binary_map',$config{spool_dir}.'../versions/idx/srcbin.idx'); +set_default(\%config,'source_binary_map',-d $config{spool_dir}.'/../versions' ? $config{spool_dir}.'/../versions/indices/srcbin.idx' : undef); diff --git a/Debbugs/Packages.pm b/Debbugs/Packages.pm index 750bff2..190d4b4 100644 --- a/Debbugs/Packages.pm +++ b/Debbugs/Packages.pm @@ -37,6 +37,8 @@ use Storable qw(dclone); use Params::Validate qw(validate_with :types); use Debbugs::Common qw(make_list); +use List::Util qw(min max); + $MLDBM::DumpMeth = 'portable'; $MLDBM::RemoveTaint = 1; @@ -135,37 +137,38 @@ sub binarytosource { # need an extra cache for speed here. return () unless defined $gBinarySourceMap; - if (tied %_binarytosource or - tie %_binarytosource, 'MLDBM', - $gBinarySourceMap, O_RDONLY) { - # avoid autovivification - my $binary = $_binarytosource{$binname}; - return () unless defined $binary; - my %binary = %{$binary}; - if (exists $binary{$binver}) { - if (defined $binarch) { - my $src = $binary{$binver}{$binarch}; - return () unless defined $src; # not on this arch - # Copy the data to avoid tiedness problems. - return dclone($src); - } else { - # Get (srcname, srcver) pairs for all architectures and - # remove any duplicates. This involves some slightly tricky - # multidimensional hashing; sorry. Fortunately there'll - # usually only be one pair returned. - my %uniq; - for my $ar (keys %{$binary{$binver}}) { - my $src = $binary{$binver}{$ar}; - next unless defined $src; - $uniq{$src->[0]}{$src->[1]} = 1; - } - my @uniq; - for my $sn (sort keys %uniq) { - push @uniq, [$sn, $_] for sort keys %{$uniq{$sn}}; - } - return @uniq; - } - } + if (not tied %_binarytosource) { + tie %_binarytosource, MLDBM => $gBinarySourceMap, O_RDONLY or + die "Unable to open $gBinarySourceMap for reading"; + } + + # avoid autovivification + my $binary = $_binarytosource{$binname}; + return () unless defined $binary; + my %binary = %{$binary}; + if (exists $binary{$binver}) { + if (defined $binarch) { + my $src = $binary{$binver}{$binarch}; + return () unless defined $src; # not on this arch + # Copy the data to avoid tiedness problems. + return dclone($src); + } else { + # Get (srcname, srcver) pairs for all architectures and + # remove any duplicates. This involves some slightly tricky + # multidimensional hashing; sorry. Fortunately there'll + # usually only be one pair returned. + my %uniq; + for my $ar (keys %{$binary{$binver}}) { + my $src = $binary{$binver}{$ar}; + next unless defined $src; + $uniq{$src->[0]}{$src->[1]} = 1; + } + my @uniq; + for my $sn (sort keys %uniq) { + push @uniq, [$sn, $_] for sort keys %{$uniq{$sn}}; + } + return @uniq; + } } # No $gBinarySourceMap, or it didn't have an entry for this name and @@ -188,20 +191,22 @@ our %_sourcetobinary; sub sourcetobinary { my ($srcname, $srcver) = @_; - if (tied %_sourcetobinary or - tie %_sourcetobinary, 'MLDBM', - $gSourceBinaryMap, O_RDONLY) { - # avoid autovivification - my $source = $_sourcetobinary{$srcname}; - return () unless defined $source; - my %source = %{$source}; - if (exists $source{$srcver}) { - my $bin = $source{$srcver}; - return () unless defined $bin; - return @$bin; - } + if (not tied %_sourcetobinary) { + tie %_sourcetobinary, MLDBM => $gSourceBinaryMap, O_RDONLY or + die "Unable top open $gSourceBinaryMap for reading"; } + + + # avoid autovivification + my $source = $_sourcetobinary{$srcname}; + return () unless defined $source; + my %source = %{$source}; + if (exists $source{$srcver}) { + my $bin = $source{$srcver}; + return () unless defined $bin; + return @$bin; + } # No $gSourceBinaryMap, or it didn't have an entry for this name and # version. Try $gPackageSource (unversioned) instead. my @srcpkgs = getsrcpkgs($srcname); @@ -306,7 +311,7 @@ sub get_versions{ ) { my $f_ver = $ver; if ($param{source}) { - $f_ver = makesourceversions($package,$arch,$ver) + ($f_ver) = makesourceversions($package,$arch,$ver); } if ($param{time}) { $versions{$f_ver} = max($versions{$f_ver}||0,$version->{$dist}{$arch}{$ver}); diff --git a/Debbugs/Status.pm b/Debbugs/Status.pm index c9c9d3e..36cea42 100644 --- a/Debbugs/Status.pm +++ b/Debbugs/Status.pm @@ -44,6 +44,8 @@ use Debbugs::Versions; use Debbugs::Versions::Dpkg; use POSIX qw(ceil); +use List::Util qw(min max); + BEGIN{ $VERSION = 1.00; @@ -593,14 +595,16 @@ sub bug_archiveable{ # There must be fixed_versions for us to look at the versioning # information + my $min_fixed_time = time; + my $min_archive_days = 0; if (@{$status->{fixed_versions}}) { my %dist_tags; @dist_tags{@{$config{removal_distribution_tags}}} = (1) x @{$config{removal_distribution_tags}}; my %dists; - @dists{@{$config{removal_default_distribution_tags}}} = + @dists{@{$config{removal_default_distribution_tags}}} = (1) x @{$config{removal_default_distribution_tags}}; - for my $tag (split ' ', $status->{tags}) { + for my $tag (split ' ', ($status->{tags}||'')) { next unless $dist_tags{$tag}; $dists{$tag} = 1; } @@ -610,6 +614,8 @@ sub bug_archiveable{ source => 1, ); @source_versions{@sourceversions} = (1) x @sourceversions; + # If the bug has not been fixed in the versions actually + # distributed, then it cannot be archived. if ('found' eq max_buggy(bug => $param{bug}, sourceversions => [keys %source_versions], found => $status->{found_versions}, @@ -621,12 +627,33 @@ sub bug_archiveable{ } # Since the bug has at least been fixed in the architectures # that matters, we check to see how long it has been fixed. - + + # To do this, we order the times from most recent to oldest; + # when we come to the first found version, we stop. + # If we run out of versions, we only report the time of the + # last one. + my %time_versions = get_versions(package => $status->{package}, + dist => [keys %dists], + source => 1, + time => 1, + ); + for my $version (sort {$time_versions{$b} <=> $time_versions{$a}} keys %time_versions) { + my $buggy = buggy(bug => $param{bug}, + version => $version, + found => $status->{found_versions}, + fixed => $status->{fixed_versions}, + version_cache => $version_cache, + package => $status->{package}, + ); + last if $buggy eq 'found'; + $min_fixed_time = min($time_versions{$version},$min_fixed_time); + } + $min_archive_days = max($min_archive_days,ceil((time - $min_fixed_time)/(60*60*24))); } # 6. at least 28 days have passed since the last action has occured or the bug was closed my $age = ceil($config{remove_age} - -M getbugcomponent($param{bug},'log')); - if ($age > 0 ) { - return $param{days_until}?$age:0; + if ($age > 0 or $min_archive_days > 0) { + return $param{days_until}?max($age,$min_archive_days):0; } else { return $param{days_until}?0:1; diff --git a/debian/changelog b/debian/changelog index 44b9a2c..68b7cfc 100644 --- a/debian/changelog +++ b/debian/changelog @@ -180,6 +180,7 @@ debbugs (2.4.2) UNRELEASED; urgency=low - Fix double leading spaces of format=flowed messages (closes: #428056) - Don't doubly select users + - Implement versioning aware archiving support (closes: #419693) -- Colin Watson Fri, 20 Jun 2003 18:57:25 +0100 -- 2.39.2