Prettify error messages for invalid component names
[matrix.git] / matrix / matrix.py
index 11d9aaa..4bf796a 100644 (file)
 #          Kalle Vahlman <kalle.vahlman@movial.fi>
 #          Tuomas Kulve <tuomas.kulve@movial.fi>
 
-import glob
+import optparse
 import os
-import re
 import sys
-import tarfile
 from sets import Set as set
 
-import config
+import cache
+import components
 import git
-from rootfs import RootFS
+import log
+from config import config
+from config import parse as config_parse
+from build import build, build_only
 
 Error = RuntimeError
 
-def main():
-       parse_config('config.local')
+def merge_config(name, value):
+       if isinstance(value, list):
+               value = getattr(config, name, []) + value
+       setattr(config, name, value)
 
-       command, params, targets = parse_args(sys.argv)
+def main(version):
+       command, targets, options = parse_args(version)
 
-       parse_config('config')
-       parse_config('boards')
-       parse_config('components')
+       for name in ('debug', 'initial_config_dirs', 'pull_config_dirs'):
+               if name in options:
+                       merge_config(name, options[name])
 
-       if 'global-cache' in config.flags:
-               config.cache_dir = config.global_cache_dir
+       config_parse('main', True)
 
-       if not os.path.exists(config.cache_dir):
-               os.makedirs(config.cache_dir)
+       for name in options:
+               merge_config(name, options[name])
 
-       all_targets = update_components()
+       for i in xrange(len(targets)):
+               name = targets[i]
+               if name.startswith('src' + os.path.sep):
+                       name = name.split(os.path.sep)[1]
+                       targets[i] = name
 
-       for name in targets:
-               if name not in config.components:
-                       raise Error('Component "%s" does not exist' % name)
+       cache.init()
+       components.init(targets)
 
        if not targets:
