2012-04-26 21:46:29 +04:00
|
|
|
#!/usr/bin/python
|
2012-05-21 15:12:37 +04:00
|
|
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
|
2020-05-05 22:53:22 +03:00
|
|
|
from __future__ import absolute_import, print_function, unicode_literals
|
|
|
|
import io
|
2012-04-26 21:46:29 +04:00
|
|
|
from optparse import OptionParser
|
|
|
|
import sys
|
|
|
|
import re
|
|
|
|
|
|
|
|
o = OptionParser()
|
2020-05-05 22:53:22 +03:00
|
|
|
o.add_option('--buildid', dest='buildid')
|
|
|
|
o.add_option('--version', dest='version')
|
2012-04-26 21:46:29 +04:00
|
|
|
|
|
|
|
(options, args) = o.parse_args()
|
|
|
|
|
|
|
|
if not options.buildid:
|
2020-05-05 22:53:22 +03:00
|
|
|
print('--buildid is required', file=sys.stderr)
|
2012-04-26 21:46:29 +04:00
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
if not options.version:
|
2020-05-05 22:53:22 +03:00
|
|
|
print('--version is required', file=sys.stderr)
|
2012-04-26 21:46:29 +04:00
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
# We want to build a version number that matches the format allowed for
|
|
|
|
# CFBundleVersion (nnnnn[.nn[.nn]]). We'll incorporate both the version
|
|
|
|
# number as well as the date, so that it changes at least daily (for nightly
|
|
|
|
# builds), but also so that newly-built older versions (e.g. beta build) aren't
|
|
|
|
# considered "newer" than previously-built newer versions (e.g. a trunk nightly)
|
|
|
|
|
2020-05-05 22:53:22 +03:00
|
|
|
define, MOZ_BUILDID, buildid = io.open(
|
|
|
|
options.buildid, 'r', encoding='utf-8').read().split()
|
2012-04-26 21:46:29 +04:00
|
|
|
|
|
|
|
# extract only the major version (i.e. "14" from "14.0b1")
|
|
|
|
majorVersion = re.match(r'^(\d+)[^\d].*', options.version).group(1)
|
|
|
|
# last two digits of the year
|
|
|
|
twodigityear = buildid[2:4]
|
|
|
|
month = buildid[4:6]
|
|
|
|
if month[0] == '0':
|
2018-05-22 00:13:07 +03:00
|
|
|
month = month[1]
|
2012-04-26 21:46:29 +04:00
|
|
|
day = buildid[6:8]
|
|
|
|
if day[0] == '0':
|
2018-05-22 00:13:07 +03:00
|
|
|
day = day[1]
|
2012-04-26 21:46:29 +04:00
|
|
|
|
2018-05-22 00:13:07 +03:00
|
|
|
print('%s.%s.%s' % (majorVersion + twodigityear, month, day))
|