2007-07-02 22:20:24 +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/.
|
|
|
|
|
2007-07-02 22:20:24 +04:00
|
|
|
|
|
|
|
from optparse import OptionParser
|
|
|
|
from datetime import datetime
|
2013-02-06 08:15:35 +04:00
|
|
|
import time
|
2007-07-02 22:20:24 +04:00
|
|
|
import sys
|
|
|
|
import os
|
|
|
|
|
|
|
|
o = OptionParser()
|
2008-01-14 18:24:19 +03:00
|
|
|
o.add_option("--buildid", dest="buildid")
|
2007-07-02 22:20:24 +04:00
|
|
|
o.add_option("--print-buildid", action="store_true", dest="print_buildid")
|
2013-02-06 08:15:35 +04:00
|
|
|
o.add_option("--print-timestamp", action="store_true", dest="print_timestamp")
|
2009-02-16 16:32:39 +03:00
|
|
|
o.add_option("--sourcestamp", dest="sourcestamp")
|
|
|
|
o.add_option("--sourcerepo", dest="sourcerepo")
|
2007-07-02 22:20:24 +04:00
|
|
|
|
|
|
|
(options, args) = o.parse_args()
|
|
|
|
|
2013-02-06 08:15:35 +04:00
|
|
|
if options.print_timestamp:
|
|
|
|
print int(time.time())
|
|
|
|
sys.exit(0)
|
|
|
|
|
2007-07-02 22:20:24 +04:00
|
|
|
if options.print_buildid:
|
2008-08-07 22:10:47 +04:00
|
|
|
print datetime.now().strftime('%Y%m%d%H%M%S')
|
2007-07-02 22:20:24 +04:00
|
|
|
sys.exit(0)
|
|
|
|
|
2008-01-14 18:24:19 +03:00
|
|
|
if not options.buildid:
|
|
|
|
print >>sys.stderr, "--buildid is required"
|
|
|
|
sys.exit(1)
|
|
|
|
|
2007-07-02 22:20:24 +04:00
|
|
|
(milestoneFile,) = args
|
|
|
|
for line in open(milestoneFile, 'r'):
|
|
|
|
if line[0] == '#':
|
|
|
|
continue
|
|
|
|
|
|
|
|
line = line.strip()
|
|
|
|
if line == '':
|
|
|
|
continue
|
|
|
|
|
|
|
|
milestone = line
|
|
|
|
|
|
|
|
print """[Build]
|
|
|
|
BuildID=%s
|
2008-01-14 18:24:19 +03:00
|
|
|
Milestone=%s""" % (options.buildid, milestone)
|
2009-02-16 16:32:39 +03:00
|
|
|
if options.sourcestamp:
|
|
|
|
print "SourceStamp=%s" % options.sourcestamp
|
|
|
|
if options.sourcerepo:
|
|
|
|
print "SourceRepository=%s" % options.sourcerepo
|