1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/app/macversion.py Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,44 @@ 1.4 +#!/usr/bin/python 1.5 +# This Source Code Form is subject to the terms of the Mozilla Public 1.6 +# License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 +# file, You can obtain one at http://mozilla.org/MPL/2.0/. 1.8 + 1.9 + 1.10 +from optparse import OptionParser 1.11 +import sys 1.12 +import re 1.13 + 1.14 +o = OptionParser() 1.15 +o.add_option("--buildid", dest="buildid") 1.16 +o.add_option("--version", dest="version") 1.17 + 1.18 +(options, args) = o.parse_args() 1.19 + 1.20 +if not options.buildid: 1.21 + print >>sys.stderr, "--buildid is required" 1.22 + sys.exit(1) 1.23 + 1.24 +if not options.version: 1.25 + print >>sys.stderr, "--version is required" 1.26 + sys.exit(1) 1.27 + 1.28 +# We want to build a version number that matches the format allowed for 1.29 +# CFBundleVersion (nnnnn[.nn[.nn]]). We'll incorporate both the version 1.30 +# number as well as the date, so that it changes at least daily (for nightly 1.31 +# builds), but also so that newly-built older versions (e.g. beta build) aren't 1.32 +# considered "newer" than previously-built newer versions (e.g. a trunk nightly) 1.33 + 1.34 +buildid = open(options.buildid, 'r').read() 1.35 + 1.36 +# extract only the major version (i.e. "14" from "14.0b1") 1.37 +majorVersion = re.match(r'^(\d+)[^\d].*', options.version).group(1) 1.38 +# last two digits of the year 1.39 +twodigityear = buildid[2:4] 1.40 +month = buildid[4:6] 1.41 +if month[0] == '0': 1.42 + month = month[1] 1.43 +day = buildid[6:8] 1.44 +if day[0] == '0': 1.45 + day = day[1] 1.46 + 1.47 +print '%s.%s.%s' % (majorVersion + twodigityear, month, day)