| 1 | # !perl |
| 2 | use strict; |
| 3 | use warnings; |
| 4 | use Data::Dumper;$Data::Dumper::Indent=1; |
| 5 | use Carp; |
| 6 | use Cwd; |
| 7 | use File::Copy; |
| 8 | use File::Temp qw( tempdir ); |
| 9 | |
| 10 | my $cwd = cwd(); |
| 11 | opendir my $DIRH, $cwd |
| 12 | or croak "Unable to open directory handle"; |
| 13 | my @tarballs = grep { m/parrot-.*\.tar\.gz$/ } readdir $DIRH; |
| 14 | closedir $DIRH or croak "Unable to close directory handle"; |
| 15 | croak "Should find exactly one gzipped tarball" |
| 16 | unless @tarballs == 1; |
| 17 | my $tb = $tarballs[0]; |
| 18 | my $distro = ''; |
| 19 | if ($tb =~ m/(parrot-\d+\.\d+\.\d+(?:-devel)?)\.tar\.gz$/ ) { |
| 20 | $distro = $1; |
| 21 | } |
| 22 | else { |
| 23 | croak "Unable to extract distro from $tb"; |
| 24 | } |
| 25 | print "Performing distcheck on $tb\n"; |
| 26 | { |
| 27 | my $tdir = tempdir( CLEANUP => 1 ); |
| 28 | chdir $tdir or croak "Unable to change to temporary directory"; |
| 29 | my $ctarball = "$tdir/$tb"; |
| 30 | copy "$cwd/$tb" => $ctarball |
| 31 | or croak "Unable to copy $tb"; |
| 32 | system(qq{tar xzf $ctarball}) |
| 33 | and croak "Unable to untar $ctarball"; |
| 34 | chdir $distro or croak "Unable to chdir to $distro"; |
| 35 | system(qq{$^X Configure.pl --silent}) and croak "Unable to configure"; |
| 36 | system(qq{make --silent}) and croak "Unable to build"; |
| 37 | system(qq{make test}) and croak "'make test' did not complete successfully"; |
| 38 | system(qq{make release}) and croak "Unable to release"; |
| 39 | system(qq{make realclean}) and croak "Unable to realclean"; |
| 40 | chdir $cwd or croak "Unable to change dir back"; |
| 41 | } |
| 42 | print "Completed distcheck on $tb\n"; |