macversion.py 1.4 KB

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