IQ.Pilot Prebuilt Release @ 6dc11f9
This commit is contained in:
10
iqpilot/system/proprietary_runtime/__init__.py
Normal file
10
iqpilot/system/proprietary_runtime/__init__.py
Normal file
@@ -0,0 +1,10 @@
|
||||
import os
|
||||
|
||||
# _verified_import.so ships ONLY in the signed rootfs runtime. It MUST be prepended so a
|
||||
# repo-side _verified_import.py can never shadow the signed native module via __path__
|
||||
# order. runtime_paths.py lives in the repo copy and still resolves from the fall-through.
|
||||
_ROOTFS_PKG = "/usr/libexec/iqpilot/python/openpilot/system/proprietary_runtime"
|
||||
if os.path.isdir(_ROOTFS_PKG):
|
||||
if _ROOTFS_PKG in __path__:
|
||||
__path__.remove(_ROOTFS_PKG)
|
||||
__path__.insert(0, _ROOTFS_PKG)
|
||||
54
iqpilot/system/proprietary_runtime/install_verified_runtime.sh
Executable file
54
iqpilot/system/proprietary_runtime/install_verified_runtime.sh
Executable file
@@ -0,0 +1,54 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../.." && pwd)"
|
||||
RUNTIME_ROOT="${IQPILOT_VERIFIED_RUNTIME_ROOT:-/usr/libexec/iqpilot}"
|
||||
PYTHON_ROOT="${RUNTIME_ROOT}/python"
|
||||
TARGET_EXT_DIR="${PYTHON_ROOT}/openpilot/system/proprietary_runtime"
|
||||
MANIFEST_SRC="${ROOT}/iqpilot/system/proprietary_runtime/rootfs_integrity.json"
|
||||
MANIFEST_SIG_SRC="${ROOT}/iqpilot/system/proprietary_runtime/rootfs_integrity.json.sig"
|
||||
|
||||
RUNNER_SRC="${ROOT}/iqpilot/system/proprietary_runtime/iqpilot_bundle_runner"
|
||||
EXT_SRC="${ROOT}/iqpilot/system/proprietary_runtime/_verified_import.so"
|
||||
STUB_ROOT="${ROOT}/iqpilot/system/proprietary_runtime/rootfs_python"
|
||||
|
||||
if [ ! -x "${RUNNER_SRC}" ]; then
|
||||
echo "missing runner: ${RUNNER_SRC}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -f "${EXT_SRC}" ]; then
|
||||
# No locally-built _verified_import.so staged in the tree. This is the NORMAL prebuilt/release case:
|
||||
# the .so is gitignored and ships baked into the OS image at /usr/libexec/iqpilot, so there is
|
||||
# nothing to install from /data. Quietly no-op and let the OS-baked verified runtime be used.
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ ! -f "${MANIFEST_SRC}" ] || [ ! -f "${MANIFEST_SIG_SRC}" ]; then
|
||||
if [ -n "${IQPILOT_SIGNING_KEY:-}" ]; then
|
||||
"${ROOT}/.venv/bin/python" \
|
||||
"${ROOT}/scripts/iqpilot/build_proprietary_runtime_manifest.py" \
|
||||
--repo-root "${ROOT}" \
|
||||
--output "${MANIFEST_SRC}"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -f "${MANIFEST_SRC}" ] || [ ! -f "${MANIFEST_SIG_SRC}" ]; then
|
||||
echo "missing rootfs runtime integrity manifest or signature"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
sudo mount -o remount,rw /
|
||||
trap 'sudo mount -o remount,ro /' EXIT
|
||||
|
||||
sudo mkdir -p "${RUNTIME_ROOT}" "${TARGET_EXT_DIR}"
|
||||
sudo install -m 0755 "${RUNNER_SRC}" "${RUNTIME_ROOT}/iqpilot_bundle_runner"
|
||||
sudo install -m 0755 "${EXT_SRC}" "${TARGET_EXT_DIR}/_verified_import.so"
|
||||
sudo install -m 0644 "${MANIFEST_SRC}" "${RUNTIME_ROOT}/runtime_integrity.json"
|
||||
sudo install -m 0644 "${MANIFEST_SIG_SRC}" "${RUNTIME_ROOT}/runtime_integrity.json.sig"
|
||||
sudo install -m 0644 "${STUB_ROOT}/openpilot/__init__.py" "${PYTHON_ROOT}/openpilot/__init__.py"
|
||||
sudo mkdir -p "${PYTHON_ROOT}/openpilot/system"
|
||||
sudo install -m 0644 "${STUB_ROOT}/openpilot/system/__init__.py" "${PYTHON_ROOT}/openpilot/system/__init__.py"
|
||||
sudo install -m 0644 "${STUB_ROOT}/openpilot/system/proprietary_runtime/__init__.py" "${TARGET_EXT_DIR}/__init__.py"
|
||||
|
||||
echo "installed verified runtime to ${RUNTIME_ROOT}"
|
||||
BIN
iqpilot/system/proprietary_runtime/iqpilot_bundle_runner
Executable file
BIN
iqpilot/system/proprietary_runtime/iqpilot_bundle_runner
Executable file
Binary file not shown.
53
iqpilot/system/proprietary_runtime/rootfs_integrity.json
Normal file
53
iqpilot/system/proprietary_runtime/rootfs_integrity.json
Normal file
@@ -0,0 +1,53 @@
|
||||
{
|
||||
"entries": [
|
||||
{
|
||||
"mode": 493,
|
||||
"path": "iqpilot_bundle_runner",
|
||||
"relative_to": "runtime_root",
|
||||
"sha256": "fc24a9a6a6b2fe8275c236a872d8de5c741ddf58b5d45ba5b18d4451a21fd921",
|
||||
"size": 134160
|
||||
},
|
||||
{
|
||||
"mode": 420,
|
||||
"path": "python/openpilot/__init__.py",
|
||||
"relative_to": "runtime_root",
|
||||
"sha256": "fd6a1be7b4975c58a149f5f8dfacab711537b623940e3fdca96942101ac1f7e5",
|
||||
"size": 582
|
||||
},
|
||||
{
|
||||
"mode": 420,
|
||||
"path": "python/openpilot/system/__init__.py",
|
||||
"relative_to": "runtime_root",
|
||||
"sha256": "a5860ee80095d837d9b64cf56fddd3c7d3b059f7ae59b97e1ebd3e1de27e07f0",
|
||||
"size": 604
|
||||
},
|
||||
{
|
||||
"mode": 420,
|
||||
"path": "python/openpilot/system/proprietary_runtime/__init__.py",
|
||||
"relative_to": "runtime_root",
|
||||
"sha256": "b60c14722a96c22f5ee9cf865d1bfcba9ca434b04a444d1a8de5692088bacf7e",
|
||||
"size": 744
|
||||
},
|
||||
{
|
||||
"mode": 493,
|
||||
"path": "python/openpilot/system/proprietary_runtime/_verified_import.so",
|
||||
"relative_to": "runtime_root",
|
||||
"sha256": "3873eb8c785efc53077b2c799c0211c9314b3ceb48148a78dd06f6c2f85c2d4f",
|
||||
"size": 200416
|
||||
},
|
||||
{
|
||||
"mode": 420,
|
||||
"path": "/usr/lib/systemd/system/hephaestusd.service",
|
||||
"relative_to": "absolute",
|
||||
"sha256": "24bf925bc7b9f4b93ea3d19f9eaf1af01de91a01981f02a2e9cfcc7b66910ae7",
|
||||
"size": 1390
|
||||
},
|
||||
{
|
||||
"mode": 420,
|
||||
"path": "/usr/lib/systemd/system/ble-transportd.service",
|
||||
"relative_to": "absolute",
|
||||
"sha256": "3aa5901a5738c523c8e7fd66b28d2933b27dac7e826076c190e5fc087ef3a888",
|
||||
"size": 1472
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
P/jJRxeRwirhGyAC3Qk+gsmO3qidsheP4ldBJQIu8QcQuhDPmodpZ3BjGUKmPdxBfkUt8KW5ttyo8DIRSSJgBg==
|
||||
@@ -0,0 +1,23 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def _resolve_source_pkg() -> Path:
|
||||
raw_root = os.environ.get("IQPILOT_SOURCE_ROOT") or os.environ.get("OPENPILOT_SOURCE_ROOT") or "/data/openpilot/iqpilot"
|
||||
source_root = Path(raw_root)
|
||||
if source_root.name == "openpilot":
|
||||
return source_root
|
||||
return source_root / "openpilot"
|
||||
|
||||
|
||||
def _extend_package_path() -> None:
|
||||
source_pkg = _resolve_source_pkg()
|
||||
if source_pkg.is_dir():
|
||||
pkg_path = str(source_pkg)
|
||||
if pkg_path not in __path__:
|
||||
__path__.append(pkg_path)
|
||||
|
||||
|
||||
_extend_package_path()
|
||||
@@ -0,0 +1,23 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def _resolve_source_pkg() -> Path:
|
||||
raw_root = os.environ.get("IQPILOT_SOURCE_ROOT") or os.environ.get("OPENPILOT_SOURCE_ROOT") or "/data/openpilot/iqpilot"
|
||||
source_root = Path(raw_root)
|
||||
if source_root.name == "openpilot":
|
||||
return source_root / "system"
|
||||
return source_root / "openpilot" / "system"
|
||||
|
||||
|
||||
def _extend_package_path() -> None:
|
||||
source_pkg = _resolve_source_pkg()
|
||||
if source_pkg.is_dir():
|
||||
pkg_path = str(source_pkg)
|
||||
if pkg_path not in __path__:
|
||||
__path__.append(pkg_path)
|
||||
|
||||
|
||||
_extend_package_path()
|
||||
@@ -0,0 +1,27 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
from ._verified_import import import_verified_module
|
||||
|
||||
|
||||
def _resolve_source_pkg() -> Path:
|
||||
raw_root = os.environ.get("IQPILOT_SOURCE_ROOT") or os.environ.get("OPENPILOT_SOURCE_ROOT") or "/data/openpilot/iqpilot"
|
||||
source_root = Path(raw_root)
|
||||
if source_root.name == "openpilot":
|
||||
return source_root / "system" / "proprietary_runtime"
|
||||
return source_root / "openpilot" / "system" / "proprietary_runtime"
|
||||
|
||||
|
||||
def _extend_package_path() -> None:
|
||||
source_pkg = _resolve_source_pkg()
|
||||
if source_pkg.is_dir():
|
||||
pkg_path = str(source_pkg)
|
||||
if pkg_path not in __path__:
|
||||
__path__.append(pkg_path)
|
||||
|
||||
|
||||
_extend_package_path()
|
||||
|
||||
__all__ = ["import_verified_module"]
|
||||
32
iqpilot/system/proprietary_runtime/runtime_paths.py
Normal file
32
iqpilot/system/proprietary_runtime/runtime_paths.py
Normal file
@@ -0,0 +1,32 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
VERIFIED_RUNTIME_ROOT = Path("/usr/libexec/iqpilot")
|
||||
VERIFIED_RUNNER_PATH = VERIFIED_RUNTIME_ROOT / "iqpilot_bundle_runner"
|
||||
VERIFIED_PYTHON_ROOT = VERIFIED_RUNTIME_ROOT / "python"
|
||||
FALLBACK_RUNNER_PATH = Path("/data/openpilot/iqpilot/system/proprietary_runtime/iqpilot_bundle_runner")
|
||||
DEFAULT_SOURCE_ROOT = Path("/data/openpilot/iqpilot")
|
||||
|
||||
|
||||
def verified_runtime_present() -> bool:
|
||||
return VERIFIED_RUNNER_PATH.is_file() and os.access(VERIFIED_RUNNER_PATH, os.X_OK)
|
||||
|
||||
|
||||
def preferred_runner_path() -> Path:
|
||||
if verified_runtime_present():
|
||||
return VERIFIED_RUNNER_PATH
|
||||
if os.getenv("IQPILOT_ALLOW_DEV_FALLBACKS") == "1" and FALLBACK_RUNNER_PATH.is_file():
|
||||
return FALLBACK_RUNNER_PATH
|
||||
return VERIFIED_RUNNER_PATH
|
||||
|
||||
|
||||
def preferred_pythonpath(existing: str = "") -> str:
|
||||
parts: list[str] = []
|
||||
if VERIFIED_PYTHON_ROOT.is_dir():
|
||||
parts.append(str(VERIFIED_PYTHON_ROOT))
|
||||
if existing:
|
||||
parts.append(existing)
|
||||
return ":".join(parts)
|
||||
Reference in New Issue
Block a user