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/.
6 from __future__
import absolute_import
, print_function
, unicode_literals
8 from optparse
import OptionParser
13 o
.add_option("--buildid", dest
="buildid")
14 o
.add_option("--version", dest
="version")
16 (options
, args
) = o
.parse_args()
18 if not options
.buildid
:
19 print("--buildid is required", file=sys
.stderr
)
22 if not options
.version
:
23 print("--version is required", file=sys
.stderr
)
26 # We want to build a version number that matches the format allowed for
27 # CFBundleVersion (nnnnn[.nn[.nn]]). We'll incorporate both the version
28 # number as well as the date, so that it changes at least daily (for nightly
29 # builds), but also so that newly-built older versions (e.g. beta build) aren't
30 # considered "newer" than previously-built newer versions (e.g. a trunk nightly)
32 define
, MOZ_BUILDID
, buildid
= (
33 io
.open(options
.buildid
, "r", encoding
="utf-8").read().split()
36 # extract only the major version (i.e. "14" from "14.0b1")
37 majorVersion
= re
.match(r
"^(\d+)[^\d].*", options
.version
).group(1)
38 # last two digits of the year
39 twodigityear
= buildid
[2:4]
47 print("%s.%s.%s" % (majorVersion
+ twodigityear
, month
, day
))