2 # This Source Code Form is subject to the terms of the Mozilla Public
3 # License, v. 2.0. If a copy of the MPL was not distributed with this
4 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 from optparse
import OptionParser
12 o
.add_option("--buildid", dest
="buildid")
13 o
.add_option("--version", dest
="version")
15 (options
, args
) = o
.parse_args()
17 if not options
.buildid
:
18 print >>sys
.stderr
, "--buildid is required"
21 if not options
.version
:
22 print >>sys
.stderr
, "--version is required"
25 # We want to build a version number that matches the format allowed for
26 # CFBundleVersion (nnnnn[.nn[.nn]]). We'll incorporate both the version
27 # number as well as the date, so that it changes at least daily (for nightly
28 # builds), but also so that newly-built older versions (e.g. beta build) aren't
29 # considered "newer" than previously-built newer versions (e.g. a trunk nightly)
31 buildid
= open(options
.buildid
, 'r').read()
33 # extract only the major version (i.e. "14" from "14.0b1")
34 majorVersion
= re
.match(r
'^(\d+)[^\d].*', options
.version
).group(1)
35 # last two digits of the year
36 twodigityear
= buildid
[2:4]
44 print '%s.%s.%s' % (majorVersion
+ twodigityear
, month
, day
)