Scons: Build sunnypilot elements with added GPG keys

This commit is contained in:
Jason Wen
2024-07-16 02:59:02 +00:00
parent e24271aa2b
commit 1fb0cb59a6
4 changed files with 65 additions and 0 deletions
+2
View File
@@ -129,6 +129,8 @@ build:
--exclude='**/selfdrive/ui/**/*.h'
--exclude='**/selfdrive/ui/qt/offroad/sunnypilot/'
--exclude='**/.git/'
--exclude='**/SConstruct'
--exclude='**/SConscript'
--delete-excluded
--chown=comma:comma
${BUILD_DIR}/ ${OUTPUT_DIR}/
+47
View File
@@ -7,6 +7,8 @@ import numpy as np
import SCons.Errors
from openpilot.common.basedir import BASEDIR
SCons.Warnings.warningAsException(True)
# pending upstream fix - https://github.com/SCons/scons/issues/4461
@@ -16,6 +18,45 @@ TICI = os.path.isfile('/TICI')
AGNOS = TICI
UBUNTU_FOCAL = int(subprocess.check_output('[ -f /etc/os-release ] && . /etc/os-release && [ "$ID" = "ubuntu" ] && [ "$VERSION_ID" = "20.04" ] && echo 1 || echo 0', shell=True, encoding='utf-8').rstrip())
Export('UBUNTU_FOCAL')
_DEBUG = False
def is_internal_developer(debug=False):
def collect_required_gpg_key_ids(keys_dir):
try:
key_ids = [f.split('.')[0] for f in os.listdir(keys_dir) if f.endswith(".gpg")]
if debug:
print(f"SP: Required GPG key IDs: {key_ids}")
return key_ids
except OSError as e:
if debug:
print(f"SP: Failed to read GPG key IDs from {keys_dir}. Error: {e}")
return []
def is_key_available(required_gpg_key_ids):
for key_id in required_gpg_key_ids:
try:
result = subprocess.check_output(['gpg', '--list-keys', key_id], stderr=subprocess.STDOUT)
if key_id in result.decode():
if debug:
print(f"SP: GPG key {key_id} is available.")
return True
except subprocess.CalledProcessError as e:
if debug:
print(f"SP: Failed to list GPG key {key_id}. Error:", e.output.decode().strip())
return False
keys_dir = os.path.join(BASEDIR, ".git-crypt/keys/default/0")
required_gpg_key_ids = collect_required_gpg_key_ids(keys_dir)
sunnypilot = is_key_available(required_gpg_key_ids)
if sunnypilot:
print("SP: Confirmed sunnypilot internal developer.")
print("SP: Loading sunnypilot elements ...")
elif debug:
print("SP: None of the required GPG keys are available.")
return sunnypilot
Decider('MD5-timestamp')
@@ -72,6 +113,12 @@ AddOption('--minimal',
default=os.path.exists(File('#.lfsconfig').abspath), # minimal by default on release branch (where there's no LFS)
help='the minimum build to run openpilot. no tests, tools, etc.')
AddOption('--sunnypilot',
action='store_true',
dest='sunnypilot',
default=is_internal_developer(_DEBUG), # check if the current user is a sunnypilot developer
help='build sunnypilot elements and other sunnypilot-specific items that are meant for internal development')
## Architecture name breakdown (arch)
## - larch64: linux tici aarch64
## - aarch64: linux pc aarch64
+6
View File
@@ -17,6 +17,12 @@ if arch == "Darwin":
# FIXME: remove this once we're on 5.15 (24.04)
qt_env['CXXFLAGS'] += ["-Wno-deprecated-declarations"]
sp_widgets_src = []
sp_qt_src = []
if GetOption('sunnypilot'):
SConscript(['sunnypilot/SConscript'])
Import('sp_widgets_src', 'sp_qt_src')
qt_util = qt_env.Library("qt_util", ["#selfdrive/ui/qt/api.cc", "#selfdrive/ui/qt/util.cc"], LIBS=base_libs)
widgets_src = ["ui.cc", "qt/widgets/input.cc", "qt/widgets/wifi.cc",
"qt/widgets/ssh_keys.cc", "qt/widgets/toggle.cc", "qt/widgets/controls.cc",
+10
View File
@@ -0,0 +1,10 @@
widgets_src = []
network_src = []
qt_src = []
sp_widgets_src = widgets_src + network_src
sp_qt_src = qt_src
Export('sp_widgets_src', 'sp_qt_src')