forked from prasanthrangan/hyprdots
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall_pkg.sh
executable file
·69 lines (60 loc) · 2.04 KB
/
install_pkg.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
#!/usr/bin/env bash
#|---/ /+----------------------------------------+---/ /|#
#|--/ /-| Script to install pkgs from input list |--/ /-|#
#|-/ /--| Prasanth Rangan |-/ /--|#
#|/ /---+----------------------------------------+/ /---|#
scrDir=$(dirname "$(realpath "$0")")
source "${scrDir}/global_fn.sh"
if [ $? -ne 0 ]; then
echo "Error: unable to source global_fn.sh..."
exit 1
fi
"${scrDir}/install_aur.sh" "${getAur}" 2>&1
chk_list "aurhlpr" "${aurList[@]}"
listPkg="${1:-"${scrDir}/custom_hypr.lst"}"
archPkg=()
aurhPkg=()
ofs=$IFS
IFS='|'
while read -r pkg deps; do
pkg="${pkg// /}"
if [ -z "${pkg}" ]; then
continue
fi
if [ ! -z "${deps}" ]; then
deps="${deps%"${deps##*[![:space:]]}"}"
while read -r cdep; do
pass=$(cut -d '#' -f 1 "${listPkg}" | awk -F '|' -v chk="${cdep}" '{if($1 == chk) {print 1;exit}}')
if [ -z "${pass}" ]; then
if pkg_installed "${cdep}"; then
pass=1
else
break
fi
fi
done < <(echo "${deps}" | xargs -n1)
if [[ ${pass} -ne 1 ]]; then
echo -e "\033[0;33m[skip]\033[0m ${pkg} is missing (${deps}) dependency..."
continue
fi
fi
if pkg_installed "${pkg}"; then
echo -e "\033[0;33m[skip]\033[0m ${pkg} is already installed..."
elif pkg_available "${pkg}"; then
repo=$(pacman -Si "${pkg}" | awk -F ': ' '/Repository / {print $2}')
echo -e "\033[0;32m[${repo}]\033[0m queueing ${pkg} from official arch repo..."
archPkg+=("${pkg}")
elif aur_available "${pkg}"; then
echo -e "\033[0;34m[aur]\033[0m queueing ${pkg} from arch user repo..."
aurhPkg+=("${pkg}")
else
echo "Error: unknown package ${pkg}..."
fi
done < <(cut -d '#' -f 1 "${listPkg}")
IFS=${ofs}
if [[ ${#archPkg[@]} -gt 0 ]]; then
sudo pacman ${use_default} -S "${archPkg[@]}"
fi
if [[ ${#aurhPkg[@]} -gt 0 ]]; then
"${aurhlpr}" ${use_default} -S "${aurhPkg[@]}"
fi