aboutsummaryrefslogtreecommitdiff
path: root/bootstrap.pl
blob: 90db16ab784589eab4d80ca0629d796e50f47b1f (plain)
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
#! /usr/bin/perl
# This file is part of acmeman.
# Copyright (C) 2014, 2017 Sergey Poznyakoff <gray@gnu.org>
#
# 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 3, 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, see <http://www.gnu.org/licenses/>.

use strict;
use CPAN;
use Cwd qw(getcwd);
use File::Path qw(mkpath);

####
my $incdir = "inc/ExtUtils";
my $topdir = getcwd;

my $modname = "ExtUtils::AutoInstall";

my $mod = CPAN::Shell->expandany($modname) or die "Can't expand $modname";
my $file = $mod->inst_file;
my $dir;

if (defined($file)) {
    print "$modname installed at $file\n";
    if (-f $file) {
	$file =~ s#/[^/]+\.pm$##;
	if (-d $file) {
	    $dir = $file;
	} else {
	    die "Can't find $modname directory";
	}
    }
} else {
    print "Getting $modname\n";
    my $distro = $mod->get or die "Can't get distribution for $modname";
    $dir = $distro->dir;
}

$file = "$dir/$incdir/AutoInstall.pm";
$file = "$dir/AutoInstall.pm" unless (-f $file);
-f $file or die "$file not found";

use autodie;
chdir $topdir;
mkpath $incdir unless -d $incdir;
chdir $incdir;
no autodie;
unlink "AutoInstall.pm";
use autodie;
symlink $file, "AutoInstall.pm";

Return to:

Send suggestions and report system problems to the System administrator.