Build and serve signed Linux ARM64 agent releases
This commit is contained in:
+18
-11
@@ -22,6 +22,12 @@ TARGETS = {
|
||||
"sha256:30ae3d90753bc39b0a98a897784c662aff9598ffab7a98a6298e8aa79145c2ec",
|
||||
[("rmm-server", "rmm-server"), ("rmm-time-broker-linux", "rmm-time-broker-linux")],
|
||||
),
|
||||
"linux-arm64": (
|
||||
"linux/arm64", "aarch64-unknown-linux-gnu",
|
||||
"sha256:30ae3d90753bc39b0a98a897784c662aff9598ffab7a98a6298e8aa79145c2ec",
|
||||
[("rmm-agent", "rmm-agent"), ("rmm-privileged-helper", "rmm-privileged-helper"),
|
||||
("rmm-updater-worker", "rmm-agent-updater")],
|
||||
),
|
||||
"linux-x64": (
|
||||
"linux/amd64", "x86_64-unknown-linux-gnu",
|
||||
"sha256:9a76ad3744ebfdddae96ca10001ce8291c1b332fb54c8df5eea0e8e999ac6fc6",
|
||||
@@ -34,6 +40,7 @@ TARGETS = {
|
||||
[("rmm-agent-windows", "rmm-agent-windows"), ("rmm-agent-windows", "rmm-helper-windows")],
|
||||
),
|
||||
}
|
||||
REMOTE_TARGETS = ("server-arm64", "linux-arm64")
|
||||
SOURCE_PATHS = ["Cargo.toml", "Cargo.lock", "rust-toolchain.toml", "crates", "proto",
|
||||
"migrations", "tools/apt-transaction", "deploy/linux", "tests"]
|
||||
|
||||
@@ -140,7 +147,7 @@ def build_archive(work, archive, revision, plan):
|
||||
print(f"Artifacts: {destination}\n{json.dumps(hashes, indent=2)}")
|
||||
|
||||
|
||||
def remote_build(archive, revision, jobs):
|
||||
def remote_build(archive, revision, jobs, target):
|
||||
from dev_stage import ssh_prefix
|
||||
|
||||
# The only SSH payload is this build driver and the selected Git sources.
|
||||
@@ -154,14 +161,14 @@ trap 'rm -rf -- "$stage"' EXIT
|
||||
cd "$stage"
|
||||
tar -xf - build.py source.tar.gz
|
||||
printf '%s build.py\\n%s source.tar.gz\\n' "$1" "$2" | sha256sum -c - >/dev/null
|
||||
python3 -I build.py _server_worker "$3" "$4"
|
||||
python3 -I build.py _server_worker "$3" "$4" "$5"
|
||||
"""
|
||||
with tempfile.TemporaryFile() as bundle:
|
||||
with tarfile.open(fileobj=bundle, mode="w") as package:
|
||||
package.add(worker, arcname="build.py")
|
||||
package.add(archive, arcname="source.tar.gz")
|
||||
bundle.seek(0)
|
||||
command = shlex.join(["sh", "-c", shell, "build", *checksums, revision, str(jobs)])
|
||||
command = shlex.join(["sh", "-c", shell, "build", *checksums, revision, str(jobs), target])
|
||||
result = subprocess.run([*ssh_prefix("server"), command], stdin=bundle)
|
||||
if result.returncode:
|
||||
raise SystemExit(f"ARM64 build via SSH failed (exit {result.returncode}).")
|
||||
@@ -176,13 +183,13 @@ def main():
|
||||
parser.add_argument("target", choices=TARGETS)
|
||||
parser.add_argument("--ref", default="HEAD", help="Git commit or ref (default: HEAD). Uncommitted edits are excluded.")
|
||||
parser.add_argument("--jobs", type=int, default=2, help="Maximum parallel Cargo jobs (default: 2).")
|
||||
parser.add_argument("--ssh", action="store_true", help="Build server-arm64 on the configured server, in ~/rmm-dev-build/.")
|
||||
parser.add_argument("--ssh", action="store_true", help="Build ARM64 binaries on the configured server, in ~/rmm-dev-build/.")
|
||||
parser.add_argument("--plan", action="store_true", help="Show the build plan without connecting, writing or building.")
|
||||
args = parser.parse_args()
|
||||
if args.jobs < 1:
|
||||
parser.error("--jobs must be positive")
|
||||
if args.ssh and args.target != "server-arm64":
|
||||
parser.error("--ssh applies to server-arm64")
|
||||
if args.ssh and args.target not in REMOTE_TARGETS:
|
||||
parser.error("--ssh applies to the ARM64 targets")
|
||||
revision = git("rev-parse", "--verify", "--end-of-options", args.ref + "^{commit}")
|
||||
windows_updater = args.target == "windows-gnu-x64" and git(
|
||||
"ls-tree", "--name-only", revision, "crates/agent-windows/src/bin/rmm-updater-windows.rs")
|
||||
@@ -196,7 +203,7 @@ def main():
|
||||
archive = Path(temporary) / "source.tar.gz"
|
||||
subprocess.run(["git", "archive", "-o", archive, revision, "--", *SOURCE_PATHS], cwd=ROOT, check=True)
|
||||
if args.ssh:
|
||||
remote_build(archive, revision, args.jobs)
|
||||
remote_build(archive, revision, args.jobs, args.target)
|
||||
else:
|
||||
build_archive(ROOT / "devstate" / "build" / args.target, archive, revision, plan)
|
||||
|
||||
@@ -204,12 +211,12 @@ def main():
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
if sys.argv[1:2] == ["_server_worker"]:
|
||||
revision, jobs_arg = sys.argv[2:]
|
||||
if (len(revision) not in (40, 64) or any(c not in "0123456789abcdef" for c in revision)
|
||||
revision, jobs_arg, target = sys.argv[2:]
|
||||
if (target not in REMOTE_TARGETS or len(revision) not in (40, 64) or any(c not in "0123456789abcdef" for c in revision)
|
||||
or not jobs_arg.isascii() or not jobs_arg.isdecimal() or int(jobs_arg) < 1):
|
||||
raise SystemExit("Invalid packed build request.")
|
||||
work = Path.home() / "rmm-dev-build" / "server-arm64"
|
||||
build_archive(work, Path("source.tar.gz").resolve(), revision, prepare("server-arm64", int(jobs_arg)))
|
||||
work = Path.home() / "rmm-dev-build" / target
|
||||
build_archive(work, Path("source.tar.gz").resolve(), revision, prepare(target, int(jobs_arg)))
|
||||
else:
|
||||
main()
|
||||
except (OSError, subprocess.CalledProcessError) as error:
|
||||
|
||||
Reference in New Issue
Block a user