Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
-agl-ivi-demo-flutter-qemu.config
-linter cleanup

Signed-off-by: Joel Winarske <[email protected]>
  • Loading branch information
jwinarske committed Feb 8, 2025
1 parent 962b24d commit 643e16b
Show file tree
Hide file tree
Showing 6 changed files with 247 additions and 368 deletions.
35 changes: 19 additions & 16 deletions common.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@
#
#

import errno
import os
import sys
import subprocess

import sys
from platform import system
from sys import stderr as stream

Expand Down Expand Up @@ -51,14 +49,6 @@ def run_command(cmd: str, cwd: str) -> str:
return output.rstrip()


def make_sure_path_exists(path: str):
try:
os.makedirs(path)
except OSError as exception:
if exception.errno != errno.EEXIST:
raise


def get_md5sum(file: str) -> str:
"""Return md5sum of specified file"""
import hashlib
Expand All @@ -76,7 +66,7 @@ def get_md5sum(file: str) -> str:


def get_sha1sum(file: str) -> str:
"""Return sha1sum of specified file"""
"""Return sha1 sum of specified file"""
import hashlib

if not os.path.exists(file):
Expand Down Expand Up @@ -108,9 +98,9 @@ def get_sha256sum(file: str):


def download_https_file(cwd, url, file, cookie_file, netrc, md5, sha1, sha256, redirect=False, connect_timeout=None):
download_filepath = os.path.join(cwd, file)
download_filepath = str(os.path.join(cwd, file))

sha256_file = os.path.join(cwd, file + '.sha256')
sha256_file = str(os.path.join(cwd, file + '.sha256'))
if compare_sha256(download_filepath, sha256_file):
print("%s exists, skipping download" % download_filepath)
return True
Expand Down Expand Up @@ -195,7 +185,7 @@ def write_sha256_file(cwd: str, filename: str):


def fetch_https_progress(download_t, download_d, _upload_t, _upload_d):
"""callback function for pycurl.XFERINFOFUNCTION"""
"""callback function for pycurl transfer info function"""
stream.write('Progress: {}/{} kiB ({}%)\r'.format(str(int(download_d / kb)), str(int(download_t / kb)),
str(int(download_d / download_t * 100) if download_t > 0 else 0)))
stream.flush()
Expand Down Expand Up @@ -306,6 +296,19 @@ def chown_workspace(username, workspace):
subprocess.check_call(cmd, cwd=workspace, stdout=subprocess.DEVNULL)


def break_version(version):
""" Break version string into major, minor, patch """
import re
match = re.match(r'^(\d+)(?:\.(\d+))?(?:\.(\d+))?$', version)
if match:
major = int(match.group(1))
minor = int(match.group(2)) if match.group(2) else 0
patch = int(match.group(3)) if match.group(3) else 0
return major, minor, patch
else:
raise ValueError("Invalid version format")


def test_internet_connection() -> bool:
"""Test internet by connecting to nameserver"""
import pycurl
Expand All @@ -319,7 +322,7 @@ def test_internet_connection() -> bool:
c.setopt(pycurl.NOBODY, 1)
try:
c.perform()
except:
except pycurl.error:
pass

