X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=maint%2Frelease.pm;h=c1a6abda038fefa82cc9ec6f9b3be8c3a8ab20d8;hb=8f00a5ec99b67236e020872367d249b5e465ce7e;hp=b0fa46ee1ec5676f8a46fd79bd476b98de930838;hpb=7dfcaf2ab0bd6438e5c77ea46cb67691770a4afc;p=checkmail.git diff --git a/maint/release.pm b/maint/release.pm index b0fa46e..c1a6abd 100644 --- a/maint/release.pm +++ b/maint/release.pm @@ -1,6 +1,6 @@ #!/usr/bin/perl # A simple system for making software releases -# (c) 2003--2006 Martin Mares +# (c) 2003--2010 Martin Mares package UCW::Release; use strict; @@ -17,7 +17,8 @@ sub new($$) { # p=preprocess, s=subst, -=discard '(^|/)(CVS|\.arch-ids|{arch}|\.git|tmp)/' => '-', '\.(lsm|spec)$' => 'ps', - '(^|/)README$' => 's' + '(^|/)README$' => 's', + '\.swp$' => '-', ], "directories" => [ ], @@ -30,11 +31,17 @@ sub new($$) { "archivedir" => "/home/mj/tmp/archives/$basename", "uploads" => [ ], + "notifiers" => [ + ], + "test_cmd" => "make", # Options "do_test" => 1, "do_patch" => 1, "diff_against" => "", - "do_upload" => 1 + "do_upload" => 1, + "do_git_tag" => 0, + "force_git_tag" => 0, + "do_notify" => 0, }; bless $s; return $s; @@ -216,15 +223,42 @@ sub GenFile($$) { push @{$s->{"distfiles"}}, $df; } +sub Usage($) { + my ($s) = @_; + my $usage = < + +Options: +--[no]verbose Be chatty about the inner workings of the release system {verbose} +--[no]test Test the package before uploading {do_test} +--[no]patch Make a patch against the previous version {do_patch} +--diff-against= Set which version we create the patch against +--[no]upload Upload released files {do_upload} +--[no]git-tag Tag the Git repository with "v" {do_git_tag} +--force-git-tag Rewrite the Git tag if it already exists {force_git_tag} +--[no]notify Call scripts to notify the world about the release {do_notify} +FOE + sub state($) { + return "(default: " . ($_[0] ? "on" : "off") . ")"; + } + $usage =~ s[{(\w+)}][state($s->{$1})]ge; + die $usage; +} + sub ParseOptions($) { my ($s) = @_; + $s->{"do_git_tag"} = 1 if (-d ".git"); + $s->{"do_notify"} = 1 if @{$s->{"notifiers"}}; GetOptions( "verbose!" => \$verbose, "test!" => \$s->{"do_test"}, "patch!" => \$s->{"do_patch"}, "diff-against=s" => \$s->{"diff_against"}, - "upload!" => \$s->{"do_upload"} - ) || die "Syntax: release [--verbose] [--test] [--nopatch] [--diff-against=] [--noupload]"; + "upload!" => \$s->{"do_upload"}, + 'git-tag!' => \$s->{"do_git_tag"}, + 'force-git-tag!' => \$s->{"force_git_tag"}, + 'notify!' => \$s->{"do_notify"}, + ) || $s->Usage; } sub Test($) { @@ -232,8 +266,9 @@ sub Test($) { my $dd = $s->{"DISTDIR"}; my $pkg = $s->{"PKG"}; my $log = "$dd/$pkg.log"; + my $test_cmd = $s->{"test_cmd"}; print "Doing a test compilation\n"; - `( cd $dd/$pkg && make ) >$log 2>&1`; + `( cd $dd/$pkg && $test_cmd ) >$log 2>&1`; die "There were errors. Please inspect $log" if $?; `grep -q [Ww]arning $log`; $? or print "There were warnings! Please inspect $log.\n"; @@ -307,11 +342,38 @@ sub Upload($) { } } +sub GitTag($) { + my ($s) = @_; + my $tag = 'v' . $s->{'VERSION'}; + my $force = ($s->{'force_git_tag'} ? '--force' : ''); + print "Tagging Git repository with $tag\n"; + `git tag $tag $force`; die if $?; + print "Pushing the tags upstream\n"; + `git push --tags`; die if $?; +} + +sub AddUcwNotifier($) { + my ($r) = @_; + push @{$r->{"notifiers"}}, sub { + my ($s) = @_; + print "Updating web pages\n"; + my $pkg = $s->{'PACKAGE'}; + my $ver = $s->{'VERSION'}; + `ssh jw 'cd web && bin/release-prog $pkg $ver'`; die if $?; + }; +}; + sub Dispatch($) { my ($s) = @_; $s->Test if $s->{"do_test"}; $s->MakePatch if $s->{"do_patch"}; + $s->GitTag if $s->{"do_git_tag"}; $s->Upload if $s->{"do_upload"}; + if ($s->{"do_notify"}) { + for my $f (@{$s->{"notifiers"}}) { + &$f($s); + } + } } 1;