PaulHowarth/Blog/2006-08-08

Tuesday 8th August 2006

Local Packages

  • Updated dovecot to 1.0.rc6

  • The RedirectMatch fix for people accessing the repo using the old hierarchy worked OK for the metadata and repoview files, but not for the packages themselves, which didn't trigger the rewrite rule. So now I have a much better solution, which also redirects accesses to missing repoview pages to the repoview index for the repo concerned.

  • Firstly, in httpd.conf:

    # RewriteLock must be in main server config
    RewriteEngine on
    RewriteLock /var/log/httpd/REWRITE.lock
    
    <VirtualHost *:80>
    
        ...
    
        RewriteEngine on
        RewriteLog /var/log/httpd/cfo-rewrite_log
        RewriteLogLevel 1
        RewriteMap repo-remap prg:/usr/local/bin/repo-remap
    
        ...
    
        #
        # Make the ftp server's files available by http too.
        #
        Alias /ftp /home/ftp/pub
    
        <Directory /home/ftp/pub>
            Options Indexes Includes FollowSymLinks
            IndexOptions +SuppressColumnSorting +VersionSort
            AllowOverride None
            order allow,deny
            allow from all
        </Directory>
    
        # Remap accesses to files in repos that are no longer there
        # (Skip next 3 rules for other locations)
        RewriteRule !^/ftp/contrib/yum-repo/[^/]+/.*$       - [S=3]
        # Try remapping the request to the new locations
        RewriteRule ^/ftp/contrib/yum-repo/(.*)$            ${repo-remap:$1}
        # If we need a redirect, do it
        RewriteRule ^/GOTO:(.*)$                            $1 [R=permanent,L]
        # If the file exists or is just a subtle redirect, pass through to next handler
        RewriteRule ^(.*)$                                  - [PT]
    
    </VirtualHost>
  • The rewrite map script, /usr/local/bin/repo-remap:

    #   generate substitution URL on stdout
    #
    # All input data is relative to the yum-repo directory
    #
    
    $repodir = '/home/ftp/pub/contrib/yum-repo';
    $repouri = '/ftp/contrib/yum-repo';
    $repourl = '/GOTO:http://www.city-fan.org' . $repouri;
    
    while (<>) {
            chomp; $reporeq = $_;
    
            # If the distro directory doesn't exist, bail out straight away
            ( $distro = $reporeq ) =~ s|/.*||;
            if ( ! -d $repodir . '/' . $distro ) {
                    print "$repouri/$reporeq\n";
                    next;
            }
    
            # If requesting index.php, change to index.html
            $reporeq =~ s|/index\.php$|/index.html|;
    
            # See if it's a request using the architecture directory
            ( $filereq = $reporeq ) =~ s|[^/]*/||;
            ( $archdir = $filereq ) =~ s|/.*||;
            if ( -d  $repodir . '/' . $distro . '/' . $archdir ) {
                    # Request has proper directory hierarchy
    
                    # If requested file exists, pass through
                    if ( -f $repodir . '/' . $reporeq || -d $repodir . '/' . $reporeq ) {
                            print "$repouri/$reporeq\n";
                            next;
                    }
    
                    # Otherwise, redirect to repo index page
                    print $repourl . '/' . $distro . '/' . $archdir . "/repodata/index.html\n";
                    next;
    
            } else {
                    # Request has old directory structure
    
                    # See if inserting the 'i386' directory fixes the issue
                    if ( -f $repodir . '/' .  $distro . '/i386/' . $filereq ||
                         -d $repodir . '/' .  $distro . '/i386/' . $filereq   ) {
                            print $repourl . '/' . $distro . '/i386/' . $filereq . "\n";
                            next;
                    }
    
                    # Otherwise, redirect to repo index page
                    print $repourl . '/' . $distro . "/i386/repodata/index.html\n";
                    next;
    
            }
    }
  • I don't do much perl, so there may be much better ways of doing the above, but it works for me
  • Updated unrar to 3.6.7 (a version that actually builds on my x86_64 box)

Fedora Extras

  • Addressed Bug #201691 on perl-MIME-tools, requesting that some of the examples be installed into /usr/bin


Recent