reorganize repository layout
authorTimo Savola <tsavola@movial.fi>
Fri, 4 Apr 2008 08:10:47 +0000 (11:10 +0300)
committerTimo Savola <tsavola@movial.fi>
Fri, 4 Apr 2008 08:24:35 +0000 (11:24 +0300)
before
    root:          host:/path/repo
    repository:    host:/path/repo/section/component.git
    branch:        matrix
    checkout:      section/component
    metadata:      section/component/.matrix

after
    root:          host:/path
    repositories:  host:/path/repo/component.git
                   host:/path/meta/component.git
    branch:        master
    checkouts:     src/component
                   src/component/meta
    metadata:      src/component/meta

examples/config
examples/plug
matrix/config.py
matrix/matrix.py
scripts/matrix-autotools.mak
scripts/matrix-custom.mak
scripts/matrix.mak

index 22ad0b4..bb0df87 100644 (file)
@@ -1,5 +1,5 @@
 if not roots:
 if not roots:
-       roots = ['matrix.movial.fi:/matrix/shared/repo']
+       roots = ['matrix.movial.fi:/matrix/shared']
 
 if not board:
        board = 'arm'
 
 if not board:
        board = 'arm'
index 591cd28..e4638f4 100644 (file)
@@ -3,7 +3,7 @@
 MATRIX_BUILD_STYLE = autotools
 
 # this makes the build happen outside of the source tree
 MATRIX_BUILD_STYLE = autotools
 
 # this makes the build happen outside of the source tree
-MATRIX_OBJ_DIR = .matrix/obj
+MATRIX_OBJ_DIR = meta/obj
 
 # run autogen.sh with no parameters
 MATRIX_AUTOGEN_WITH = ""
 
 # run autogen.sh with no parameters
 MATRIX_AUTOGEN_WITH = ""
index 26a174a..af7cc91 100644 (file)
@@ -2,10 +2,10 @@
 # Authors: Timo Savola <tsavola@movial.fi>
 #          Kalle Vahlman <kalle.vahlman@movial.fi>
 
 # Authors: Timo Savola <tsavola@movial.fi>
 #          Kalle Vahlman <kalle.vahlman@movial.fi>
 
-import os as __os
+import os as _os
 
 
-top_dir = __os.environ.get('MATRIX_TOPDIR', __os.getcwd())
-cache_dir = __os.path.join(top_dir, 'build-cache')
+top_dir = _os.environ.get('MATRIX_TOPDIR', _os.getcwd())
+cache_dir = _os.path.join(top_dir, 'build-cache')
 global_cache_dir = '/usr/share/matrix/build-cache'
 script_dir = None
 
 global_cache_dir = '/usr/share/matrix/build-cache'
 script_dir = None
 
@@ -32,25 +32,33 @@ class Board(object):
 
                boards[name] = self
 
 
                boards[name] = self
 
-class Component(object):
-       import git
+class _Repository(object):
+       def __init__(self, name, path):
+               self.name = name
+               self.path = path
+               self.active_url = None
+               self.active_hash = None
 
 
+class Component(object):
        from_platform = False
 
        from_platform = False
 
-       def __init__(self, name, tag='matrix', tags={}, flags=[]):
+       def __init__(self, name, tag='master', tags={}, flags=[]):
                self.name = name
 
                self.name = name
 
+               self.repo = _Repository(
+                       'repo/%s' % name, _os.path.join(top_dir, 'src', name))
+               self.meta = _Repository(
+                       'meta/%s' % name, _os.path.join(top_dir, 'src', name, 'meta'))
+
                self.tags = {}
                self.tags.update(tags)
                self.tags[None] = tag
 
                self.flags = flags
 
                self.tags = {}
                self.tags.update(tags)
                self.tags[None] = tag
 
                self.flags = flags
 
-               self.active_url = None
                self.__active_tag = None
                self.active_packages = None
                self.active_depends = None
                self.__active_tag = None
                self.active_packages = None
                self.active_depends = None
-               self.__active_hash = None
                self.active_state = None
 
                components[name] = self
                self.active_state = None
 
                components[name] = self
@@ -66,13 +74,6 @@ class Component(object):
 
                return self.__active_tag
 
 
                return self.__active_tag
 
-       def get_active_hash(self):
-               if self.__active_hash is None:
-                       self.__active_hash \
-                           = self.git.rev_parse(self.name, 'HEAD')
-
-               return self.__active_hash
-
 class PlatformProvidedComponent(Component):
        """A Component that is provided by the platform.
           The sources will not be built during install."""
 class PlatformProvidedComponent(Component):
        """A Component that is provided by the platform.
           The sources will not be built during install."""
