From e450d14e9d9e37c1fd3934f32f5200bdde8a15b2 Mon Sep 17 00:00:00 2001 From: alichinese Date: Sat, 25 Feb 2023 11:32:25 +0000 Subject: [PATCH 1/3] oebuild: add LICENSE file * add LICENSE file with mulan Signed-off-by: lixinyu --- LICENSE.txt | 9 +++++++++ src/oebuild/parse_template.py | 5 ++++- 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 LICENSE.txt diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..1949e66 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,9 @@ +Copyright (c) 2023 openEuler Embedded +oebuild is licensed under Mulan PSL v2. +You can use this software according to the terms and conditions of the Mulan PSL v2. +You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 +THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +See the Mulan PSL v2 for more details. \ No newline at end of file diff --git a/src/oebuild/parse_template.py b/src/oebuild/parse_template.py index f29e17f..4dd8503 100644 --- a/src/oebuild/parse_template.py +++ b/src/oebuild/parse_template.py @@ -166,7 +166,8 @@ class ParseTemplate: nativesdk_dir = None, toolchain_dir = None, build_in: str = BUILD_IN_DOCKER, - sstate_cache = None): + sstate_cache = None, + tmp_dir = None): ''' first param common yaml ''' @@ -236,6 +237,8 @@ class ParseTemplate: compile_conf['toolchain_dir'] = toolchain_dir if sstate_cache is not None: compile_conf['sstate_cache'] = sstate_cache + if tmp_dir is not None: + compile_conf['tmp_dir'] = tmp_dir compile_conf['repos'] = repos compile_conf['local_conf'] = local_conf -- Gitee From a1a15945ca8a292453ff894be1d65e97c683de5d Mon Sep 17 00:00:00 2001 From: alichinese Date: Sat, 25 Feb 2023 11:33:40 +0000 Subject: [PATCH 2/3] ogit: optimize python execute git command * when execute oebuild by other command with screen and it will be raise ValueError so and try to avoid it Signed-off-by: lixinyu --- src/oebuild/ogit.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/oebuild/ogit.py b/src/oebuild/ogit.py index c169860..6e09d7f 100644 --- a/src/oebuild/ogit.py +++ b/src/oebuild/ogit.py @@ -37,7 +37,10 @@ class OGit: self._remote_url = remote_url self._branch = branch self._last_code = 0 - _, self._screen_width = os.popen('stty size', 'r').read().split() + try: + _, self._screen_width = os.popen('stty size', 'r').read().split() + except ValueError as v_e: + log.warning(str(v_e)) @property def repo_dir(self): @@ -118,7 +121,8 @@ class OGit: return pmsg = "\r" + pmsg - pmsg = pmsg.ljust(int(self._screen_width), ' ') + if hasattr(self, '_screen_width'): + pmsg = pmsg.ljust(int(self._screen_width), ' ') print(pmsg, end='', flush=True) @staticmethod -- Gitee From 61b4ab387f740b4bf11ed22596a4bce7d171e186 Mon Sep 17 00:00:00 2001 From: alichinese Date: Sat, 25 Feb 2023 11:36:36 +0000 Subject: [PATCH 3/3] generate: add a command param tmp_dir * add a param in generate command namespace with -m tmp_dir the param can specify tmp directory * modify description about param -s sstate_cache Signed-off-by: lixinyu --- src/oebuild/app/plugins/generate/generate.py | 15 +++++++++++++-- src/oebuild/local_conf.py | 9 +++++++++ src/oebuild/parse_compile.py | 10 ++++++++++ 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/oebuild/app/plugins/generate/generate.py b/src/oebuild/app/plugins/generate/generate.py index b660044..9940ee3 100644 --- a/src/oebuild/app/plugins/generate/generate.py +++ b/src/oebuild/app/plugins/generate/generate.py @@ -31,6 +31,7 @@ class Generate(OebuildCommand): self.nativesdk_dir = None self.toolchain_dir = None self.sstate_cache = None + self.tmp_dir = None super().__init__( 'generate', 'help to mkdir build directory and generate compile.yaml', @@ -61,7 +62,13 @@ class Generate(OebuildCommand): parser.add_argument('-s', dest='sstate_cache', help=''' - this param is for arch, for example aarch4-std, aarch64-pro and so on + this param is for sstate_cache directory + ''' + ) + + parser.add_argument('-m', dest='tmp_dir', + help=''' + this param is for tmp directory, the build result will be stored in ''' ) @@ -120,6 +127,9 @@ class Generate(OebuildCommand): if args.sstate_cache is not None: self.sstate_cache = args.sstate_cache + if args.tmp_dir is not None: + self.tmp_dir = args.tmp_dir + yocto_dir = self.configure.source_yocto_dir() if not self.check_support_oebuild(yocto_dir): log.err('Currently, yocto-meta-openeuler does not support oebuild, \ @@ -173,7 +183,8 @@ class Generate(OebuildCommand): nativesdk_dir= self.nativesdk_dir, toolchain_dir= self.toolchain_dir, build_in=build_in, - sstate_cache= self.sstate_cache + sstate_cache= self.sstate_cache, + tmp_dir = self.tmp_dir )) log.info("=============================================") diff --git a/src/oebuild/local_conf.py b/src/oebuild/local_conf.py index a560077..ef3241e 100644 --- a/src/oebuild/local_conf.py +++ b/src/oebuild/local_conf.py @@ -34,6 +34,7 @@ NATIVESDK_SYSROOT = "sysroots/x86_64-pokysdk-linux" OPENEULER_SP_DIR = "OPENEULER_SP_DIR" NATIVESDK_ENVIRONMENT = "environment-setup-x86_64-pokysdk-linux" SSTATE_MIRRORS = "SSTATE_MIRRORS" +TMP_DIR = "TMPDIR" NATIVE_GCC_DIR = '/usr1/openeuler/native_gcc' SSTATE_CACHE = '/usr1/openeuler/sstate-cache' @@ -148,6 +149,14 @@ class LocalConf: content=content ) + # replace tmpdir + if parse_compile.tmp_dir is not None: + content = match_and_replace( + pre=TMP_DIR, + new_str= TMP_DIR + ' = "' + parse_compile.tmp_dir + '"', + content=content + ) + content = self.match_lib_param(content=content) content = self._match_lib(parse_compile=parse_compile, content=content) diff --git a/src/oebuild/parse_compile.py b/src/oebuild/parse_compile.py index 1cacf4f..b8a0e05 100644 --- a/src/oebuild/parse_compile.py +++ b/src/oebuild/parse_compile.py @@ -33,6 +33,8 @@ class Compile(PlatformTemplate): sstate_cache: str + tmp_dir: str + class BaseParseCompileError(ValueError): ''' parse compile basic error @@ -76,6 +78,7 @@ class ParseCompile: toolchain_dir=None if 'toolchain_dir' not in data else data['toolchain_dir'], nativesdk_dir=None if 'nativesdk_dir' not in data else data['nativesdk_dir'], sstate_cache=None if 'sstate_cache' not in data else data['sstate_cache'], + tmp_dir=None if 'tmp_dir' not in data else data['tmp_dir'], not_use_repos=False if 'not_use_repos' not in data else data['not_use_repos'], repos=None if "repos" not in data else ParseTemplate.parse_oebuild_repo(data['repos']), local_conf=None if "local_conf" not in data else data['local_conf'], @@ -152,6 +155,13 @@ class ParseCompile: ''' return self.compile.sstate_cache + @property + def tmp_dir(self): + ''' + return attr of tmp_dir + ''' + return self.compile.tmp_dir + def pull_repos(self, base_dir): ''' Download the repos set in compile.yaml based on the given base path -- Gitee