|
1 #!/usr/bin/python |
|
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/. |
|
5 |
|
6 |
|
7 from optparse import OptionParser |
|
8 import sys |
|
9 import re |
|
10 |
|
11 o = OptionParser() |
|
12 o.add_option("--buildid", dest="buildid") |
|
13 o.add_option("--version", dest="version") |
|
14 |
|
15 (options, args) = o.parse_args() |
|
16 |
|
17 if not options.buildid: |
|
18 print >>sys.stderr, "--buildid is required" |
|
19 sys.exit(1) |
|
20 |
|
21 if not options.version: |
|
22 print >>sys.stderr, "--version is required" |
|
23 sys.exit(1) |
|
24 |
|
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) |
|
30 |
|
31 buildid = open(options.buildid, 'r').read() |
|
32 |
|
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] |
|
37 month = buildid[4:6] |
|
38 if month[0] == '0': |
|
39 month = month[1] |
|
40 day = buildid[6:8] |
|
41 if day[0] == '0': |
|
42 day = day[1] |
|
43 |
|
44 print '%s.%s.%s' % (majorVersion + twodigityear, month, day) |