src.nth.io/

summaryrefslogtreecommitdiff
path: root/mattertimectl/build/tasks/main.yaml
blob: 87ce346d63cfa05f06d8314896da9df24f60631a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
---

- 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

# rs-matter needs rustc >= 1.87; 26.04's apt ships 1.93, so the distro
# toolchain suffices. 24.04 builds needed rustup instead (see git history).
- name: install rustc and cargo
  become: yes
  apt:
    name:
      - "rustc"
      - "cargo"

- name: unarchive mattertimectl source
  unarchive:
    remote_src: yes
    src: "{{mattertimectl_tar}}"
    dest: "{{build_work_dir}}/"
    creates: "{{mattertimectl_build_dir}}"

- name: build mattertimectl release binary
  command: "cargo build --release"
  args:
    chdir: "{{mattertimectl_build_dir}}"
    creates: "{{mattertimectl_cargo_target_dir}}/release/mattertimectl"
  environment:
    CARGO_HOME: "{{mattertimectl_cargo_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