diff --git a/source-builder/sb/reports.py b/source-builder/sb/reports.py index a67b603..6214493 100644 --- a/source-builder/sb/reports.py +++ b/source-builder/sb/reports.py @@ -266,30 +266,21 @@ class report: self.config_end(name) def buildset(self, name): - try_config = False - try: - self.bset_nesting += 1 - self.buildset_start(name) - bset = setbuilder.buildset(name, - _configs = self.configs, - _defaults = self.defaults, - opts = self.opts) - for c in bset.load(): - if c.endswith('.bset'): - self.buildset(c) - elif c.endswith('.cfg'): - self.config(c) - else: - raise error.general('invalid config type: %s' % (c)) - self.buildset_end(name) - self.bset_nesting -= 1 - except error.general, gerr: - if gerr.msg.startswith('no build set file found'): - try_config = True + self.bset_nesting += 1 + self.buildset_start(name) + bset = setbuilder.buildset(name, + _configs = self.configs, + _defaults = self.defaults, + opts = self.opts) + for c in bset.load(): + if c.endswith('.bset'): + self.buildset(c) + elif c.endswith('.cfg'): + self.config(c) else: - raise - if try_config: - self.config(name) + raise error.general('invalid config type: %s' % (c)) + self.buildset_end(name) + self.bset_nesting -= 1 def generate(self, name): if self.format == 'html': @@ -313,7 +304,15 @@ class report: def make(self, inname, outname, intro_text = None): self.setup() self.introduction(inname, intro_text) - self.buildset(inname) + config = setbuilder.find_config(inname, self.configs) + if config is None: + raise error.general('config file not found: %s' % (inname)) + if config.endswith('.bset'): + self.buildset(config) + elif config.endswith('.cfg'): + self.config(config) + else: + raise error.general('invalid config type: %s' % (config)) self.generate(outname) def run(args): diff --git a/source-builder/sb/setbuilder.py b/source-builder/sb/setbuilder.py index 800e09d..801341e 100644 --- a/source-builder/sb/setbuilder.py +++ b/source-builder/sb/setbuilder.py @@ -58,6 +58,18 @@ def _notice(opts, text): log.output(text) log.flush() +def find_config(config, configs): + if config.endswith('.bset') or config.endswith('.cfg'): + names = [config] + else: + names = ['%s.cfg' % (path.basename(config)), + '%s.bset' % (path.basename(config))] + for c in configs['files']: + if path.basename(c) in names: + if path.dirname(c).endswith(path.dirname(config)): + return c + return None + class buildset: """Build a set builds a set of packages.""" @@ -74,18 +86,6 @@ class buildset: if not self.opts.quiet(): log.output(text) - def find_config(self, config): - if config.endswith('.bset') or config.endswith('.cfg'): - names = [config] - else: - names = ['%s.cfg' % (path.basename(config)), - '%s.bset' % (path.basename(config))] - for c in self.configs['files']: - if path.basename(c) in names: - if path.dirname(c).endswith(path.dirname(config)): - return c - return None - def copy(self, src, dst): if not os.path.isdir(path.host(src)): raise error.general('copying tree: no source directory: %s' % (path.host(src))) @@ -100,7 +100,7 @@ class buildset: except distutils.errors.DistutilsFileError, err: raise error.general('copying tree: %s' % (str(err))) - def report(self, _config, tmproot): + def report(self, _config, _build): if not self.opts.get_arg('--no-report'): format = self.opts.get_arg('--report-format') if format is None: @@ -120,11 +120,13 @@ class buildset: ext = '.html' else: raise error.general('invalid report format: %s' % (format[1])) + buildroot = _build.config.abspath('%{buildroot}') prefix = self.opts.expand('%{_prefix}', self.defaults) - outname = path.host(path.join(tmproot, prefix, path.splitext(path.basename(_config))[0] + ext)) - _notice(self.opts, 'reporting: %s -> %s' % (_config, outname)) + name = path.splitext(path.basename(_config))[0] + ext + outname = path.host(path.join(buildroot, prefix, name)) + _notice(self.opts, 'reporting: %s -> %s' % (_config, name)) if not self.opts.dry_run(): - r = report.report(format, self.configs, self.defaults) + r = reports.report(format, self.configs, self.defaults, self.opts) r.make(_config, outname) del r @@ -230,7 +232,7 @@ class buildset: raise error.general('invalid directive in build set files: %s' % (l)) else: l = l.strip() - c = self.find_config(l) + c = find_config(l, self.configs) if c is None: raise error.general('cannot find file: %s' % (l)) configs += [c] @@ -289,8 +291,8 @@ class buildset: if s == 0: tmproot = self.first_package(b) b.make() + self.report(configs[s], b) self.every_package(b, tmproot) - self.report(configs[s], tmproot) if s == len(configs) - 1: self.last_package(b, tmproot) builds += [b]