mirror of https://github.com/1okko/openpilot.git
casync build: caidx filename is canonical representation of build (#31964)
* canonical * short commit * channel * cleanup * let's do 9 characters * fixes * set the build style during release creation * as a property
This commit is contained in:
parent
b59ae50961
commit
33f9193c94
|
@ -11,5 +11,5 @@ else
|
|||
fi
|
||||
|
||||
cd $SOURCE_DIR
|
||||
cp -pR --parents $(cat release/files_common) $BUILD_DIR/
|
||||
cp -pR --parents $(cat release/files_common) $TARGET_DIR/
|
||||
cp -pR --parents $(cat $FILES_SRC) $TARGET_DIR/
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import pathlib
|
||||
|
||||
from openpilot.system.updated.casync.common import create_caexclude_file, create_casync_release, create_build_metadata_file
|
||||
|
@ -17,9 +18,12 @@ if __name__ == "__main__":
|
|||
target_dir = pathlib.Path(args.target_dir)
|
||||
output_dir = pathlib.Path(args.output_dir)
|
||||
|
||||
create_build_metadata_file(target_dir, get_build_metadata(), args.channel)
|
||||
build_metadata = get_build_metadata()
|
||||
build_metadata.openpilot.build_style = "release" if os.environ.get("RELEASE", None) is not None else "debug"
|
||||
|
||||
create_build_metadata_file(target_dir, build_metadata, args.channel)
|
||||
create_caexclude_file(target_dir)
|
||||
|
||||
digest, caidx = create_casync_release(target_dir, output_dir, args.channel)
|
||||
digest, caidx = create_casync_release(target_dir, output_dir, build_metadata.canonical)
|
||||
|
||||
print(f"Created casync release from {target_dir} to {caidx} with digest {digest}")
|
||||
|
|
|
@ -46,8 +46,8 @@ def create_build_metadata_file(path: pathlib.Path, build_metadata: BuildMetadata
|
|||
f.write(json.dumps(build_metadata_dict))
|
||||
|
||||
|
||||
def create_casync_release(target_dir: pathlib.Path, output_dir: pathlib.Path, channel: str):
|
||||
caidx_file = output_dir / f"{channel}.caidx"
|
||||
def create_casync_release(target_dir: pathlib.Path, output_dir: pathlib.Path, caidx_name: str):
|
||||
caidx_file = output_dir / f"{caidx_name}.caidx"
|
||||
run(["casync", "make", *CASYNC_ARGS, caidx_file, target_dir])
|
||||
digest = run(["casync", "digest", *CASYNC_ARGS, target_dir]).decode("utf-8").strip()
|
||||
return digest, caidx_file
|
||||
|
|
|
@ -62,13 +62,14 @@ def is_dirty(cwd: str = BASEDIR) -> bool:
|
|||
return dirty
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@dataclass
|
||||
class OpenpilotMetadata:
|
||||
version: str
|
||||
release_notes: str
|
||||
git_commit: str
|
||||
git_origin: str
|
||||
git_commit_date: str
|
||||
build_style: str
|
||||
is_dirty: bool # whether there are local changes
|
||||
|
||||
@property
|
||||
|
@ -90,7 +91,7 @@ class OpenpilotMetadata:
|
|||
.replace(":", "/", 1)
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@dataclass
|
||||
class BuildMetadata:
|
||||
channel: str
|
||||
openpilot: OpenpilotMetadata
|
||||
|
@ -103,6 +104,10 @@ class BuildMetadata:
|
|||
def release_channel(self) -> bool:
|
||||
return self.channel in RELEASE_BRANCHES
|
||||
|
||||
@property
|
||||
def canonical(self) -> str:
|
||||
return f"{self.openpilot.version}-{self.openpilot.git_commit}-{self.openpilot.build_style}"
|
||||
|
||||
|
||||
def build_metadata_from_dict(build_metadata: dict) -> BuildMetadata:
|
||||
channel = build_metadata.get("channel", "unknown")
|
||||
|
@ -112,6 +117,7 @@ def build_metadata_from_dict(build_metadata: dict) -> BuildMetadata:
|
|||
git_commit = openpilot_metadata.get("git_commit", "unknown")
|
||||
git_origin = openpilot_metadata.get("git_origin", "unknown")
|
||||
git_commit_date = openpilot_metadata.get("git_commit_date", "unknown")
|
||||
build_style = openpilot_metadata.get("build_style", "unknown")
|
||||
return BuildMetadata(channel,
|
||||
OpenpilotMetadata(
|
||||
version=version,
|
||||
|
@ -119,6 +125,7 @@ def build_metadata_from_dict(build_metadata: dict) -> BuildMetadata:
|
|||
git_commit=git_commit,
|
||||
git_origin=git_origin,
|
||||
git_commit_date=git_commit_date,
|
||||
build_style=build_style,
|
||||
is_dirty=False))
|
||||
|
||||
|
||||
|
@ -139,6 +146,7 @@ def get_build_metadata(path: str = BASEDIR) -> BuildMetadata:
|
|||
git_commit=get_commit(path),
|
||||
git_origin=get_origin(path),
|
||||
git_commit_date=get_commit_date(path),
|
||||
build_style="unknown",
|
||||
is_dirty=is_dirty(path)))
|
||||
|
||||
cloudlog.exception("unable to get build metadata")
|
||||
|
|
Loading…
Reference in New Issue