2007-07-02 11:20:24 -07:00
|
|
|
#!/usr/bin/python
|
2012-05-21 04:12:37 -07: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 11:20:24 -07:00
|
|
|
|
|
|
|
from optparse import OptionParser
|
|
|
|
from datetime import datetime
|
2013-02-05 20:15:35 -08:00
|
|
|
import time
|
2007-07-02 11:20:24 -07:00
|
|
|
import sys
|
|
|
|
import os
|
|
|
|
|
|
|
|
o = OptionParser()
|
2008-01-14 07:24:19 -08:00
|
|
|
o.add_option("--buildid", dest="buildid")
|
2007-07-02 11:20:24 -07:00
|
|
|
o.add_option("--print-buildid", action="store_true", dest="print_buildid")
|
2013-02-05 20:15:35 -08:00
|
|
|
o.add_option("--print-timestamp", action="store_true", dest="print_timestamp")
|
2009-02-16 05:32:39 -08:00
|
|
|
o.add_option("--sourcestamp", dest="sourcestamp")
|
|
|
|
o.add_option("--sourcerepo", dest="sourcerepo")
|
2007-07-02 11:20:24 -07:00
|
|
|
|
|
|
|
(options, args) = o.parse_args()
|
|
|
|
|
2013-02-05 20:15:35 -08:00
|
|
|
if options.print_timestamp:
|
|
|
|
print int(time.time())
|
|
|
|
sys.exit(0)
|
|
|
|
|
2007-07-02 11:20:24 -07:00
|
|
|
if options.print_buildid:
|
2008-08-07 11:10:47 -07:00
|
|
|
print datetime.now().strftime('%Y%m%d%H%M%S')
|
2007-07-02 11:20:24 -07:00
|
|
|
sys.exit(0)
|
|
|
|
|
2008-01-14 07:24:19 -08:00
|
|
|
if not options.buildid:
|
|
|
|
print >>sys.stderr, "--buildid is required"
|
|
|
|
sys.exit(1)
|
|
|
|
|
2007-07-02 11:20:24 -07: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 07:24:19 -08:00
|
|
|
Milestone=%s""" % (options.buildid, milestone)
|
2009-02-16 05:32:39 -08:00
|
|
|
if options.sourcestamp:
|
|
|
|
print "SourceStamp=%s" % options.sourcestamp
|
|
|
|
if options.sourcerepo:
|
|
|
|
print "SourceRepository=%s" % options.sourcerepo
|