dev.stuconnolly.com / svn / safaritabs

  1. #! /usr/bin/perl -w
  2.  
  3. ## $Id: output-versions.pl 224 2011-08-13 20:39:45Z stuart $
  4. ##
  5. ## Author:      Stuart Connolly (stuconnolly.com)
  6. ##              Copyright (c) 2011 Stuart Connolly. All rights reserved.
  7. ##
  8. ## Paramters:   $1 -- The file path to which the versions are to be written to.
  9. ##              $2 -- The path of the 'Info.plist' file from which the versions should be extracted from.
  10. ##
  11. ## Description: Extracts the CFBundleVersion and CFBundleShortVersionString from the supplied Info.plist file and writes
  12. ##              them to the supplied file path.
  13.  
  14. use strict;
  15.  
  16. my $info_plist    = $ARGV[0];
  17. my $versions_file = $ARGV[1];
  18.  
  19. open(INFO_FH, "<$info_plist");
  20. my $info = join("", <INFO_FH>);
  21. close(INFO_FH);
  22.  
  23. my $version_string = 0;
  24. my $bundle_version = 0;
  25.  
  26. # Version string
  27. ($info =~ m/[\t ]+<key>CFBundleShortVersionString<\/key>\n[\t ]+<string>([0-9.]+)<\/string>/) && ($version_string = $1);
  28.  
  29. # Bundle version
  30. ($info =~ m/[\t ]+<key>CFBundleVersion<\/key>\n[\t ]+<string>(\d+)<\/string>/) && ($bundle_version = $1);
  31.  
  32. # Write versions to file
  33. open(VERSIONS_FH, ">$versions_file");
  34. print VERSIONS_FH "${version_string}:${bundle_version}\n";
  35. close(VERSIONS_FH);
  36.