inc_bldnum revision 5401
15394N/A#!/usr/bin/perl -w
15394N/A
15394N/A# Increment the tarball build number in Moz/Evo/APOC spec files.
20903N/A#
15394N/A# Created by Damien Carbery, 25 April 2005.
15394N/A
15394N/A
17185N/Ause strict;
17093N/Ause Getopt::Long;
15394N/Ause File::Basename;
15394N/Ause POSIX; # For strftime.
18632N/A
17176N/A
15394N/A# Display usage information.
18810N/Asub Usage
15394N/A{
22050N/A my $ScriptName = basename( $0 );
15394N/A
15394N/A print << "END_OF_USAGE_INFO";
18615N/AIncrement the build source tarball number and add %changelog entry.
15394N/AUsage: $ScriptName -buildnum num
22050N/A
19052N/A-buildnum Specify build number to insert into spec files. (Required)
19051N/A-email Specify email address to be listed in %changelog.
18810N/A-help Display this usage information.
18810N/AEND_OF_USAGE_INFO
18810N/A
20783N/A exit 1; # Indicate an error.
20903N/A}
15394N/A
17093N/A
15394N/A# ####################################
17093N/A# Main program.
17093N/A# ####################################
15394N/A
15394N/A
15394N/A# Display usage if no arguments.
20783N/AUsage if ( $#ARGV == -1 );
20783N/A
20783N/Amy $DisplayHelp = 0;
20903N/Amy $BuildNum;
17093N/Amy $Email = 'dermot.mccluskey@sun.com';
15394N/A
15394N/A# ############################
15394N/A# Begin command line parsing.
15394N/A# ############################
15394N/A#Getopt::Long::Configure( 'pass_through' ); # Ignore unknown options.
18022N/AGetOptions( 'buildnum=i' => \$BuildNum,
20783N/A 'email=s' => \$Email,
20783N/A 'help' => \$DisplayHelp );
20783N/A
18022N/AUsage if ( $DisplayHelp );
18022N/AUsage if ( ! defined $BuildNum );
18022N/A
18022N/A
18022N/A# List of spec files to update.
18022N/Amy @specfiles = qw / apoc.spec evolution.spec gnome-spell.spec gtkhtml.spec hydrogen.spec libgal.spec libsoup.spec mozilla.spec oxygen2.spec /;
20783N/A
20790N/Aforeach my $file ( @specfiles )
20790N/A{
20790N/A # Ensure all the specified files are present, quitting if any aren't.
15394N/A my $MissingFiles = 0;
15394N/A foreach my $file ( @ARGV )
15394N/A {
15394N/A if ( ! -r $file )
15394N/A {
15394N/A print "ERROR: $file is missing or not readable.\n";
15394N/A $MissingFiles++;
15394N/A }
18007N/A }
18007N/A exit 1 if ( $MissingFiles );
18007N/A}
15394N/A
15394N/A
15394N/A# Change t_suffix and Release data and add %changelog entry for each file.
15394N/Aforeach my $file ( @specfiles )
15394N/A{
15394N/A if ( open( IN, '<' . $file ) )
15394N/A {
15394N/A if ( open( OUT, '>' . $file . ".$$" ) )
15394N/A {
15394N/A while ( <IN> )
15394N/A {
22050N/A if ( /^(%define t_suffix \D+)(\d+)(\D+)$/ )
22050N/A {
20903N/A print OUT $1,$BuildNum,$3;
20903N/A }
20862N/A elsif ( /^(Release:\s+)(\d+)(\D+)$/ )
20862N/A {
20841N/A print OUT $1,(${2}+1),$3;
20841N/A }
20783N/A elsif ( /^%changelog$/ )
20783N/A {
19051N/A print OUT;
19051N/A print OUT '* ', strftime("%a %b %d %Y",localtime), " - $Email\n- Bump source tarball to build $BuildNum.\n\n";
18810N/A }
18810N/A else
18810N/A {
18806N/A print OUT;
18806N/A }
18806N/A }
18657N/A
18657N/A close( OUT );
18513N/A }
18513N/A close( IN );
18473N/A rename( $file . ".$$", $file );
18473N/A print "$file - done\n";
18379N/A }
18379N/A else
18276N/A {
18276N/A print "WARNING: Unable to open $file ($!). Skipping.\n";
18276N/A }
18271N/A}
18271N/A
18271N/A# Update ChangeLog too, putting info at the top of the file.
18022N/Aif ( open( IN, '<' . 'ChangeLog' ) )
18022N/A{
18022N/A if ( open( OUT, '>' . 'ChangeLog' . ".$$" ) )
18007N/A {
18007N/A print OUT strftime("%Y-%m-%d",localtime), " <$Email>\n\n";
18007N/A print OUT "\t* ", join( ' ', @specfiles[0..4] ), "\n\t", join( ' ', @specfiles[5..$#specfiles] ), ":\n\t* Bump source tarballs to build $BuildNum.\n\n";
18007N/A # Just pass-through the rest of the lines.
17577N/A print OUT while ( <IN> );
17577N/A close( OUT );
17393N/A }
17393N/A close( IN );
17232N/A rename( 'ChangeLog'. ".$$", 'ChangeLog' );
17232N/A print "ChangeLog - done\n";
17093N/A}
17232N/A
17232N/Aprint "\nUse 'cvs diff' to verify changes.\nTo commit changes:\n cvs commit -m \"Bump source tarballs for Mozilla/Evolution/APOC\"\n";
17232N/A