diff options
Diffstat (limited to 'scripts/lib')
| -rw-r--r-- | scripts/lib/devtool/deploy.py | 19 | ||||
| -rwxr-xr-x | scripts/lib/devtool/ide_sdk.py | 2 | ||||
| -rw-r--r-- | scripts/lib/wic/ksparser.py | 21 | ||||
| -rw-r--r-- | scripts/lib/wic/plugins/imager/direct.py | 14 | 
4 files changed, 43 insertions, 13 deletions
| 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 | ||
| 21 | logger = logging.getLogger('devtool') | 21 | logger = logging.getLogger('devtool') | 
| 22 | 22 | ||
| 23 | deploylist_path = '/.devtool' | 23 | deploylist_dirname = '.devtool' | 
| 24 | 24 | ||
| 25 | def _prepare_remote_script(deploy, verbose=False, dryrun=False, undeployall=False, nopreserve=False, nocheckspace=False): | 25 | def _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 | ||
| 106 | class RecipeGdbCross(RecipeNative): | 106 | class 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 48b5b09ddd..4ccd70dc55 100644 --- a/scripts/lib/wic/ksparser.py +++ b/scripts/lib/wic/ksparser.py | |||
| @@ -16,6 +16,7 @@ import os | |||
| 16 | import shlex | 16 | import shlex | 
| 17 | import logging | 17 | import logging | 
| 18 | import re | 18 | import re | 
| 19 | import uuid | ||
| 19 | 20 | ||
| 20 | from argparse import ArgumentParser, ArgumentError, ArgumentTypeError | 21 | from argparse import ArgumentParser, ArgumentError, ArgumentTypeError | 
| 21 | 22 | ||
| @@ -196,7 +197,7 @@ class KickStart(): | |||
| 196 | bootloader.add_argument('--configfile') | 197 | bootloader.add_argument('--configfile') | 
| 197 | bootloader.add_argument('--ptable', choices=('msdos', 'gpt', 'gpt-hybrid'), | 198 | bootloader.add_argument('--ptable', choices=('msdos', 'gpt', 'gpt-hybrid'), | 
| 198 | default='msdos') | 199 | default='msdos') | 
| 199 | bootloader.add_argument('--diskid', type=lambda x: int(x, 0)) | 200 | bootloader.add_argument('--diskid') | 
| 200 | bootloader.add_argument('--timeout', type=int) | 201 | bootloader.add_argument('--timeout', type=int) | 
| 201 | bootloader.add_argument('--source') | 202 | bootloader.add_argument('--source') | 
| 202 | 203 | ||
| @@ -297,6 +298,24 @@ class KickStart(): | |||
| 297 | if append_var: | 298 | if append_var: | 
| 298 | self.bootloader.append = ' '.join(filter(None, \ | 299 | self.bootloader.append = ' '.join(filter(None, \ | 
| 299 | (self.bootloader.append, append_var))) | 300 | (self.bootloader.append, append_var))) | 
| 301 | if parsed.diskid: | ||
| 302 | if parsed.ptable == "msdos": | ||
| 303 | try: | ||
| 304 | self.bootloader.diskid = int(parsed.diskid, 0) | ||
| 305 | except ValueError: | ||
| 306 | err = "with --ptbale msdos only 32bit integers " \ | ||
| 307 | "are allowed for --diskid. %s could not " \ | ||
| 308 | "be parsed" % self.ptable | ||
| 309 | raise KickStartError(err) | ||
| 310 | else: | ||
| 311 | try: | ||
| 312 | self.bootloader.diskid = uuid.UUID(parsed.diskid) | ||
| 313 | except ValueError: | ||
| 314 | err = "with --ptable %s only valid uuids are " \ | ||
| 315 | "allowed for --diskid. %s could not be " \ | ||
| 316 | "parsed" % (parsed.ptable, parsed.diskid) | ||
| 317 | raise KickStartError(err) | ||
| 318 | |||
| 300 | else: | 319 | else: | 
| 301 | err = "%s:%d: more than one bootloader specified" \ | 320 | err = "%s:%d: more than one bootloader specified" \ | 
| 302 | % (confpath, lineno) | 321 | % (confpath, lineno) | 
| diff --git a/scripts/lib/wic/plugins/imager/direct.py b/scripts/lib/wic/plugins/imager/direct.py index f40f033a3d..ad922cfbf1 100644 --- a/scripts/lib/wic/plugins/imager/direct.py +++ b/scripts/lib/wic/plugins/imager/direct.py | |||
| @@ -315,7 +315,14 @@ 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 disk_id: | 318 | if disk_id and ptable_format in ('gpt', 'gpt-hybrid'): | 
| 319 | self.disk_guid = disk_id | ||
| 320 | elif os.getenv('SOURCE_DATE_EPOCH'): | ||
| 321 | self.disk_guid = uuid.UUID(int=int(os.getenv('SOURCE_DATE_EPOCH'))) | ||
| 322 | else: | ||
| 323 | self.disk_guid = uuid.uuid4() | ||
| 324 | |||
| 325 | if disk_id and ptable_format == 'msdos': | ||
| 319 | self.identifier = disk_id | 326 | self.identifier = disk_id | 
| 320 | elif os.getenv('SOURCE_DATE_EPOCH'): | 327 | elif os.getenv('SOURCE_DATE_EPOCH'): | 
| 321 | self.identifier = random.Random(int(os.getenv('SOURCE_DATE_EPOCH'))).randint(1, 0xffffffff) | 328 | self.identifier = random.Random(int(os.getenv('SOURCE_DATE_EPOCH'))).randint(1, 0xffffffff) | 
| @@ -545,11 +552,6 @@ class PartitionedImage(): | |||
| 545 | 552 | ||
| 546 | def _write_disk_guid(self): | 553 | def _write_disk_guid(self): | 
| 547 | if self.ptable_format in ('gpt', 'gpt-hybrid'): | 554 | if self.ptable_format in ('gpt', 'gpt-hybrid'): | 
| 548 | if os.getenv('SOURCE_DATE_EPOCH'): | ||
| 549 | self.disk_guid = uuid.UUID(int=int(os.getenv('SOURCE_DATE_EPOCH'))) | ||
| 550 | else: | ||
| 551 | self.disk_guid = uuid.uuid4() | ||
| 552 | |||
| 553 | logger.debug("Set disk guid %s", self.disk_guid) | 555 | logger.debug("Set disk guid %s", self.disk_guid) | 
| 554 | sfdisk_cmd = "sfdisk --sector-size %s --disk-id %s %s" % \ | 556 | sfdisk_cmd = "sfdisk --sector-size %s --disk-id %s %s" % \ | 
| 555 | (self.sector_size, self.path, self.disk_guid) | 557 | (self.sector_size, self.path, self.disk_guid) | 