index 5bdb6e7..11d9aaa 100644 (file)
@@ -24,7 +24,7 @@ def main():
 
        parse_config('config')
        parse_config('boards')
 
        parse_config('config')
        parse_config('boards')
-       parse_config('components/components')
+       parse_config('components')
 
        if 'global-cache' in config.flags:
                config.cache_dir = config.global_cache_dir
 
        if 'global-cache' in config.flags:
                config.cache_dir = config.global_cache_dir
@@ -183,16 +183,20 @@ def update_components():
        return targets
 
 def update_component_url(c):
        return targets
 
 def update_component_url(c):
-       url=git.getvar(c.name,'remote.origin.url')
+       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:
        if url:
-               c.active_url=url
+               repo.active_url = url
                if config.debug:
                if config.debug:
-                       print 'Using', c.active_url
+                       print 'Using', repo.active_url
                return
 
        for root in config.roots:
                for suffix in ('.git', ''):
                return
 
        for root in config.roots:
                for suffix in ('.git', ''):
-                       url = root + '/' + c.name + suffix
+                       url = '%s/%s%s' % (root, repo.name, suffix)
 
                        if config.debug:
                                print 'Trying', url
 
                        if config.debug:
                                print 'Trying', url
@@ -200,12 +204,12 @@ def update_component_url(c):
                        if not git.peek_remote(url, quiet=True):
                                continue
 
                        if not git.peek_remote(url, quiet=True):
                                continue
 
-                       c.active_url = url
+                       repo.active_url = url
                        if config.debug:
                        if config.debug:
-                               print 'Found', c.active_url
+                               print 'Found', repo.active_url
                        return
 
                        return
 
-       raise Error('Failed to locate repository of ' + c.name)
+       raise Error('Failed to locate repository: ' + repo.name)
 
 def update_component_depends(packages):
        for pkg in packages.itervalues():
 
 def update_component_depends(packages):
        for pkg in packages.itervalues():
@@ -264,21 +268,29 @@ def execute(args):
                raise Error('Failed: ' + ' '.join(args))
 
 def download_component(c, overwrite=False):
                raise Error('Failed: ' + ' '.join(args))
 
 def download_component(c, overwrite=False):
-       if os.path.exists(c.name) and not overwrite:
+       if os.path.exists(c.repo.path) and not overwrite:
                return
 
        print 'Downloading component:', c.name
 
                return
 
        print 'Downloading component:', c.name
 
-       execute(['rm', '-rf', c.name])
-       git.clone(c.name, c.active_url, checkout=False)
+       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()
 
        branch = c.get_active_tag()
-       git.create_branch(c.name, branch, 'origin/%s'%branch, checkout=True, link=True,force=True)
+       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 = {}
 
 
 def update_component_packages(c, targets, packages):
        c.active_packages = {}
 
-       for path in glob.glob(os.path.join(c.name, '.matrix', '*.package')):
+       for path in glob.glob(os.path.join(c.meta.path, '*.package')):
                name = os.path.basename(path)[:-8]
 
                pkg = parse_package(name, c, path)
                name = os.path.basename(path)[:-8]
 
                pkg = parse_package(name, c, path)
@@ -382,8 +394,11 @@ def component_cached(c):
        if c.from_platform:
                return True
 
        if c.from_platform:
                return True
 
-       if git.ls_files(c.name, ['-m', '-d']):
+       ls_opts = ['-m', '-d']
+       if git.ls_files(c.repo.path, ls_opts):
                raise Error('Component contains dirty files: ' + c.name)
                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):
 
        path = os.path.join(config.cache_dir, c.name)
        if not os.path.exists(path):
@@ -399,7 +414,7 @@ def component_cached(c):
 
        hash, flagstring = match.groups()
 
 
        hash, flagstring = match.groups()
 
-       if hash != c.get_active_hash():
+       if hash != get_component_hash(c):
                print 'Component has been changed:', c.name
                return False
 
                print 'Component has been changed:', c.name
                return False
 
@@ -422,15 +437,30 @@ def update_cache(c):
                os.makedirs(dir)
 
        file = open(path, 'w')
                os.makedirs(dir)
 
        file = open(path, 'w')
-       print >>file, c.get_active_hash(), ','.join(c.flags)
-       file.close()
+       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')
 
 
 def start_job(c, jobs, make_jobs):
        board = config.boards[config.board]
 
        makefile = os.path.join(config.script_dir, 'matrix.mak')
 
