1#!/usr/bin/perl 2 3# 4# This script is a hack to update the ScummVM version in all (?) files that 5# contain it. Obviously, it should be used before a release. 6 7use strict; 8 9if ($#ARGV+1 < 3 or $#ARGV+1 > 4) { 10 # TODO: Allow the user to specify the version as "1.2.3svn" 11 # and automatically split that into 1, 2, 3, svn 12 print STDERR "Usage: $0 MAJOR MINOR PATCH [EXTRA]\n"; 13 print STDERR " TODO\n"; 14 exit 1; 15} 16 17# TODO: Verify that major/minor/patch are actually numbers 18my $VER_MAJOR = $ARGV[0]; 19my $VER_MINOR = $ARGV[1]; 20my $VER_PATCH = $ARGV[2]; 21my $VER_EXTRA = $ARGV[3]; 22my $VERSION = "$VER_MAJOR.$VER_MINOR.$VER_PATCH$VER_EXTRA"; 23 24die "MAJOR must be a natural number\n" unless ($VER_MAJOR =~ /^\d+$/); 25die "MINOR must be a natural number\n" unless ($VER_MINOR =~ /^\d+$/); 26die "PATCH must be a natural number\n" unless ($VER_PATCH =~ /^\d+$/); 27 28 29print "Setting version to '$VERSION'\n"; 30 31 32# List of the files in which we need to perform substitution. 33my @subs_files = qw( 34 base/internal_version.h 35 dists/redhat/scummvm.spec 36 dists/redhat/scummvm-tools.spec 37 dists/slackware/scummvm.SlackBuild 38 dists/macosx/Info.plist 39 dists/macosx/dockplugin/Info.plist 40 dists/iphone/Info.plist 41 dists/ios7/Info.plist 42 dists/irix/scummvm.spec 43 dists/wii/meta.xml 44 dists/openpandora/PXML.xml 45 dists/openpandora/README-OPENPANDORA 46 dists/openpandora/README-PND.txt 47 dists/openpandora/index.html 48 dists/gph/README-GPH 49 dists/gph/scummvm.ini 50 dists/riscos/!Boot,feb 51 dists/amigaos/md2ag.rexx 52 backends/platform/psp/README.PSP 53 ); 54 55my %subs = ( 56 VER_MAJOR => $VER_MAJOR, 57 VER_MINOR => $VER_MINOR, 58 VER_PATCH => $VER_PATCH, 59 VER_EXTRA => $VER_EXTRA, 60 VERSION => $VERSION 61 ); 62 63foreach my $file (@subs_files) { 64 print "Processing $file...\n"; 65 open(INPUT, "< $file.in") or die "Can't open '$file.in' for reading: $!\n"; 66 open(OUTPUT, "> $file") or die "Can't open '$file' for writing: $!\n"; 67 68 while (<INPUT>) { 69 while (my ($key, $value) = each(%subs)) { 70 s/\@$key\@/$value/; 71 } 72 print OUTPUT; 73 } 74 75 close(INPUT); 76 close(OUTPUT); 77} 78