res = False
Expand Down
113 changes: 113 additions & 0 deletions configs/agl-ivi-demo-flutter-qemu.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
{
"id": "agl-ivi-demo-flutter-qemu",
"load": false,
"supported_archs": [
"arm64",
"x86_64"
],
"supported_host_types": [
"darwin",
"ubuntu",
"fedora"
],
"type": "qemu",
"env": {
"RELEASE_NAME": "master",
"RELEASE_VERSION": "latest",
"FLUTTER_DEBUG_PORT": "1234",
"FLUTTER_OBSERVATORY_HOST": "0.0.0.0",
"CONTAINER_SSH_PORT": "2222",
"DEVICE_HOSTNAME": "localhost",
"FLUTTER_AUTO_EXE": "flutter-auto --j=/tmp/${appName}/default_config.json --b=/tmp/${appName}",
"PING_CMD": "(echo >/dev/tcp/localhost/${CONTAINER_SSH_PORT}) &>/dev/null && echo open || echo closed",
"DELETE_USER_PWD": "ssh -p ${CONTAINER_SSH_PORT} -t -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -oBatchMode=yes root@${DEVICE_HOSTNAME} passwd -d agl-driver",
"CREATE_BUNDLE_FOLDER": "ssh -p ${CONTAINER_SSH_PORT} -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o BatchMode=yes agl-driver@${DEVICE_HOSTNAME} mkdir -p /tmp/${appName}/data",
"COPY_PLATFORM_ID_TO_DEVICE": "scp -P ${CONTAINER_SSH_PORT} -r ${PLATFORM_ID_DIR}/default_config.json agl-driver@${DEVICE_HOSTNAME}:/tmp/${appName}/",
"COPY_ASSETS_TO_DEVICE": "scp -P ${CONTAINER_SSH_PORT} -r ${localPath}/* agl-driver@${DEVICE_HOSTNAME}:/tmp/${appName}/data/flutter_assets",
"DELETE_APP_FOLDER": "ssh -p ${CONTAINER_SSH_PORT} -o BatchMode=yes agl-driver@${DEVICE_HOSTNAME} rm -rf /tmp/${appName}"
},
"runtime": {
"config": {
"view": [
{
"window_type": "BG",
"width": 1920,
"height": 1080
}
]
},
"pre-requisites": {
"arm64": {
"darwin": {
"cmds": [
"bash -c \"arch -arm64 brew install xz\"",
"bash -c \"arch -arm64 brew install qemu\""
]
}
}
},
"artifacts": {
"http": {
"url": "https://download.automotivelinux.org/AGL/snapshots/${RELEASE_NAME}/${RELEASE_VERSION}",
"artifacts": {
"x86_64": [
{
"endpoint": "/qemux86-64/deploy/images/qemux86-64/agl-ivi-demo-flutter-qemux86-64.wic.xz"
}
],
"arm64": [
{
"endpoint": "/qemuarm64/deploy/images/qemuarm64/agl-ivi-demo-flutter-qemuarm64.ext4.xz"
},
{
"endpoint": "/qemuarm64/deploy/images/qemuarm64/Image-qemuarm64.bin"
}
]
}
}
},
"qemu": {
"cmd": "qemu-system-${FORMAL_MACHINE_ARCH}",
"x86_64": {
"image": "agl-ivi-demo-flutter-qemux86-64.wic",
"args": "-m 2048 ${QEMU_EXTRA} -hda ${QEMU_IMAGE} -cpu kvm64 -cpu qemu64,+ssse3,+sse4.1,+sse4.2,+popcnt -vga virtio -device virtio-rng-pci -serial mon:stdio -serial null -device intel-hda -device hda-duplex -device virtio-net-pci,netdev=net0,mac=${RANDOM_MAC} -netdev user,id=net0,hostfwd=tcp::${CONTAINER_SSH_PORT}-:22,hostfwd=tcp::${FLUTTER_DEBUG_PORT}-:${FLUTTER_DEBUG_PORT}"
},
"arm64": {
"kernel": "Image-qemuarm64.bin",
"image": "agl-demo-platform-crosssdk-qemuarm64.ext4",
"args": "-accel hvf -cpu host -M virt ${QEMU_EXTRA} -m 4096 -device virtio-gpu-pci -nographic -display cocoa,show-cursor=on -object rng-random,filename=/dev/urandom,id=rng0 -device virtio-rng-pci,rng=rng0 -device qemu-xhci -device usb-tablet -device usb-mouse -device usb-kbd -device virtio-net-pci,netdev=vnet -netdev user,id=vnet,hostfwd=tcp::${CONTAINER_SSH_PORT}-:22,hostfwd=tcp::${FLUTTER_DEBUG_PORT}-:${FLUTTER_DEBUG_PORT} -kernel ${QEMU_KERNEL} -drive file=${QEMU_IMAGE},format=raw,if=virtio -append root=/dev/vda"
},
"extra": {
"darwin": "-smp cpus=8,sockets=1,cores=8,threads=1",
"ubuntu": "-bios OVMF.fd",
"fedora": "-bios /usr/share/edk2/ovmf/OVMF_CODE.fd"
}
},
"post_cmds": [
{
"cwd": "${PLATFORM_ID_DIR}",
"cmds": [
"bash -c \"rm ${QEMU_IMAGE}|true\"",
"unxz --keep ${QEMU_IMAGE}.xz"
]
}
]
},
"overwrite-existing": true,
"custom-device": {
"id": "agl-qemu-${RELEASE_NAME}",
"label": "AGL ${RELEASE_NAME}-${RELEASE_VERSION} QEMU Image",
"sdkNameAndVersion": "qemu-${RELEASE_NAME} ${RELEASE_VERSION}",
"platform": "linux-x64",
"enabled": true,
"ping": "bash -c \"${PING_CMD}\"",
"pingSuccessRegex": "open",
"postBuild": "bash -c \"${DELETE_USER_PWD}\"",
"install": "bash -c \"${CREATE_BUNDLE_FOLDER} && ${COPY_PLATFORM_ID_TO_DEVICE} && ${COPY_ASSETS_TO_DEVICE}\"",
"uninstall": "bash -c \"${DELETE_APP_FOLDER}\"",
"runDebug": "bash -c \"ssh -t -t -o BatchMode=yes agl-driver@${DEVICE_HOSTNAME} ${FLUTTER_AUTO_EXE}\"",
"forwardPort": null,
"forwardPortSuccessRegex": null,
"screenshot": null
}
}
113 changes: 0 additions & 113 deletions configs/qemu-agl-master.json

This file was deleted.

Loading

0 comments on commit 643e16b

Please sign in to comment.