-
Notifications
You must be signed in to change notification settings - Fork 1
/
install
executable file
·158 lines (139 loc) · 4.08 KB
/
install
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#!/usr/bin/env bash
# Validation/Usage
print-usage() {
echo -e "NAME\n\t$0 - install dotfiles"
echo -e "SYNOPSIS\n\t$0 [--help] (<bundle> | <layer>) [<bundle>...] [<layer>...]\n"
echo -e "OPTIONS\n"
echo -e "\t<layer>..."
echo -e "\t Folders to be stowed to ~ (not starting with '@')."
echo -e "\t<bundle>..."
echo -e "\t Bundles to be installed (starting with '@')."
echo -e "\t Bundles contain instructions to install more than one layer and"
echo -e "\t may install OS packages/programs."
echo -e "EXAMPLE\n\t$0 @minimal @wsl ptpython\n"
echo -en "NOTES\n\tEnv vars SKIP_PACKAGES, SKIP_UPDATE and VERBOSE "
echo -e "can be used to control the installation.\n"
}
if [[ "$*" == *--help* ]]; then
print-usage
exit 0
fi
if [ "$#" -lt 1 ]; then
echo -e "************************ MISSING ARGUMENTS ************************"
echo -e "* Please provide at least one argument (e.g. \"@default\") *"
echo -e "*******************************************************************\n\n"
print-usage
exit 1
fi
# Setup vars
DIR=$(pwd)
args=($@)
bundles=($({ IFS=$'\n'; echo "${args[*]}"; } | grep '@'))
extra_layers=($({ IFS=$'\n'; echo "${args[*]}"; } | grep -v '@'))
cd "$(dirname "${BASH_SOURCE[0]}")" || {
echo "Unable to switch to ${BASH_SOURCE[0]}"
exit 1
}
BASE_DIR=$(pwd)
log () { echo -e "$*"; }
# Import Libraries
for lib in $BASE_DIR/+lib/*.sh; do
# shellcheck source=/dev/null
source "$lib"
done
if [ -z "${SKIP_UPDATE+x}" ]; then
log "Updating submodules ..."
{ set +x;
git submodule update --init --recursive;
}
fi
log "Bootstraping installation of bundles ..."
bootstrap_scripts=($(find-scripts 'bootstrap.sh' "${bundles[@]}"))
for script in "${bootstrap_scripts[@]}"; do
log "Running $script ..."
# shellcheck source=/dev/null
bash "$script"
done
log "Installing layers ..."
layers=($(read-list '*.stow' "${bundles[@]}"))
layers=("${layers[@]}" "${extra_layers[@]}")
stow_cmd="${VERBOSE+"stow -v -R"}"
stow_cmd="${stow_cmd:-"stow -R"}"
{ set +x;
$stow_cmd "${layers[@]}";
}
log "Compile zsh files ..."
make pre-compile
if [ -z "${SKIP_PACKAGES+x}" ]; then
log "Installing packages ..."
# SKIP_PACKAGES is not set
brew_pkgs=($(read-list '*.brew' "${bundles[@]}"))
if (( ${#brew_pkgs[@]} )); then
bootstrap-brew
{ set +x;
brew install "${brew_pkgs[@]}";
}
fi
if [ -z "${SKIP_SYSTEM_PACKAGES+x}" ]; then
if command-exists apt-get; then
apt_pkgs=($(read-list '*.apt' "${bundles[@]}"))
if (( ${#apt_pkgs[@]} )); then
{ set +x;
sudo apt-get update;
sudo apt-get install "${apt_pkgs[@]}";
}
fi
fi
if command-exists pacman; then
pacman_pkgs=($(read-list '*.packman' "${bundles[@]}"))
if (( ${#pacman_pkgs[@]} )); then
{ set +x;
sudo pacman -Syu;
sudo pacman -S "${pacman_pkgs[@]}";
}
fi
trizen_pkgs=($(read-list '*.trizen' "${bundles[@]}"))
if (( ${#trizen_pkgs[@]} )); then
bootstrap-trizen
{ set +x;
trizen -S "${trizen_pkgs[@]}";
}
fi
fi
else
log "Skipping installation of packages at system level ..."
fi
if command-exists python3; then
pipx_pkgs=($(read-list '*.pipx' "${bundles[@]}"))
if (( ${#pipx_pkgs[@]} )); then
{ set +x;
bootstrap-pipx;
printf '%s\n' "${pipx_pkgs[@]}" | xargs -n1 pipx install
}
fi
pip_pkgs=($(read-list '*.pip' "${bundles[@]}"))
{ set +x;
pip3 install --user --update "${pipx_pkgs[@]}";
}
fi
if command-exists ruby; then
gem_pkgs=($(read-list '*.gem' "${bundles[@]}"))
if (( ${#gem_pkgs[@]} )); then
export PATH="$(ruby -r rubygems -e 'puts Gem.user_dir')/bin:$PATH"
{ set +x;
gem install --user-install "${gem_pkgs[@]}";
}
fi
fi
else
log "Skipping installation of packages ..."
fi
log "Finishing installation of bundles ..."
finish_scripts=($(find-scripts 'finish.sh' "${bundles[@]}"))
for script in "${finish_scripts[@]}"; do
log "Running $script ..."
# shellcheck source=/dev/null
bash "$script"
done
exit 0
cd "$DIR"