-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelpers.sh
executable file
·74 lines (64 loc) · 1.78 KB
/
helpers.sh
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/bash
# source the distro specific variables
. distro.sh
blue=$(tput setaf 4)
green=$(tput setaf 2)
red=$(tput setaf 1)
yellow=$(tput setaf 3)
normal=$(tput sgr0)
function echo_error() {
printf "[${red}!!${normal}] $1 \n"
}
function echo_warning() {
printf "[${yellow}/\${normal}] $1 \n"
}
function echo_success() {
printf "[${green}OK${normal}] $1 \n"
}
function echo_info() {
printf "[${blue}..${normal}] $1 \n"
}
function _install() {
# core = My "core" dependencies from the official repository
if [[ $1 == "core" ]]; then
for pkg in "${PKGS[@]}"; do
echo_info "Installing ${pkg}..."
sudo "$PKGMN" "$PKGI" "$pkg" "${PKGOPT[@]}"
echo_success "Installed ${pkg}"
done
elif [[ $1 == "aur" ]]; then
for pkg in "${AUR[@]}"; do
echo_info "Installing ${pkg} from AUR..."
"$PKGMNAUR" "$PKGI" "$pkg" "${PKGOPT[@]}"
echo_success "Installed ${pkg} from AUR."
done
else
echo_info "Installing package ${1}..."
sudo "$PKGMN" "$PKGI" "$1"
fi
}
function _install_aur() {
# Using sudo with yay would be a bad habit. yay calls makepkg behind the scenes
# and makepkg should never be run as root.
# https://wiki.archlinux.org/index.php/Makepkg#Usage
echo_info "Installing $1 from AUR..."
"$PKGMNAUR" "$PKGI" "$1" "${PKGOPT[@]}"
echo_success "Installed $1 from AUR."
}
function _update() {
if [[ $1 != "system" ]]; then
echo_info "Updating system packages..."
sudo "$PKGMN" "$PKGU" "${PKGOPT[@]}"
echo_info "Updated system packages."
else
echo_info "Updating $1"
"$PKGMN" "$PKGI" "$1"
echo_success "Updated $1"
fi
}
function _run_install_files() {
for filename in $(echo $HOME/.dotfiles/**/install.sh | tr " " "\n")
do
source $filename
done
}