Skip to content

Instantly share code, notes, and snippets.

@dolmen
Last active August 29, 2015 14:13
Show Gist options
  • Save dolmen/39bc90ccdd044b3639b6 to your computer and use it in GitHub Desktop.
Save dolmen/39bc90ccdd044b3639b6 to your computer and use it in GitHub Desktop.
An installer that will link the system SVN::* modules to the current perl dirs
#!/usr/bin/env perl
# System perl on Debian is threaded.
# Here is how to try to build a compatible one with plenv:
# plenv install 5.20.1 --as=5.20.1-thr -Dusethread
use Config;
use File::Path 'make_path';
my $errors = 0;
my %DIRS = (
'SVN' => $Config{installsitelib},
'auto/SVN' => $Config{installarchlib},
);
my @links;
foreach my $dir (keys %DIRS) {
my $target = "/usr/lib/perl5/$dir";
if (! -d "$target") {
warn "$target is missing\n";
$errors++;
next
}
my $dest = $DIRS{$dir};
if (-l "$dest/$dir") {
warn "$dest/$dir already symlinked\n";
push @links, "$dest/$dir";
next
}
if (-d "$dest/$dir") {
warn "$dest/$dir already exists\n";
$errors++;
next
}
print "$dest/$dir -> $target\n";
if ((my $parent = $dir) =~ s!/[^/]*$!!) {
make_path "$dest/$parent";
chdir "$dest/$parent" or die;
} else {
chdir $dest or die;
}
symlink $target, 'SVN' or die;
push @links, "$dest/$dir";
}
unless ($errors) {
print "Testing...\n";
system("perl -MSVN::Core -e0");
if ($? & 127) {
print "Crash! :(\n";
$errors++;
} elsif ($? >> 8) {
print "Doesn't work :( ; removing links...\n";
$errors++;
} else {
print "Success! $?\n";
}
if ($errors) {
unlink for @links;
}
}
exit $errors;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment