From: Frank Lichtenheld Date: Sun, 15 Apr 2007 00:28:12 +0000 (+0200) Subject: Support "changelog:" short links X-Git-Url: https://git.deb.at/?p=deb%2Fpackages.git;a=commitdiff_plain;h=da0b1ee79860ccd17033f11da212178d51ce9f47 Support "changelog:" short links Generate a map file for mod_rewrite since we need to map binary packages to source packages. --- diff --git a/bin/create_changelogs_map b/bin/create_changelogs_map new file mode 100755 index 0000000..fbee3f2 --- /dev/null +++ b/bin/create_changelogs_map @@ -0,0 +1,81 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use DB_File; + +use lib './lib'; + +use Deb::Versions; + +unless (@ARGV == 2) { + die "Usage: create_changelogs_map \n"; +} + +my ($dbdir, $outfile) = @ARGV; + +tie my %src_packages, 'DB_File', "$dbdir/sources_small.db", + O_RDONLY, 0666, $DB_BTREE + or die "couldn't tie DB $dbdir/sources_small.db: $!"; +tie my %src2bin, 'DB_File', "$dbdir/sources_packages.db", + O_RDONLY, 0666, $DB_BTREE + or die "couldn't open $dbdir/sources_packages.db: $!"; + +open my $out, '>', "$outfile.new" + or die "couldn't open $outfile.new: $!"; + +sub get_dir_from_name { + my $name = shift; + + if ($name =~ /^(lib.)/o) { + return "$1/$name"; + } else { + return substr( $name, 0, 1 )."/$name"; + } +} + +use Data::Dumper; +my %bin; +while (my ($source, $data) = each %src_packages) { + my @src = map { [ split(/\s+/) ] } split( /\0/, $data ); + my $newest = (sort( { version_cmp($b->[-1],$a->[-1]) } @src))[0]; + my ($section, $version) = @{$newest}[2,5]; + my $directory = get_dir_from_name($source); +# warn "src=$source sect=$section v=$version dir=$directory\n"; + + my $bin_data = $src2bin{$source}; + unless ($bin_data) { + warn "no binary data found for $source\n"; + # source packages without binaries have most + # likely been succeded + next; + } + + print $out "$source\tpool/$section/$directory/current/changelog\n"; + + my @bin = map { [ split(/\s+/) ] } split( /\0/, $bin_data ); + my %seen; + foreach (@bin) { + my ($pkg, $ver) = @{$_}[2,3]; + next if $seen{"$pkg/$ver"}++; # weed out multiple arches/suites faster + if ($bin{$pkg} + && ($bin{$pkg}{source} ne $source) + && (version_cmp($bin{$pkg}{version},$ver) > 0)) { + warn "ignore $pkg/$ver from $source for ". + "$pkg/$bin{$pkg}{version} from $bin{$pkg}{source}\n"; + next; + } else { + $bin{$pkg} = { version => $ver, source => $source, + target => "$section/$directory" }; + } + } +} + +while (my ($pkg, $data) = each %bin) { +# warn "pkg=$pkg v=$data->{version} src=$data->{source} tgt=$data->{target}\n"; + print $out "$pkg\tpool/$data->{target}/current/changelog\n"; +} + +close $out or warn $!; +rename("$outfile.new", $outfile); diff --git a/conf/apache.conf.sed.in b/conf/apache.conf.sed.in index 36032d7..2b6913b 100644 --- a/conf/apache.conf.sed.in +++ b/conf/apache.conf.sed.in @@ -106,6 +106,8 @@ RewriteLog /var/log/apache2/rewrite.log RewriteLogLevel 0 + RewriteMap changelog-url txt:%TOPDIR%/files/changelogs-map + RewriteRule ^/cgi-bin/search_packages.pl(.*)$ /search$1 RewriteRule ^/cgi-bin/search_contents.pl(.*)$ /search$1 RewriteRule ^/unstable/newpkg_([a-z]+)\.[a-z]+\.rdf /unstable/$1/newpkg?format=rss [R=permanent,L] @@ -122,6 +124,7 @@ # RewriteRule ^/$ http://www.debian.org/distrib/packages RewriteRule ^/$ /index.html [L] RewriteRule ^/([^/+]*)([+])([^/]*)$ "/$1%%{%}2B$3" [N] + RewriteRule ^/changelog:(.+)$ http://%SITE%/changelogs/${changelog-url:$1} [R,L,NE] RewriteRule ^/src:([^/]+)$ /source/$1 [R,L,NE] RewriteRule ^/(.+)$ /cgi-bin/dispatcher.pl/$1 [L,PT] diff --git a/cron.d/400changelogs_map b/cron.d/400changelogs_map new file mode 100755 index 0000000..71469d2 --- /dev/null +++ b/cron.d/400changelogs_map @@ -0,0 +1,9 @@ +#!/bin/sh + +. `dirname $0`/../config.sh + +cd "$topdir" + +date +./bin/create_changelogs_map "$filesdir/db/" "$filesdir/changelogs-map" +date