Update of /cvsroot/fink/experimental/alexkhansen/3rdparty/fink/mirror
In directory sfp-cvsdas-3.v30.ch3.sourceforge.com:/tmp/cvs-serv25050/fink/mirror

Added Files:
        postinstall.pl.in 
Log Message:
Draft for CVS tunneling via HTTP proxy.

--- NEW FILE: postinstall.pl.in ---
#!/usr/bin/perl -w
#
# postinstall.pl - perl script to re-choose the mirrors when a new
#                fink-mirrors package is installed
#
# Fink - a package manager that downloads source and installs it
# Copyright (c) 2001 Christoph Pfisterer
# Copyright (c) 2001-2010 The Fink Package Manager Team
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA.
#

# Thanks to Tanaka Atushi for the changes which allow this to work with cvs 
proxies

$| = 1;
use 5.008_001;  # perl 5.8.1 or newer required
use strict;

use lib "@PREFIX@/lib/perl5";

use Fink::Config qw($config);
use Fink::Services qw(&read_config);
use Fink::Configure qw(&choose_mirrors);

read_config("@PREFIX@/etc/fink.conf");

#back up the configuration file
`cp @PREFIX@/etc/fink.conf @PREFIX@/etc/fink.conf.bak`;

#get mirror selections, write write new configuration file if changed
choose_mirrors(1) || $config->save();

# now we correct the CVS location... the code below should eventually be
# moved to fink itself and called from here

use File::Find;

# parse a typical CVS/Root
my $sentinel_cvs = '@PREFIX@/fink/dists/CVS';
if (-d $sentinel_cvs) {
    my ($method_user, $repo, $repo_file, $stored_repo);

    open(IN,'<',"$sentinel_cvs/Root") or die "can't open $sentinel_cvs/Root: 
$!";
    while (defined($_=<IN>)) {
        chomp;
        if (/^(:\S+:\S+)@(.+)$/) { # allow for proxy
            $method_user = $1;
            $repo = $2;
        }
    }
    close(IN);
    die "couldn't parse $sentinel_cvs/Root\n" unless ((defined $method_user) 
and (defined $repo));
    if (defined $method_user and $method_user =~ /^:pserver(.*):anonymous$/) { 
#allow for proxy
        $repo_file = "@PREFIX@/lib/fink/URL/anonymous-cvs";
    } else {
        $repo_file = "@PREFIX@/lib/fink/URL/developer-cvs";
    }

    # read "correct" Root path from fink-mirrors pkg
    open(IN,'<',$repo_file) or die "can't open $repo_file: $!\n";
    while (defined($_=<IN>)) {
        chomp;
        $stored_repo = $_;  # we are assuming that this file only has one line
    }
    close(IN);

    if (defined $stored_repo and $stored_repo ne $repo) {
        # active CVS/Root doesn't match current path; fix so it does
        warn "Updating CVS/Root data...\n";

        my $replace_cvs_root = sub {
            if ($File::Find::name =~ /\/CVS\/Root$/ && -e $File::Find::name) {
                # we should *really* do this ourselves instead of spawning 
processes
                system 
('/usr/bin/perl','-pi','-e',"s|\...@$repo|\...@$stored_repo|",$File::Find::name);
            }
        };

        File::Find::find({wanted => $replace_cvs_root}, '@PREFIX@/fink');
    }
}

exit;



------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand 
malware threats, the impact they can have on your business, and how you 
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
Fink-commits mailing list
Fink-commits@lists.sourceforge.net
http://news.gmane.org/gmane.os.apple.fink.cvs

Reply via email to