summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--recipes-sota/aktualizr/aktualizr_git.bb10
-rw-r--r--scripts/qemucommand.py50
-rwxr-xr-xscripts/run-qemu-ota26
3 files changed, 65 insertions, 21 deletions
diff --git a/recipes-sota/aktualizr/aktualizr_git.bb b/recipes-sota/aktualizr/aktualizr_git.bb
index 03840ac..d9f50c3 100644
--- a/recipes-sota/aktualizr/aktualizr_git.bb
+++ b/recipes-sota/aktualizr/aktualizr_git.bb
@@ -8,14 +8,14 @@ LIC_FILES_CHKSUM = "file://${S}/LICENSE;md5=9741c346eef56131163e13b9db1241b3"
8DEPENDS = "boost curl openssl libarchive libsodium sqlite3 asn1c-native" 8DEPENDS = "boost curl openssl libarchive libsodium sqlite3 asn1c-native"
9DEPENDS_append = "${@bb.utils.contains('PTEST_ENABLED', '1', ' coreutils-native net-tools-native ostree-native aktualizr-native ', '', d)}" 9DEPENDS_append = "${@bb.utils.contains('PTEST_ENABLED', '1', ' coreutils-native net-tools-native ostree-native aktualizr-native ', '', d)}"
10RDEPENDS_${PN}_class-target = "aktualizr-configs lshw" 10RDEPENDS_${PN}_class-target = "aktualizr-configs lshw"
11RDEPENDS_${PN}-host-tools = "aktualizr aktualizr-repo aktualizr-cert-provider ${@bb.utils.contains('PACKAGECONFIG', 'sota-tools', 'garage-deploy garage-push', '', d)}" 11RDEPENDS_${PN}-host-tools = "aktualizr aktualizr-cert-provider ${@bb.utils.contains('PACKAGECONFIG', 'sota-tools', 'garage-deploy garage-push', '', d)}"
12 12
13RDEPENDS_${PN}-ptest += "bash cmake curl net-tools python3-core python3-misc python3-modules openssl-bin sqlite3 valgrind" 13RDEPENDS_${PN}-ptest += "bash cmake curl net-tools python3-core python3-misc python3-modules openssl-bin sqlite3 valgrind"
14 14
15PV = "1.0+git${SRCPV}" 15PV = "1.0+git${SRCPV}"
16PR = "7" 16PR = "7"
17 17
18GARAGE_SIGN_PV = "0.7.0-25-ge74a964" 18GARAGE_SIGN_PV = "0.7.0-33-g214dfb1"
19 19
20SRC_URI = " \ 20SRC_URI = " \
21 gitsm://github.com/advancedtelematic/aktualizr;branch=${BRANCH} \ 21 gitsm://github.com/advancedtelematic/aktualizr;branch=${BRANCH} \
@@ -28,10 +28,10 @@ SRC_URI = " \
28 " 28 "
29 29
30# for garage-sign archive 30# for garage-sign archive
31SRC_URI[md5sum] = "9601dd891abac754400852cf367e86a2" 31SRC_URI[md5sum] = "66ffe8dcd61d4c15646e1c4b7dde7401"
32SRC_URI[sha256sum] = "1ebe2c9655b1fcc8d597dbda10c8a413eca12e5351582d916d0b088a84c33cd2" 32SRC_URI[sha256sum] = "7a7193ddf7e1a33ea60fbb20f98318a8bd78c325dab391d8c4ebd644a738abdc"
33 33
34SRCREV = "03778511cc937d07bf53a8092f8b268e65f5d9a6" 34SRCREV = "3bb9fe91b4c614a79373beadc721272fcf7acce2"
35BRANCH ?= "master" 35BRANCH ?= "master"
36 36
37S = "${WORKDIR}/git" 37S = "${WORKDIR}/git"
diff --git a/scripts/qemucommand.py b/scripts/qemucommand.py
index a869d4d..9b23c54 100644
--- a/scripts/qemucommand.py
+++ b/scripts/qemucommand.py
@@ -2,6 +2,7 @@ from os.path import exists, isdir, join, realpath, abspath
2from os import listdir 2from os import listdir
3import random 3import random
4import socket 4import socket
5from shutil import copyfile
5from subprocess import check_output 6from subprocess import check_output
6 7
7EXTENSIONS = { 8EXTENSIONS = {
@@ -39,6 +40,8 @@ def random_mac():
39 40
40class QemuCommand(object): 41class QemuCommand(object):
41 def __init__(self, args): 42 def __init__(self, args):
43 self.dry_run = args.dry_run
44 self.overlay = args.overlay
42 if args.machine: 45 if args.machine:
43 self.machine = args.machine 46 self.machine = args.machine
44 else: 47 else:
@@ -49,21 +52,53 @@ class QemuCommand(object):
49 self.machine = machines[0] 52 self.machine = machines[0]
50 else: 53 else:
51 raise ValueError("Could not autodetect machine type. More than one entry in %s. Maybe --machine qemux86-64?" % args.dir) 54 raise ValueError("Could not autodetect machine type. More than one entry in %s. Maybe --machine qemux86-64?" % args.dir)
55
56 # If using an overlay with U-Boot, copy the rom when we create the
57 # overlay so that we can keep it around just in case.
52 if args.efi: 58 if args.efi:
53 self.bios = 'OVMF.fd' 59 self.bios = 'OVMF.fd'
54 else: 60 else:
55 uboot = abspath(join(args.dir, self.machine, 'u-boot-qemux86-64.rom')) 61 uboot_path = abspath(join(args.dir, self.machine, 'u-boot-qemux86-64.rom'))
56 if not exists(uboot): 62 if self.overlay:
57 raise ValueError("U-Boot image %s does not exist" % uboot) 63 new_uboot_path = self.overlay + '.u-boot.rom'
58 self.bios = uboot 64 if not exists(self.overlay):
65 if not exists(uboot_path):
66 raise ValueError("U-Boot image %s does not exist" % uboot_path)
67 if not exists(new_uboot_path):
68 if self.dry_run:
69 print("cp %s %s" % (uboot_path, new_uboot_path))
70 else:
71 copyfile(uboot_path, new_uboot_path)
72 uboot_path = new_uboot_path
73 if not exists(uboot_path) and not (self.dry_run and not exists(self.overlay)):
74 raise ValueError("U-Boot image %s does not exist" % uboot_path)
75 self.bios = uboot_path
76
77 # If using an overlay, we need to keep the "backing" image around, as
78 # bitbake will often clean it up, and the overlay silently depends on
79 # the hardcoded path. The easiest solution is to keep the file and use
80 # a relative path to it.
59 if exists(args.imagename): 81 if exists(args.imagename):
60 image = args.imagename 82 image = realpath(args.imagename)
61 else: 83 else:
62 ext = EXTENSIONS.get(self.machine, 'wic') 84 ext = EXTENSIONS.get(self.machine, 'wic')
63 image = join(args.dir, self.machine, '%s-%s.%s' % (args.imagename, self.machine, ext)) 85 image = join(args.dir, self.machine, '%s-%s.%s' % (args.imagename, self.machine, ext))
64 self.image = realpath(image) 86 if self.overlay:
65 if not exists(self.image): 87 new_image_path = self.overlay + '.img'
88 if not exists(self.overlay):
89 if not exists(image):
90 raise ValueError("OS image %s does not exist" % image)
91 if not exists(new_image_path):
92 if self.dry_run:
93 print("cp %s %s" % (image, new_image_path))
94 else:
95 copyfile(image, new_image_path)
96 self.image = new_image_path
97 else:
98 self.image = realpath(image)
99 if not exists(self.image) and not (self.dry_run and not exists(self.overlay)):
66 raise ValueError("OS image %s does not exist" % self.image) 100 raise ValueError("OS image %s does not exist" % self.image)
101
67 if args.mac: 102 if args.mac:
68 self.mac_address = args.mac 103 self.mac_address = args.mac
69 else: 104 else:
@@ -86,7 +121,6 @@ class QemuCommand(object):
86 self.gui = not args.no_gui 121 self.gui = not args.no_gui
87 self.gdb = args.gdb 122 self.gdb = args.gdb
88 self.pcap = args.pcap 123 self.pcap = args.pcap
89 self.overlay = args.overlay
90 self.secondary_network = args.secondary_network 124 self.secondary_network = args.secondary_network
91 125
92 def command_line(self): 126 def command_line(self):
diff --git a/scripts/run-qemu-ota b/scripts/run-qemu-ota
index de63297..232ee11 100755
--- a/scripts/run-qemu-ota
+++ b/scripts/run-qemu-ota
@@ -2,7 +2,7 @@
2 2
3from argparse import ArgumentParser 3from argparse import ArgumentParser
4from subprocess import Popen 4from subprocess import Popen
5from os.path import exists 5from os.path import exists, dirname
6import sys 6import sys
7from qemucommand import QemuCommand 7from qemucommand import QemuCommand
8 8
@@ -39,27 +39,37 @@ def main():
39 'This can be used to test Uptane Primary/Secondary communication.') 39 'This can be used to test Uptane Primary/Secondary communication.')
40 parser.add_argument('-n', '--dry-run', help='Print qemu command line rather then run it', action='store_true') 40 parser.add_argument('-n', '--dry-run', help='Print qemu command line rather then run it', action='store_true')
41 args = parser.parse_args() 41 args = parser.parse_args()
42
43 if args.overlay and not exists(args.overlay) and dirname(args.overlay) and not dirname(args.overlay) == '.':
44 print('Error: please provide a file name in the current working directory. ' +
45 'Overlays do not work properly with other directories.')
46 sys.exit(1)
47 if args.overlay and exists(args.overlay) and args.imagename != parser.get_default('imagename'):
48 # qemu-img amend -o <filename> might work, but it has not yet been done
49 # successfully.
50 print('Warning: cannot change backing image of overlay after it has been created.')
51
42 try: 52 try:
43 qemu_command = QemuCommand(args) 53 qemu_command = QemuCommand(args)
44 except ValueError as e: 54 except ValueError as e:
45 print(e.message) 55 print(e.message)
46 sys.exit(1) 56 sys.exit(1)
47 57
48 print("Launching %s with mac address %s" % (args.imagename, qemu_command.mac_address))
49 print("To connect via SSH:")
50 print(" ssh -o StrictHostKeyChecking=no root@localhost -p %d" % qemu_command.ssh_port)
51 print("To connect to the serial console:")
52 print(" nc localhost %d" % qemu_command.serial_port)
53
54 cmdline = qemu_command.command_line() 58 cmdline = qemu_command.command_line()
55 if args.overlay and not exists(args.overlay): 59 if args.overlay and not exists(args.overlay):
56 print("Image file %s does not yet exist, creating." % args.overlay) 60 print("Overlay file %s does not yet exist, creating." % args.overlay)
57 img_cmdline = qemu_command.img_command_line() 61 img_cmdline = qemu_command.img_command_line()
58 if args.dry_run: 62 if args.dry_run:
59 print(" ".join(img_cmdline)) 63 print(" ".join(img_cmdline))
60 else: 64 else:
61 Popen(img_cmdline).wait() 65 Popen(img_cmdline).wait()
62 66
67 print("Launching %s with mac address %s" % (args.imagename, qemu_command.mac_address))
68 print("To connect via SSH:")
69 print(" ssh -o StrictHostKeyChecking=no root@localhost -p %d" % qemu_command.ssh_port)
70 print("To connect to the serial console:")
71 print(" nc localhost %d" % qemu_command.serial_port)
72
63 if args.dry_run: 73 if args.dry_run:
64 print(" ".join(cmdline)) 74 print(" ".join(cmdline))
65 else: 75 else: