From dcb283c0a89bb0c05b78584657f6c8d12f6bf873 Mon Sep 17 00:00:00 2001 From: Don Armstrong Date: Sun, 27 May 2007 15:28:24 -0700 Subject: [PATCH] * Fix copyright/license statements in a bunch of the modules * Fix get_versions so that it handles multiple architectures and distributions * Call makesourceversions directly from get_versions so that the source is always right * Add the version and binsrc/srcbin indices configuration variables to Debbugs::Config --- Debbugs/Bugs.pm | 6 ++ Debbugs/CGI.pm | 8 +++ Debbugs/Common.pm | 8 +++ Debbugs/Config.pm | 54 ++++++++++++++ Debbugs/Email.pm | 2 +- Debbugs/Estraier.pm | 6 ++ Debbugs/Log.pm | 10 +++ Debbugs/MIME.pm | 10 +++ Debbugs/Mail.pm | 7 +- Debbugs/Packages.pm | 147 ++++++++++++++++++++++++++++++--------- Debbugs/Status.pm | 32 +++++---- Debbugs/URI.pm | 11 +++ Debbugs/User.pm | 10 +++ Debbugs/Versions.pm | 8 +++ Debbugs/Versions/Dpkg.pm | 10 +++ 15 files changed, 281 insertions(+), 48 deletions(-) diff --git a/Debbugs/Bugs.pm b/Debbugs/Bugs.pm index e46e70e..9b80e98 100644 --- a/Debbugs/Bugs.pm +++ b/Debbugs/Bugs.pm @@ -1,3 +1,9 @@ +# This module is part of debbugs, and is released +# under the terms of the GPL version 2, or any later +# version at your option. +# See the file README and COPYING for more information. +# +# Copyright 2007 by Don Armstrong . package Debbugs::Bugs; diff --git a/Debbugs/CGI.pm b/Debbugs/CGI.pm index 1e87bb7..a9afdd9 100644 --- a/Debbugs/CGI.pm +++ b/Debbugs/CGI.pm @@ -1,3 +1,11 @@ +# This module is part of debbugs, and is released +# under the terms of the GPL version 2, or any later +# version at your option. +# See the file README and COPYING for more information. +# +# [Other people have contributed to this file; their copyrights should +# go here too.] +# Copyright 2007 by Don Armstrong . package Debbugs::CGI; diff --git a/Debbugs/Common.pm b/Debbugs/Common.pm index 453720f..457c7ad 100644 --- a/Debbugs/Common.pm +++ b/Debbugs/Common.pm @@ -1,3 +1,11 @@ +# This module is part of debbugs, and is released +# under the terms of the GPL version 2, or any later +# version at your option. +# See the file README and COPYING for more information. +# +# [Other people have contributed to this file; their copyrights should +# go here too.] +# Copyright 2007 by Don Armstrong . package Debbugs::Common; diff --git a/Debbugs/Config.pm b/Debbugs/Config.pm index 60b1072..9134718 100644 --- a/Debbugs/Config.pm +++ b/Debbugs/Config.pm @@ -1,3 +1,9 @@ +# This module is part of debbugs, and is released +# under the terms of the GPL version 2, or any later +# version at your option. +# See the file README and COPYING for more information. +# +# Copyright 2007 by Don Armstrong . package Debbugs::Config; @@ -51,6 +57,7 @@ BEGIN { qw($gIncomingDir $gWebDir $gDocDir $gMaintainerFile), qw($gMaintainerFileOverride $gPseudoDescFile $gPackageSource), qw($gVersionPackagesDir $gVersionIndex $gBinarySourceMap $gSourceBinaryMap), + qw($gVersionTimeIndex), qw($gSendmail $gLibPath $gSpamScan @gExcludeFromControl), qw(%gSeverityDisplay @gTags @gSeverityList @gStrongSeverities), qw(%gSearchEstraier), @@ -430,8 +437,55 @@ set_default(\%config,'maintainer_file_override',$config{config_dir}.'/Maintainer set_default(\%config,'pseudo_desc_file',$config{config_dir}.'/pseudo-packages.description'); set_default(\%config,'package_source',$config{config_dir}.'/indices/sources'); + +=item version_packages_dir + +Location where the version package information is kept; defaults to +spool_dir/../versions/pkg + +=cut + 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 + +=cut + + +set_default(\%config,'version_time_index',$config{spool_dir}.'../versions/idx/versions_time.idx'); + +=item version_index + +Location of the version index file. Defaults to +spool_dir/../versions/idx/versions.idx + +=cut + +set_default(\%config,'version_index',$config{spool_dir}.'../versions/idx/versions.idx'); + +=item binary_source_map + +Location of the binary -> source map. Defaults to +spool_dir/../versions/idx/binsrc.idx + +=cut + +set_default(\%config,'binary_source_map',$config{spool_dir}.'../versions/idx/binsrc.idx'); + +=item source_binary_map + +Location of the source -> binary map. Defaults to +spool_dir/../versions/idx/srcbin.idx + +=cut + +set_default(\%config,'source_binary_map',$config{spool_dir}.'../versions/idx/srcbin.idx'); + + + set_default(\%config,'post_processall',[]); =item sendmail diff --git a/Debbugs/Email.pm b/Debbugs/Email.pm index 9978744..980b5fb 100644 --- a/Debbugs/Email.pm +++ b/Debbugs/Email.pm @@ -1,4 +1,4 @@ -package Debbugs::Email; +package Debbugs::Email; use strict; diff --git a/Debbugs/Estraier.pm b/Debbugs/Estraier.pm index f2f6cb8..75d4032 100644 --- a/Debbugs/Estraier.pm +++ b/Debbugs/Estraier.pm @@ -1,3 +1,9 @@ +# This module is part of debbugs, and is released +# under the terms of the GPL version 2, or any later +# version at your option. +# See the file README and COPYING for more information. +# +# Copyright 2007 by Don Armstrong . package Debbugs::Estraier; diff --git a/Debbugs/Log.pm b/Debbugs/Log.pm index c9a9e30..5632f43 100644 --- a/Debbugs/Log.pm +++ b/Debbugs/Log.pm @@ -1,3 +1,13 @@ +# This module is part of debbugs, and is released +# under the terms of the GPL version 2, or any later +# version at your option. +# See the file README and COPYING for more information. +# +# [Other people have contributed to this file; their copyrights should +# go here too.] +# Copyright 2004 by Collin Waston + + package Debbugs::Log; use strict; diff --git a/Debbugs/MIME.pm b/Debbugs/MIME.pm index 6976000..f5d6acd 100644 --- a/Debbugs/MIME.pm +++ b/Debbugs/MIME.pm @@ -1,3 +1,13 @@ +# This module is part of debbugs, and is released +# under the terms of the GPL version 2, or any later +# version at your option. +# See the file README and COPYING for more information. +# +# [Other people have contributed to this file; their copyrights should +# go here too.] +# Copyright 2006 by Don Armstrong . + + package Debbugs::MIME; use strict; diff --git a/Debbugs/Mail.pm b/Debbugs/Mail.pm index d915c67..54e52f5 100644 --- a/Debbugs/Mail.pm +++ b/Debbugs/Mail.pm @@ -1,4 +1,9 @@ -# $Id: Mail.pm,v 1.1 2005/08/17 21:46:16 don Exp $ +# This module is part of debbugs, and is released +# under the terms of the GPL version 2, or any later +# version at your option. +# See the file README and COPYING for more information. +# +# Copyright 2004-7 by Don Armstrong . package Debbugs::Mail; diff --git a/Debbugs/Packages.pm b/Debbugs/Packages.pm index a5c2cac..750bff2 100644 --- a/Debbugs/Packages.pm +++ b/Debbugs/Packages.pm @@ -1,3 +1,12 @@ +# This module is part of debbugs, and is released +# under the terms of the GPL version 2, or any later +# version at your option. +# See the file README and COPYING for more information. +# +# [Other people have contributed to this file; their copyrights should +# go here too.] +# Copyright 2007 by Don Armstrong . + package Debbugs::Packages; use warnings; @@ -12,7 +21,7 @@ BEGIN { $VERSION = 1.00; @EXPORT = (); - %EXPORT_TAGS = (versions => [qw(getversions)], + %EXPORT_TAGS = (versions => [qw(getversions get_versions)], mapping => [qw(getpkgsrc getpkgcomponent getsrcpkgs), qw(binarytosource sourcetobinary makesourceversions) ], @@ -25,6 +34,8 @@ BEGIN { use Fcntl qw(O_RDONLY); use MLDBM qw(DB_File Storable); use Storable qw(dclone); +use Params::Validate qw(validate_with :types); +use Debbugs::Common qw(make_list); $MLDBM::DumpMeth = 'portable'; $MLDBM::RemoveTaint = 1; @@ -204,39 +215,113 @@ architecture =cut -our %_versions; sub getversions { my ($pkg, $dist, $arch) = @_; - return () unless defined $gVersionIndex; - $dist = 'unstable' unless defined $dist; + return get_versions(package=>$pkg, + dist => $dist, + defined $arch ? (arch => $arch):(), + ); +} - unless (tied %_versions) { - tie %_versions, 'MLDBM', $gVersionIndex, O_RDONLY - or die "can't open versions index: $!"; - } - my $version = $_versions{$pkg}; - return () unless defined $version; - my %version = %{$version}; - - if (defined $arch and exists $version{$dist}{$arch}) { - my $ver = $version{$dist}{$arch}; - return $ver if defined $ver; - return (); - } else { - my %uniq; - for my $ar (keys %{$version{$dist}}) { - $uniq{$version{$dist}{$ar}} = 1 unless $ar eq 'source'; - } - if (%uniq) { - return keys %uniq; - } elsif (exists $version{$dist}{source}) { - # Maybe this is actually a source package with no corresponding - # binaries? - return $version{$dist}{source}; - } else { - return (); - } - } + + +=head2 get_versions + + get_version(package=>'foopkg', + dist => 'unstable', + arch => 'i386', + ); + +Returns a list of the versions of package in the distributions and +architectures listed. This routine only returns unique values. + +=over + +=item package -- package to return list of versions + +=item dist -- distribution (unstable, stable, testing); can be an +arrayref + +=item arch -- architecture (i386, source, ...); can be an arrayref + +=item time -- returns a version=>time hash at which the newest package +matching this version was uploaded + +=item source -- returns source/version instead of just versions + +=back + +=cut + +our %_versions; +our %_versions_time; + +sub get_versions{ + my %param = validate_with(params => \@_, + spec => {package => {type => SCALAR, + }, + dist => {type => SCALAR|ARRAYREF, + default => 'unstable', + }, + arch => {type => SCALAR|ARRAYREF, + optional => 1, + }, + time => {type => BOOLEAN, + default => 0, + }, + source => {type => BOOLEAN, + default => 0, + }, + }, + ); + my $versions; + if ($param{time}) { + return () if not defined $gVersionTimeIndex; + unless (tied %_versions_time) { + tie %_versions_time, 'MLDBM', $gVersionTimeIndex, O_RDONLY + or die "can't open versions index $gVersionTimeIndex: $!"; + } + $versions = \%_versions_time; + } + else { + return () if not defined $gVersionIndex; + unless (tied %_versions) { + tie %_versions, 'MLDBM', $gVersionIndex, O_RDONLY + or die "can't open versions index $gVersionIndex: $!"; + } + $versions = \%_versions; + } + my %versions; + for my $package (make_list($param{package})) { + my $version = $versions->{$package}; + next unless defined $version; + for my $dist (make_list($param{dist})) { + for my $arch (exists $param{arch}? + make_list($param{arch}): + (keys %{$version->{$dist}})) { + next unless defined $version->{$dist}{$arch}; + for my $ver (ref $version->{$dist}{$arch} ? + keys %{$version->{$dist}{$arch}} : + $version->{$dist}{$arch} + ) { + my $f_ver = $ver; + if ($param{source}) { + $f_ver = makesourceversions($package,$arch,$ver) + } + if ($param{time}) { + $versions{$f_ver} = max($versions{$f_ver}||0,$version->{$dist}{$arch}{$ver}); + } + else { + $versions{$f_ver} = 1; + } + } + } + } + } + if ($param{time}) { + return %versions + } + return keys %versions; } diff --git a/Debbugs/Status.pm b/Debbugs/Status.pm index 0cc0af9..c9c9d3e 100644 --- a/Debbugs/Status.pm +++ b/Debbugs/Status.pm @@ -1,3 +1,11 @@ +# This module is part of debbugs, and is released +# under the terms of the GPL version 2, or any later +# version at your option. +# See the file README and COPYING for more information. +# +# [Other people have contributed to this file; their copyrights should +# go here too.] +# Copyright 2007 by Don Armstrong . package Debbugs::Status; @@ -31,7 +39,7 @@ use Params::Validate qw(validate_with :types); use Debbugs::Common qw(:util :lock :quit :misc); use Debbugs::Config qw(:config); use Debbugs::MIME qw(decode_rfc1522 encode_rfc1522); -use Debbugs::Packages qw(makesourceversions getversions binarytosource); +use Debbugs::Packages qw(makesourceversions getversions get_versions binarytosource); use Debbugs::Versions; use Debbugs::Versions::Dpkg; use POSIX qw(ceil); @@ -597,18 +605,11 @@ sub bug_archiveable{ $dists{$tag} = 1; } my %source_versions; - for my $dist (keys %dists){ - my @versions; - @versions = getversions($status->{package}, - $dist, - undef); - # TODO: This should probably be handled further out for efficiency and - # for more ease of distinguishing between pkg= and src= queries. - my @sourceversions = makesourceversions($status->{package}, - $dist, - @versions); - @source_versions{@sourceversions} = (1) x @sourceversions; - } + my @sourceversions = get_versions(package => $status->{package}, + dist => [keys %dists], + source => 1, + ); + @source_versions{@sourceversions} = (1) x @sourceversions; if ('found' eq max_buggy(bug => $param{bug}, sourceversions => [keys %source_versions], found => $status->{found_versions}, @@ -618,10 +619,11 @@ sub bug_archiveable{ )) { return $cannot_archive; } + # Since the bug has at least been fixed in the architectures + # that matters, we check to see how long it has been fixed. + } # 6. at least 28 days have passed since the last action has occured or the bug was closed - # XXX We still need some more work here before we actually can archive; - # we really need to track when a bug was closed in a version. my $age = ceil($config{remove_age} - -M getbugcomponent($param{bug},'log')); if ($age > 0 ) { return $param{days_until}?$age:0; diff --git a/Debbugs/URI.pm b/Debbugs/URI.pm index 307f11f..d7cf4f2 100644 --- a/Debbugs/URI.pm +++ b/Debbugs/URI.pm @@ -1,3 +1,14 @@ +# This module is part of debbugs, and is released +# under the terms of the GPL version 2, or any later +# version at your option. +# See the file README and COPYING for more information. +# +# Copyright 2007 by Don Armstrong . +# query_form is +# Copyright 1995-2003 Gisle Aas. +# Copyright 1995 Martijn Koster. + + package Debbugs::URI; =head1 NAME diff --git a/Debbugs/User.pm b/Debbugs/User.pm index 8f97659..b82ce70 100644 --- a/Debbugs/User.pm +++ b/Debbugs/User.pm @@ -1,3 +1,13 @@ +# This module is part of debbugs, and is released +# under the terms of the GPL version 2, or any later +# version at your option. +# See the file README and COPYING for more information. +# +# [Other people have contributed to this file; their copyrights should +# go here too.] +# Copyright 2004 by Anthony Towns + + package Debbugs::User; diff --git a/Debbugs/Versions.pm b/Debbugs/Versions.pm index 822139f..26f0138 100644 --- a/Debbugs/Versions.pm +++ b/Debbugs/Versions.pm @@ -1,3 +1,11 @@ +# This module is part of debbugs, and is released +# under the terms of the GPL version 2, or any later +# version at your option. +# See the file README and COPYING for more information. +# +# [Other people have contributed to this file; their copyrights should +# go here too.] + package Debbugs::Versions; use strict; diff --git a/Debbugs/Versions/Dpkg.pm b/Debbugs/Versions/Dpkg.pm index e061b34..9745cbb 100644 --- a/Debbugs/Versions/Dpkg.pm +++ b/Debbugs/Versions/Dpkg.pm @@ -1,3 +1,13 @@ +# This module is part of debbugs, and is released +# under the terms of the GPL version 2, or any later +# version at your option. +# See the file README and COPYING for more information. +# +# Copyright Colin Watson +# Copyright Ian Jackson +# Copyright 2007 by Don Armstrong . + + package Debbugs::Versions::Dpkg; use strict; -- 2.39.2