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