summaryrefslogtreecommitdiff
path: root/Porting/make_snapshot.pl
diff options
context:
space:
mode:
authorYves Orton <demerphq@gemini.(none)>2009-07-28 10:51:56 +0200
committerYves Orton <demerphq@gemini.(none)>2009-07-28 10:52:06 +0200
commita23cb041bc3354bdcb49e0dd42a3683d9850d471 (patch)
tree26f6363b090703e8c9a53723dbb2ab9245680a31 /Porting/make_snapshot.pl
parent09236310cc067b3e1bdd319db9fcf3e18363dff9 (diff)
downloadperl-a23cb041bc3354bdcb49e0dd42a3683d9850d471.tar.gz
Add Porting/make_snapshot.pl
Which should have been included with the corresponding MANIFEST change in the previous commit.
Diffstat (limited to 'Porting/make_snapshot.pl')
-rwxr-xr-xPorting/make_snapshot.pl68
1 files changed, 68 insertions, 0 deletions
diff --git a/Porting/make_snapshot.pl b/Porting/make_snapshot.pl
new file mode 100755
index 0000000000..6ff3c93858
--- /dev/null
+++ b/Porting/make_snapshot.pl
@@ -0,0 +1,68 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+use File::Path;
+use Cwd;
+
+use POSIX qw(strftime);
+sub isotime { strftime "%Y-%m-%d.%H:%M:%S",gmtime(shift||time) }
+
+my ($abbr,$sha1,$tstamp);
+$sha1= shift || "HEAD";
+my $zip_root= $ENV{PERL_SNAPSHOT_ZIP_ROOT} || "/gitcommon/branches/snapshot";
+my $gitdir= shift || `git rev-parse --git-dir`
+ or die "Not a git repo!\n";
+chomp $gitdir;
+my $workdir= $gitdir;
+if ( $workdir =~ s!/\.git\z!! ) {
+ chdir $workdir
+ or die "Failed to chdir to $workdir\n";
+} else {
+ chdir $workdir
+ or die "Failed to chdir to bare repo $workdir\n";
+}
+
+($sha1, $abbr,$tstamp)= split /\s+/, `git log --pretty='format:%H %h %ct' -1 $sha1`
+ or die "Failed to parse '$sha1'\n";
+chomp($sha1,$abbr,$tstamp);
+
+#die "'$sha1','$abbr'\n";
+
+my $path= join "/", $zip_root, substr($sha1,0,2), substr($sha1,0,4);
+my $tar_file= "$sha1.tar.$$";
+my $gz_file= "$sha1.tgz";
+my $prefix= "perl-$abbr/";
+
+if (!-e "$path/$gz_file") {
+ mkpath $path if !-d $path;
+
+ system("git archive --format=tar --prefix=$prefix $sha1 > $path/$tar_file");
+ my @branches=(
+ 'origin/blead',
+ 'origin/maint-5.10',
+ 'origin/maint-5.8',
+ 'origin/maint-5.8-dor',
+ 'origin/maint-5.6',
+ 'origin/maint-5.005',
+ 'origin/maint-5.004',
+ );
+ my $branch;
+ foreach my $b (@branches) {
+ $branch= $b and last
+ if `git log --pretty='format:%H' $b | grep $sha1`;
+ }
+
+ $branch ||= "unknown-branch";
+ chomp(my $describe= `git describe`);
+ chdir $path;
+ {
+ open my $fh,">","$path/$$.patch" or die "Failed to open $$.patch for writing\n";
+ print $fh join(" ", $branch, $tstamp, $sha1, $describe) . "\n";
+ close $fh;
+ }
+ system("tar -f $tar_file --transform='s,^$$,$prefix,g' --owner=root --group=root --mode=664 --append $$.patch");
+ system("gzip -S .gz -9 $tar_file");
+ rename "$tar_file.gz", "$gz_file";
+}
+print "$path/$gz_file", -t STDOUT ? "\n" :"";
+