diff options
-rw-r--r-- | classes/image_types_ostree.bbclass | 10 | ||||
-rw-r--r-- | lib/oeqa/selftest/updater.py | 112 | ||||
-rw-r--r-- | recipes-sota/aktualizr/aktualizr_git.bb | 4 |
3 files changed, 81 insertions, 45 deletions
diff --git a/classes/image_types_ostree.bbclass b/classes/image_types_ostree.bbclass index db8cae6..ea3c7a2 100644 --- a/classes/image_types_ostree.bbclass +++ b/classes/image_types_ostree.bbclass | |||
@@ -183,7 +183,7 @@ IMAGE_DEPENDS_garagesign = "garage-sign-native:do_populate_sysroot" | |||
183 | IMAGE_CMD_garagesign () { | 183 | IMAGE_CMD_garagesign () { |
184 | if [ -n "${SOTA_PACKED_CREDENTIALS}" ]; then | 184 | if [ -n "${SOTA_PACKED_CREDENTIALS}" ]; then |
185 | # if credentials are issued by a server that doesn't support offline signing, exit silently | 185 | # if credentials are issued by a server that doesn't support offline signing, exit silently |
186 | unzip -p ${SOTA_PACKED_CREDENTIALS} root.json targets.pub targets.sec repo.url 2>&1 >/dev/null || exit 0 | 186 | unzip -p ${SOTA_PACKED_CREDENTIALS} root.json targets.pub targets.sec tufrepo.url 2>&1 >/dev/null || exit 0 |
187 | 187 | ||
188 | java_version=$( java -version 2>&1 | awk -F '"' '/version/ {print $2}' ) | 188 | java_version=$( java -version 2>&1 | awk -F '"' '/version/ {print $2}' ) |
189 | if [ "${java_version}" = "" ]; then | 189 | if [ "${java_version}" = "" ]; then |
@@ -198,11 +198,7 @@ IMAGE_CMD_garagesign () { | |||
198 | garage-sign init --repo ${GARAGE_SIGN_REPO} --home-dir ${GARAGE_SIGN_REPO} --credentials ${SOTA_PACKED_CREDENTIALS} | 198 | garage-sign init --repo ${GARAGE_SIGN_REPO} --home-dir ${GARAGE_SIGN_REPO} --credentials ${SOTA_PACKED_CREDENTIALS} |
199 | fi | 199 | fi |
200 | 200 | ||
201 | if [ -n "${GARAGE_SIGN_REPOSERVER}" ]; then | 201 | reposerver_args="--reposerver $( unzip -p ${SOTA_PACKED_CREDENTIALS} tufrepo.url )" |
202 | reposerver_args="--reposerver ${GARAGE_SIGN_REPOSERVER}" | ||
203 | else | ||
204 | reposerver_args="" | ||
205 | fi | ||
206 | 202 | ||
207 | ostree_target_hash=$(cat ${OSTREE_REPO}/refs/heads/${OSTREE_BRANCHNAME}) | 203 | ostree_target_hash=$(cat ${OSTREE_REPO}/refs/heads/${OSTREE_BRANCHNAME}) |
208 | 204 | ||
@@ -235,7 +231,7 @@ IMAGE_DEPENDS_garagecheck = "aktualizr-native:do_populate_sysroot" | |||
235 | IMAGE_CMD_garagecheck () { | 231 | IMAGE_CMD_garagecheck () { |
236 | if [ -n "${SOTA_PACKED_CREDENTIALS}" ]; then | 232 | if [ -n "${SOTA_PACKED_CREDENTIALS}" ]; then |
237 | # if credentials are issued by a server that doesn't support offline signing, exit silently | 233 | # if credentials are issued by a server that doesn't support offline signing, exit silently |
238 | unzip -p ${SOTA_PACKED_CREDENTIALS} root.json targets.pub targets.sec repo.url 2>&1 >/dev/null || exit 0 | 234 | unzip -p ${SOTA_PACKED_CREDENTIALS} root.json targets.pub targets.sec tufrepo.url 2>&1 >/dev/null || exit 0 |
239 | ostree_target_hash=$(cat ${OSTREE_REPO}/refs/heads/${OSTREE_BRANCHNAME}) | 235 | ostree_target_hash=$(cat ${OSTREE_REPO}/refs/heads/${OSTREE_BRANCHNAME}) |
240 | 236 | ||
241 | garage-check --ref=${ostree_target_hash} \ | 237 | garage-check --ref=${ostree_target_hash} \ |
diff --git a/lib/oeqa/selftest/updater.py b/lib/oeqa/selftest/updater.py index ad99964..e3d4fc3 100644 --- a/lib/oeqa/selftest/updater.py +++ b/lib/oeqa/selftest/updater.py | |||
@@ -118,49 +118,16 @@ class QemuTests(oeSelfTest): | |||
118 | 118 | ||
119 | @classmethod | 119 | @classmethod |
120 | def setUpClass(cls): | 120 | def setUpClass(cls): |
121 | logger = logging.getLogger("selftest") | 121 | cls.qemu, cls.s = qemu_launch(machine='qemux86-64') |
122 | logger.info('Running bitbake to build core-image-minimal') | ||
123 | bitbake('core-image-minimal') | ||
124 | # Create empty object. | ||
125 | args = type('', (), {})() | ||
126 | args.imagename = 'core-image-minimal' | ||
127 | args.mac = None | ||
128 | # Could use DEPLOY_DIR_IMAGE here but it's already in the machine | ||
129 | # subdirectory. | ||
130 | args.dir = 'tmp/deploy/images' | ||
131 | args.efi = False | ||
132 | args.machine = None | ||
133 | args.kvm = None # Autodetect | ||
134 | args.no_gui = True | ||
135 | args.gdb = False | ||
136 | args.pcap = None | ||
137 | args.overlay = None | ||
138 | args.dry_run = False | ||
139 | |||
140 | cls.qemu = QemuCommand(args) | ||
141 | cmdline = cls.qemu.command_line() | ||
142 | print('Booting image with run-qemu-ota...') | ||
143 | cls.s = subprocess.Popen(cmdline) | ||
144 | time.sleep(10) | ||
145 | 122 | ||
146 | @classmethod | 123 | @classmethod |
147 | def tearDownClass(cls): | 124 | def tearDownClass(cls): |
148 | try: | 125 | qemu_terminate(cls.s) |
149 | cls.s.terminate() | ||
150 | except KeyboardInterrupt: | ||
151 | pass | ||
152 | |||
153 | def run_test_qemu(self, command): | ||
154 | command = ['ssh -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@localhost -p ' + | ||
155 | str(self.qemu.ssh_port) + ' "' + command + '"'] | ||
156 | s2 = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | ||
157 | value, err = s2.communicate() | ||
158 | return value, err | ||
159 | 126 | ||
160 | def test_hostname(self): | 127 | def test_hostname(self): |
161 | print('') | 128 | print('') |
162 | print('Checking machine name (hostname) of device:') | 129 | print('Checking machine name (hostname) of device:') |
163 | value, err = self.run_test_qemu('hostname') | 130 | value, err = qemu_send_command(self.qemu.ssh_port, 'hostname') |
164 | machine = get_bb_var('MACHINE', 'core-image-minimal') | 131 | machine = get_bb_var('MACHINE', 'core-image-minimal') |
165 | self.assertEqual(err, b'', 'Error: ' + err.decode()) | 132 | self.assertEqual(err, b'', 'Error: ' + err.decode()) |
166 | # Strip off line ending. | 133 | # Strip off line ending. |
@@ -172,8 +139,79 @@ class QemuTests(oeSelfTest): | |||
172 | def test_var_sota(self): | 139 | def test_var_sota(self): |
173 | print('') | 140 | print('') |
174 | print('Checking contents of /var/sota:') | 141 | print('Checking contents of /var/sota:') |
175 | value, err = self.run_test_qemu('ls /var/sota') | 142 | value, err = qemu_send_command(self.qemu.ssh_port, 'ls /var/sota') |
176 | self.assertEqual(err, b'', 'Error: ' + err.decode()) | 143 | self.assertEqual(err, b'', 'Error: ' + err.decode()) |
177 | print(value.decode()) | 144 | print(value.decode()) |
178 | 145 | ||
146 | class GrubTests(oeSelfTest): | ||
147 | |||
148 | def setUpLocal(self): | ||
149 | # This is a bit of a hack but I can't see a better option. | ||
150 | path = os.path.abspath(os.path.dirname(__file__)) | ||
151 | metadir = path + "/../../../../" | ||
152 | grub_config = 'OSTREE_BOOTLOADER = "grub"\nMACHINE = "intel-corei7-64"' | ||
153 | self.append_config(grub_config) | ||
154 | self.meta_intel = metadir + "meta-intel" | ||
155 | self.meta_minnow = metadir + "meta-updater-minnowboard" | ||
156 | runCmd('bitbake-layers add-layer "%s"' % self.meta_intel) | ||
157 | runCmd('bitbake-layers add-layer "%s"' % self.meta_minnow) | ||
158 | self.qemu, self.s = qemu_launch(efi=True, machine='intel-corei7-64') | ||
159 | |||
160 | def tearDownLocal(self): | ||
161 | qemu_terminate(self.s) | ||
162 | runCmd('bitbake-layers remove-layer "%s"' % self.meta_intel, ignore_status=True) | ||
163 | runCmd('bitbake-layers remove-layer "%s"' % self.meta_minnow, ignore_status=True) | ||
164 | |||
165 | def test_grub(self): | ||
166 | print('') | ||
167 | print('Checking machine name (hostname) of device:') | ||
168 | value, err = qemu_send_command(self.qemu.ssh_port, 'hostname') | ||
169 | machine = get_bb_var('MACHINE', 'core-image-minimal') | ||
170 | self.assertEqual(err, b'', 'Error: ' + err.decode()) | ||
171 | # Strip off line ending. | ||
172 | value_str = value.decode()[:-1] | ||
173 | self.assertEqual(value_str, machine, | ||
174 | 'MACHINE does not match hostname: ' + machine + ', ' + value_str) | ||
175 | print(value_str) | ||
176 | |||
177 | |||
178 | def qemu_launch(efi=False, machine=None): | ||
179 | logger = logging.getLogger("selftest") | ||
180 | logger.info('Running bitbake to build core-image-minimal') | ||
181 | bitbake('core-image-minimal') | ||
182 | # Create empty object. | ||
183 | args = type('', (), {})() | ||
184 | args.imagename = 'core-image-minimal' | ||
185 | args.mac = None | ||
186 | # Could use DEPLOY_DIR_IMAGE here but it's already in the machine | ||
187 | # subdirectory. | ||
188 | args.dir = 'tmp/deploy/images' | ||
189 | args.efi = efi | ||
190 | args.machine = machine | ||
191 | args.kvm = None # Autodetect | ||
192 | args.no_gui = True | ||
193 | args.gdb = False | ||
194 | args.pcap = None | ||
195 | args.overlay = None | ||
196 | args.dry_run = False | ||
197 | |||
198 | qemu = QemuCommand(args) | ||
199 | cmdline = qemu.command_line() | ||
200 | print('Booting image with run-qemu-ota...') | ||
201 | s = subprocess.Popen(cmdline) | ||
202 | time.sleep(10) | ||
203 | return qemu, s | ||
204 | |||
205 | def qemu_terminate(s): | ||
206 | try: | ||
207 | s.terminate() | ||
208 | except KeyboardInterrupt: | ||
209 | pass | ||
210 | |||
211 | def qemu_send_command(port, command): | ||
212 | command = ['ssh -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@localhost -p ' + | ||
213 | str(port) + ' "' + command + '"'] | ||
214 | s2 = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | ||
215 | value, err = s2.communicate() | ||
216 | return value, err | ||
179 | 217 | ||
diff --git a/recipes-sota/aktualizr/aktualizr_git.bb b/recipes-sota/aktualizr/aktualizr_git.bb index 3cd8a64..140a670 100644 --- a/recipes-sota/aktualizr/aktualizr_git.bb +++ b/recipes-sota/aktualizr/aktualizr_git.bb | |||
@@ -18,7 +18,7 @@ PR = "7" | |||
18 | SRC_URI = " \ | 18 | SRC_URI = " \ |
19 | git://github.com/advancedtelematic/aktualizr;branch=${BRANCH} \ | 19 | git://github.com/advancedtelematic/aktualizr;branch=${BRANCH} \ |
20 | " | 20 | " |
21 | SRCREV = "612da8cae6e72ce7250de2fb5333af0d7041de7b" | 21 | SRCREV = "860553a1c98513bf43f6ce98491bf65addcf7e48" |
22 | BRANCH ?= "master" | 22 | BRANCH ?= "master" |
23 | 23 | ||
24 | S = "${WORKDIR}/git" | 24 | S = "${WORKDIR}/git" |
@@ -39,10 +39,12 @@ do_install_append_class-target () { | |||
39 | } | 39 | } |
40 | do_install_append_class-native () { | 40 | do_install_append_class-native () { |
41 | rm -f ${D}${bindir}/aktualizr | 41 | rm -f ${D}${bindir}/aktualizr |
42 | rm -f ${D}${bindir}/aktualizr-info | ||
42 | } | 43 | } |
43 | 44 | ||
44 | FILES_${PN}_class-target = " \ | 45 | FILES_${PN}_class-target = " \ |
45 | ${bindir}/aktualizr \ | 46 | ${bindir}/aktualizr \ |
47 | ${bindir}/aktualizr-info \ | ||
46 | " | 48 | " |
47 | FILES_${PN}_class-native = " \ | 49 | FILES_${PN}_class-native = " \ |
48 | ${bindir}/aktualizr_implicit_writer \ | 50 | ${bindir}/aktualizr_implicit_writer \ |