-       args = ['make', '--no-print-directory', '-f', makefile, '-C', c.name,
+       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,
                '-j', str(make_jobs), 'build_matrix_component',
                'MATRIX_TOPDIR='    + config.top_dir,
                'MATRIX_SCRIPTDIR=' + config.script_dir,
@@ -487,8 +517,13 @@ def clean_components(targets):
        for name in targets:
                print 'Cleaning component:', name
 
        for name in targets:
                print 'Cleaning component:', name
 
-               files = git.ls_files(name, ['-o'])
-               paths = [os.path.join(name, i) for i in files]
+               c = config.components[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]
+
                paths.sort()
                paths.reverse()
 
                paths.sort()
                paths.reverse()
 
@@ -502,12 +537,13 @@ def clean_components(targets):
 
                        if os.path.islink(path) or not os.path.isdir(path):
                                os.remove(path)
 
                        if os.path.islink(path) or not os.path.isdir(path):
                                os.remove(path)
-                       else:
+                       elif not os.path.exists(os.path.join(path, '.git')):
                                os.rmdir(path)
 
                                os.rmdir(path)
 
-               files = git.ls_files(name, ['-m', '-d'])
-               if files:
-                       print len(files), 'dirty files left in', name
+               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 pull_components(targets):
        if not targets:
 
 def pull_components(targets):
        if not targets:
@@ -515,8 +551,10 @@ def pull_components(targets):
 
        for name in targets:
                print 'Pulling component:', name
 
        for name in targets:
                print 'Pulling component:', name
+
                c = config.components[name]
                c = config.components[name]
-               git.pull(name)
+               git.pull(c.repo.path)
+               git.pull(c.meta.path)
 
 def source_dist_components(targets):
        if not targets:
 
 def source_dist_components(targets):
        if not targets:
index de9fe59..0fcd54b 100644 (file)
@@ -62,7 +62,7 @@ __configure: $(MATRIX_AUTOGEN)
 ifdef MATRIX_OBJ_DIR
        rm -rf $(MATRIX_OBJ_DIR)
        mkdir -p $(MATRIX_OBJ_DIR)
 ifdef MATRIX_OBJ_DIR
        rm -rf $(MATRIX_OBJ_DIR)
        mkdir -p $(MATRIX_OBJ_DIR)
-       @cd $(MATRIX_OBJ_DIR) && $(MATRIX_CONFIGURE_ENV) $(MATRIX_TOPDIR)/$(MATRIX_COMPONENT)/configure --build=$(MATRIX_AUTOTOOLS_BUILD_ARCH) --host=$(MATRIX_AUTOTOOLS_HOST_ARCH) $(MATRIX_CONFIGURE_ARGS)
+       @cd $(MATRIX_OBJ_DIR) && $(MATRIX_CONFIGURE_ENV) $(MATRIX_TOPDIR)/src/$(MATRIX_COMPONENT)/configure --build=$(MATRIX_AUTOTOOLS_BUILD_ARCH) --host=$(MATRIX_AUTOTOOLS_HOST_ARCH) $(MATRIX_CONFIGURE_ARGS)
 else   
        @$(MATRIX_CONFIGURE_ENV) $(CCTOOL_BUILD) ./configure $(MATRIX_CONFIGURE_ARGS)
 endif
 else   
        @$(MATRIX_CONFIGURE_ENV) $(CCTOOL_BUILD) ./configure $(MATRIX_CONFIGURE_ARGS)
 endif
index 910eb21..b82ac70 100644 (file)
@@ -11,13 +11,12 @@ include $(MATRIX_SCRIPTDIR)/matrix-common.mak
 __matrix_build: __configure __build __install_pre_lock
 
 __configure: configure
 __matrix_build: __configure __build __install_pre_lock
 
 __configure: configure
-       @$(CCTOOL_BUILD) $(MAKE) -f .matrix/plug configure
+       @$(CCTOOL_BUILD) $(MAKE) -f meta/plug configure
 
 __build: __configure build
 
 __build: __configure build
-       @$(CCTOOL_BUILD) $(MAKE) -f .matrix/plug build
+       @$(CCTOOL_BUILD) $(MAKE) -f meta/plug build
 
 # this can't have any requisites as that would trigger a rebuild
 # __install_pre_lock depends on __build so we're safe here
 __install_post_lock:
 
 # this can't have any requisites as that would trigger a rebuild
 # __install_pre_lock depends on __build so we're safe here
 __install_post_lock:
-       @$(matrix_install_lock) $(CCTOOL_INSTALL) $(MAKE) -f .matrix/plug install
-
+       @$(matrix_install_lock) $(CCTOOL_INSTALL) $(MAKE) -f meta/plug install
index bd504f5..d9b8de6 100644 (file)
@@ -19,7 +19,7 @@ else
 MATRIX_MAK_DEBUG =
 endif
 
 MATRIX_MAK_DEBUG =
 endif
 
-include .matrix/plug
+include meta/plug
 
 ifeq ("$(MATRIX_COMPILER_OPTIONS)","")
 
 
 ifeq ("$(MATRIX_COMPILER_OPTIONS)","")