Page MenuHomeDevCentral

D4156.diff
No OneTemporary

D4156.diff

diff --git a/roles/devserver/userland-home/homefiles.sls b/roles/devserver/userland-home/homefiles.sls
--- a/roles/devserver/userland-home/homefiles.sls
+++ b/roles/devserver/userland-home/homefiles.sls
@@ -53,6 +53,14 @@
- runas: {{ username }}
- creates: /home/{{ username }}/.rustup/toolchains/{{ toolchain }}-{{ triplet }}
{% endfor %}
+
+{{ dirs.etc }}/cron.d/cargo-index-{{ username }}:
+ file.managed:
+ - contents: |
+ # Update Cargo crates index for {{ username }}
+ 11 3 * * * {{ username }} {{ dirs.bin }}/cargo-index-update stable
+ 27 3 * * * {{ username }} {{ dirs.bin }}/cargo-index-update nightly
+
{% endif %}
{% if "install_diesel" in tasks %}
diff --git a/roles/devserver/userland-software/dev.sls b/roles/devserver/userland-software/dev.sls
--- a/roles/devserver/userland-software/dev.sls
+++ b/roles/devserver/userland-software/dev.sls
@@ -183,6 +183,11 @@
- source: salt://roles/devserver/userland-software/files/rustup-init.sh
- mode: 755
+{{ dirs.bin }}/cargo-index-update:
+ file.managed:
+ - source: salt://roles/devserver/userland-software/files/rust/cargo-index-update.sh
+ - mode: 755
+
# -------------------------------------------------------------
# Shell
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/roles/devserver/userland-software/files/rust/cargo-index-update.sh b/roles/devserver/userland-software/files/rust/cargo-index-update.sh
new file mode 100644
--- /dev/null
+++ b/roles/devserver/userland-software/files/rust/cargo-index-update.sh
@@ -0,0 +1,55 @@
+#!/bin/sh
+
+# -------------------------------------------------------------
+# Rust :: Cargo :: Update registry index
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Project: Nasqueron
+# License: Trivial work, not eligible to copyright
+# Source file: roles/devserver/userland-software/files/rust/cargo-index-update.sh
+# -------------------------------------------------------------
+#
+# <auto-generated>
+# This file is managed by our rOPS SaltStack repository.
+#
+# Changes to this file may cause incorrect behavior
+# and will be lost if the state is redeployed.
+# </auto-generated>
+
+set -e
+
+# -------------------------------------------------------------
+# Parse arguments
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+if [ $# -eq 0 ]; then
+ echo "Usage: $(basename "$0") <toolchain>" >&2
+ exit 1
+fi
+
+TOOLCHAIN=$1
+
+# -------------------------------------------------------------
+# Ensure rustup is available
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+USER=$(id -un)
+RUSTUP="/home/${USER}/.cargo/bin/rustup"
+
+if [ ! -x "$RUSTUP" ]; then
+ # No rustup, nothing to update
+ exit 0
+fi
+
+# -------------------------------------------------------------
+# Trigger Cargo registry index update
+#
+# As there is no command implemented, we can simulate any
+# operation normally triggering an update.
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+TMP_DIR=$(mktemp -d "/tmp/cargo-index-${USER}-${TOOLCHAIN}-XXXXXX") || exit 1
+cd "$TMP_DIR" || exit 1
+"$RUSTUP" run "$TOOLCHAIN" cargo init >/dev/null 2>&1
+"$RUSTUP" run "$TOOLCHAIN" cargo add serde >/dev/null 2>&1
+cd / || exit 1
+rm -rf "$TMP_DIR"

File Metadata

Mime Type
text/plain
Expires
Wed, Aug 12, 06:42 (18 h, 32 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3987187
Default Alt Text
D4156.diff (3 KB)

Event Timeline