Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dagolden/111693 to your computer and use it in GitHub Desktop.
Save dagolden/111693 to your computer and use it in GitHub Desktop.
gitperl
#!/usr/bin/perl
use strict;
use warnings;
use Cwd qw/cwd/;
use File::Temp qw/tempdir/;
#--------------------------------------------------------------------------#
my $manual;
sub _die {
if ( $manual ) {
warn @_;
system("bash");
exit;
}
else {
die @_;
}
}
#--------------------------------------------------------------------------#
my ($tag, @args) = @ARGV;
$manual = grep { $_ eq '--manual' } @args;
@args = grep { $_ ne '--manual' } @args;
die "usage: $0 <tag/branch-name> [configure args]\n(Include '-Dusethreads' for threaded build)\n"
if not defined $tag;
my $cwd = cwd; END { chdir $cwd if $cwd };
chdir '/home/david/git/perl/' or die "Couldn't get to perl git directory\n";
my (undef, $tag_ref) = split ' ', `git show-ref --tags $tag`;
my (undef, $br_ref) = split ' ', `git show-ref $tag`;
if ( ! $tag_ref && ! $br_ref ) {
die "Tag/branch $tag doesn't exist\n";
}
my $git_obj = $tag_ref || $br_ref;
my $target = $tag;
$target =~ s{^\w+/}{};
$target =~ s{^perl-}{};
$target = "/opt/perl/$target";
$target .= "-threads" if @args && grep { /-Dusethreads/ } @args;
die "Target directory '$target' already exists. Stopping.\n"
if -d $target;
my $tempdir = tempdir( CLEANUP => 1 );
system("git archive --format=tar $git_obj | (cd $tempdir && tar xf -)");
chdir $tempdir;
print "Now in directory '" . cwd . "'\n";
print "Building for installation in '$target'\n";
my $config_args="-de -Dusedevel -Dprefix=$target -Dusemorebits -Uversiononly -Dmydomain=.hyperbolic.net -Dcf_email=xdaveg\@gmail.com -Dperladmin=xdaveg\@gmail.com -Dcc=gcc";
$config_args .= " @args" if @args;
#--------------------------------------------------------------------------#
# check perl version and avoid parallel on 5.8.7
#--------------------------------------------------------------------------#
my $is_587;
if ( -f 'META.yml' ) {
my $meta = do { local (@ARGV,$/)='META.yml'; <> };
$is_587 = $meta =~ m{version:\s+5.008007}ms;
}
my $make_args = $is_587 ? "" : "-j3";
#--------------------------------------------------------------------------#
# build it up
#--------------------------------------------------------------------------#
system("sh ./Configure $config_args") and _die "Problem with Configuration. Stopping.\n";
system("make depend") and _die "Problem with make depend. Stopping.\n";
system("make $make_args") and _die "Problem with make. Stopping\n";
system("make install") and _die "Problem with install. Stopping\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment