Skip to content
This repository
tree: e82b6825f8
Fetching contributors…

Cannot retrieve contributors at this time

executable file 92 lines (77 sloc) 3.094 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
#!/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-2012 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.
#

$| = 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;
Something went wrong with that request. Please try again.