-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
install.sh
executable file
·127 lines (109 loc) · 4.01 KB
/
install.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
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
#! /bin/env bash
SUPER() {
local command="$*"
echo -ne "\e[33m[ROOT]\e[0m ${command}"
if command -v doas >/dev/null 2>&1 && [ -f /etc/doas.conf ]; then
doas sh -c "$command"
else
sudo sh -c "$command"
fi
}
export -f SUPER
check_deps() {
for cmd in "${@}"; do
echo $cmd
if ! command -v "$cmd" >/dev/null 2>&1; then
echo "'$cmd' not found."
export requirements+="${cmd} "
fi
done
[ -n "${requirements}" ] && echo -e "Dependencies: ${requirements}\nInstall them using your package manager"
}
export -f check_deps
if [[ 1 -ne ${HYDE_LOCAL} ]]; then
PACKAGE_MANAGER=$(which pacman >/dev/null 2>&1 && echo "pacman" || true)
# PACKAGE_MANAGER=${PACKAGE_MANAGER:-$(which apt >/dev/null 2>&1 && echo "apt" || true)}
# PACKAGE_MANAGER=${PACKAGE_MANAGER:-$(which zypper >/dev/null 2>&1 && echo "zypper" || true)}
# PACKAGE_MANAGER=${PACKAGE_MANAGER:-$(which yum >/dev/null 2>&1 && echo "yum" || true)}
echo "Package manager: $PACKAGE_MANAGER"
case "${PACKAGE_MANAGER}" in
dnf)
:
#Yes possible! But I'm Lazy
;;
pacman)
pkgname=hyde-cli-git
if pacman -Q yay &>/dev/null; then
aurhlpr="yay"
elif pacman -Q paru &>/dev/null; then
aurhlpr="paru"
else
select opt in "yay" "paru"; do if [[ -n $opt ]]; then
aurhlpr=$opt
break
fi; done
SUPER pacman -S --needed git base-devel
rm -fr ${clone_hyde_cli}/${aurhlpr}
git clone https://aur.archlinux.org/${aurhlpr}.git ${clone_hyde_cli}/${aurhlpr}
cd ${clone_hyde_cli}/${aurhlpr}
makepkg -si --noconfirm
fi
if ! pacman -Q "${aurhlpr}" &>/dev/null; then echo "Please try to rerun script!" && exit 0; fi
if pacman -Q "${pkgname}" 2>/dev/null; then
if ${aurhlpr} -Qu --devel "${pkgname}" | grep -q "${pkgname}"; then
${aurhlpr} -Sy "${pkgname}" --noconfirm
else
echo "Already up to date"
fi
exit 0
else
"${aurhlpr}" -Sy "${pkgname}" --noconfirm
if pacman -Q "${pkgname}" 2>/dev/null; then exit 0; fi
fi
;;
esac
else
check_deps jq git kitty
clone_hyde_cli=${HOME}/.cache/hyde/Hyde-cli
# mkdir -p "${clone_hyde_cli}"
if [[ 1 -ne ${HYDE_UPDATE} ]]; then
rm -fr "${clone_hyde_cli}"
git clone https://github.com/kRHYME7/Hyde-cli "${clone_hyde_cli}"
fi
cd "${clone_hyde_cli}" || { git clone https://github.com/kRHYME7/Hyde-cli "${clone_hyde_cli}" && cd "${clone_hyde_cli}" ;}
git reset --hard
git clean -fdi
git pull
if [[ true == "HYDE_BRANCH" ]]; then
if ! git config --get-regexp 'remote.origin.fetch' | grep -q 'refs/heads/\*:refs/remotes/origin/\*'; then
git remote set-branches origin '*'
fi
git fetch --all
Git_Repo="$(git remote get-url origin)"
branches=$(curl -s "https://api.github.com/repos/${Git_Repo#*://*/}/branches" | jq -r '.[].name')
branches=($branches)
if [[ ${#branches[@]} -le 1 ]]; then
git_branch=${branches[0]}
else
echo "Select a Branch (default Master): "
if command -v flzf; then
git_branch=$(git branch -a | fzf --prompt='Choose a branch')
{ [[ -z ${git_branch} ]] && git_branch=master && echo "Default master branch"; }
else
select git_branch in "${branches[@]}"; do [[ -n $git_branch ]] && break || echo "Invalid Selection"; done
fi
fi
[[ -z ${git_branch} ]] && echo "Operation cancelled" && exit 0
if [[ $git_branch == *"*"* ]]; then
echo "Already in branch: ${git_branch}"
return 1
else
# Extract the branch name without the remote prefix and trim leading whitespace
branch_name=$(echo "${git_branch}" | sed 's/.*\///' | sed 's/^[[:space:]]*//')
# Switch to the selected branch
git switch "${branch_name}"
fi
fi
echo "Installing ${pkgname} locally"
make LOCAL=1 clean all
fi