mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-06-24 15:32:07 +08:00
@@ -86,6 +86,11 @@ def set_consistent_flag(consistent: bool) -> None:
|
||||
os.sync()
|
||||
|
||||
|
||||
def get_consistent_flag() -> bool:
|
||||
consistent_file = Path(os.path.join(FINALIZED, ".overlay_consistent"))
|
||||
return consistent_file.is_file()
|
||||
|
||||
|
||||
def parse_release_notes(releases_md: str) -> str:
|
||||
try:
|
||||
r = releases_md.split('\n\n', 1)[0] # Slice latest release notes
|
||||
@@ -98,3 +103,13 @@ def parse_release_notes(releases_md: str) -> str:
|
||||
except Exception:
|
||||
cloudlog.exception("failed to parse release notes")
|
||||
return ""
|
||||
|
||||
|
||||
def get_version(path) -> str:
|
||||
with open(os.path.join(path, "common", "version.h")) as f:
|
||||
return f.read().split('"')[1]
|
||||
|
||||
|
||||
def get_release_notes(path) -> str:
|
||||
with open(os.path.join(path, "RELEASES.md"), "r") as f:
|
||||
return parse_release_notes(f.read())
|
||||
|
||||
@@ -12,7 +12,8 @@ from typing import List
|
||||
from openpilot.common.basedir import BASEDIR
|
||||
from openpilot.common.params import Params
|
||||
from openpilot.common.swaglog import cloudlog
|
||||
from openpilot.selfdrive.updated.common import FINALIZED, STAGING_ROOT, UpdateStrategy, parse_release_notes, set_consistent_flag, run
|
||||
from openpilot.selfdrive.updated.common import FINALIZED, STAGING_ROOT, UpdateStrategy, \
|
||||
get_consistent_flag, get_release_notes, get_version, set_consistent_flag, run
|
||||
|
||||
|
||||
OVERLAY_UPPER = os.path.join(STAGING_ROOT, "upper")
|
||||
@@ -127,8 +128,7 @@ class GitUpdateStrategy(UpdateStrategy):
|
||||
return list(self.branches.keys())
|
||||
|
||||
def update_ready(self) -> bool:
|
||||
consistent_file = Path(os.path.join(FINALIZED, ".overlay_consistent"))
|
||||
if consistent_file.is_file():
|
||||
if get_consistent_flag():
|
||||
hash_mismatch = self.get_commit_hash(BASEDIR) != self.branches[self.target_channel]
|
||||
branch_mismatch = self.get_branch(BASEDIR) != self.target_channel
|
||||
on_target_channel = self.get_branch(FINALIZED) == self.target_channel
|
||||
@@ -165,8 +165,7 @@ class GitUpdateStrategy(UpdateStrategy):
|
||||
try:
|
||||
branch = self.get_branch(basedir)
|
||||
commit = self.get_commit_hash(basedir)[:7]
|
||||
with open(os.path.join(basedir, "common", "version.h")) as f:
|
||||
version = f.read().split('"')[1]
|
||||
version = get_version(basedir)
|
||||
|
||||
commit_unix_ts = run(["git", "show", "-s", "--format=%ct", "HEAD"], basedir).rstrip()
|
||||
dt = datetime.datetime.fromtimestamp(int(commit_unix_ts))
|
||||
@@ -175,16 +174,12 @@ class GitUpdateStrategy(UpdateStrategy):
|
||||
cloudlog.exception("updater.get_description")
|
||||
return f"{version} / {branch} / {commit} / {commit_date}"
|
||||
|
||||
def release_notes_branch(self, basedir) -> str:
|
||||
with open(os.path.join(basedir, "RELEASES.md"), "r") as f:
|
||||
return parse_release_notes(f.read())
|
||||
|
||||
def describe_current_channel(self) -> tuple[str, str]:
|
||||
return self.describe_branch(BASEDIR), self.release_notes_branch(BASEDIR)
|
||||
return self.describe_branch(BASEDIR), get_release_notes(BASEDIR)
|
||||
|
||||
def describe_ready_channel(self) -> tuple[str, str]:
|
||||
if self.update_ready():
|
||||
return self.describe_branch(FINALIZED), self.release_notes_branch(FINALIZED)
|
||||
return self.describe_branch(FINALIZED), get_release_notes(FINALIZED)
|
||||
|
||||
return "", ""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user