From: Gerfried Fuchs Date: Mon, 13 Sep 2010 07:23:02 +0000 (+0200) Subject: Make the fallback_suite a function X-Git-Url: https://git.deb.at/w?a=commitdiff_plain;h=bc93e89c358b392cfefd7de372cf3dfcb8a8cd63;p=deb%2Fpackages.git Make the fallback_suite a function The function is inspired by the ubuntu-master branch --- diff --git a/lib/Packages/Search.pm b/lib/Packages/Search.pm index 4170863..3a47e3d 100644 --- a/lib/Packages/Search.pm +++ b/lib/Packages/Search.pm @@ -101,14 +101,16 @@ sub read_entry { read_entry_all( $hash, $key, $results, \@non_results, $opts ); } -#FIXME: make configurable -my %fallback_suites = ( - 'etch-backports' => 'etch', - 'etch-volatile' => 'etch', - 'lenny-backports' => 'lenny', - 'lenny-volatile' => 'lenny', - 'squeeze-backports' => 'squeeze', - experimental => 'sid' ); +sub fallback_suite { + my $suite = shift; + if ($suite =~ /^(\S+)-(?:updates|backports|volatile)/) { + return $1; + } elsif ($suite eq 'experimental') { + return 'sid'; + } else { + return undef; + } +} sub read_entry_simple { my ($hash, $key, $archives, $suite) = @_; @@ -128,7 +130,7 @@ sub read_entry_simple { debug( "use entry: @data", 2 ) if DEBUG && $data[1] eq $suite; return [ $virt{$suite}, @data ] if $data[1] eq $suite; } - if (my $fb_suite = $fallback_suites{$suite}) { + if (my $fb_suite = fallback_suite($suite)) { my $fb_result = read_entry_simple( $hash, $key, $archives, $fb_suite ); my $fb_virt = shift(@$fb_result); $virt{$suite} .= $virt{$suite} ? " $fb_virt" : $fb_virt if $fb_virt;