inc_bldnum revision 5386
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus#!/usr/bin/perl -w
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus# Increment the tarball build number in Moz/Evo/APOC spec files.
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus#
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus# Created by Damien Carbery, 25 April 2005.
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikususe strict;
8cf870d281dc8c242f083d14dfef05f24aa5fceeJnRouvignacuse Getopt::Long;
8cf870d281dc8c242f083d14dfef05f24aa5fceeJnRouvignacuse File::Basename;
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikususe POSIX; # For strftime.
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus# Display usage information.
8cf870d281dc8c242f083d14dfef05f24aa5fceeJnRouvignacsub Usage
8cf870d281dc8c242f083d14dfef05f24aa5fceeJnRouvignac{
8cf870d281dc8c242f083d14dfef05f24aa5fceeJnRouvignac my $ScriptName = basename( $0 );
8cf870d281dc8c242f083d14dfef05f24aa5fceeJnRouvignac
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus print << "END_OF_USAGE_INFO";
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikusIncrement the build source tarball number and add %changelog entry.
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikusUsage: $ScriptName -buildnum num
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus-buildnum Specify build number to insert into spec files. (Required)
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus-email Specify email address to be listed in %changelog.
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus-help Display this usage information.
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikusEND_OF_USAGE_INFO
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus exit 1; # Indicate an error.
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus}
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus# ####################################
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus# Main program.
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus# ####################################
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus# Display usage if no arguments.
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikusUsage if ( $#ARGV == -1 );
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikusmy $DisplayHelp = 0;
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikusmy $BuildNum;
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikusmy $Email = 'dermot.mccluskey@sun.com';
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus# ############################
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus# Begin command line parsing.
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus# ############################
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus#Getopt::Long::Configure( 'pass_through' ); # Ignore unknown options.
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikusGetOptions( 'buildnum=i' => \$BuildNum,
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus 'email=s' => \$Email,
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus 'help' => \$DisplayHelp );
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikusUsage if ( $DisplayHelp );
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikusUsage if ( ! defined $BuildNum );
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus# List of spec files to update.
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikusmy @specfiles = qw / apoc.spec evolution.spec gnome-spell.spec gtkhtml.spec hydrogen.spec libgal.spec libsoup.spec mozilla.spec oxygen2.spec /;
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikusforeach my $file ( @specfiles )
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus{
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus # Ensure all the specified files are present, quitting if any aren't.
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus my $MissingFiles = 0;
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus foreach my $file ( @ARGV )
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus {
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus if ( ! -r $file )
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus {
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus print "ERROR: $file is missing or not readable.\n";
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus $MissingFiles++;
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus }
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus }
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus exit 1 if ( $MissingFiles );
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus}
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus# Change t_suffix and Release data and add %changelog entry for each file.
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikusforeach my $file ( @specfiles )
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus{
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus if ( open( IN, '<' . $file ) )
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus {
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus if ( open( OUT, '>' . $file . ".$$" ) )
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus {
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus while ( <IN> )
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus {
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus if ( /^(%define t_suffix \D+)(\d+)(\D+)$/ )
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus {
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus print OUT $1,$BuildNum,$3;
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus }
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus elsif ( /^(Release:\s+)(\d+)(\D+)$/ )
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus {
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus print OUT $1,(${2}+1),$3;
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus }
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus elsif ( /^%changelog$/ )
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus {
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus print OUT;
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus print OUT '* ', strftime("%a %b %e %Y",localtime), " - $Email\n- Bump source tarball to build $BuildNum.\n";
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus }
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus else
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus {
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus print OUT;
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus }
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus }
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus close( OUT );
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus }
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus close( IN );
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus rename( $file . ".$$", $file );
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus print "$file - done\n";
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus }
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus else
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus {
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus print "WARNING: Unable to open $file ($!). Skipping.\n";
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus }
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus}
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus# Update ChangeLog too, putting info at the top of the file.
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikusif ( open( IN, '<' . 'ChangeLog' ) )
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus{
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus if ( open( OUT, '>' . 'ChangeLog' . ".$$" ) )
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus {
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus print OUT "\t* ", join( ' ', @specfiles[0..4] ), "\n\t", join( ' ', @specfiles[5..$#specfiles] ), ":\n\t* Bump source tarballs to build $BuildNum.\n\n";
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus # Just pass-through the rest of the lines.
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus print OUT while ( <IN> );
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus close( OUT );
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus }
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus close( IN );
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus rename( 'ChangeLog'. ".$$", 'ChangeLog' );
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus print "ChangeLog - done\n";
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus}
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikusprint "\nUse 'cvs diff' to verify changes.\nTo commit changes:\n cvs commit -m \"Bump source tarballs for Mozilla/Evolution/APOC\"\n";
b6659196f7a2ac319119e1859150bb214ce1f7d7jpikus