diff --git a/src/oebuild/app/plugins/bitbake/bitbake.py b/src/oebuild/app/plugins/bitbake/bitbake.py index f2e5aafa44a20ec2841b35a51700f0a3ca3e0534..f4cf0cdd352aea8af034ccd0d148d77ffde768d0 100644 --- a/src/oebuild/app/plugins/bitbake/bitbake.py +++ b/src/oebuild/app/plugins/bitbake/bitbake.py @@ -81,7 +81,11 @@ class Bitbake(OebuildCommand): except CheckCompileError as c_e: log.err(str(c_e)) return - parse_compile.pull_repos(self.configure.source_dir()) + + # if has manifest.yaml, init layer repo with it + yocto_dir = os.path.join(self.configure.source_dir(), "yocto-meta-openeuler") + manifest_path = os.path.join(yocto_dir, ".oebuild/manifest.yaml") + parse_compile.pull_repos(self.configure.source_dir(), manifest_path=manifest_path) parse_env = ParseEnv(env_dir='.env') if parse_compile.build_in == BUILD_IN_HOST: diff --git a/src/oebuild/ogit.py b/src/oebuild/ogit.py index f18a1bfe1629116594c77a05654defc7d1f23a91..608fe6bb9efd7a090def1bcc74eebad2a8ca55fc 100644 --- a/src/oebuild/ogit.py +++ b/src/oebuild/ogit.py @@ -13,6 +13,7 @@ See the Mulan PSL v2 for more details. import os import git +from git import GitCommandError from oebuild.my_log import MyLog as log @@ -143,3 +144,24 @@ class OGit: return "","" except ValueError: return "","" + + def clone_or_pull_with_version(self, version, depth): + ''' + clone or pull with version and depth + ''' + repo = git.Repo.init(self._repo_dir) + remote = None + for item in repo.remotes: + if self._remote_url == item.url: + remote = item + else: + continue + if remote is None: + remote_name = "manifest" + remote = git.Remote.add(repo = repo, name = remote_name, url = self._remote_url) + log.info(f"Pulling into '{self._repo_dir}'...") + try: + repo.git.checkout(version) + except GitCommandError: + remote.fetch(version, depth = depth, progress=self.clone_process) + repo.git.checkout(version) diff --git a/src/oebuild/parse_compile.py b/src/oebuild/parse_compile.py index d1f678b8de225da510c4b6288d0808d7fa1319df..5e4f3889f2b31932f92c6511969336f4a5a47f28 100644 --- a/src/oebuild/parse_compile.py +++ b/src/oebuild/parse_compile.py @@ -172,17 +172,24 @@ class ParseCompile: ''' return self.compile.tmp_dir - def pull_repos(self, base_dir): + def pull_repos(self, base_dir, manifest_path): ''' Download the repos set in compile.yaml based on the given base path ''' + manifest = None + if os.path.exists(manifest_path): + manifest = oebuild_util.read_yaml(pathlib.Path(manifest_path))['manifest_list'] if not self.compile.not_use_repos: repos = self.compile.repos - for _, repo in repos.items(): + for repo_local, repo in repos.items(): repo_dir = os.path.join(base_dir, repo.path) try: repo_git = OGit(repo_dir=repo_dir, remote_url=repo.url, branch=repo.refspec) - repo_git.clone_or_pull_repo() + if manifest is not None and repo_local in manifest: + repo_item = manifest[repo_local] + repo_git.clone_or_pull_with_version(version=repo_item['version'], depth=1) + else: + repo_git.clone_or_pull_repo() except Exception as e_p: raise e_p diff --git a/src/oebuild/version.py b/src/oebuild/version.py index c3d1e7e2e596bb7e754bee9955506b7a2ad31663..7c1203a2acb5dc28c76375fd4c14d063d32d6471 100644 --- a/src/oebuild/version.py +++ b/src/oebuild/version.py @@ -10,4 +10,4 @@ MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. See the Mulan PSL v2 for more details. ''' -__version__ = '0.0.13' +__version__ = '0.0.14'