Add function to build crates directly from git

This commit is contained in:
2021-11-16 18:45:31 +01:00
parent efb3e54dcb
commit d283bcddcd

View File

@@ -409,7 +409,7 @@
when: distro == 'ubuntu' when: distro == 'ubuntu'
- name: add rustup stable toolchain - name: add rustup stable toolchain
shell: . ~/.cargo/env && rustup default stable shell: . ~/.cargo/env && rustup toolchain install stable && rustup default stable
become: true become: true
become_user: rust_build become_user: rust_build
changed_when: false changed_when: false
@@ -420,17 +420,43 @@
become_user: rust_build become_user: rust_build
changed_when: false changed_when: false
- name: build rust crates - name: add rustup nightly toolchain
shell: . ~/.cargo/env && rustup toolchain install nightly
become: true
become_user: rust_build
changed_when: false
- name: update rustup nightly toolchain
shell: . ~/.cargo/env && rustup update nightly
become: true
become_user: rust_build
changed_when: false
- name: build rust crates from crates.io
shell: | shell: |
set -o errexit set -o errexit
. ~/.cargo/env . ~/.cargo/env
cargo install --version {{ item.version }} {{ item.crate }}
mv /var/lib/rust_build/.cargo/bin/{{ item. binary }} /var/lib/rust_build/.cargo/bin/{{ item.binary }}.{{ item.version }} rustup run {{ item.toolchain|default('stable') }} cargo install --version {{ item.version }} {{ item.crate }}
mv /var/lib/rust_build/.cargo/bin/{{ item.binary }} /var/lib/rust_build/.cargo/bin/{{ item.binary }}.{{ item.version }}
args: args:
creates: /var/lib/rust_build/.cargo/bin/{{ item.binary }}.{{ item.version }} creates: /var/lib/rust_build/.cargo/bin/{{ item.binary }}.{{ item.version }}
become: true # do not build as root! become: true # do not build as root!
become_user: rust_build become_user: rust_build
loop: "{{ cargo_crate_list }}" loop: "{{ cargo_crate_list }}"
when: item.source|default('crates.io') == 'crates.io'
- name: build rust crates from git
shell: |
set -o errexit
. ~/.cargo/env
rustup run {{ item.toolchain|default('stable') }} cargo install --git {{ item.url }} --branch {{ item.branch }}
args:
creates: /var/lib/rust_build/.cargo/bin/{{ item.binary }}
become: true # do not build as root!
become_user: rust_build
loop: "{{ cargo_crate_list }}"
when: item.source|default('crates.io') == 'git'
- name: create target directory - name: create target directory
file: file:
@@ -441,7 +467,7 @@
mode: '0775' mode: '0775'
become: true become: true
- name: move binaries - name: move binaries for crates.io
shell: | shell: |
mv /var/lib/rust_build/.cargo/bin/{{ item.binary }}.{{ item.version }} /usr/local/lib/binaries/{{ item.binary }}.{{ item.version }} mv /var/lib/rust_build/.cargo/bin/{{ item.binary }}.{{ item.version }} /usr/local/lib/binaries/{{ item.binary }}.{{ item.version }}
ln -s /usr/local/lib/binaries/{{ item.binary }}.{{ item.version }} /var/lib/rust_build/.cargo/bin/{{ item.binary }}.{{ item.version }} ln -s /usr/local/lib/binaries/{{ item.binary }}.{{ item.version }} /var/lib/rust_build/.cargo/bin/{{ item.binary }}.{{ item.version }}
@@ -449,8 +475,19 @@
creates: /usr/local/lib/binaries/{{ item.binary }}.{{ item.version }} creates: /usr/local/lib/binaries/{{ item.binary }}.{{ item.version }}
become: true become: true
loop: "{{ cargo_crate_list }}" loop: "{{ cargo_crate_list }}"
when: item.source|default('crates.io') == 'crates.io'
- name: link binaries - name: move binaries for git
shell: |
mv /var/lib/rust_build/.cargo/bin/{{ item.binary }} /usr/local/lib/binaries/{{ item.binary }}
ln -s /usr/local/lib/binaries/{{ item.binary }} /var/lib/rust_build/.cargo/bin/{{ item.binary }}
args:
creates: /usr/local/lib/binaries/{{ item.binary }}
become: true
loop: "{{ cargo_crate_list }}"
when: item.source|default('crates.io') == 'git'
- name: link binaries for crates.io
file: file:
src: /usr/local/lib/binaries/{{ item.binary }}.{{ item.version }} src: /usr/local/lib/binaries/{{ item.binary }}.{{ item.version }}
dest: /usr/local/bin/{{ item.binary }} dest: /usr/local/bin/{{ item.binary }}
@@ -460,6 +497,19 @@
force: true force: true
become: true become: true
loop: "{{ cargo_crate_list }}" loop: "{{ cargo_crate_list }}"
when: item.source|default('crates.io') == 'crates.io'
- name: link binaries for git
file:
src: /usr/local/lib/binaries/{{ item.binary }}
dest: /usr/local/bin/{{ item.binary }}
owner: root
group: root
state: link
force: true
become: true
loop: "{{ cargo_crate_list }}"
when: item.source|default('crates.io') == 'git'
tags: tags:
- rust_binaries - rust_binaries