summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/contrib/improve_kernel_cve_report.py27
-rw-r--r--scripts/lib/devtool/deploy.py19
-rwxr-xr-xscripts/lib/devtool/ide_sdk.py2
-rw-r--r--scripts/lib/wic/ksparser.py1
-rw-r--r--scripts/lib/wic/plugins/imager/direct.py8
5 files changed, 48 insertions, 9 deletions
diff --git a/scripts/contrib/improve_kernel_cve_report.py b/scripts/contrib/improve_kernel_cve_report.py
index 5c39df05a5..3a15b1ed26 100755
--- a/scripts/contrib/improve_kernel_cve_report.py
+++ b/scripts/contrib/improve_kernel_cve_report.py
@@ -236,6 +236,26 @@ def read_spdx3(spdx):
236 cfiles.add(filename) 236 cfiles.add(filename)
237 return cfiles 237 return cfiles
238 238
239def read_debugsources(file_path):
240 '''
241 Read zstd file from pkgdata to extract sources
242 '''
243 import zstandard as zstd
244 import itertools
245 # Decompress the .zst file
246 cfiles = set()
247 with open(file_path, 'rb') as fh:
248 dctx = zstd.ZstdDecompressor()
249 with dctx.stream_reader(fh) as reader:
250 decompressed_bytes = reader.read()
251 json_data = json.loads(decompressed_bytes)
252 # We need to remove one level from the debug sources
253 for source_list in json_data.values():
254 for source in source_list:
255 src = source.split("/",1)[1]
256 cfiles.add(src)
257 return cfiles
258
239def check_kernel_compiled_files(compiled_files, cve_info): 259def check_kernel_compiled_files(compiled_files, cve_info):
240 """ 260 """
241 Return if a CVE affected us depending on compiled files 261 Return if a CVE affected us depending on compiled files
@@ -373,6 +393,10 @@ def main():
373 help="SPDX2/3 for the kernel. Needs to include compiled sources", 393 help="SPDX2/3 for the kernel. Needs to include compiled sources",
374 ) 394 )
375 parser.add_argument( 395 parser.add_argument(
396 "--debug-sources-file",
397 help="Debug sources zstd file generated from Yocto",
398 )
399 parser.add_argument(
376 "--datadir", 400 "--datadir",
377 type=pathlib.Path, 401 type=pathlib.Path,
378 help="Directory where CVE data is", 402 help="Directory where CVE data is",
@@ -415,6 +439,9 @@ def main():
415 if args.spdx: 439 if args.spdx:
416 compiled_files = read_spdx(args.spdx) 440 compiled_files = read_spdx(args.spdx)
417 logging.info("Total compiled files %d", len(compiled_files)) 441 logging.info("Total compiled files %d", len(compiled_files))
442 if args.debug_sources_file:
443 compiled_files = read_debugsources(args.debug_sources_file)
444 logging.info("Total compiled files %d", len(compiled_files))
418 445
419 if args.old_cve_report: 446 if args.old_cve_report:
420 with open(args.old_cve_report, encoding='ISO-8859-1') as f: 447 with open(args.old_cve_report, encoding='ISO-8859-1') as f:
diff --git a/scripts/lib/devtool/deploy.py b/scripts/lib/devtool/deploy.py
index b5ca8f2c2f..a98b33c571 100644
--- a/scripts/lib/devtool/deploy.py
+++ b/scripts/lib/devtool/deploy.py
@@ -20,9 +20,9 @@ from devtool import exec_fakeroot_no_d, setup_tinfoil, check_workspace_recipe, D
20 20
21logger = logging.getLogger('devtool') 21logger = logging.getLogger('devtool')
22 22
23deploylist_path = '/.devtool' 23deploylist_dirname = '.devtool'
24 24
25def _prepare_remote_script(deploy, verbose=False, dryrun=False, undeployall=False, nopreserve=False, nocheckspace=False): 25def _prepare_remote_script(deploy, destdir='/', verbose=False, dryrun=False, undeployall=False, nopreserve=False, nocheckspace=False):
26 """ 26 """
27 Prepare a shell script for running on the target to 27 Prepare a shell script for running on the target to
28 deploy/undeploy files. We have to be careful what we put in this 28 deploy/undeploy files. We have to be careful what we put in this
@@ -31,6 +31,7 @@ def _prepare_remote_script(deploy, verbose=False, dryrun=False, undeployall=Fals
31 busybox rather than bash with coreutils). 31 busybox rather than bash with coreutils).
32 """ 32 """
33 lines = [] 33 lines = []
34 deploylist_path = os.path.join(destdir, deploylist_dirname)
34 lines.append('#!/bin/sh') 35 lines.append('#!/bin/sh')
35 lines.append('set -e') 36 lines.append('set -e')
36 if undeployall: 37 if undeployall:
@@ -146,7 +147,7 @@ def deploy(args, config, basepath, workspace):
146 except Exception as e: 147 except Exception as e:
147 raise DevtoolError('Exception parsing recipe %s: %s' % 148 raise DevtoolError('Exception parsing recipe %s: %s' %
148 (args.recipename, e)) 149 (args.recipename, e))
149 150
150 srcdir = rd.getVar('D') 151 srcdir = rd.getVar('D')
151 workdir = rd.getVar('WORKDIR') 152 workdir = rd.getVar('WORKDIR')
152 path = rd.getVar('PATH') 153 path = rd.getVar('PATH')
@@ -244,6 +245,7 @@ def deploy_no_d(srcdir, workdir, path, strip_cmd, libdir, base_libdir, max_proce
244 tmpscript = '/tmp/devtool_deploy.sh' 245 tmpscript = '/tmp/devtool_deploy.sh'
245 tmpfilelist = os.path.join(os.path.dirname(tmpscript), 'devtool_deploy.list') 246 tmpfilelist = os.path.join(os.path.dirname(tmpscript), 'devtool_deploy.list')
246 shellscript = _prepare_remote_script(deploy=True, 247 shellscript = _prepare_remote_script(deploy=True,
248 destdir=destdir,
247 verbose=args.show_status, 249 verbose=args.show_status,
248 nopreserve=args.no_preserve, 250 nopreserve=args.no_preserve,
249 nocheckspace=args.no_check_space) 251 nocheckspace=args.no_check_space)
@@ -303,12 +305,19 @@ def undeploy(args, config, basepath, workspace):
303 scp_port = "-P %s" % args.port 305 scp_port = "-P %s" % args.port
304 ssh_port = "-p %s" % args.port 306 ssh_port = "-p %s" % args.port
305 307
306 args.target = args.target.split(':')[0] 308 try:
309 host, destdir = args.target.split(':')
310 except ValueError:
311 destdir = '/'
312 else:
313 args.target = host
314 if not destdir.endswith('/'):
315 destdir += '/'
307 316
308 tmpdir = tempfile.mkdtemp(prefix='devtool') 317 tmpdir = tempfile.mkdtemp(prefix='devtool')
309 try: 318 try:
310 tmpscript = '/tmp/devtool_undeploy.sh' 319 tmpscript = '/tmp/devtool_undeploy.sh'
311 shellscript = _prepare_remote_script(deploy=False, dryrun=args.dry_run, undeployall=args.all) 320 shellscript = _prepare_remote_script(deploy=False, destdir=destdir, dryrun=args.dry_run, undeployall=args.all)
312 # Write out the script to a file 321 # Write out the script to a file
313 with open(os.path.join(tmpdir, os.path.basename(tmpscript)), 'w') as f: 322 with open(os.path.join(tmpdir, os.path.basename(tmpscript)), 'w') as f:
314 f.write(shellscript) 323 f.write(shellscript)
diff --git a/scripts/lib/devtool/ide_sdk.py b/scripts/lib/devtool/ide_sdk.py
index d9b54f7991..87a4c13ec5 100755
--- a/scripts/lib/devtool/ide_sdk.py
+++ b/scripts/lib/devtool/ide_sdk.py
@@ -104,7 +104,7 @@ class RecipeNative:
104 104
105 105
106class RecipeGdbCross(RecipeNative): 106class RecipeGdbCross(RecipeNative):
107 """Handle handle gdb-cross on the host and the gdbserver on the target device""" 107 """Handle gdb-cross on the host and the gdbserver on the target device"""
108 108
109 def __init__(self, args, target_arch, target_device): 109 def __init__(self, args, target_arch, target_device):
110 super().__init__('gdb-cross-' + target_arch, target_arch) 110 super().__init__('gdb-cross-' + target_arch, target_arch)
diff --git a/scripts/lib/wic/ksparser.py b/scripts/lib/wic/ksparser.py
index a762d3b6cf..48b5b09ddd 100644
--- a/scripts/lib/wic/ksparser.py
+++ b/scripts/lib/wic/ksparser.py
@@ -196,6 +196,7 @@ class KickStart():
196 bootloader.add_argument('--configfile') 196 bootloader.add_argument('--configfile')
197 bootloader.add_argument('--ptable', choices=('msdos', 'gpt', 'gpt-hybrid'), 197 bootloader.add_argument('--ptable', choices=('msdos', 'gpt', 'gpt-hybrid'),
198 default='msdos') 198 default='msdos')
199 bootloader.add_argument('--diskid', type=lambda x: int(x, 0))
199 bootloader.add_argument('--timeout', type=int) 200 bootloader.add_argument('--timeout', type=int)
200 bootloader.add_argument('--source') 201 bootloader.add_argument('--source')
201 202
diff --git a/scripts/lib/wic/plugins/imager/direct.py b/scripts/lib/wic/plugins/imager/direct.py
index 6e1f1c8cba..f40f033a3d 100644
--- a/scripts/lib/wic/plugins/imager/direct.py
+++ b/scripts/lib/wic/plugins/imager/direct.py
@@ -76,7 +76,7 @@ class DirectPlugin(ImagerPlugin):
76 break 76 break
77 77
78 image_path = self._full_path(self.workdir, self.parts[0].disk, "direct") 78 image_path = self._full_path(self.workdir, self.parts[0].disk, "direct")
79 self._image = PartitionedImage(image_path, self.ptable_format, 79 self._image = PartitionedImage(image_path, self.ptable_format, self.ks.bootloader.diskid,
80 self.parts, self.native_sysroot, 80 self.parts, self.native_sysroot,
81 options.extra_space) 81 options.extra_space)
82 82
@@ -302,7 +302,7 @@ class PartitionedImage():
302 Partitioned image in a file. 302 Partitioned image in a file.
303 """ 303 """
304 304
305 def __init__(self, path, ptable_format, partitions, native_sysroot=None, extra_space=0): 305 def __init__(self, path, ptable_format, disk_id, partitions, native_sysroot=None, extra_space=0):
306 self.path = path # Path to the image file 306 self.path = path # Path to the image file
307 self.numpart = 0 # Number of allocated partitions 307 self.numpart = 0 # Number of allocated partitions
308 self.realpart = 0 # Number of partitions in the partition table 308 self.realpart = 0 # Number of partitions in the partition table
@@ -315,7 +315,9 @@ class PartitionedImage():
315 # all partitions (in bytes) 315 # all partitions (in bytes)
316 self.ptable_format = ptable_format # Partition table format 316 self.ptable_format = ptable_format # Partition table format
317 # Disk system identifier 317 # Disk system identifier
318 if os.getenv('SOURCE_DATE_EPOCH'): 318 if disk_id:
319 self.identifier = disk_id
320 elif os.getenv('SOURCE_DATE_EPOCH'):
319 self.identifier = random.Random(int(os.getenv('SOURCE_DATE_EPOCH'))).randint(1, 0xffffffff) 321 self.identifier = random.Random(int(os.getenv('SOURCE_DATE_EPOCH'))).randint(1, 0xffffffff)
320 else: 322 else:
321 self.identifier = random.SystemRandom().randint(1, 0xffffffff) 323 self.identifier = random.SystemRandom().randint(1, 0xffffffff)