aboutsummaryrefslogtreecommitdiff
path: root/bootstrap.pl
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2014-04-08 14:26:23 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2014-04-08 14:40:26 +0300
commitb39389f1a8b2344bbe80eba028c0101b72eceec1 (patch)
tree1d094b8885ab997049be2755b2686dee6ce1311e /bootstrap.pl
parentafd5c92337ff2df9d1eca2db1d8ef70a9fa01bc4 (diff)
downloaddnstools-b39389f1a8b2344bbe80eba028c0101b72eceec1.tar.gz
dnstools-b39389f1a8b2344bbe80eba028c0101b72eceec1.tar.bz2
Use ExtUtils::AutoInstall to handle dependencies.
* .gitignore: Add inc * README: New file. * Makefile: Add copyleft statement (SUBDIRS): Add vhostcname * bootstrap.pl: New file. * axfr2acl/Makefile.PL: Use ExtUtils::AutoInstall * dnsdbck/Makefile.PL: Likewise. * renewck/Makefile.PL: Likewise. * rpsl2acl/Makefile.PL: Likewise. * vhostcname/Makefile.PL: Likewise. * vhostcname/MANIFEST: Add inc/ExtUtils/AutoInstall.pm * dnsdbck/MANIFEST: Likewise. * axfr2acl/MANIFEST: Likewise. * renewck/MANIFEST: Likewise. * rpsl2acl/MANIFEST: Likewise.
Diffstat (limited to 'bootstrap.pl')
-rw-r--r--bootstrap.pl93
1 files changed, 93 insertions, 0 deletions
diff --git a/bootstrap.pl b/bootstrap.pl
new file mode 100644
index 0000000..6625365
--- /dev/null
+++ b/bootstrap.pl
@@ -0,0 +1,93 @@
+#! /usr/bin/perl
+# This file is part of dnstools.
+# Copyright (C) 2014 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);
+
+sub find_subdirs {
+ my $line;
+ my @ret;
+
+ open(my $fd, "<", "Makefile") or die "Can't open Makefile: $!";
+ while (<$fd>) {
+ s/#.*//;
+ next if (/^\s*$/);
+ if (s/\\\s*$//) {
+ $line .= $_;
+ next;
+ } else {
+ $line .= $_;
+ $line =~ s/^\s+//;
+ if ($line =~ s/^SUBDIRS\s*=\s*(.*)//) {
+ @ret = split /\s+/, $1;
+ last;
+ }
+ }
+ }
+ close($fd);
+ return @ret;
+}
+
+####
+my $incdir = "inc/ExtUtils";
+my $topdir = getcwd;
+
+my @subdirs = find_subdirs();
+die "No SUBDIRS found in the Makefile; make sure you run this script from the project's top-level directory\n" if ($#subdirs == -1);
+
+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";
+-f $file or die "$file not found";
+
+chdir $topdir or die "Can't change to $topdir: $!";
+foreach my $d (@subdirs) {
+ print "Directory $d/$incdir\n";
+ if (! -d "$d/$incdir") {
+ mkpath "$d/$incdir" or die "Can't create $d/$incdir: $!";
+ }
+ chdir "$d/$incdir"
+ or die "Can't change to $d/$incdir: $!";
+ unlink("AutoInstall.pm");
+ symlink($file, "AutoInstall.pm")
+ or die "Can't create symlink in ". getcwd . ": $!";
+ chdir $topdir
+ or die "Can't change back to $topdir: $!";
+}
+

Return to:

Send suggestions and report system problems to the System administrator.