diff --git a/src/oebuild/app/conf/plugins.yaml b/src/oebuild/app/conf/plugins.yaml index 7aa6c42cb8acb976286a34ad3679cef7d24b1a74..2c62fd974dc9ff862a0042164099cafa672ea086 100644 --- a/src/oebuild/app/conf/plugins.yaml +++ b/src/oebuild/app/conf/plugins.yaml @@ -17,9 +17,3 @@ plugins: - name: clear class: Clear path: plugins/clear/clear.py -- name: compile - class: Compile - path: plugins/compile/compile.py -- name: qemu_run - class: Qemu_run - path: plugins/qemu_run/qemu_run.py diff --git a/src/oebuild/app/plugins/clear/clear.py b/src/oebuild/app/plugins/clear/clear.py index 8b6733c72a065dd67a83e8f77c42bdf10af088d4..91fd29614f0b41a89a817bc6f5fe73be0d235bc6 100644 --- a/src/oebuild/app/plugins/clear/clear.py +++ b/src/oebuild/app/plugins/clear/clear.py @@ -15,6 +15,8 @@ import textwrap import os import pathlib +from docker.errors import DockerException + from oebuild.command import OebuildCommand import oebuild.util as oebuild_util from oebuild.configure import Configure @@ -22,10 +24,13 @@ from oebuild.docker_proxy import DockerProxy from oebuild.m_log import logger class Clear(OebuildCommand): + ''' + for some clear task + ''' def __init__(self): self.configure = Configure() - self.client = DockerProxy() + self.client = None super().__init__( 'clear', 'clear someone which oebuild generate', @@ -58,6 +63,11 @@ class Clear(OebuildCommand): args = args.parse_args(unknown) if args.item == "docker": + try: + self.client = DockerProxy() + except DockerException: + logger.error("please install docker first!!!") + return self.clear_docker() def clear_docker(self,): diff --git a/src/oebuild/app/plugins/compile/compile.py b/src/oebuild/app/plugins/compile/compile.py index 655eda4eda3b1f9948921c6665237939eb3eb5c3..56d6e5cb4b8ac92802cb1cb0178977e6d6705787 100644 --- a/src/oebuild/app/plugins/compile/compile.py +++ b/src/oebuild/app/plugins/compile/compile.py @@ -13,32 +13,27 @@ See the Mulan PSL v2 for more details. import argparse import textwrap import os -import sys -import pathlib -from shutil import copyfile + +from docker.errors import DockerException from docker.models.containers import Container from oebuild.docker_proxy import DockerProxy from oebuild.command import OebuildCommand -import oebuild.util as oebuild_util -from oebuild.parse_compile import ParseCompile,CheckCompileError -from oebuild.configure import Configure, ConfigBasicRepo, YOCTO_META_OPENEULER -from oebuild.parse_template import BaseParseTemplate, ParseTemplate, BUILD_IN_DOCKER, BUILD_IN_HOST -from oebuild.m_log import logger, INFO_COLOR -from oebuild.check_docker_tag import CheckDockerTag - -''' -The command for cross-compile, configure runtime environment, run code and output results. -''' +from oebuild.configure import Configure +from oebuild.m_log import logger class Compile(OebuildCommand): - + ''' + The command for cross-compile, configure runtime environment, run code and output results. + ''' def __init__(self): self.compile_conf_dir = os.path.join(os.getcwd(), 'compile.yaml') self.configure = Configure() - self.client = DockerProxy() + self.client = None self.container_id = None + self.dir_platform = None + self.chain_platform = None super().__init__( 'cross-compile', @@ -67,26 +62,33 @@ class Compile(OebuildCommand): this param is for arch. All possible choices: arm, aarch64, riscv64, x86_64 ''' ) - + return parser def do_run(self, args: argparse.Namespace, unknown=None): - + #logger.info(args) # perpare parse help command if self.pre_parse_help(args, unknown): return # Parse the command-line arguments args = args.parse_args(unknown) - + try: + self.client = DockerProxy() + except DockerException: + logger.error("please install docker first!!!") + return + if(args.source_directory) is None: logger.error('Please specify directory of the source file') self.dir_platform, self.chain_platform = self._check_platform(args) self._check_file(args) self.cross_compile(cross_compile_dir_target_file = args.source_directory) - + def cross_compile(self, cross_compile_dir_target_file): - + ''' + for cross compile task + ''' logger.info("cross-compilation starting ...") default_image = "swr.cn-north-4.myhuaweicloud.com/openeuler-embedded/openeuler-container:latest" diff --git a/src/oebuild/app/plugins/generate/generate.py b/src/oebuild/app/plugins/generate/generate.py index c3c3edb015170acacb455b1c2883bcfb2a7abc6a..63db52946fe761d2025324d80b14950248073684 100644 --- a/src/oebuild/app/plugins/generate/generate.py +++ b/src/oebuild/app/plugins/generate/generate.py @@ -58,37 +58,37 @@ class Generate(OebuildCommand): %(prog)s [-p platform] [-f features] [-t toolchain_dir] [-d build_directory] [-l list] [-b_in build_in] ''') - parser.add_argument('-l', dest='list',action = "store_true", + parser.add_argument('-l', '--list', dest='list',action = "store_true", help=''' will list support archs and features ''' ) - parser.add_argument('-p', dest='platform', default="qemu-aarch64", + parser.add_argument('-p', '--platform', dest='platform', default="qemu-aarch64", help=''' this param is for arch, you can find it in yocto-meta-openeuler/.oebuild/platform ''' ) - parser.add_argument('-s', dest='sstate_cache', + parser.add_argument('-s','--state_cache', dest='sstate_cache', help=''' this param is for SSTATE_MIRRORS ''' ) - parser.add_argument('-s_dir', dest='sstate_dir', + parser.add_argument('-s_dir', '--sstate_dir', dest='sstate_dir', help=''' this param is for SSTATE_DIR ''' ) - parser.add_argument('-m', dest='tmp_dir', + parser.add_argument('-m', '--tmp_dir', dest='tmp_dir', help=''' this param is for tmp directory, the build result will be stored in ''' ) - parser.add_argument('-f', dest='features', action='append', + parser.add_argument('-f', '--features', dest='features', action='append', help=''' this param is feature, it's a reuse command ''' @@ -100,33 +100,33 @@ class Generate(OebuildCommand): ''' ) - parser.add_argument('-d', dest='directory', + parser.add_argument('-d', '--directory', dest='directory', help=''' this param is build directory, the default is same to platform ''' ) - parser.add_argument('-t', dest='toolchain_dir', default = '', + parser.add_argument('-t', '--toolchain_dir', dest='toolchain_dir', default = '', help=''' this param is for external toolchain dir, if you want use your own toolchain ''' ) - parser.add_argument('-n', dest='nativesdk_dir', default = '', + parser.add_argument('-n', '--nativesdk_dir', dest='nativesdk_dir', default = '', help=''' this param is for external nativesdk dir, the param will be useful when you want to build in host ''' ) - parser.add_argument('-tag', dest='docker_tag', default = '', + parser.add_argument('-tag', '--docker_tag', dest='docker_tag', default = '', help=''' when build in docker, the param can be point docker image ''' ) - parser.add_argument('-dt', '--datetime', dest = "is_datetime", action = "store_true", + parser.add_argument('-dt', '--datetime', dest = "datetime", help=''' - this param is add DATETIME to local.conf, the value is getting current time + this param is add DATETIME to local.conf, the value format is 20231212010101 ''') parser.add_argument('-df', @@ -137,7 +137,7 @@ class Generate(OebuildCommand): this param is set openeuler_fetch in local.conf, the default value is enable, if set -df, the OPENEULER_FETCH will set to 'disable' ''') - parser.add_argument('-b_in', dest='build_in', choices=[BUILD_IN_DOCKER, BUILD_IN_HOST], + parser.add_argument('-b_in', '--build_in', dest='build_in', choices=[BUILD_IN_DOCKER, BUILD_IN_HOST], default = BUILD_IN_DOCKER, help=''' This parameter marks the mode at build time, and is built in the container by docker ''' @@ -241,7 +241,7 @@ class Generate(OebuildCommand): check_docker_tag = CheckDockerTag(args.docker_tag, self.configure) oebuild_config = self.configure.parse_oebuild_config() if check_docker_tag.get_tag() is not None: - docker_tag = check_docker_tag.get_tag() + docker_tag = str(check_docker_tag.get_tag()) else: # select docker image while True: @@ -272,7 +272,7 @@ following container, enter it numerically, and enter q to exit:''') build_in=build_in, sstate_cache= self.sstate_cache, tmp_dir = self.tmp_dir, - is_datetime = args.is_datetime, + datetime = args.datetime, is_disable_fetch = args.is_disable_fetch, docker_image=docker_image )) diff --git a/src/oebuild/app/plugins/init/init.py b/src/oebuild/app/plugins/init/init.py index 602a629aa39ffbea0145d0d011311609225101cc..5644e1d4ff84850bc24d8180a24e66fccdf14cbb 100644 --- a/src/oebuild/app/plugins/init/init.py +++ b/src/oebuild/app/plugins/init/init.py @@ -59,10 +59,10 @@ class Init(OebuildCommand): %(prog)s [directory] [-u yocto_remote_url] [-b branch] ''') - parser_adder.add_argument('-u', dest = 'yocto_remote_url', + parser_adder.add_argument('-u','--yocto_remote_url', dest = 'yocto_remote_url', help='''Specifies the remote of yocto-meta-openeuler''') - parser_adder.add_argument('-b', dest = 'branch', + parser_adder.add_argument('-b', '--branch', dest = 'branch', help='''Specifies the branch of yocto-meta-openeuler''') parser_adder.add_argument( diff --git a/src/oebuild/app/plugins/manifest/manifest.py b/src/oebuild/app/plugins/manifest/manifest.py index f20b9e9cea1bed758b246d7ca2f8e6315a18e720..1eaca5e2604def23e7009eb995bb413ff83d5ac9 100644 --- a/src/oebuild/app/plugins/manifest/manifest.py +++ b/src/oebuild/app/plugins/manifest/manifest.py @@ -74,6 +74,7 @@ class Manifest(OebuildCommand): ''') parser.add_argument('-m_dir', + '--manifest_dir', dest='manifest_dir', help=''' specify a manifest path to perform the create or restore operation diff --git a/src/oebuild/app/plugins/qemu_run/qemu_run.py b/src/oebuild/app/plugins/qemu_run/qemu_run.py index 2860dd8781cb2aad92ae1c401e36191c93881cdb..b7a8401b07ead486e60402fc949ed3ffb2f45833 100644 --- a/src/oebuild/app/plugins/qemu_run/qemu_run.py +++ b/src/oebuild/app/plugins/qemu_run/qemu_run.py @@ -13,31 +13,24 @@ See the Mulan PSL v2 for more details. import argparse import textwrap import os -import sys -import pathlib -from shutil import copyfile + +from docker.errors import DockerException from docker.models.containers import Container from oebuild.docker_proxy import DockerProxy from oebuild.command import OebuildCommand -import oebuild.util as oebuild_util -from oebuild.parse_compile import ParseCompile,CheckCompileError -from oebuild.configure import Configure, ConfigBasicRepo, YOCTO_META_OPENEULER -from oebuild.parse_template import BaseParseTemplate, ParseTemplate, BUILD_IN_DOCKER, BUILD_IN_HOST -from oebuild.m_log import logger, INFO_COLOR -from oebuild.check_docker_tag import CheckDockerTag - -''' -The command for run executable file under qemu. -''' - -class Qemu_run(OebuildCommand): +from oebuild.configure import Configure +from oebuild.m_log import logger +class QemuRun(OebuildCommand): + ''' + The command for run executable file under qemu. + ''' def __init__(self): self.compile_conf_dir = os.path.join(os.getcwd(), 'compile.yaml') self.configure = Configure() - self.client = DockerProxy() + self.client = None self.container_id = None super().__init__( @@ -73,17 +66,22 @@ class Qemu_run(OebuildCommand): this param is for the mode for running qemu. All possible choices: user, system ''' ) - + return parser def do_run(self, args: argparse.Namespace, unknown=None): - # perpare parse help command if self.pre_parse_help(args, unknown): return # Parse the command-line arguments args = args.parse_args(unknown) + try: + self.client = DockerProxy() + except DockerException: + logger.error("please install docker first!!!") + return + if(args.target_directory) is None: logger.error('Please specify directory of the target file') self._check_file(args) diff --git a/src/oebuild/app/plugins/update/update.py b/src/oebuild/app/plugins/update/update.py index 84409a3883f80e01c14c4fd94664d8a283c6493b..5a3c8bd2108211d6e50c60153e0d244a31b57678 100644 --- a/src/oebuild/app/plugins/update/update.py +++ b/src/oebuild/app/plugins/update/update.py @@ -66,7 +66,7 @@ class Update(OebuildCommand): usage=''' %(prog)s [yocto docker layer] [-tag] ''') - parser.add_argument('-tag', dest='docker_tag', + parser.add_argument('-tag','--tag', dest='docker_tag', help=''' with platform will list support archs, with feature will list support features ''' diff --git a/src/oebuild/oebuild_parser.py b/src/oebuild/oebuild_parser.py index 055a5ff653dbe69a5ce158b077733bdbca512823..5d43b89ba40f6db71501afc32b6ca02355b665b1 100644 --- a/src/oebuild/oebuild_parser.py +++ b/src/oebuild/oebuild_parser.py @@ -111,7 +111,7 @@ class OebuildArgumentParser(argparse.ArgumentParser): self._format_thing_and_help(append, opt_str, help_msg, width) def _format_command(self, append, command, width): - thing = f' {command.name}:' + thing = f' {command.name}' self._format_thing_and_help(append, thing, command.help, width) def _format_thing_and_help(self, append, thing, help_msg: str, width): diff --git a/src/oebuild/parse_template.py b/src/oebuild/parse_template.py index e235457682b08489fca5060de59679ee75eb845f..4443d276c5b6c62264309992477989eebb425a90 100644 --- a/src/oebuild/parse_template.py +++ b/src/oebuild/parse_template.py @@ -14,7 +14,6 @@ from dataclasses import dataclass from typing import Dict, Optional import pathlib import os -import time from ruamel.yaml.scalarstring import LiteralScalarString @@ -169,7 +168,7 @@ class ParseTemplate: build_in: str = BUILD_IN_DOCKER, sstate_cache = None, tmp_dir = None, - is_datetime = False, + datetime = None, is_disable_fetch = False, docker_image = ""): ''' @@ -230,9 +229,8 @@ class ParseTemplate: if feature.local_conf is not None: local_conf = LiteralScalarString(feature.local_conf + '\n' + local_conf) - if is_datetime: - now_time = time.strftime('%Y%m%d%H%M%S', time.localtime(time.time())) - datetime_str = LiteralScalarString(f'DATETIME = "{now_time}"') + if datetime is not None: + datetime_str = LiteralScalarString(f'DATETIME = "{datetime}"') local_conf = LiteralScalarString(local_conf + '\n' + datetime_str) if is_disable_fetch: diff --git a/src/oebuild/version.py b/src/oebuild/version.py index eae0a1229fe673f16ec543f9524cb97023c1aa68..b05f40a938d03e73a745ca47e41ea43885b6725f 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.30' +__version__ = '0.0.31'