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