-               targets = all_targets
-
-       if command == 'install':
-               build_components(targets, **params)
-       elif command == 'download':
-               # Actual downloading took place already in update_components()
-               pass
-       elif command == 'clean':
-               clean_components(targets)
-       elif command == 'pull':
-               pull_components(targets)
-       elif command == 'source-dist':
-               source_dist_components(targets)
-       elif command == 'rootfs':
-               build_rootfs(**params)
-       else:
-               raise Error('Invalid command: ' + command)
-
-def help(file, args):
+               targets = components.by_name.keys()
+               targets.sort()
+
+       command_funcs = {
+               'install':      build,
+               'install-only': build_only,
+               'meta':         meta,
+               'clone':        clone,
+               'clean':        clean,
+               'update':       update,
+               'rebase':       rebase,
+               'update-rebase':update_rebase,
+               'pull':         pull,
+               'changes':      changes,
+               'source-dist':  source_dist,
+       }
+
+       func = command_funcs.get(command)
+       if not func:
+               raise Error('Invalid command: "%s"' % command)
+
+       func(targets)
+
+def print_help(file, parser):
+       parser.print_help(file=file)
        print >>file, '''
-Copyright (C) 2006-2008 Movial Oy
-
-Usage: %(progname)s [options] [command] [params] [component1 component2 ...]
-
-Components must be given like this: core/glibc core/busybox X/xserver
-If no components are given, all of them will be subject to the operation.
-
-Options:
-       -v              Verbose output
-       -d              Debug output
-       -r URL          Specify the root for component git repos to clone from.
-                       If this option is not given, the default specified in
-                       the components file will be used.  This option may be
-                       specified multiple times.
-       -h, --help      Print this help text.
-
-Commands and their parameters:
-
-       download        Only download the components and validate the tree.
-       install         Download, build and install the components.
-               -j N            Execute N build jobs in parallel.
-               -mj N           Run component builds with make -j N.
-       clean           Remove all non-tracked files from the component git
-                       repository directories.
-       pull            Run git pull for the components.
-       source-dist     Download and package the component sources.
-       rootfs          Build a rootfs from the current target installation.
-               -n              Do not clean env.faked and stripped directory.
-               -r              Only generate a stripped rootfs.
-               -j              Only generate a jffs2 image
-               -d              Only generate a rootstrap (development rootfs).
-       list [parameter] [pattern]
-               -p              List packages.
-               -pv             List packages with full details.
-               -c              List components (default).
-               -cdep           List components and their dependencies.
-''' % {'progname': args[0]}
-
-def parse_args(args):
-       def parse_jobs(arg):
-               jobs = int(arg)
-               if jobs <= 0:
-                       raise Error('Please specify a valid number of jobs')
-               return jobs
-
-       command = None
-       params = {}
-       targets = []
-
-       i = 1
-       while i < len(args):
-               if args[i].startswith('-'):
-                       if not command:
-                               if args[i] == '-v':
-                                       config.verbose = True
-                               elif args[i] == '-d':
-                                       config.debug = True
-                               elif args[i] == '-r':
-                                       i += 1
-                                       config.roots.append(args[i])
-                               elif args[i] in ('-h', '--help'):
-                                       help(sys.stdout, args)
-                                       sys.exit(0)
-                               else:
-                                       raise Error('Bad option: ' + args[i])
-                       elif command == 'install':
-                               if args[i] == '-j':
-                                       i += 1
-                                       params['build_jobs'] = parse_jobs(args[i])
-                               elif args[i] == '-mj':
-                                       i += 1
-                                       params['make_jobs'] = parse_jobs(args[i])
-                               else:
-                                       raise Error('Bad parameter: ' + args[i])
-                       elif command == 'rootfs':
-                               if args[i] == '-n':
-                                       i += 1
-                                       params['clean'] = False
-                               elif args[i] == '-r':
-                                       i += 1
-                                       params['rootfs_only'] = True
-                               elif args[i] == '-j':
-                                       i += 1
-                                       params['jffs2_only'] = True
-                               elif args[i] == '-d':
-                                       i += 1
-                                       params['devrootfs_only'] = True
-                       else:
-                               raise Error('Command takes no parameters')
-               elif not command:
-                       command = args[i]
-               else:
-                       targets.append(args[i])
-               i += 1
-
-       if not command:
-               help(sys.stderr, args)
+commands:
+  meta          download the components' meta repositories
+  clone         download the components' git repositories
+  install       download, build and install the components
+  install-only  download, build and install the specified components without
+                dependencies
+  clean         remove all non-tracked files from the component git repository
+                directories
+  update        download remote repositories from server
+  rebase        rebase local repositories against remote repositories (remotes
+                won't be updated first)
+  update-rebase update remote repositories and rebase local repositories
+  pull          update remote repositories and merge with local repositories
+  changes       show commits which are not on the server
+  source-dist   download and package the component sources
+'''
+
+def parse_args(matrix_version):
+       options = {}
+
+       def help(option, opt, value, parser):
+               print_help(sys.stdout, parser)
+               sys.exit(0)
+
+       def version(option, opt, value, parser):
+               print matrix_version
+               sys.exit(0)
+
+       def set_flag(option, opt, value, parser):
+               options[option.dest] = True
+
+       def set_jobs(option, opt, value, parser):
+               if value < 1:
+                       raise optparse.OptionValueError(
+                               'option %s: invalid job count: %d' % \
+                               (opt, value))
+               options[option.dest] = value
+
+       def append(option, opt, value, parser):
+               l = options.get(option.dest, [])
+               if not l:
+                       options[option.dest] = l
+               l.append(value)
+
+       parser = optparse.OptionParser(
+               usage='%prog [<options>] <command> [<components>]',
+               add_help_option=False)
+
+       parser.add_option(
+               '-h', '--help',
+               help='show this help message and exit',
+               action='callback', callback=help)
+
+       parser.add_option(
+               '--version',
+               help='print Matrix version',
+               action='callback', callback=version)
+
+       parser.add_option(
+               '-v', '--verbose',
+               help='show build output',
+               dest='verbose', action='callback', callback=set_flag)
+
+       parser.add_option(
+               '-d', '--debug',
+               help='debug output',
+               dest='debug', action='callback', callback=set_flag)
+
+       parser.add_option(
+               '-c', '--config-dir', metavar='DIR',
+               help='add a directory for finding config files (may be set ' \
+                    'multiple times)',
+               dest='initial_config_dirs', action='callback', callback=append,
+               type='string')
+
+       parser.add_option(
+               '-p', '--pull-config-dirs',
+               help='git-pull config dirs which are backed by Git repositories',
+               dest='pull_config_dirs', action='callback', callback=set_flag)
+
+       parser.add_option(
+               '-r', '--root', metavar='URL',
+               help='add a location for finding git repos when cloning ' \
+                    '(may be set multiple times)',
+               dest='roots', action='callback', callback=append,
+               type='string')
+
+       parser.add_option(
+               '-f', '--force',
+               help='build (or be quiet about) components with dirty files',
+               dest='force', action='callback', callback=set_flag)
+
+       parser.add_option(
+               '-k', '--keep-going',
+               help='build as much as possible after an error',
+               dest='keep_going', action='callback', callback=set_flag)
+
+       parser.add_option(
+               '-j', '--jobs',
+               help='execute up to N build jobs in parallel', metavar='N',
+               dest='jobs', action='callback', callback=set_jobs,
+               type='int')
+
+       parser.add_option(
+               '-J', '--make-jobs',
+               help='run component builds with make -j N', metavar='N',
+               dest='make_jobs', action='callback', callback=set_jobs,
+               type='int')
+
+       values, args = parser.parse_args(values=None)
+       if not args:
+               print_help(sys.stderr, parser)
                sys.exit(1)
 
-       return command, params, targets
-
-def parse_config(path):
-       if os.path.isabs(path):
-               path = os.path.join(config.top_dir, path)
-
-       if os.path.exists(path):
-               print 'Reading', path
-               execfile(path, config.__dict__, config.__dict__)
-
-def update_components():
-       targets = []
-       packages = {}
-
-       for c in config.components.itervalues():
-               update_component_url(c)
-               download_component(c)
-               update_component_packages(c, targets, packages)
-               c.active_depends = []
-
-       update_component_depends(packages)
-
-       return targets
-
-def update_component_url(c):
-       update_repository_url(c.repo)
-       update_repository_url(c.meta)
-
-def update_repository_url(repo):
-       url = git.getvar(repo.path, 'remote.origin.url')
-       if url:
-               repo.active_url = url
-               if config.debug:
-                       print 'Using', repo.active_url
-               return
-
-       for root in config.roots:
-               for suffix in ('.git', ''):
-                       url = '%s/%s%s' % (root, repo.name, suffix)
-
-                       if config.debug:
-                               print 'Trying', url
-
-                       if not git.peek_remote(url, quiet=True):
-                               continue
-
-                       repo.active_url = url
-                       if config.debug:
-                               print 'Found', repo.active_url
-                       return
-
-       raise Error('Failed to locate repository: ' + repo.name)
-
-def update_component_depends(packages):
-       for pkg in packages.itervalues():
-               for spec in pkg.depends.split():
-                       depname = Depend(spec).name
-                       deppkg = packages.get(depname)
-
-                       if not deppkg:
-                               print >>sys.stderr, 'Package', pkg.name, \
-                                       'depends on non-existent package', depname
-                               continue
-
-                       if deppkg.component == pkg.component:
-                               continue
-
-                       pkg.component.active_depends.append(deppkg.component)
-
-       fail = False
-       for pkg in packages.itervalues():
-               for spec in pkg.depends.split():
-                       if not Depend(spec).check(packages):
-                               fail = True
-                               print >>sys.stderr, 'Dependency', spec, \
-                                       'failed for', pkg.name
-
-               for spec in pkg.conflicts.split():
-                       if Depend(spec).check(packages):
-                               fail = True
-                               print >>sys.stderr, pkg.name, \
-                                       'conflicts with', spec
-
-       if fail:
-               raise Error('Invalid component tree')
-
-class Depend(object):
-       regex = re.compile(r'([@]?)([^\s:]+)[:]?([<>=]*)([^\s:]*)[:]?(.*)')
-
-       def __init__(self, spec):
-               match = self.regex.match(spec)
-               if not match:
-                       raise Error('Bad dependency specification: ' + spec)
-
-               self.build, self.name, self.tag_op, self.tag, flags \
-                       = match.groups()
-               self.flags = flags.split()
-
-       def check(self, packages):
-               # TODO: check version and flags
-               return self.name in packages
+       return args[0], args[1:], options
 
 def execute(args):
        if config.debug:
@@ -267,361 +195,145 @@ def execute(args):
        if os.spawnvp(os.P_WAIT, args[0], args) != 0:
                raise Error('Failed: ' + ' '.join(args))
 
-def download_component(c, overwrite=False):
-       if os.path.exists(c.repo.path) and not overwrite:
-               return
-
-       print 'Downloading component:', c.name
-
-       execute(['rm', '-rf', c.repo.path])
-       download_repository(c, c.repo)
-       download_repository(c, c.meta)
-
-def download_repository(c, repo):
-       if config.debug:
-               print 'Downloading repository:', repo.name
-
-       git.clone(repo.path, repo.active_url, checkout=False)
-
-       branch = c.get_active_tag()
-       git.create_branch(repo.path, branch, 'origin/%s' % branch,
-                         checkout=True, link=True, force=True)
-
-def update_component_packages(c, targets, packages):
-       c.active_packages = {}
-
-       for path in glob.glob(os.path.join(c.meta.path, '*.package')):
-               name = os.path.basename(path)[:-8]
+def remove_tree(path):
+       execute(['rm', '-rf', path])
 
-               pkg = parse_package(name, c, path)
-               if not pkg:
-                       continue
-
-               c.active_packages[name] = pkg
-               packages[name] = pkg
-
-               if config.debug:
-                       print 'Component', c.name, 'provides', name
-
-       if c.active_packages:
-               targets.append(c.name)
-       elif config.debug:
-               print 'Component', c.name, 'does not provide any packages'
-
-class Package(object):
-       def __init__(self, name, component):
-               self.name = name
-               self.component = component
-
-               self.depends = []
-               self.conflicts = []
-               self.architectures = None
-
-def parse_package(name, component, path):
-       pkg = Package(name, component)
-       execfile(path, pkg.__dict__, pkg.__dict__)
-
-       if pkg.architectures:
-               arch = config.boards[config.board].arch
-               if arch not in pkg.architectures:
-                       return None
-
-       return pkg
-
-def build_components(targets, build_jobs=1, make_jobs=1):
-       selected = set([config.components[i] for i in targets])
-
-       depends = None
-       while depends is None or depends:
-               depends = set()
+def find_component(name):
+       try:
+               return components.by_name[name]
+       except KeyError:
+               raise Error("Component " + name + " not found");
 
-               for c in selected:
-                       for dep in c.active_depends:
-                               if dep not in selected:
-                                       depends.add(dep)
+def meta(targets):
+       for name in targets:
+               c = find_component(name)
+               if not c.meta.exists():
+                       c.meta.clone()
+       
+def clone(targets):
+       for name in targets:
+               c = find_component(name)
+               clone_component(c)
 
-               selected |= depends
+def clone_component(c, overwrite=False):
+       have_source = c.source.exists()
+       have_meta = c.meta.exists()
 
-       components = list(selected)
-       components.sort()
+       if not overwrite and have_source and have_meta:
+               return
 
-       if config.debug:
-               print 'Building components:'
-               for c in components:
-                       print '\t' + c.name
-
-       jobs = {}
-
-       while True:
-               found = False
-               for c in components:
-                       if len(jobs) >= build_jobs:
-                               break
-
-                       if component_buildable(c):
-                               found = True
-
-                               if not component_cached(c):
-                                       print 'Starting to build', c.name
-                                       start_job(c, jobs, make_jobs)
-                               else:
-                                       print c.name, 'found from cache'
-                                       c.active_state = 'built'
-
-               if not found and not jobs:
-                       for c in components:
-                               if c.active_state != 'built':
-                                       raise Error('Internal error')
-                       break
-
-               wait_for_job(jobs)
-
-def component_buildable(c):
-       if c.active_state:
-               if config.debug:
-                       print c.name, 'is in state:', c.active_state
-               return False
-
-       for dep in c.active_depends:
-               if config.components[dep.name].active_state != 'built':
-                       if config.debug:
-                               print c.name, 'depends on unbuilt', dep.name
-                       return False
-
-       return True
-
-def component_cached(c):
-       if c.from_platform:
-               return True
-
-       ls_opts = ['-m', '-d']
-       if git.ls_files(c.repo.path, ls_opts):
-               raise Error('Component contains dirty files: ' + c.name)
-       if git.ls_files(c.meta.path, ls_opts):
-               raise Error('Component contains dirty meta files: ' + c.name)
-
-       path = os.path.join(config.cache_dir, c.name)
-       if not os.path.exists(path):
-               return False
-
-       file = open(path, 'r')
-       line = file.readline()
-       file.close()
-
-       match = re.match(r'([^\s]+)[\s]?([^\s]*)', line)
-       if not match:
-               return False
-
-       hash, flagstring = match.groups()
-
-       if hash != get_component_hash(c):
-               print 'Component has been changed:', c.name
-               return False
-
-       if flagstring:
-               flags = flagstring.split(',')
-       else:
-               flags = []
+       if overwrite and os.path.exists(c.source.path):
+               print 'Removing', c
 
-       if set(flags) != set(c.flags):
-               print 'Component flags have been changed:', c.name
-               return False
+               remove_tree(c.source.path)
+               have_source = False
+               have_meta = False
 
-       return True
+       if not have_source:
+               c.source.clone()
+       if not have_meta:
+               c.meta.clone()
 
-def update_cache(c):
-       path = os.path.join(config.cache_dir, c.name)
+def clean(targets):
+       changed = False
 
-       dir = os.path.dirname(path)
-       if not os.path.exists(dir):
-               os.makedirs(dir)
+       for name in targets:
+               c = find_component(name)
+               c.source.clean()
+               cache.remove(c)
 
-       file = open(path, 'w')
-       done = False
-       try:
-               print >>file, get_component_hash(c.repo), ','.join(c.flags)
-               done = True
-       finally:
-               file.close()
-               if not done:
-                       os.remove(path)
-
-def get_component_hash(c):
-       return '%s+%s' % (get_repository_hash(c.repo), get_repository_hash(c.meta))
-
-def get_repository_hash(repo):
-       if repo.active_hash is None:
-               repo.active_hash = git.rev_parse(repo.path, 'HEAD')
-       return repo.active_hash
-
-def start_job(c, jobs, make_jobs):
-       board = config.boards[config.board]
-
-       makefile = os.path.join(config.script_dir, 'matrix.mak')
-
-       workdir = os.path.join(config.top_dir, 'src', c.name)
-       args = ['make', '--no-print-directory', '-f', makefile, '-C', workdir,
-               '-j', str(make_jobs), 'build_matrix_component',
-               'MATRIX_TOPDIR='    + config.top_dir,
-               'MATRIX_SCRIPTDIR=' + config.script_dir,
-               'MATRIX_COMPONENT=' + c.name,
-               'MATRIX_ARCH='      + board.arch,
-               'MATRIX_GCC_MARCH=' + board.gcc_march,
-               'MATRIX_GCC_MCPU='  + board.gcc_mcpu,
-               'MATRIX_GCC_MFPU='  + board.gcc_mfpu,
-               'MATRIX_GCC_OPTIONS=' + board.gcc_options,
-               'MATRIX_GNU_HOST='  + board.gnu_host,
-               'MATRIX_LIBC='      + config.libc]
-
-       for flag in config.flags:
-               args.append(flag + '=1')
-
-       if config.verbose:
-               args.append('MATRIX_VERBOSE=1')
+               if not config.force:
+                       changed = check_dirty(c)
 
-       if config.debug:
-               print 'Executing:', ' '.join(args)
+       if changed:
+               raise Error()
 
-       pid = os.spawnvp(os.P_NOWAIT, args[0], args)
+def for_each_repository(func, targets=None):
+       ret = None
 
-       jobs[pid] = c
-       c.active_state = 'running'
+       for name in targets:
+               c = find_component(name)
+               if c.source.exists():
+                       value = func(c.source)
+                       if value:
+                               ret = value
+               value = func(c.meta)
+               if value:
+                       ret = value
 
-def wait_for_job(jobs):
-       if not jobs:
-               return
+       return ret
 
-       pid, status = os.wait()
+def update(targets):
+       for_each_repository(lambda repo: repo.update(), targets)
 
-       c = jobs.get(pid)
-       if not c:
-               return
+def rebase(targets):
+       for_each_repository(lambda repo: repo.rebase(), targets)
 
-       del jobs[pid]
+def update_rebase(targets):
+       def action(repo):
+               repo.update()
+               repo.rebase()
 
-       if status == 0:
-               c.active_state = 'built'
-               update_cache(c)
-               print c.name, 'completed'
-       else:
-               c.active_state = 'error'
-               print >>sys.stderr, c.name, 'failed with status:', status
+       for_each_repository(action, targets)
 
-               wait_for_job(jobs)
-               raise Error('Build failed')
+def pull(targets):
+       for_each_repository(lambda repo: repo.pull(), targets)
 
-def clean_components(targets):
-       if not targets:
-               targets = config.components.keys()
+def changes(targets):
+       changed = False
 
        for name in targets:
-               print 'Cleaning component:', name
-
-               c = config.components[name]
+               c = find_component(name)
 
-               paths = []
-               for repo in (c.repo, c.meta):
-                       files = git.ls_files(repo.path, ['-o'])
-                       paths += [os.path.join(repo.path, i) for i in files]
+               if c.source.exists():
+                       if check_changes(c.source):
+                               changed = True
 
-               paths.sort()
-               paths.reverse()
+               if check_changes(c.meta):
+                       changed = True
 
-               cache = os.path.join(config.cache_dir, name)
-               if os.path.exists(cache):
-                       paths.append(cache)
+               if not config.force and check_dirty(c):
+                       changed = True
 
-               for path in paths:
-                       if config.debug:
-                               print 'Deleting', path
+       if changed:
+               raise Error()
 
-                       if os.path.islink(path) or not os.path.isdir(path):
-                               os.remove(path)
-                       elif not os.path.exists(os.path.join(path, '.git')):
-                               os.rmdir(path)
+def check_changes(repo):
+       ret = repo.changes()
+       if ret:
+               log.message('Changes in %s' % repo)
+       return ret
 
-               for repo in (c.repo, c.meta):
-                       files = git.ls_files(repo.path, ['-m', '-d'])
-                       if files:
-                               print len(files), 'dirty files left in', repo.path
+def check_dirty(c):
+       ret = c.is_dirty()
+       if ret:
+               log.message('Dirty files in %s' % c.name)
+       return ret
 
-def pull_components(targets):
-       if not targets:
-               targets = config.components.keys()
+def source_dist(targets):
+       location = 'dist'
+       if not os.path.exists(location):
+               os.makedirs(location)
 
        for name in targets:
-               print 'Pulling component:', name
-
-               c = config.components[name]
-               git.pull(c.repo.path)
-               git.pull(c.meta.path)
-
-def source_dist_components(targets):
-       if not targets:
-               targets = config.components.keys()
-
-       for name in targets:
-               c = config.components[name]
-               generate_component_changes(c, 'dist')
-               package_component_sources(c, 'dist')
-
-def generate_component_changes(c, location):
-       print 'Generating component change log:', c.name
+               c = find_component(name)
+               dist_changes(c, location)
+               dist_sources(c, location)
 
+def dist_changes(c, location):
        path = os.path.join(location, c.name) + '.changes'
+       c.source.dump_log(path)
 
-       pathdir = os.path.dirname(path)
-       if not os.path.exists(pathdir):
-               os.makedirs(pathdir)
-
-       fd = os.open(path, os.O_WRONLY | os.O_CREAT, 0644)
-       git.log(c.name, [c.get_active_tag()], fd=fd)
-       os.close(fd)
-
-def package_component_sources(c, location):
-       print 'Packaging component sources:', c.name
-
-       rev=git.describe(c.name)
+def dist_sources(c, location):
+       rev = c.source.describe()
        if rev:
-               rev = '_'+rev
+               rev = '_' + rev
        else:
                rev = ''
-       path = os.path.join(location, c.name) + rev + '.tar.bz2'
+
+       name = c.name + rev
+       path = os.path.join(location, name) + '.tar.bz2'
        if os.path.exists(path):
                os.remove(path)
 
-       pathdir = os.path.dirname(path)
-       if not os.path.exists(pathdir):
-               os.makedirs(pathdir)
-
-       git.archive(c.name,path,
-                               prefix=os.path.basename(c.name)+'/',
-                               branch=c.get_active_tag())
-
-def build_rootfs(clean=True, rootfs_only=False, jffs2_only=False, devrootfs_only=False):
-       parse_config('rootfs')
-
-       f = os.popen('sb-conf cu')
-       target = f.read()
-       f.close()
-
-       rootfs = RootFS(target.strip())
-       rootfs.include_paths(config.include_paths)
-       rootfs.include_files(config.include_files)
-       rootfs.filter_paths(config.exclude_paths)
-       rootfs.filter_files(config.exclude_files)
-       rootfs.filter_expressions(config.exclude_expressions)
-       rootfs.add_paths(config.created_paths)
-       rootfs.set_devices(config.devices)
-       rootfs.set_change_owner(config.change_owner)
-       rootfs.set_erase_size(config.boards[config.board].flash_erase_size)
-       rootfs.set_pad_size(config.boards[config.board].flash_pad_size)
-
-       if rootfs_only:
-               rootfs.generate(clean, build_target="rootfs")
-       elif jffs2_only:
-               rootfs.generate(clean, build_target="jffs2")
-       elif devrootfs_only:
-               rootfs.generate(clean, build_target="devrootfs")
-       else:
-               rootfs.generate(clean, build_target="all")
+       c.source.archive(name, path)