Merge "ensure-rust: rework global install"
This commit is contained in:
commit
d5e4d55c15
@ -7,7 +7,8 @@ Install the Rust toolchain
|
||||
.. zuul:rolevar:: ensure_rust_rustup
|
||||
:default: True
|
||||
|
||||
Install Rust via the ``rustup`` installer.
|
||||
Install Rust via the ``rustup`` installer. This installs the toolchain
|
||||
globally (for all users).
|
||||
|
||||
.. zuul:rolevar:: ensure_rust_rustup_toolchain
|
||||
:default: stable
|
||||
@ -15,11 +16,11 @@ Install the Rust toolchain
|
||||
The Rust toolchain to install with ``rustup``.
|
||||
|
||||
.. zuul:rolevar:: ensure_rust_rustup_path
|
||||
:default: /usr
|
||||
:default: /opt/rust
|
||||
|
||||
Where to install Rust/Cargo with ``rustup``. ``/usr`` provides the
|
||||
tools globally. This may conflict with distribution Rust packages
|
||||
if installed.
|
||||
Where to install Rust/Cargo with ``rustup``. Wrappers will
|
||||
be installed in ``/usr/local/bin/`` to make them available for
|
||||
all users.
|
||||
|
||||
.. zuul:rolevar:: ensure_rust_packages
|
||||
:default: False
|
||||
|
@ -1,4 +1,4 @@
|
||||
ensure_rust_rustup: true
|
||||
ensure_rust_packages: false
|
||||
ensure_rust_rustup_toolchain: stable
|
||||
ensure_rust_rustup_path: /usr
|
||||
ensure_rust_rustup_path: /opt/rust
|
||||
|
@ -9,5 +9,19 @@
|
||||
executable: /bin/bash
|
||||
become: yes
|
||||
|
||||
- name: Use as selected Rust toolchain
|
||||
command: rustup default {{ ensure_rust_rustup_toolchain }}
|
||||
# Install wrappers that set env vars for global usage. See
|
||||
# https://github.com/rust-lang/rustup/issues/1085#issuecomment-296604244
|
||||
|
||||
- name: Install wrapper helper script
|
||||
template:
|
||||
src: rust-wrap-setup.sh.j2
|
||||
dest: /usr/local/bin/rust-wrap-setup
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0755
|
||||
become: yes
|
||||
|
||||
- name: Run wrapper installation
|
||||
shell: |
|
||||
/usr/local/bin/rust-wrap-setup
|
||||
become: yes
|
||||
|
16
roles/ensure-rust/templates/rust-wrap-setup.sh.j2
Normal file
16
roles/ensure-rust/templates/rust-wrap-setup.sh.j2
Normal file
@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
|
||||
cat <<'EOF' > /usr/local/bin/rust-wrap
|
||||
#!/bin/sh
|
||||
|
||||
RUSTUP_HOME={{ ensure_rust_rustup_path }} exec {{ ensure_rust_rustup_path }}/bin/${0##*/} "$@"
|
||||
EOF
|
||||
|
||||
chmod 0755 /usr/local/bin/rust-wrap
|
||||
|
||||
for f in {{ ensure_rust_rustup_path }}/bin/*
|
||||
do
|
||||
name=$(basename ${f})
|
||||
echo "Install link for ${name}"
|
||||
ln -f /usr/local/bin/rust-wrap /usr/local/bin/${name}
|
||||
done
|
Loading…
Reference in New Issue
Block a user