matrix-rootfs: add jffs2_extra_args
[matrix.git] / matrix / config.py
index d825ff6..2b926fa 100644 (file)
@@ -1,8 +1,9 @@
-# Copyright (C) 2007-2008 Movial Oy
-# Authors: Timo Savola <tsavola@movial.fi>
-#          Kalle Vahlman <kalle.vahlman@movial.fi>
+# Copyright (C) 2007-2009 Movial Creative Technologies Inc.
+# Authors: Timo Savola
+#          Kalle Vahlman <kalle.vahlman@movial.com>
+#          Daniel Bainton <daniel.bainton@movial.com>
 
-import sre
+import re
 from glob import glob
 from os import getenv
 from os.path import basename, exists, isabs, isdir, join
@@ -10,7 +11,7 @@ from sets import Set as set
 
 Error = RuntimeError
 
-exclude = sre.compile(r'^[.#].*|.*[~#]$')
+exclude = re.compile(r'^[.#].*|.*[~#]$')
 
 def _make_list(arg):
        if arg is None:
@@ -30,7 +31,7 @@ def config_dir(path=None, url=None, branch='master', optional=False):
 
                path = basename(url)
                if path.endswith('.git'):
-                       path = path.rsplit('.', 1)[0]
+                       path = path[:-4]
 
        if optional and path not in config.initial_config_dirs:
                if config.debug:
@@ -40,13 +41,21 @@ def config_dir(path=None, url=None, branch='master', optional=False):
        if url:
                name = basename(path)
                repo = Repository(name=name, path=path, url=url, branch=branch)
-               if not repo.exists():
+
+               if repo.exists():
+                       if config.pull_config_dirs:
+                               repo.pull()
+               else:
                        repo.clone()
        else:
                if not isdir(path):
                        raise Error('Config dir does not exist: %s' % path)
 
-       config.config_dirs.append(path)
+       if path not in config.initial_config_dirs:
+               config.config_dirs.append(path)
+
+def pull_config_dirs(flag):
+       config.pull_config_dirs = flag
 
 def root(url, branch='master'):
        config.roots.append((url, branch))
@@ -63,7 +72,10 @@ class Board(object):
                     ubifs_leb_size=0,
                     ubifs_max_leb_count=0,
                     ubifs_min_io_size=0,
-                    ubinize_config_vol_size=0):
+                    ubinize_config_vol_size=0,
+                    cleanmarkers="unknown",
+                    jffs2_extra_args="",
+                    flags=[]):
 
                self.name = name
                self.arch = arch
@@ -79,6 +91,9 @@ class Board(object):
                self.ubifs_max_leb_count = ubifs_max_leb_count
                self.ubifs_min_io_size = ubifs_min_io_size
                self.ubinize_config_vol_size = ubinize_config_vol_size
+               self.cleanmarkers = cleanmarkers
+               self.jffs2_extra_args = jffs2_extra_args
+               self.flags = flags
 
                config.boards[name] = self
 
@@ -134,6 +149,9 @@ def clear_flag(name):
 def use_board(name):
        config.board = name
 
+def cache_dir(path):
+       config.cache_dir = path
+
 def sb2_target(name):
        config.sb2_target = name
 
@@ -146,6 +164,57 @@ def sb2_init_options(args):
 def get_variables():
        return config
 
+def rootfs_root(path, target = None):
+       rootfs.path = path
+       rootfs.target = target
+
+def include_paths(paths):
+       rootfs.include_paths.extend(paths)
+
+def include_files(files):
+       rootfs.include_files.extend(files)
+
+def exclude_paths(paths):
+       rootfs.exclude_paths.extend(paths)
+
+def exclude_files(files):
+       rootfs.exclude_files.extend(files)
+
+def exclude_expressions(expressions):
+       rootfs.exclude_expressions.extend(expressions)
+
+def created_paths(paths):
+       rootfs.created_paths.extend(paths)
+
+def file_modes(modes):
+       rootfs.file_modes.update(modes)
+
+def directory_owners(owners):
+       rootfs.directory_owners.update(owners)
+
+def device_nodes(devices):
+       rootfs.devices.update(devices)
+
+def remove_account(uid=None, gid=None):
+       rootfs.remove_uid = uid
+       rootfs.remove_gid = gid
+
+class RootFS(object):
+       def __init__(self):
+               self.path = None
+               self.target = None
+               self.include_paths = []
+               self.include_files = []
+               self.exclude_paths = []
+               self.exclude_files = []
+               self.exclude_expressions = []
+               self.created_paths = []
+               self.devices = {}
+               self.file_modes = {}
+               self.directory_owners = {}
+               self.remove_uid = None
+               self.remove_gid = None
+
 class Config(object):
        def __init__(self):
                self.initial_config_dirs = []
@@ -163,8 +232,10 @@ class Config(object):
                self.flags = set()
                self.verbose = False
                self.debug = False
+               self.protocol = False
                self.force = False
                self.keep_going = False
+               self.pull_config_dirs = False
                self.jobs = 1
                self.make_jobs = 1
 
@@ -174,18 +245,33 @@ class Config(object):
 
 actions = dict(
        Board = Board,
+       CacheDir = cache_dir,
        ClearFlag = clear_flag,
        Component = component,
        ConfigDir = config_dir,
        GetVariables = get_variables,
        Parse = parse,
        ProvideComponent = provide_component,
+       PullConfigDirs = pull_config_dirs,
        Root = root,
        SB2Compiler = sb2_compiler,
        SB2InitOptions = sb2_init_options,
        SB2Target = sb2_target,
        SetFlag = set_flag,
        UseBoard = use_board,
+       RootFSRootPath = rootfs_root,
+       RootFSPaths = include_paths,
+       RootFSFiles = include_files,
+       RootFSExcludePaths = exclude_paths,
+       RootFSExcludeFiles = exclude_files,
+       RootFSExcludeExpressions = exclude_expressions,
+       RootFSCreatePaths = created_paths,
+       RootFSFileModes = file_modes,
+       RootFSDirectoryOwners = directory_owners,
+       RootFSDeviceNodes = device_nodes,
+       RootFSRemoveAccount = remove_account,
 )
 
 config = Config()
+rootfs = RootFS()
+