def _special_project(name): # Returns a Project instance for one of the special repositories in west/, # so that we can reuse the project-related functions for them remote = Remote(name=config.get(name, 'remote', fallback='origin'), url='dummy URL for {} repository'.format(name)) # 'revision' always exists and defaults to 'master' return Project(name, remote, None, revision=config.get(name, 'revision', fallback='master'), path=os.path.join('west', name))
def _special_project(args, name): # Returns a Project instance for one of the special repositories in west/, # so that we can reuse the project-related functions for them if name == 'manifest': url = config.get(name, 'remote', fallback='origin') revision = config.get(name, 'revision', fallback='master') return SpecialProject(name, revision=revision, path=os.path.join('west', name), url=url) return Manifest.from_file(_manifest_path(args), name).west_project
def manifest_path(): '''Return the path to the manifest file. Raises WestNotFound if called from outside of a west working directory.''' try: return os.path.join(util.west_topdir(), config.get('manifest', 'path'), 'west.yml') except (configparser.NoOptionError, configparser.NoSectionError) as e: raise MalformedConfig('missing key: \'{}\' in west config file'.format( e.args[0])) from e
def _special_project(name): # Returns a Project instance for one of the special repositories in west/, # so that we can reuse the project-related functions for them # TODO: Maybe the Remote class could be replaced by a single # project.remote_name field, now that we no longer use the Git remote # mechanism and fetch directly from URLs remote = Remote(name='dummy name for {} repository'.format(name), url='dummy URL for {} repository'.format(name)) # 'revision' always exists and defaults to 'master' project = Project(name, remote, None, revision=config.get(name, 'revision', fallback='master'), path=os.path.join('west', name)) # This could also be the name of a Git remote. The naming breaks a bit # here. project.url = config.get(name, 'remote', fallback='origin') return project
def _load(self, data, sections): # Initialize this instance's fields from values given in the # manifest data, which must be validated according to the schema. if 'west' in sections: west = data.get('west', {}) url = west.get('url') or WEST_URL_DEFAULT revision = west.get('revision') or WEST_REV_DEFAULT self.west_project = SpecialProject('west', url=url, revision=revision, path=os.path.join( '.west', 'west')) # Next is the manifest section if 'manifest' not in sections: return projects = [] project_abspaths = set() manifest = data.get('manifest') path = config.get('manifest', 'path', fallback=None) self_tag = manifest.get('self') if path is None: path = self_tag.get('path') if self_tag else None west_commands = self_tag.get('west-commands') if self_tag else None project = SpecialProject(path, path=path, west_commands=west_commands) projects.insert(MANIFEST_PROJECT_INDEX, project) # Map from each remote's name onto that remote's data in the manifest. remotes = tuple( Remote(r['name'], r['url-base']) for r in manifest['remotes']) remotes_dict = {r.name: r for r in remotes} # Get any defaults out of the manifest. # # md = manifest defaults (dictionary with values parsed from # the manifest) md = manifest.get('defaults', dict()) mdrem = md.get('remote') if mdrem: # The default remote name, if provided, must refer to a # well-defined remote. if mdrem not in remotes_dict: self._malformed( 'default remote {} is not defined'.format(mdrem)) default_remote = remotes_dict[mdrem] default_remote_name = mdrem else: default_remote = None default_remote_name = None defaults = Defaults(remote=default_remote, revision=md.get('revision')) # mp = manifest project (dictionary with values parsed from # the manifest) for mp in manifest['projects']: # Validate the project name. name = mp['name'] if name == 'west': self._malformed('the name "west" is reserved and cannot ' 'be used to name a manifest project') # Validate the project remote. remote_name = mp.get('remote', default_remote_name) if remote_name is None: self._malformed( 'project {} does not specify a remote'.format(name)) if remote_name not in remotes_dict: self._malformed('project {} remote {} is not defined'.format( name, remote_name)) # Create the project instance for final checking. project = Project(name, remotes_dict[remote_name], defaults, path=mp.get('path'), clone_depth=mp.get('clone-depth'), revision=mp.get('revision'), west_commands=mp.get('west-commands')) # Two projects cannot have the same path. We use absolute # paths to check for collisions to ensure paths are # normalized (e.g. for case-insensitive file systems or # in cases like on Windows where / or \ may serve as a # path component separator). if project.abspath in project_abspaths: self._malformed('project {} path {} is already in use'.format( project.name, project.path)) project_abspaths.add(project.abspath) projects.append(project) self.defaults = defaults self.remotes = remotes self._remotes_dict = remotes_dict self.projects = tuple(projects)