diff options
author | Martin Wilke <miwi@FreeBSD.org> | 2012-05-29 07:15:42 +0000 |
---|---|---|
committer | Martin Wilke <miwi@FreeBSD.org> | 2012-05-29 07:15:42 +0000 |
commit | 3833a90f6ab05e4395d49f4b77beccf3a98eeb6f (patch) | |
tree | 32322a0f2d9d6bc3278349571c89d8f6c68ce4dc /Tools | |
parent | 881319ef72a6a0b50da62ee1fde70803102336f2 (diff) |
Notes
Diffstat (limited to 'Tools')
-rwxr-xr-x | Tools/scripts/getpr | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/Tools/scripts/getpr b/Tools/scripts/getpr new file mode 100755 index 000000000000..7b0eabf1b119 --- /dev/null +++ b/Tools/scripts/getpr @@ -0,0 +1,93 @@ +#!/usr/bin/perl +# +# MAINTAINER= miwi@FreeBSD.org +# +# $FreeBSD$ +# + +use strict; + +my $pr = shift; +my $user = shift; +my $ssh; + +if ($pr eq "") { + print STDERR "getpr prnum [username]\n"; + exit 1 +} + +if( !defined $ENV{"CVS_RSH"} ) { + $ssh = "ssh"; +} else { + $ssh = $ENV{"CVS_RSH"}; +} + +if ($user ne "") { + $user = "$user@"; +} + +# get the PR off of freefall + +open(D, "> $pr") or die "$pr: $!"; +open(PATCH, "> pr-patch") or die "pr-patch: $!"; +open(PR, " ${ssh} ${user}freefall.freebsd.org query-pr -F $pr | ") or die $!; + +my $fix = ""; +my $infix = 0; + +while(<PR>) { + print D; + + if (m/^>Release-Note:/) { + $infix = 0; + } + if ($infix == 1) { + print PATCH; + } + if (m/^>Fix:/) { + $infix = 1; + } +} +close(D); +close(PR); +close(PATCH); + +# decode the submission attempting to find a file attachment by extension +# .tar.gz, .shar or just .gz, if not found, display what we think of as +# the file submission (probably just a patch) + +open(PATCH, "pr-patch"); +while(<PATCH>) { + if (m/^# This is a shell archive. Save it in a file, remove anything before/) { + &shar; + exit; + } + if (m/^begin (\d+)? (.*)/) { + &uudecode($2); + close(PATCH); + exit; + } +} + +close(PATCH); +system("more pr-patch"); + +exit; + +sub uudecode { + my ($fname) = @_; + + $fname =~ s/\s+$//g; + print "$fname\n"; + + print `uudecode pr-patch`; + if (($fname =~ m/.tar.gz$/) || ($fname =~ m/.tgz$/)) { + print "you may extract this tarball by typing tar xvzf $fname\n"; + } elsif ($fname =~ m/.gz$/) { + print `gunzip $fname`; + } +} + +sub shar { + print "you may extract this shar archive by typing sh pr-patch\n"; +} |