oebuild 0.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- usr/local/bin/oebuild +33 -0
- usr/local/lib/python3.10/dist-packages/oebuild/__init__.py +0 -0
- usr/local/lib/python3.10/dist-packages/oebuild/__main__.py +15 -0
- usr/local/lib/python3.10/dist-packages/oebuild/__pycache__/__init__.cpython-310.pyc +0 -0
- usr/local/lib/python3.10/dist-packages/oebuild/__pycache__/__main__.cpython-310.pyc +0 -0
- usr/local/lib/python3.10/dist-packages/oebuild/__pycache__/bblayers.cpython-310.pyc +0 -0
- usr/local/lib/python3.10/dist-packages/oebuild/__pycache__/command.cpython-310.pyc +0 -0
- usr/local/lib/python3.10/dist-packages/oebuild/__pycache__/configure.cpython-310.pyc +0 -0
- usr/local/lib/python3.10/dist-packages/oebuild/__pycache__/docker_proxy.cpython-310.pyc +0 -0
- usr/local/lib/python3.10/dist-packages/oebuild/__pycache__/local_conf.cpython-310.pyc +0 -0
- usr/local/lib/python3.10/dist-packages/oebuild/__pycache__/my_log.cpython-310.pyc +0 -0
- usr/local/lib/python3.10/dist-packages/oebuild/__pycache__/ogit.cpython-310.pyc +0 -0
- usr/local/lib/python3.10/dist-packages/oebuild/__pycache__/parse_compile.cpython-310.pyc +0 -0
- usr/local/lib/python3.10/dist-packages/oebuild/__pycache__/parse_env.cpython-310.pyc +0 -0
- usr/local/lib/python3.10/dist-packages/oebuild/__pycache__/parse_template.cpython-310.pyc +0 -0
- usr/local/lib/python3.10/dist-packages/oebuild/__pycache__/util.cpython-310.pyc +0 -0
- usr/local/lib/python3.10/dist-packages/oebuild/__pycache__/version.cpython-310.pyc +0 -0
- usr/local/lib/python3.10/dist-packages/oebuild/app/__init__.py +0 -0
- usr/local/lib/python3.10/dist-packages/oebuild/app/__pycache__/__init__.cpython-310.pyc +0 -0
- usr/local/lib/python3.10/dist-packages/oebuild/app/__pycache__/main.cpython-310.pyc +0 -0
- usr/local/lib/python3.10/dist-packages/oebuild/app/conf/config.yaml +11 -0
- usr/local/lib/python3.10/dist-packages/oebuild/app/conf/plugins.yaml +16 -0
- usr/local/lib/python3.10/dist-packages/oebuild/app/conf/upgrade.yaml +3 -0
- usr/local/lib/python3.10/dist-packages/oebuild/app/main.py +346 -0
- usr/local/lib/python3.10/dist-packages/oebuild/app/plugins/bitbake/__init__.py +0 -0
- usr/local/lib/python3.10/dist-packages/oebuild/app/plugins/bitbake/__pycache__/__init__.cpython-310.pyc +0 -0
- usr/local/lib/python3.10/dist-packages/oebuild/app/plugins/bitbake/__pycache__/base_build.cpython-310.pyc +0 -0
- usr/local/lib/python3.10/dist-packages/oebuild/app/plugins/bitbake/__pycache__/bitbake.cpython-310.pyc +0 -0
- usr/local/lib/python3.10/dist-packages/oebuild/app/plugins/bitbake/__pycache__/const.cpython-310.pyc +0 -0
- usr/local/lib/python3.10/dist-packages/oebuild/app/plugins/bitbake/__pycache__/in_container.cpython-310.pyc +0 -0
- usr/local/lib/python3.10/dist-packages/oebuild/app/plugins/bitbake/__pycache__/in_host.cpython-310.pyc +0 -0
- usr/local/lib/python3.10/dist-packages/oebuild/app/plugins/bitbake/base_build.py +75 -0
- usr/local/lib/python3.10/dist-packages/oebuild/app/plugins/bitbake/bitbake.py +112 -0
- usr/local/lib/python3.10/dist-packages/oebuild/app/plugins/bitbake/const.py +22 -0
- usr/local/lib/python3.10/dist-packages/oebuild/app/plugins/bitbake/in_container.py +327 -0
- usr/local/lib/python3.10/dist-packages/oebuild/app/plugins/bitbake/in_host.py +143 -0
- usr/local/lib/python3.10/dist-packages/oebuild/app/plugins/demo/__pycache__/demo.cpython-310.pyc +0 -0
- usr/local/lib/python3.10/dist-packages/oebuild/app/plugins/demo/demo.py +36 -0
- usr/local/lib/python3.10/dist-packages/oebuild/app/plugins/generate/__pycache__/generate.cpython-310.pyc +0 -0
- usr/local/lib/python3.10/dist-packages/oebuild/app/plugins/generate/generate.py +299 -0
- usr/local/lib/python3.10/dist-packages/oebuild/app/plugins/init/__pycache__/init.cpython-310.pyc +0 -0
- usr/local/lib/python3.10/dist-packages/oebuild/app/plugins/init/init.py +157 -0
- usr/local/lib/python3.10/dist-packages/oebuild/app/plugins/update/__pycache__/update.cpython-310.pyc +0 -0
- usr/local/lib/python3.10/dist-packages/oebuild/app/plugins/update/update.py +201 -0
- usr/local/lib/python3.10/dist-packages/oebuild/app/plugins/upgrade/__pycache__/upgrade.cpython-310.pyc +0 -0
- usr/local/lib/python3.10/dist-packages/oebuild/app/plugins/upgrade/upgrade.py +96 -0
- usr/local/lib/python3.10/dist-packages/oebuild/bb/__init__.py +0 -0
- usr/local/lib/python3.10/dist-packages/oebuild/bb/__pycache__/__init__.cpython-310.pyc +0 -0
- usr/local/lib/python3.10/dist-packages/oebuild/bb/__pycache__/utils.cpython-310.pyc +0 -0
- usr/local/lib/python3.10/dist-packages/oebuild/bb/utils.py +364 -0
- usr/local/lib/python3.10/dist-packages/oebuild/bblayers.py +83 -0
- usr/local/lib/python3.10/dist-packages/oebuild/command.py +219 -0
- usr/local/lib/python3.10/dist-packages/oebuild/configure.py +207 -0
- usr/local/lib/python3.10/dist-packages/oebuild/docker_proxy.py +289 -0
- usr/local/lib/python3.10/dist-packages/oebuild/local_conf.py +239 -0
- usr/local/lib/python3.10/dist-packages/oebuild/my_log.py +58 -0
- usr/local/lib/python3.10/dist-packages/oebuild/ogit.py +139 -0
- usr/local/lib/python3.10/dist-packages/oebuild/parse_compile.py +206 -0
- usr/local/lib/python3.10/dist-packages/oebuild/parse_env.py +143 -0
- usr/local/lib/python3.10/dist-packages/oebuild/parse_template.py +261 -0
- usr/local/lib/python3.10/dist-packages/oebuild/util.py +125 -0
- usr/local/lib/python3.10/dist-packages/oebuild/version.py +13 -0
- usr/local/lib/python3.10/dist-packages/oebuild-0.0.1.egg-info/PKG-INFO +564 -0
- usr/local/lib/python3.10/dist-packages/oebuild-0.0.1.egg-info/SOURCES.txt +43 -0
- usr/local/lib/python3.10/dist-packages/oebuild-0.0.1.egg-info/dependency_links.txt +1 -0
- usr/local/lib/python3.10/dist-packages/oebuild-0.0.1.egg-info/entry_points.txt +3 -0
- usr/local/lib/python3.10/dist-packages/oebuild-0.0.1.egg-info/requires.txt +9 -0
- usr/local/lib/python3.10/dist-packages/oebuild-0.0.1.egg-info/top_level.txt +1 -0
usr/local/bin/oebuild
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
#!/usr/bin/python
|
|
2
|
+
# EASY-INSTALL-ENTRY-SCRIPT: 'oebuild==0.0.1','console_scripts','oebuild'
|
|
3
|
+
import re
|
|
4
|
+
import sys
|
|
5
|
+
|
|
6
|
+
# for compatibility with easy_install; see #2198
|
|
7
|
+
__requires__ = 'oebuild==0.0.1'
|
|
8
|
+
|
|
9
|
+
try:
|
|
10
|
+
from importlib.metadata import distribution
|
|
11
|
+
except ImportError:
|
|
12
|
+
try:
|
|
13
|
+
from importlib_metadata import distribution
|
|
14
|
+
except ImportError:
|
|
15
|
+
from pkg_resources import load_entry_point
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def importlib_load_entry_point(spec, group, name):
|
|
19
|
+
dist_name, _, _ = spec.partition('==')
|
|
20
|
+
matches = (
|
|
21
|
+
entry_point
|
|
22
|
+
for entry_point in distribution(dist_name).entry_points
|
|
23
|
+
if entry_point.group == group and entry_point.name == name
|
|
24
|
+
)
|
|
25
|
+
return next(matches).load()
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
globals().setdefault('load_entry_point', importlib_load_entry_point)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
if __name__ == '__main__':
|
|
32
|
+
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
|
|
33
|
+
sys.exit(load_entry_point('oebuild==0.0.1', 'console_scripts', 'oebuild')())
|
|
File without changes
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'''
|
|
2
|
+
Copyright (c) 2023 openEuler Embedded
|
|
3
|
+
oebuild is licensed under Mulan PSL v2.
|
|
4
|
+
You can use this software according to the terms and conditions of the Mulan PSL v2.
|
|
5
|
+
You may obtain a copy of Mulan PSL v2 at:
|
|
6
|
+
http://license.coscl.org.cn/MulanPSL2
|
|
7
|
+
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
|
8
|
+
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
|
9
|
+
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
|
10
|
+
See the Mulan PSL v2 for more details.
|
|
11
|
+
'''
|
|
12
|
+
|
|
13
|
+
from oebuild.app.main import main
|
|
14
|
+
|
|
15
|
+
main()
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
docker:
|
|
2
|
+
repo_url: swr.cn-north-4.myhuaweicloud.com/openeuler-embedded/openeuler-container
|
|
3
|
+
tag_map:
|
|
4
|
+
openEuler-22.09: "22.09"
|
|
5
|
+
openEuler-22.03-lts-sp1: "22.03-lts-sp1"
|
|
6
|
+
master: "latest"
|
|
7
|
+
basic_repo:
|
|
8
|
+
yocto_meta_openeuler:
|
|
9
|
+
path: yocto-meta-openeuler
|
|
10
|
+
remote_url: https://gitee.com/openeuler/yocto-meta-openeuler.git
|
|
11
|
+
branch: master
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
plugins:
|
|
2
|
+
- name: init
|
|
3
|
+
class: Init
|
|
4
|
+
path: plugins/init/init.py
|
|
5
|
+
- name: update
|
|
6
|
+
class: Update
|
|
7
|
+
path: plugins/update/update.py
|
|
8
|
+
- name: generate
|
|
9
|
+
class: Generate
|
|
10
|
+
path: plugins/generate/generate.py
|
|
11
|
+
- name: bitbake
|
|
12
|
+
class: Bitbake
|
|
13
|
+
path: plugins/bitbake/bitbake.py
|
|
14
|
+
- name: upgrade
|
|
15
|
+
class: Upgrade
|
|
16
|
+
path: plugins/upgrade/upgrade.py
|
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
'''
|
|
2
|
+
Copyright (c) 2023 openEuler Embedded
|
|
3
|
+
oebuild is licensed under Mulan PSL v2.
|
|
4
|
+
You can use this software according to the terms and conditions of the Mulan PSL v2.
|
|
5
|
+
You may obtain a copy of Mulan PSL v2 at:
|
|
6
|
+
http://license.coscl.org.cn/MulanPSL2
|
|
7
|
+
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
|
8
|
+
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
|
9
|
+
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
|
10
|
+
See the Mulan PSL v2 for more details.
|
|
11
|
+
'''
|
|
12
|
+
|
|
13
|
+
import sys
|
|
14
|
+
import argparse
|
|
15
|
+
import pathlib
|
|
16
|
+
import shutil
|
|
17
|
+
import textwrap
|
|
18
|
+
from io import StringIO
|
|
19
|
+
from collections import OrderedDict
|
|
20
|
+
import getpass
|
|
21
|
+
|
|
22
|
+
import colorama
|
|
23
|
+
|
|
24
|
+
import oebuild.util as oebuild_util
|
|
25
|
+
from oebuild.version import __version__
|
|
26
|
+
from oebuild.command import ExtCommand, extension_commands
|
|
27
|
+
from oebuild.my_log import MyLog as log
|
|
28
|
+
|
|
29
|
+
APP = "app"
|
|
30
|
+
|
|
31
|
+
class OebuildApp:
|
|
32
|
+
'''
|
|
33
|
+
The execution body of the oebuild tool, and all oebuild
|
|
34
|
+
commands are resolved and executed by this body
|
|
35
|
+
'''
|
|
36
|
+
def __init__(self):
|
|
37
|
+
self.base_oebuild_dir = oebuild_util.get_base_oebuild()
|
|
38
|
+
self.oebuild_parser = None
|
|
39
|
+
self.subparser_gen = None
|
|
40
|
+
self.cmd = None
|
|
41
|
+
try:
|
|
42
|
+
plugins_dir = pathlib.Path(self.base_oebuild_dir,'app/conf','plugins.yaml')
|
|
43
|
+
self.command_ext = self.get_command_ext(oebuild_util.read_yaml(plugins_dir)['plugins'])
|
|
44
|
+
self.command_spec = {}
|
|
45
|
+
except Exception as e_p:
|
|
46
|
+
raise e_p
|
|
47
|
+
|
|
48
|
+
@staticmethod
|
|
49
|
+
def get_command_ext(plugins:list):
|
|
50
|
+
'''
|
|
51
|
+
return command information object
|
|
52
|
+
'''
|
|
53
|
+
command_ext = OrderedDict()
|
|
54
|
+
for app in plugins:
|
|
55
|
+
command_ext[app['name']] = ExtCommand(
|
|
56
|
+
name=app['name'],
|
|
57
|
+
class_name=app['class'],
|
|
58
|
+
path=app['path'])
|
|
59
|
+
return command_ext
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def _load_extension_specs(self, ):
|
|
63
|
+
self.command_spec = extension_commands(APP, self.command_ext)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def _setup_parsers(self):
|
|
67
|
+
# Set up and install command-line argument parsers.
|
|
68
|
+
|
|
69
|
+
oebuild_parser, subparser_gen = self.make_parsers()
|
|
70
|
+
|
|
71
|
+
# Add sub-parsers for the command_ext commands.
|
|
72
|
+
for command_name in self.command_ext:
|
|
73
|
+
subparser_gen.add_parser(command_name, add_help=False)
|
|
74
|
+
|
|
75
|
+
# Save the instance state.
|
|
76
|
+
self.oebuild_parser = oebuild_parser
|
|
77
|
+
self.subparser_gen = subparser_gen
|
|
78
|
+
|
|
79
|
+
def make_parsers(self,):
|
|
80
|
+
'''
|
|
81
|
+
Make a fresh instance of the top level argument parser
|
|
82
|
+
and subparser generator, and return them in that order.
|
|
83
|
+
The prog='oebuild' override avoids the absolute path of the
|
|
84
|
+
main.py script showing up when West is run via the wrapper
|
|
85
|
+
'''
|
|
86
|
+
|
|
87
|
+
parser = OebuildArgumentParser(
|
|
88
|
+
prog='oebuild', description='The openEuler Embedded meta-tool.',
|
|
89
|
+
epilog='''Run "oebuild <command> -h" for help on each <command>.''',
|
|
90
|
+
add_help=False, oebuild_app=self
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
parser.add_argument('-h', '--help', action=OebuildHelpAction, nargs=0,
|
|
94
|
+
help='get help for oebuild or a command')
|
|
95
|
+
|
|
96
|
+
parser.add_argument('-v', '--version', action='version',
|
|
97
|
+
version=f'Oebuild version: v{__version__}',
|
|
98
|
+
help='print the program version and exit')
|
|
99
|
+
|
|
100
|
+
subparser_gen = parser.add_subparsers(metavar='<command>',
|
|
101
|
+
dest='command')
|
|
102
|
+
|
|
103
|
+
return parser, subparser_gen
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def _check_command(self, args):
|
|
107
|
+
if args.help or \
|
|
108
|
+
args.command is None or \
|
|
109
|
+
args.command not in self.command_ext or \
|
|
110
|
+
args.command == 'help':
|
|
111
|
+
self.help()
|
|
112
|
+
return False
|
|
113
|
+
|
|
114
|
+
return True
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def run_command(self, argv):
|
|
118
|
+
'''
|
|
119
|
+
Parse command line arguments and run the OebuildCommand.
|
|
120
|
+
If we're running an extension, instantiate it from its
|
|
121
|
+
spec and re-parse arguments before running.
|
|
122
|
+
'''
|
|
123
|
+
args, unknown = self.oebuild_parser.parse_known_args(args=argv)
|
|
124
|
+
|
|
125
|
+
if not self._check_command(args=args):
|
|
126
|
+
return
|
|
127
|
+
|
|
128
|
+
# Finally, run the command.
|
|
129
|
+
self._run_extension(args.command, unknown)
|
|
130
|
+
|
|
131
|
+
def _run_extension(self, name, unknown):
|
|
132
|
+
# Check a program invariant.
|
|
133
|
+
self.cmd =self.command_spec[name].factory()
|
|
134
|
+
|
|
135
|
+
args = self.cmd.add_parser(self.subparser_gen)
|
|
136
|
+
|
|
137
|
+
self.cmd.run(args, unknown)
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
def run(self, argv):
|
|
141
|
+
'''
|
|
142
|
+
the function will be exec first
|
|
143
|
+
'''
|
|
144
|
+
self._load_extension_specs()
|
|
145
|
+
# Set up initial argument parsers. This requires knowing
|
|
146
|
+
# self.extensions, so it can't happen before now.
|
|
147
|
+
self._setup_parsers()
|
|
148
|
+
|
|
149
|
+
# OK, we are all set. Run the command.
|
|
150
|
+
self.run_command(argv)
|
|
151
|
+
|
|
152
|
+
def help(self,):
|
|
153
|
+
'''
|
|
154
|
+
print help message
|
|
155
|
+
'''
|
|
156
|
+
self.oebuild_parser.print_help(top_level=True)
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
class OebuildHelpAction(argparse.Action):
|
|
160
|
+
'''
|
|
161
|
+
set argparse help is true
|
|
162
|
+
'''
|
|
163
|
+
def __call__(self, parser, namespace, values, option_string=None):
|
|
164
|
+
# Just mark that help was requested.
|
|
165
|
+
namespace.help = True
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
class OebuildArgumentParser(argparse.ArgumentParser):
|
|
169
|
+
'''
|
|
170
|
+
The argparse module is infuriatingly coy about its parser and
|
|
171
|
+
help formatting APIs, marking almost everything you need to
|
|
172
|
+
customize help output an "implementation detail". Even accessing
|
|
173
|
+
the parser's description and epilog attributes as we do here is
|
|
174
|
+
technically breaking the rules.
|
|
175
|
+
|
|
176
|
+
Even though the implementation details have been pretty stable
|
|
177
|
+
since the module was first introduced in Python 3.2, let's avoid
|
|
178
|
+
possible headaches by overriding some "proper" argparse APIs
|
|
179
|
+
here instead of monkey-patching the module or breaking
|
|
180
|
+
abstraction barriers. This is duplicative but more future-proof.
|
|
181
|
+
'''
|
|
182
|
+
|
|
183
|
+
def __init__(self, *args, **kwargs):
|
|
184
|
+
# The super constructor calls add_argument(), so this has to
|
|
185
|
+
# come first as our override of that method relies on it.
|
|
186
|
+
self.oebuild_optionals = []
|
|
187
|
+
self.oebuild_app = kwargs.pop('oebuild_app', None)
|
|
188
|
+
super(OebuildArgumentParser, self).__init__(*args, **kwargs)
|
|
189
|
+
|
|
190
|
+
def print_help(self, file=None, top_level=False):
|
|
191
|
+
print(self.format_help(top_level=top_level), end='',
|
|
192
|
+
file=file or sys.stdout)
|
|
193
|
+
|
|
194
|
+
def format_help(self, top_level=False):
|
|
195
|
+
# When top_level is True, we override the parent method to
|
|
196
|
+
# produce more readable output, which separates commands into
|
|
197
|
+
# logical groups. In order to print optionals, we rely on the
|
|
198
|
+
# data available in our add_argument() override below.
|
|
199
|
+
#
|
|
200
|
+
# If top_level is False, it's because we're being called from
|
|
201
|
+
# one of the subcommand parsers, and we delegate to super.
|
|
202
|
+
|
|
203
|
+
if not top_level:
|
|
204
|
+
return super(OebuildArgumentParser, self).format_help()
|
|
205
|
+
|
|
206
|
+
# Format the help to be at most 75 columns wide, the maximum
|
|
207
|
+
# generally recommended by typographers for readability.
|
|
208
|
+
#
|
|
209
|
+
# If the terminal width (COLUMNS) is less than 75, use width
|
|
210
|
+
# (COLUMNS - 2) instead, unless that is less than 30 columns
|
|
211
|
+
# wide, which we treat as a hard minimum.
|
|
212
|
+
width = min(75, max(shutil.get_terminal_size().columns - 2, 30))
|
|
213
|
+
|
|
214
|
+
with StringIO() as sio:
|
|
215
|
+
|
|
216
|
+
def append(*strings):
|
|
217
|
+
for s_t in strings:
|
|
218
|
+
print(s_t, file=sio)
|
|
219
|
+
|
|
220
|
+
append(self.format_usage(),
|
|
221
|
+
self.description,
|
|
222
|
+
'')
|
|
223
|
+
|
|
224
|
+
append('optional arguments:')
|
|
225
|
+
for w_o in self.oebuild_optionals:
|
|
226
|
+
self._format_oebuild_optional(append, w_o, width)
|
|
227
|
+
|
|
228
|
+
append('')
|
|
229
|
+
for _,command in self.oebuild_app.command_spec.items():
|
|
230
|
+
self._format_command(append, command, width)
|
|
231
|
+
|
|
232
|
+
if self.epilog:
|
|
233
|
+
append(self.epilog)
|
|
234
|
+
|
|
235
|
+
return sio.getvalue()
|
|
236
|
+
|
|
237
|
+
def _format_oebuild_optional(self, append, w_o, width):
|
|
238
|
+
metavar = w_o['metavar']
|
|
239
|
+
options = w_o['options']
|
|
240
|
+
help_msg = w_o.get('help')
|
|
241
|
+
|
|
242
|
+
# Join the various options together as a comma-separated list,
|
|
243
|
+
# with the metavar if there is one. That's our "thing".
|
|
244
|
+
if metavar is not None:
|
|
245
|
+
opt_str = ' ' + ', '.join(f'{o} {metavar}' for o in options)
|
|
246
|
+
else:
|
|
247
|
+
opt_str = ' ' + ', '.join(options)
|
|
248
|
+
|
|
249
|
+
# Delegate to the generic formatter.
|
|
250
|
+
self._format_thing_and_help(append, opt_str, help_msg, width)
|
|
251
|
+
|
|
252
|
+
def _format_command(self, append, command, width):
|
|
253
|
+
thing = f' {command.name}:'
|
|
254
|
+
self._format_thing_and_help(append, thing, command.help, width)
|
|
255
|
+
|
|
256
|
+
def _format_extension_spec(self, append, spec, width):
|
|
257
|
+
self._format_thing_and_help(append, ' ' + spec.name + ':',
|
|
258
|
+
spec.help, width)
|
|
259
|
+
|
|
260
|
+
def _format_thing_and_help(self, append, thing, help_msg, width):
|
|
261
|
+
# Format help for some "thing" (arbitrary text) and its
|
|
262
|
+
# corresponding help text an argparse-like way.
|
|
263
|
+
help_offset = min(max(10, width - 20), 24)
|
|
264
|
+
help_indent = ' ' * help_offset
|
|
265
|
+
|
|
266
|
+
thinglen = len(thing)
|
|
267
|
+
|
|
268
|
+
if help_msg is None:
|
|
269
|
+
# If there's no help string, just print the thing.
|
|
270
|
+
append(thing)
|
|
271
|
+
else:
|
|
272
|
+
# Reflow the lines in help to the desired with, using
|
|
273
|
+
# the help_offset as an initial indent.
|
|
274
|
+
help_msg = ' '.join(help_msg.split())
|
|
275
|
+
help_lines = textwrap.wrap(help_msg, width=width,
|
|
276
|
+
initial_indent=help_indent,
|
|
277
|
+
subsequent_indent=help_indent)
|
|
278
|
+
|
|
279
|
+
if thinglen > help_offset - 1:
|
|
280
|
+
# If the "thing" (plus room for a space) is longer
|
|
281
|
+
# than the initial help offset, print it on its own
|
|
282
|
+
# line, followed by the help on subsequent lines.
|
|
283
|
+
append(thing)
|
|
284
|
+
append(*help_lines)
|
|
285
|
+
else:
|
|
286
|
+
# The "thing" is short enough that we can start
|
|
287
|
+
# printing help on the same line without overflowing
|
|
288
|
+
# the help offset, so combine the "thing" with the
|
|
289
|
+
# first line of help.
|
|
290
|
+
help_lines[0] = thing + help_lines[0][thinglen:]
|
|
291
|
+
append(*help_lines)
|
|
292
|
+
|
|
293
|
+
def add_argument(self, *args, **kwargs):
|
|
294
|
+
# Track information we want for formatting help. The argparse
|
|
295
|
+
# module calls kwargs.pop(), so can't call super first without
|
|
296
|
+
# losing data.
|
|
297
|
+
optional = {'options': [], 'metavar': kwargs.get('metavar', None)}
|
|
298
|
+
need_metavar = (optional['metavar'] is None and
|
|
299
|
+
kwargs.get('action') in (None, 'store'))
|
|
300
|
+
for arg in args:
|
|
301
|
+
if not arg.startswith('-'):
|
|
302
|
+
break
|
|
303
|
+
optional['options'].append(arg)
|
|
304
|
+
# If no metavar was given, the last option name is
|
|
305
|
+
# used. By convention, long options go last, so this
|
|
306
|
+
# matches the default argparse behavior.
|
|
307
|
+
if need_metavar:
|
|
308
|
+
optional['metavar'] = arg.lstrip('-').translate(
|
|
309
|
+
{ord('-'): '_'}).upper()
|
|
310
|
+
optional['help'] = kwargs.get('help')
|
|
311
|
+
self.oebuild_optionals.append(optional)
|
|
312
|
+
|
|
313
|
+
# Let argparse handle the actual argument.
|
|
314
|
+
super().add_argument(*args, **kwargs)
|
|
315
|
+
|
|
316
|
+
def error(self, message):
|
|
317
|
+
# if (self.oebuild_app and
|
|
318
|
+
# self.oebuild_app.mle and
|
|
319
|
+
# isinstance(self.oebuild_app.mle,
|
|
320
|
+
# ManifestVersionError) and
|
|
321
|
+
# self.oebuild_app.cmd):
|
|
322
|
+
# self.oebuild_app.cmd.die(mve_msg(self.west_app.mle))
|
|
323
|
+
super().error(message=message)
|
|
324
|
+
|
|
325
|
+
def check_user():
|
|
326
|
+
'''
|
|
327
|
+
check execute user must in normal user
|
|
328
|
+
'''
|
|
329
|
+
if getpass.getuser() == "root":
|
|
330
|
+
log.err("can not use oebuild in root")
|
|
331
|
+
return False
|
|
332
|
+
return True
|
|
333
|
+
|
|
334
|
+
def main(argv=None):
|
|
335
|
+
'''
|
|
336
|
+
oebuild main entrypoint
|
|
337
|
+
'''
|
|
338
|
+
if not check_user():
|
|
339
|
+
return
|
|
340
|
+
|
|
341
|
+
colorama.init()
|
|
342
|
+
app = OebuildApp()
|
|
343
|
+
app.run(argv or sys.argv[1:])
|
|
344
|
+
|
|
345
|
+
if __name__ == "__main__":
|
|
346
|
+
main()
|
|
File without changes
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
usr/local/lib/python3.10/dist-packages/oebuild/app/plugins/bitbake/__pycache__/const.cpython-310.pyc
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
'''
|
|
2
|
+
Copyright (c) 2023 openEuler Embedded
|
|
3
|
+
oebuild is licensed under Mulan PSL v2.
|
|
4
|
+
You can use this software according to the terms and conditions of the Mulan PSL v2.
|
|
5
|
+
You may obtain a copy of Mulan PSL v2 at:
|
|
6
|
+
http://license.coscl.org.cn/MulanPSL2
|
|
7
|
+
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
|
8
|
+
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
|
9
|
+
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
|
10
|
+
See the Mulan PSL v2 for more details.
|
|
11
|
+
'''
|
|
12
|
+
import os
|
|
13
|
+
|
|
14
|
+
import oebuild.util as oebuild_util
|
|
15
|
+
from oebuild.local_conf import LocalConf
|
|
16
|
+
from oebuild.bblayers import BBLayers
|
|
17
|
+
import oebuild.app.plugins.bitbake.const as bitbake_const
|
|
18
|
+
|
|
19
|
+
class BaseBuild:
|
|
20
|
+
'''
|
|
21
|
+
The class provides the basic methods that the build class inherits
|
|
22
|
+
'''
|
|
23
|
+
def _set_tmpfile_content(self, content: str):
|
|
24
|
+
while True:
|
|
25
|
+
tmp_file = oebuild_util.generate_random_str(6)
|
|
26
|
+
if os.path.exists(tmp_file):
|
|
27
|
+
continue
|
|
28
|
+
with open(tmp_file, 'w', encoding="utf-8") as w_f:
|
|
29
|
+
w_f.write(content)
|
|
30
|
+
break
|
|
31
|
+
return tmp_file
|
|
32
|
+
|
|
33
|
+
def replace_local_conf(self, parse_compile, local_dir, src_dir = None):
|
|
34
|
+
'''
|
|
35
|
+
replace some param in local.conf, the LocalConf will be instantiated
|
|
36
|
+
and exec update
|
|
37
|
+
'''
|
|
38
|
+
local_conf = LocalConf(local_conf_dir=local_dir)
|
|
39
|
+
local_conf.update(parse_compile=parse_compile, src_dir=src_dir)
|
|
40
|
+
|
|
41
|
+
def add_bblayers(self, bblayers_dir: str, pre_dir: str, base_dir: str, layers: list):
|
|
42
|
+
'''
|
|
43
|
+
add_layers has two main functions, one is to initialize
|
|
44
|
+
the compilation directory, and the other is to add the
|
|
45
|
+
bblayer layer so that subsequent build directory file
|
|
46
|
+
replacement operations can be successfully executed
|
|
47
|
+
'''
|
|
48
|
+
bblayers = BBLayers(bblayers_dir=bblayers_dir,
|
|
49
|
+
base_dir=base_dir)
|
|
50
|
+
pre_dir = os.path.join(pre_dir, 'yocto-poky/..')
|
|
51
|
+
bblayers.add_layer(pre_dir=pre_dir, layers=layers)
|
|
52
|
+
|
|
53
|
+
def _restore_bashrc_content(self, old_content):
|
|
54
|
+
new_content = ''
|
|
55
|
+
for line in old_content.split('\n'):
|
|
56
|
+
line: str = line
|
|
57
|
+
if line.endswith(bitbake_const.BASH_END_FLAG) or line.replace(" ", '') == '':
|
|
58
|
+
continue
|
|
59
|
+
new_content = new_content + line + '\n'
|
|
60
|
+
return new_content
|
|
61
|
+
|
|
62
|
+
def _add_bashrc(self, content: str, line: str):
|
|
63
|
+
if not content.endswith('\n'):
|
|
64
|
+
content = content + '\n'
|
|
65
|
+
content = content + line + bitbake_const.BASH_END_FLAG + '\n'
|
|
66
|
+
|
|
67
|
+
return content
|
|
68
|
+
|
|
69
|
+
def _init_bashrc_content(self, old_content, init_command: list):
|
|
70
|
+
new_content = self._restore_bashrc_content(old_content=old_content)
|
|
71
|
+
|
|
72
|
+
for command in init_command:
|
|
73
|
+
new_content = new_content + command + bitbake_const.BASH_END_FLAG + '\n'
|
|
74
|
+
|
|
75
|
+
return new_content
|