From 207bff9cb9773e3e0ef7fe7114e4b1aa70ffd4b6 Mon Sep 17 00:00:00 2001 From: Luke Hoersten Date: Tue, 28 Jul 2026 21:11:08 -0500 Subject: Rename mattertimesync role to mattertimectl (build + controller) - Rename role dir and all vars from mattertimesync to mattertimectl - Rename the server subrole to controller - Build via cargo instead of npm; run the binary directly (no node) - Default fabricLabel to "Matter Time Controller" --- mattertimectl/build/defaults/main.yaml | 16 ++++++++ mattertimectl/build/meta/main.yaml | 5 +++ mattertimectl/build/tasks/main.yaml | 71 ++++++++++++++++++++++++++++++++++ 3 files changed, 92 insertions(+) create mode 100644 mattertimectl/build/defaults/main.yaml create mode 100644 mattertimectl/build/meta/main.yaml create mode 100644 mattertimectl/build/tasks/main.yaml (limited to 'mattertimectl/build') diff --git a/mattertimectl/build/defaults/main.yaml b/mattertimectl/build/defaults/main.yaml new file mode 100644 index 0000000..56cabdc --- /dev/null +++ b/mattertimectl/build/defaults/main.yaml @@ -0,0 +1,16 @@ +--- + +mattertimectl_version: "0.1.0" +# https://github.com/lukehoersten/mattertimectl/tags +# Rust project: cargo build --release produces one self-contained binary +# (all runtime deps are pure Rust), so the target only needs the binary to +# run it. The source tarball must point at the Rust implementation. +mattertimectl_tar: "https://github.com/{{github_user}}/mattertimectl/archive/refs/tags/v{{mattertimectl_version}}.tar.gz" +mattertimectl_build_dir: "{{build_work_dir}}/mattertimectl-{{mattertimectl_version}}" +mattertimectl_srv_dir: "{{build_srv_dir}}" + +# Keep cargo's registry cache, the rustup toolchains, and the build output +# on build_work_dir (the SSD), not the SD card. +mattertimectl_cargo_home: "{{build_work_dir}}/.cargo" +mattertimectl_rustup_home: "{{build_work_dir}}/.rustup" +mattertimectl_cargo_target_dir: "{{build_work_dir}}/.cargo-target" diff --git a/mattertimectl/build/meta/main.yaml b/mattertimectl/build/meta/main.yaml new file mode 100644 index 0000000..dae4be5 --- /dev/null +++ b/mattertimectl/build/meta/main.yaml @@ -0,0 +1,5 @@ +--- + +# No role dependency: the Rust toolchain is installed inline via rustup +# (the distro rustc is too old for this crate's Rust edition). +dependencies: [] diff --git a/mattertimectl/build/tasks/main.yaml b/mattertimectl/build/tasks/main.yaml new file mode 100644 index 0000000..d5721d7 --- /dev/null +++ b/mattertimectl/build/tasks/main.yaml @@ -0,0 +1,71 @@ +--- + +- name: ensure build work dir exists + become: yes + file: + path: "{{build_work_dir}}" + state: "directory" + owner: "{{ansible_user}}" + group: "{{ansible_user}}" + mode: "0755" + +- name: check if mattertimectl build exists + stat: + path: "{{mattertimectl_srv_dir}}/mattertimectl-{{mattertimectl_version}}.tar.gz" + register: build_file + +# NOTE: rustup is used only because rs-matter requires a newer rustc than +# Ubuntu 24.04's apt ships (apt rustc is 1.75; rs-matter needs >= 1.87). Once +# the build host runs an Ubuntu whose apt rustc/cargo are new enough, drop +# rustup and the toolchain tasks below and just `apt install rustc cargo`. +- name: install rustup + become: yes + apt: + name: "rustup" + state: "present" + +- name: install a current stable rust toolchain + command: "rustup toolchain install stable" + environment: + CARGO_HOME: "{{mattertimectl_cargo_home}}" + RUSTUP_HOME: "{{mattertimectl_rustup_home}}" + when: not build_file.stat.exists + +- name: unarchive mattertimectl source + unarchive: + remote_src: yes + src: "{{mattertimectl_tar}}" + dest: "{{build_work_dir}}/" + creates: "{{mattertimectl_build_dir}}" + +- name: build mattertimectl release binary + # rustup run stable dispatches cargo through the toolchain regardless of + # the apt rustup package's proxy layout or the configured default. + command: "rustup run stable cargo build --release" + args: + chdir: "{{mattertimectl_build_dir}}" + creates: "{{mattertimectl_cargo_target_dir}}/release/mattertimectl" + environment: + CARGO_HOME: "{{mattertimectl_cargo_home}}" + RUSTUP_HOME: "{{mattertimectl_rustup_home}}" + CARGO_TARGET_DIR: "{{mattertimectl_cargo_target_dir}}" + when: not build_file.stat.exists + +- name: create build server dir + become: yes + file: + path: "{{mattertimectl_srv_dir}}" + mode: "0755" + state: "directory" + +- name: create gz archive of mattertimectl binary + become: yes + archive: + path: "{{mattertimectl_cargo_target_dir}}/release/mattertimectl" + dest: "{{mattertimectl_srv_dir}}/mattertimectl-{{mattertimectl_version}}.tar.gz" + format: "gz" + # force a real tar for the single-file binary; the module otherwise gzips + # a lone file into a bare .gz that the server's unarchive can't extract. + # The tar preserves the executable bit the target relies on. + force_archive: true + when: not build_file.stat.exists -- cgit v1.2.3