add pre_deploy.sh script for dotter

This commit is contained in:
Alexander Navarro 2024-11-19 15:48:29 -03:00
parent 808cdb3201
commit d93bf44ae0
7 changed files with 192 additions and 16 deletions

View file

@ -1 +1,43 @@
sudo dnf install -y {{# each packages }} {{ this }} {{/each}}
#!/usr/bin/env bash
# shellcheck disable=all
# This is a handlerbars template, so ignore issues
{{!~ Detect the distribution ~}}
{{~ assign "distro" (trim (command_output "awk -F= '/^ID=/ {print $2}' /etc/os-release | tr -d '\"'")) ~}}
{{ header "Running pre deploy script for distro" (to_title_case distro) }}
{{#if (eq distro "fedora") ~}}
{{! extract the copr repositories variable }}
{{~ assign "copr" (flatten_table copr) ~}}
{{#if (ne (len copr) 0) ~}}
{{ header "Enabling copr repositories" }}
{{# each copr }}
sudo -B dnf copr enable -y '{{ this }}'
{{ /each }}
{{~ /if }}
{{ header "Installing dnf packages" }}
sudo -B dnf install -y {{~# each (flatten_table packages) }} '{{ this }}' {{~ /each }}
{{~ /if }}
{{#if (and dotter.packages.rust (not (is_executable "cargo"))) }}
{{ header "Installing rust" }}
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --no-modify-path --default-toolchain stable
{{ /if }}
{{#if (and dotter.packages.rust (ne (len cargo.packages) 0)) }}
{{ header "Installing crates" }}
cargo install --locked {{# each cargo.packages }} "{{ this }}" {{ /each }}
{{ /if }}
{{ header "Done :3" }}