Changeset e8f5111 in rtems-source-builder


Ignore:
Timestamp:
Dec 3, 2015, 11:22:17 AM (4 years ago)
Author:
Chris Johns <chrisj@…>
Branches:
4.11
Children:
d963c671
Parents:
0d59530
Message:

sb. Add VERSION support for releasing the RSB.

Add support to release the RSB by adding the VERSION file. The file
is a single line with the version.

Fix the reports to include the version. Update the INI file
support to include the details of the build.

Show the GIT or released version when the command starts.

Closes #2480.

Location:
source-builder
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • source-builder/defaults.mc

    r0d59530 re8f5111  
    4545release:             none,    none,     ''
    4646buildname:           none,    none,     '%{name}'
     47
     48# The default is not release.
     49is_rsb_release:      none,    none,     '0'
    4750
    4851# GNU triples needed to build packages
  • source-builder/sb/bootstrap.py

    r0d59530 re8f5111  
    243243        optargs = { '--rtems':       'The RTEMS source directory',
    244244                    '--preinstall':  'Preinstall AM generation' }
    245         log.notice('RTEMS Source Builder - RTEMS Bootstrap, v%s' % (version.str()))
     245        log.notice('RTEMS Source Builder - RTEMS Bootstrap, %s' % (version.str()))
    246246        opts = options.load(sys.argv, optargs)
    247247        if opts.get_arg('--rtems'):
  • source-builder/sb/build.py

    r0d59530 re8f5111  
    535535        optargs = { '--list-configs': 'List available configurations' }
    536536        opts = options.load(args, optargs)
    537         log.notice('RTEMS Source Builder, Package Builder v%s' % (version.str()))
     537        log.notice('RTEMS Source Builder, Package Builder, %s' % (version.str()))
    538538        if not check.host_setup(opts):
    539539            if not opts.force():
  • source-builder/sb/check.py

    r0d59530 re8f5111  
    163163    try:
    164164        _opts = options.load(args = sys.argv)
    165         log.notice('RTEMS Source Builder - Check, v%s' % (version.str()))
     165        log.notice('RTEMS Source Builder - Check, %s' % (version.str()))
    166166        if host_setup(_opts):
    167167            print 'Environment is ok'
  • source-builder/sb/options.py

    r0d59530 re8f5111  
    302302                self.defaults.load(rsb_macros)
    303303
     304    def sb_released(self):
     305        if version.released():
     306            self.defaults['is_rsb_released'] = '1'
     307            self.defaults['_sbreleased'] = '1'
     308            self.defaults['_sbversion'] = version.str()
     309
    304310    def sb_git(self):
    305311        repo = git.repo(self.defaults.expand('%{_sbdir}'), self)
     
    614620        o.defaults[k] = overrides[k]
    615621
     622    o.sb_released()
    616623    o.sb_git()
    617624    o.rtems_options()
     
    624631    try:
    625632        _opts = load(args = args, defaults = 'defaults.mc')
    626         log.notice('RTEMS Source Builder - Defaults, v%s' % (version.str()))
     633        log.notice('RTEMS Source Builder - Defaults, %s' % (version.str()))
    627634        _opts.log_info()
    628635        log.notice('Options:')
  • source-builder/sb/reports.py

    r0d59530 re8f5111  
    11#
    22# RTEMS Tools Project (http://www.rtems.org/)
    3 # Copyright 2010-2013 Chris Johns (chrisj@rtems.org)
     3# Copyright 2010-2015 Chris Johns (chrisj@rtems.org)
    44# All rights reserved.
    55#
     
    5454_title = 'RTEMS Tools Project <users@rtems.org>'
    5555
     56_release_status_text = 'RTEMS Source Builder Release'
    5657_git_status_text = 'RTEMS Source Builder Repository Status'
    5758
     
    105106    def buildset_start(self, nest_level, name):
    106107        self.line('=-' * (_line_len / 2))
    107         self.line('Build Set: %s' % (name))
     108        self.line('Build Set: (%d) %s' % (nest_level, name))
    108109
    109110    def buildset_end(self, nest_level, name):
     
    166167        if intro_text:
    167168            self.line('%s' % ('\n'.join(intro_text)))
     169
     170    def release_status(self, release_string):
     171        self.line('')
     172        self.line("'''")
     173        self.line('')
     174        self.line('.%s' % (_release_status_text))
     175        self.line('*Version*: %s;;' % (release_string))
     176        self.line('')
     177        self.line("'''")
     178        self.line('')
    168179
    169180    def git_status(self, valid, dirty, head, remotes):
     
    294305        self.line('Report: %s' % (name))
    295306
     307    def release_status_header(self):
     308        self.line('-' * _line_len)
     309        self.line('%s' % (_release_status_text))
     310
     311    def release_status(self, release_string):
     312        self.release_status_header()
     313        self.line('%s Version: %s' % (self.cini, release_string))
     314
    296315    def git_status_header(self):
    297316        self.line('-' * _line_len)
     
    325344        super(ini_formatter, self).__init__()
    326345        self.cini = ';'
     346        self.ini_pkg = {}
     347        self.name = None
    327348
    328349    def format(self):
     
    340361            self.line(';')
    341362
     363    def epilogue(self, name):
     364        pkgs = sorted(self.ini_pkg.keys())
     365        for pkg in pkgs:
     366            self.line('')
     367            self.line('[%s]' % (pkg))
     368            items = sorted(self.ini_pkg[pkg].keys())
     369            for item in items:
     370                i = self.ini_pkg[pkg][item]
     371                if len(i) == 1:
     372                    self.line('%s = "%s"' % (item, i[0]))
     373                else:
     374                    self.line('%s = <<<DATA' % (item))
     375                    self.line('\n'.join(i))
     376                    self.line('DATA')
     377        self.line('')
     378
     379    def release_status_header(self):
     380        self.line(';')
     381        self.line('; %s' % (_release_status_text))
     382
    342383    def git_status_header(self):
    343384        self.line(';')
     
    346387
    347388    def config(self, nest_level, name, _config):
    348         return
     389        pass
    349390
    350391    def buildset_start(self, nest_level, name):
    351         return
     392        if name.endswith('.cfg'):
     393            self.name = path.basename(name[:-4])
     394            if self.name not in self.ini_pkg:
     395                self.ini_pkg[self.name] = {}
     396
     397    def buildset_end(self, nest_level, name):
     398        self.name = None
    352399
    353400    def info(self, nest_level, name, info, separated):
    354         return
     401        if self.name:
     402            if 'info' not in self.ini_pkg[self.name]:
     403                self.ini_pkg[self.name]['info'] = []
     404            self.ini_pkg[self.name]['info'] += info
    355405
    356406    def directive(self, nest_level, name, data):
    357         return
     407        if self.name:
     408            if name not in self.ini_pkg[self.name]:
     409                self.ini_pkg[self.name][name] = []
     410            self.ini_pkg[self.name][name] += data
    358411
    359412    def files(self, nest_level, singular, plural, _files):
    360         return
     413        pass
    361414
    362415class xml_formatter(formatter):
     
    377430    def epilogue(self, name):
    378431        self.line('</RTEMSSourceBuilderReport>')
     432
     433    def release_status(self, release_string):
     434        self.line('\t<Release>')
     435        self.line('\t\t<Version>%s</Version>' % (release_string))
     436        self.line('\t</Release>')
    379437
    380438    def git_status(self, valid, dirty, head, remotes):
     
    470528
    471529    def output(self, text):
    472         self.out += text + '\n'
     530        self.formatter.line(text)
    473531
    474532    def is_ini(self):
     
    480538    def footer(self):
    481539        pass
     540
     541    def release_status(self):
     542        self.formatter.release_status(version.str())
    482543
    483544    def git_status(self):
     
    488549        now = datetime.datetime.now().ctime()
    489550        self.formatter.introduction(name, now, intro_text)
    490         self.git_status()
     551        if version.released():
     552            self.release_status()
     553        else:
     554            self.git_status()
    491555
    492556    def epilogue(self, name):
     
    505569
    506570    def buildset_start(self, name):
     571        self.bset_nesting += 1
    507572        self.files['buildsets'] += [name]
    508573        self.formatter.buildset_start(self.bset_nesting, name)
     
    510575    def buildset_end(self, name):
    511576        self.formatter.buildset_end(self.bset_nesting, name)
     577        self.bset_nesting -= 1
    512578
    513579    def source(self, macros):
     
    546612        if directive is not None:
    547613            self.formatter.directive(self.bset_nesting + 2, name, directive)
     614
     615    def tree_packages(self, tree, packages = []):
     616        if 'bset' in tree:
     617            for node in sorted(tree['bset'].keys()):
     618                packages += [_tree_name(node)]
     619                packages += self.tree_packages(tree['bset'][node], packages)
     620        return set(packages)
    548621
    549622    def tree_sources(self, name, tree, sources = []):
     
    627700                                       prefix)
    628701
    629     def generate_ini_node(self, name, tree, sections = []):
    630         if name not in sections:
    631             sections += [name]
    632             self.output('')
    633             self.output('[%s]' % (name))
    634             if 'bset' in tree and len(tree['bset']):
    635                 self.output(' packages = %s' % \
    636                                 (', '.join([_tree_name(n) for n in sorted(tree['bset'])])))
    637             if 'cfg' in tree:
    638                 packages = {}
    639                 if 'sources' in tree['cfg']:
    640                     _merge(packages, tree['cfg']['sources'])
    641                 if 'patches' in tree['cfg']:
    642                     _merge(packages, tree['cfg']['patches'])
    643                 for package in packages:
    644                     self.output(' %s = %s' % (package, ', '.join([s[0] for s in packages[package]])))
    645             if 'bset' in tree:
    646                 for node in sorted(tree['bset'].keys()):
    647                     self.generate_ini_node(_tree_name(node), tree['bset'][node], sections)
    648 
    649702    def generate_ini_source(self, sources):
    650703        self.output('')
     
    665718
    666719    def generate_ini(self):
    667         #self.output(pp.pformat(self.tree))
    668720        nodes = sorted([node for node in self.tree.keys() if node != 'bset'])
    669721        self.output(';')
     
    682734        self.generate_ini_source(sources)
    683735        self.generate_ini_hash(sources)
    684         for node in nodes:
    685             self.generate_ini_node(_tree_name(node), self.tree[node])
    686736
    687737    def write(self, name):
    688738        self.out = self.formatter.post_process()
    689         if self.is_ini():
    690             self.generate_ini()
    691739        if name is not None:
    692740            try:
     
    699747
    700748    def generate(self, name, tree = None, opts = None, macros = None):
    701         self.bset_nesting += 1
    702749        self.buildset_start(name)
    703750        if tree is None:
     
    716763                self.generate(c, tree[name]['bset'], bset.opts, macros)
    717764            elif c.endswith('.cfg'):
     765                self.buildset_start(c)
    718766                self.config(config.file(c, bset.opts, macros),
    719767                            tree[name]['cfg'], bset.opts, macros)
     768                self.buildset_end(c)
    720769            else:
    721770                raise error.general('invalid config type: %s' % (c))
    722771        self.buildset_end(name)
    723         self.bset_nesting -= 1
    724772
    725773    def create(self, inname, outname = None, intro_text = None):
    726774        self.introduction(inname, intro_text)
    727775        self.generate(inname)
     776        if self.is_ini():
     777            self.generate_ini()
    728778        self.epilogue(inname)
    729779        self.write(outname)
     
    738788        if opts.get_arg('--output') and len(opts.params()) > 1:
    739789            raise error.general('--output can only be used with a single config')
    740         print 'RTEMS Source Builder, Reporter v%s' % (version.str())
     790        print 'RTEMS Source Builder, Reporter, %s' % (version.str())
    741791        opts.log_info()
    742792        if not check.host_setup(opts):
  • source-builder/sb/rtemsconfig.py

    r0d59530 re8f5111  
    192192
    193193        if opts.get_arg('--list'):
    194             log.notice('RTEMS Source Builder - RTEMS Configuration, v%s' % (version.str()))
     194            log.notice('RTEMS Source Builder - RTEMS Configuration, %s' % (version.str()))
    195195            opts.log_info()
    196196            configs = bsp.keys()
  • source-builder/sb/setbuilder.py

    r0d59530 re8f5111  
    469469        mailer.append_options(optargs)
    470470        opts = options.load(sys.argv, optargs)
    471         log.notice('RTEMS Source Builder - Set Builder, v%s' % (version.str()))
     471        log.notice('RTEMS Source Builder - Set Builder, %s' % (version.str()))
    472472        opts.log_info()
    473473        if not check.host_setup(opts):
  • source-builder/sb/version.py

    r0d59530 re8f5111  
    11#
    22# RTEMS Tools Project (http://www.rtems.org/)
    3 # Copyright 2010-2014 Chris Johns (chrisj@rtems.org)
     3# Copyright 2010-2015 Chris Johns (chrisj@rtems.org)
    44# All rights reserved.
    55#
     
    1919
    2020#
    21 # Manage paths locally. The internally the path is in Unix or shell format and
    22 # we convert to the native format when performing operations at the Python
    23 # level. This allows macro expansion to work.
     21# To release the RSB create a git archive and then add a suitable VERSION file
     22# to the top directory.
    2423#
     24
     25import sys
     26
     27import error
     28import git
     29import path
    2530
    2631major = 4
     
    2833revision = 0
    2934
     35#
     36# Default to an internal string.
     37#
     38_version_str =  '%d.%d.%d' % (major, minor, revision)
     39_released = False
     40_git = False
     41
     42def _top():
     43    top = path.dirname(sys.argv[0])
     44    if len(top) == 0:
     45        top = '.'
     46    return top
     47
     48def _load_released_version():
     49    global _released
     50    global _version_str
     51    top = _top()
     52    for ver in [top, '..']:
     53        if path.exists(path.join(ver, 'VERSION')):
     54            try:
     55                with open(path.join(ver, 'VERSION')) as v:
     56                    _version_str = v.readline().strip()
     57                v.close()
     58                _released = True
     59            except:
     60                raise error.general('Cannot access the VERSION file')
     61    return _released
     62
     63def _load_git_version():
     64    global _git
     65    global _version_str
     66    repo = git.repo(_top())
     67    if repo.valid():
     68        head = repo.head()
     69        if repo.dirty():
     70            modified = ' modified'
     71        else:
     72            modified = ''
     73        _version_str = '%d.%d.%d (%s%s)' % (major, minor, revision, head[0:12], modified)
     74        _git = True
     75    return _git
     76
     77def released():
     78    return _load_released_version()
     79
     80def version_control():
     81    return _load_git_version()
     82
    3083def str():
    31     return '%d.%d.%d'% (major, minor, revision)
     84    if not _released and not _git:
     85        if not _load_released_version():
     86            _load_git_version()
     87    return _version_str
    3288
    3389if __name__ == '__main__':
Note: See TracChangeset for help on using the changeset viewer.