forked from rime/plum
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rime-install
executable file
·61 lines (50 loc) · 1.37 KB
/
rime-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
#!/usr/bin/env bash
if [[ -z "${plum_repo}" ]]; then
plum_repo='rime/plum'
fi
if [[ -z "${plum_dir}" ]]; then
# am I in a working copy already?
plum_dir="$(dirname "$(readlink -f "$0")")"
if ! [[ -f "${plum_dir}"/scripts/install-packages.sh ]]; then
# make a copy of plum in a subdirectory
plum_dir='plum'
fi
fi
if ! [[ -e "${plum_dir}" ]]; then
git clone --depth 1 "https://github.com/${plum_repo}.git" "${plum_dir}"
fi
if ! [[ "$0" -ef "${plum_dir}"/rime-install ]]; then
# run the newer version of rime-install
"${plum_dir}"/rime-install "$@"
exit
fi
export root_dir="${plum_dir}"
source "${root_dir}"/scripts/bootstrap.sh
require 'styles'
if [[ -z "${rime_dir}" ]]; then
# Output to Rime user directory
require 'frontend'
guess_rime_user_dir # exports `rime_dir`
fi
if [[ "$1" == '--select' ]]; then
shift
interactive=1
fi
if [[ $# -eq 0 ]]; then
targets=(':preset')
else
targets=("$@")
fi
if [[ -n "${interactive}" ]]; then
require 'selector'
select_packages "${targets[@]}"
targets=("${selected_packages[@]}")
fi
for target in "${targets[@]}"; do
if [[ "${target}" == 'plum' ]]; then
echo $(print_result 'Updating plum at') "'${plum_dir}'"
(cd "${plum_dir}"; git pull)
continue
fi
"${root_dir}"/scripts/install-packages.sh "${target}" "${rime_dir:-.}"
done