matrix-rootfs: add jffs2_extra_args
[matrix.git] / matrix / config.py
index 384a2ce..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:
@@ -40,7 +41,11 @@ 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):
@@ -49,6 +54,9 @@ def config_dir(path=None, url=None, branch='master', optional=False):
        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))
 
@@ -64,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
@@ -80,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
 
@@ -172,15 +186,23 @@ def exclude_expressions(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 = []
@@ -188,7 +210,10 @@ class RootFS(object):
                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):
@@ -207,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
 
@@ -225,6 +252,7 @@ actions = dict(
        GetVariables = get_variables,
        Parse = parse,
        ProvideComponent = provide_component,
+       PullConfigDirs = pull_config_dirs,
        Root = root,
        SB2Compiler = sb2_compiler,
        SB2InitOptions = sb2_init_options,
@@ -238,8 +266,10 @@ actions = dict(
        RootFSExcludeFiles = exclude_files,
        RootFSExcludeExpressions = exclude_expressions,
        RootFSCreatePaths = created_paths,
+       RootFSFileModes = file_modes,
        RootFSDirectoryOwners = directory_owners,
        RootFSDeviceNodes = device_nodes,
+       RootFSRemoveAccount = remove_account,
 )
 
 config = Config()