browser/app/macversion.py

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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/.
     7 from optparse import OptionParser
     8 import sys
     9 import re
    11 o = 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"
    19     sys.exit(1)
    21 if not options.version:
    22     print >>sys.stderr, "--version is required"
    23     sys.exit(1)
    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]
    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]
    44 print '%s.%s.%s' % (majorVersion + twodigityear, month, day)

mercurial