source: rtems-tools/specbuilder/specbuilder/version.py @ 68c9b8a

4.104.115
Last change on this file since 68c9b8a was 68c9b8a, checked in by Chris Johns <chrisj@…>, on 08/04/12 at 12:29:24

Remove CVS Id and update the copyright year.

  • Property mode set to 100644
File size: 2.9 KB
Line 
1#
2# RTEMS Tools Project (http://www.rtems.org/)
3# Copyright 2010-2012 Chris Johns (chrisj@rtems.org)
4# All rights reserved.
5#
6# This file is part of the RTEMS Tools package in 'rtems-tools'.
7#
8# RTEMS Tools is free software: you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation, either version 3 of the License, or
11# (at your option) any later version.
12#
13# RTEMS Tools is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with RTEMS Tools.  If not, see <http://www.gnu.org/licenses/>.
20#
21
22#
23# Extract the status of the spec files found in the SPECS directory.
24# The status is the name, source and patches.
25#
26
27import os
28
29import defaults
30import error
31import spec
32
33class versions:
34    """Return the versions of packages given a spec file."""
35
36    def __init__(self, name, _defaults, opts):
37        self.opts = opts
38        self.spec = spec.file(name, _defaults = _defaults, opts = opts)
39
40    def __str__(self):
41
42        def str_package(package):
43            sources = package.sources()
44            patches = package.patches()
45            version = package.version()
46            release = package.release()
47            buildarch = package.buildarch()
48            s = '\nNAME="' + package.name() + '"'
49            if buildarch:
50                s += '\nARCH="' + buildarch + '"'
51            if version:
52                s += '\nVERSION="' + version + '"'
53            if release:
54                s += '\nRELEASE="' + release + '"'
55            if len(sources):
56                s += '\nSOURCES=%d' % (len(sources))
57                c = 1
58                for i in sources:
59                    s += '\nSOURCE%d="' % (c) + sources[i][0] + '"'
60                    c += 1
61                s += '\nPATCHES=%d' % (len(patches))
62                c = 1
63                for i in patches:
64                    s += '\nPATCH%d="' % (c) + patches[i][0] + '"'
65                    c += 1
66            return s
67
68        packages = self.spec.packages()
69        s = 'SPEC=' + os.path.basename(self.spec.name) + \
70            str_package(packages['main'])
71        for p in packages:
72            if p != 'main':
73                s += str_package(packages[p])
74        return s + '\n'
75
76def run():
77    import sys
78    try:
79        opts, _defaults = defaults.load(sys.argv)
80        for spec_file in opts.spec_files():
81            s = versions(spec_file, _defaults = _defaults, opts = opts)
82            print s
83            del s
84    except error.general, gerr:
85        print gerr
86        sys.exit(1)
87    except error.internal, ierr:
88        print ierr
89        sys.exit(1)
90    sys.exit(0)
91
92if __name__ == "__main__":
93    run()
Note: See TracBrowser for help on using the repository browser.