1 From 516085675edd2a3330b4ddba10c4b613ee91955b Mon Sep 17 00:00:00 2001
2 From: Jackie Huang <jackie.huang@windriver.com>
3 Date: Wed, 26 Jul 2023 14:55:29 +0800
4 Subject: [PATCH 3/4] build-tools: add supoort for arm64
7 * use ARCH to replace the hardcoded arch names.
8 * Support arch specific pkg list files and yaml files,
9 and the arch specific one (with suffix _arm64) will
14 debian-image_arm64.inc
17 debian_iso_image_arm64.inc
23 base-bullseye_arm64.yaml
25 base-initramfs-bullseye.yaml
26 base-initramfs-bullseye_arm64.yaml
32 PASS: update packages list for arm64 in repos:
38 PASS: downloader -s -b on x86-64 host
39 PASS: downloader -s -b on arm64 host
40 PASS: build-pkgs on x86-64 host
41 PASS: build-image on x86-64 host
42 PASS: build-pkgs on arm64 host
43 PASS: build-image on arm64 host
44 PASS: Deploy AIO-SX on x86-64 target
45 PASS: Deploy AIO-SX on arm64 target
50 Change-Id: I9e381f3f04f6747c68d40011c9eda419219c2311
51 Signed-off-by: Jackie Huang <jackie.huang@windriver.com>
53 build-tools/stx/aptly_deb_usage.py | 12 ++++--
54 build-tools/stx/build-image | 65 ++++++++++++++++++++++++------
55 build-tools/stx/build-pkgs | 8 +++-
56 build-tools/stx/discovery.py | 42 ++++++++++++++++---
57 build-tools/stx/downloader | 2 +-
58 build-tools/stx/repo_manage.py | 9 ++++-
59 6 files changed, 111 insertions(+), 27 deletions(-)
61 diff --git a/build-tools/stx/aptly_deb_usage.py b/build-tools/stx/aptly_deb_usage.py
62 index f1d91c2..d10e6a2 100755
63 --- a/build-tools/stx/aptly_deb_usage.py
64 +++ b/build-tools/stx/aptly_deb_usage.py
65 @@ -25,6 +25,7 @@ from debian import debian_support
68 from typing import Optional
71 PREFIX_LOCAL = 'deb-local-'
72 PREFIX_REMOTE = 'deb-remote-'
73 @@ -34,6 +35,11 @@ SIGN_PASSWD = 'starlingx'
74 DEFAULT_TIMEOUT_COUNT = 1
75 STX_DIST = os.environ.get('STX_DIST')
78 +host_arch = platform.machine()
79 +if host_arch == 'aarch64':
82 # Class used to manage aptly data base, it can:
83 # create_remote: Create a repository link to a remote mirror
84 # deploy_remote: Sync and deploy a remote mirror
85 @@ -326,7 +332,7 @@ class Deb_aptly():
86 self.logger.warning('Drop failed publication %s : %s', publish_name, task_state)
88 task = self.aptly.publish.publish(source_kind='local', sources=[{'Name': repo_name}],
89 - architectures=['amd64', 'source'], prefix=publish_name,
90 + architectures=[STX_ARCH, 'source'], prefix=publish_name,
91 distribution=None, sign_skip=True)
92 task_state = self.__wait_for_task(task, 10)
93 if task_state != 'SUCCEEDED':
94 @@ -366,8 +372,8 @@ class Deb_aptly():
95 extra_param['distribution'] = mirror.distribution
96 extra_param['origin'] = None
98 - # Only support binary_amd64 and source packages
99 - extra_param['architectures'] = ['amd64', 'source']
100 + # Only support binary_amd64/arm64 and source packages
101 + extra_param['architectures'] = [STX_ARCH, 'source']
102 extra_param['distribution'] = None
103 extra_param['origin'] = self.origin
105 diff --git a/build-tools/stx/build-image b/build-tools/stx/build-image
106 index 8536c32..ea04fa2 100755
107 --- a/build-tools/stx/build-image
108 +++ b/build-tools/stx/build-image
109 @@ -28,11 +28,17 @@ import sys
115 STX_DEFAULT_DISTRO = discovery.STX_DEFAULT_DISTRO
116 ALL_LAYERS = discovery.get_all_layers(distro=STX_DEFAULT_DISTRO)
117 ALL_BUILD_TYPES = discovery.get_all_build_types(distro=STX_DEFAULT_DISTRO)
120 +host_arch = platform.machine()
121 +if host_arch == 'aarch64':
124 LAT_ROOT = '/localdisk'
125 REPO_ALL = 'deb-merge-all'
126 REPO_BINARY = 'deb-local-binary'
127 @@ -48,8 +54,8 @@ IMAGE_LAYERS_PATH = os.path.join(
131 -stx_std_kernel = 'linux-image-5.10.0-6-amd64-unsigned'
132 -stx_rt_kernel = 'linux-rt-image-5.10.0-6-rt-amd64-unsigned'
133 +stx_std_kernel = 'linux-image-5.10.0-6-%s-unsigned' % STX_ARCH
134 +stx_rt_kernel = 'linux-rt-image-5.10.0-6-rt-%s-unsigned' % STX_ARCH
135 WAIT_TIME_BEFORE_CHECKING_LOG = 2
136 # The max timeout value to wait LAT to output the build log
137 MAX_WAIT_LAT_TIME = 300
138 @@ -242,7 +248,7 @@ def update_rt_kernel_in_initramfs_yaml(initramfs_yaml):
140 # Updated the name of kernel module
141 for layer in ALL_LAYERS:
142 - pkg_dirs = discovery.package_dir_list(distro=STX_DEFAULT_DISTRO, layer=layer, build_type='rt')
143 + pkg_dirs = discovery.package_dir_list(distro=STX_DEFAULT_DISTRO, layer=layer, build_type='rt', arch=STX_ARCH)
146 for pkg_dir in pkg_dirs:
147 @@ -305,7 +311,7 @@ def add_lat_packages(img_yaml, packages):
148 yaml_doc['packages'].extend(packages)
150 for build_type in ALL_BUILD_TYPES:
151 - pkgs = discovery.package_iso_list(distro=STX_DEFAULT_DISTRO, layer="all", build_type=build_type)
152 + pkgs = discovery.package_iso_list(distro=STX_DEFAULT_DISTRO, layer="all", build_type=build_type, arch=STX_ARCH)
153 yaml_doc['packages'].extend(pkgs)
155 yaml_doc['packages'] = list(set(yaml_doc['packages']))
156 @@ -319,8 +325,16 @@ def add_lat_packages(img_yaml, packages):
159 def check_base_os_binaries(repomgr):
160 - base_bins_list = os.path.join(os.environ.get('MY_REPO_ROOT_DIR'),
161 + base_bins_list_default = os.path.join(os.environ.get('MY_REPO_ROOT_DIR'),
162 'cgcs-root/build-tools/stx/debian-image.inc')
163 + base_bins_list_arch = os.path.join(os.environ.get('MY_REPO_ROOT_DIR'),
164 + 'cgcs-root/build-tools/stx',
165 + 'debian-image_%s.inc' % STX_ARCH)
166 + if os.path.exists(base_bins_list_arch):
167 + base_bins_list = base_bins_list_arch
169 + base_bins_list = base_bins_list_default
171 if not os.path.exists(base_bins_list):
172 logger.error(' '.join(['Base OS packages list', base_bins_list,
174 @@ -338,8 +352,15 @@ def check_base_os_binaries(repomgr):
177 def check_stx_binaries(repomgr, btype='std'):
178 - stx_bins_list = ''.join([PKG_LIST_DIR, '/debian/distro/os-', btype,
180 + stx_bins_list_default = ''.join([PKG_LIST_DIR, '/debian/distro/os-',
182 + stx_bins_list_arch = ''.join([PKG_LIST_DIR, '/debian/distro/os-',
183 + btype, '_', STX_ARCH, '.lst'])
184 + if os.path.exists(stx_bins_list_arch):
185 + stx_bins_list = stx_bins_list_arch
187 + stx_bins_list = stx_bins_list_default
189 if not os.path.exists(stx_bins_list):
190 logger.warning(' '.join(['STX binary packages list', stx_bins_list,
192 @@ -660,16 +681,30 @@ if __name__ == "__main__":
193 logger.error("Fail to get prepared to build image")
196 - base_yaml = os.path.join(PKG_LIST_DIR, 'debian/common/base-bullseye.yaml')
197 - base_initramfs_yaml = os.path.join(PKG_LIST_DIR, 'debian/common/base-initramfs-bullseye.yaml')
198 + base_yaml_default = os.path.join(PKG_LIST_DIR, 'debian/common/base-bullseye.yaml')
199 + base_yaml_arch = os.path.join(PKG_LIST_DIR, 'debian/common/base-bullseye_%s.yaml' % STX_ARCH)
200 + base_initramfs_yaml_default = os.path.join(PKG_LIST_DIR, 'debian/common/base-initramfs-bullseye.yaml')
201 + base_initramfs_yaml_arch = os.path.join(PKG_LIST_DIR, 'debian/common/base-initramfs-bullseye_%s.yaml' % STX_ARCH)
203 os.environ["WORKSPACE_DIR"] = LAT_ROOT
204 lat_yaml = os.path.join(LAT_ROOT, "lat.yaml")
205 lat_initramfs_yaml = os.path.join(LAT_ROOT, "lat-initramfs.yaml")
207 - for yaml_file in (base_yaml, base_initramfs_yaml):
208 - if not os.path.exists(yaml_file):
209 - logger.error(' '.join(['Base yaml file', yaml_file, 'does not exist']))
211 + if os.path.exists(base_yaml_arch):
212 + base_yaml = base_yaml_arch
213 + elif os.path.exists(base_yaml_default):
214 + base_yaml = base_yaml_default
216 + logger.error(' '.join(['Base yaml file', base_yaml_default, 'does not exist']))
219 + if os.path.exists(base_initramfs_yaml_arch):
220 + base_initramfs_yaml = base_initramfs_yaml_arch
221 + elif os.path.exists(base_initramfs_yaml_default):
222 + base_initramfs_yaml = base_initramfs_yaml_default
224 + logger.error(' '.join(['Base yaml file', base_initramfs_yaml_default, 'does not exist']))
227 if not os.path.exists(LAT_ROOT):
228 os.makedirs(LAT_ROOT)
229 @@ -758,6 +793,10 @@ if __name__ == "__main__":
230 logger.info("build-image successfully done, check the output in %s", LAT_ROOT)
233 + if STX_ARCH == "arm64" and "INFO: Create ISO Image: Succeeded" in line:
234 + logger.info("build-image successfully done, check the output in %s", LAT_ROOT)
240 diff --git a/build-tools/stx/build-pkgs b/build-tools/stx/build-pkgs
241 index a8feaa9..9dacef3 100755
242 --- a/build-tools/stx/build-pkgs
243 +++ b/build-tools/stx/build-pkgs
244 @@ -37,7 +37,7 @@ import tempfile
251 BUILDER_URL = os.environ.get('BUILDER_URL')
252 REPOMGR_URL = os.environ.get('REPOMGR_URL')
253 @@ -49,6 +49,10 @@ USER = os.environ.get('MYUNAME')
254 PROJECT = os.environ.get('PROJECT')
255 DISTRIBUTION = os.environ.get('DEBIAN_DISTRIBUTION')
257 +host_arch = platform.machine()
258 +if host_arch == 'aarch64':
261 STX_META_NAME = 'stx-meta'
262 STX_META_PKG = 'stx-meta_1.0.orig.tar.gz'
263 # Different reasons can lead to package build failure
264 @@ -1658,7 +1662,7 @@ class BuildController():
265 logger.error('Failed to specify build_type')
268 - pkg_dirs = discovery.package_dir_list(distro=self.attrs['distro'], layer=layer, build_type=build_type)
269 + pkg_dirs = discovery.package_dir_list(distro=self.attrs['distro'], layer=layer, build_type=build_type, arch=STX_ARCH)
270 layer_pkg_dirs = pkg_dirs
273 diff --git a/build-tools/stx/discovery.py b/build-tools/stx/discovery.py
274 index 3de7d48..d16e520 100644
275 --- a/build-tools/stx/discovery.py
276 +++ b/build-tools/stx/discovery.py
277 @@ -17,6 +17,7 @@ import os
283 from git_utils import git_list
284 from repo_utils import repo_root
285 @@ -30,6 +31,11 @@ STX_DEFAULT_DISTRO_LIST = [ "debian", "centos" ]
286 STX_DEFAULT_BUILD_TYPE = "std"
287 STX_DEFAULT_BUILD_TYPE_LIST = [STX_DEFAULT_BUILD_TYPE]
290 +STX_SUPPORTED_ARCH = ["amd64", "arm64"]
291 +host_arch = platform.machine()
292 +if host_arch == 'aarch64':
295 def get_all_distros():
296 distro_lst = STX_DEFAULT_DISTRO_LIST
297 @@ -126,6 +132,14 @@ def get_layer_build_types (layer, distro="debian", skip_non_buildable=True):
298 for proj_dir in project_dir_list_all:
299 for pkg_dir_file in glob.glob("%s/%s%s" % (proj_dir, distro, "_pkg_dirs_*")):
300 bt = os.path.basename(pkg_dir_file).split("_pkg_dirs_")[1]
301 + # cleanup arch specific suffix
302 + if bt in STX_SUPPORTED_ARCH:
305 + for arch in STX_SUPPORTED_ARCH:
306 + arch_suffix = "_" + arch
307 + if bt.endswith(arch_suffix):
308 + bt = bt.replace(arch_suffix, "")
311 return sort_build_type_list(bt_lst, layer)
312 @@ -137,6 +151,14 @@ def get_all_build_types (distro="debian", skip_non_buildable=True):
313 for proj_dir in project_dir_list_all:
314 for pkg_dir_file in glob.glob("%s/%s%s" % (proj_dir, distro, "_pkg_dirs_*")):
315 bt = os.path.basename(pkg_dir_file).split("_pkg_dirs_")[1]
316 + # cleanup arch specific suffix
317 + if bt in STX_SUPPORTED_ARCH:
320 + for arch in STX_SUPPORTED_ARCH:
321 + arch_suffix = "_" + arch
322 + if bt.endswith(arch_suffix):
323 + bt = bt.replace(arch_suffix, "")
326 return sorted(bt_lst)
327 @@ -186,32 +208,40 @@ def package_dir_list_handler(entry, proj_dir):
331 -def package_iso_list (distro="debian", layer="all", build_type="std", skip_non_buildable=True):
332 +def package_iso_list (distro="debian", layer="all", build_type="std", arch=STX_ARCH, skip_non_buildable=True):
336 for proj_dir in project_dir_list(distro=distro, layer=layer, skip_non_buildable=skip_non_buildable):
337 - iso_file = os.path.join(proj_dir, "%s%s%s%s" % (distro, "_iso_image_", build_type, ".inc"))
338 + iso_file = os.path.join(proj_dir, "%s_%s_%s_%s%s" % (distro, "iso_image", build_type, arch, ".inc"))
339 + if not os.path.isfile(iso_file):
340 + iso_file = os.path.join(proj_dir, "%s_%s_%s%s" % (distro, "iso_image", build_type, ".inc"))
341 if not os.path.isfile(iso_file):
342 if build_type == "std":
343 # It's permitted to omit the "_std" suffix from the file name
344 - iso_file = os.path.join(proj_dir, "%s%s" % (distro, "_iso_image.inc"))
345 + iso_file = os.path.join(proj_dir, "%s_%s_%s%s" % (distro, "iso_image", arch, ".inc"))
346 + if not os.path.isfile(iso_file):
347 + iso_file = os.path.join(proj_dir, "%s_%s" % (distro, "iso_image.inc"))
348 if not os.path.isfile(iso_file):
350 pkg_iso_list.extend(bc_safe_fetch(iso_file))
354 -def package_dir_list (distro="debian", layer="all", build_type="std", skip_non_buildable=True):
355 +def package_dir_list (distro="debian", layer="all", build_type="std", arch=STX_ARCH, skip_non_buildable=True):
359 for proj_dir in project_dir_list(distro=distro, layer=layer, skip_non_buildable=skip_non_buildable):
360 - pkg_file = os.path.join(proj_dir, "%s%s%s" % (distro, "_pkg_dirs_", build_type))
361 + pkg_file = os.path.join(proj_dir, "%s_%s_%s_%s" % (distro, "pkg_dirs", build_type, arch))
362 + if not os.path.isfile(pkg_file):
363 + pkg_file = os.path.join(proj_dir, "%s_%s_%s" % (distro, "pkg_dirs", build_type))
364 if not os.path.isfile(pkg_file):
365 if build_type == "std":
366 # It's permitted to omit the "_std" suffix from the file name
367 - pkg_file = os.path.join(proj_dir, "%s%s" % (distro, "_pkg_dirs"))
368 + pkg_file = os.path.join(proj_dir, "%s_%s_%s" % (distro, "pkg_dirs", arch))
369 + if not os.path.isfile(pkg_file):
370 + pkg_file = os.path.join(proj_dir, "%s_%s" % (distro, "pkg_dirs"))
371 if not os.path.isfile(pkg_file):
373 pkg_dir_list.extend(bc_safe_fetch(pkg_file, package_dir_list_handler, proj_dir))
374 diff --git a/build-tools/stx/downloader b/build-tools/stx/downloader
375 index 2d98707..47093ea 100755
376 --- a/build-tools/stx/downloader
377 +++ b/build-tools/stx/downloader
378 @@ -635,7 +635,7 @@ class SrcDownloader(BaseDownloader):
379 logger.warning(' '.join([build_type, 'is not a valid build_type for distro', distro, 'of layer', layer]))
382 - pkg_dirs.extend(discovery.package_dir_list(distro=distro, layer=layer, build_type=build_type))
383 + pkg_dirs.extend(discovery.package_dir_list(distro=distro, layer=layer, build_type=build_type, arch=STX_ARCH))
385 if not len(pkg_dirs):
386 logger.info("No source packages found")
387 diff --git a/build-tools/stx/repo_manage.py b/build-tools/stx/repo_manage.py
388 index dbe0cc3..bf68b70 100755
389 --- a/build-tools/stx/repo_manage.py
390 +++ b/build-tools/stx/repo_manage.py
391 @@ -31,6 +31,7 @@ import shutil
392 from threading import Lock
393 import urllib.request
397 REPOMGR_URL = os.environ.get('REPOMGR_URL')
398 REPOMGR_ORIGIN = os.environ.get('REPOMGR_ORIGIN')
399 @@ -38,6 +39,10 @@ REPOMGR_DEPLOY_URL = os.environ.get('REPOMGR_DEPLOY_URL')
404 +host_arch = platform.machine()
405 +if host_arch == 'aarch64':
410 @@ -497,7 +502,7 @@ class RepoMgr():
411 # kwargs:url: URL of the upstream repo (http://deb.debian.org/debian)
412 # kwargs:distribution: the distribution of the repo (bullseye)
413 # kwargs:component: component of the repo (main)
414 - # kwargs:architecture: architecture of the repo, "all" is always enabled. (amd64)
415 + # kwargs:architecture: architecture of the repo, "all" is always enabled. (amd64 or arm64)
416 # kwargs:with_sources: include source packages, default is False.
418 def mirror(self, repo_name, **kwargs):
419 @@ -923,7 +928,7 @@ def subcmd_mirror(subparsers):
420 mirror_parser.add_argument('--component', '-c', help='component name', required=False,
422 mirror_parser.add_argument('--architectures', '-a', help='architectures', required=False,
425 mirror_parser.add_argument('--with-sources', '-s', help='include source packages',
427 mirror_parser.set_defaults(handle=_handleMirror)