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/.
9 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("--buildid is required", file=sys
.stderr
)
21 if not options
.version
:
22 print("--version is required", file=sys
.stderr
)
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 define
, MOZ_BUILDID
, buildid
= (
32 io
.open(options
.buildid
, "r", encoding
="utf-8").read().split()
35 # extract only the major version (i.e. "14" from "14.0b1")
36 majorVersion
= re
.match(r
"^(\d+)[^\d].*", options
.version
).group(1)
37 # last two digits of the year
38 twodigityear
= buildid
[2:4]
46 print("%s.%s.%s" % (majorVersion
+ twodigityear
, month
, day
))