-
Notifications
You must be signed in to change notification settings - Fork 71
/
Copy pathpixiw
executable file
·91 lines (74 loc) · 2.31 KB
/
pixiw
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
#!/bin/sh
require_ver=0.41
set -euf
[ "${DEBUG-}" != true ] || set -x
IFS=. read -r __req_major __req_minor __req_patch <<-END
$require_ver
END
__check_pixi() {
__pixi="${1-}"
[ -x "${__pixi-}" ] || hash "${__pixi-}" 2>/dev/null || return 1
# accept any version
[ "${__req_major:=0}.${__req_minor:=0}.${__req_patch:=0}" != 0.0.0 ] || return 0
IFS=' .' read -r __prefix __major __minor __patch <<-END
$("$__pixi" -V 2>/dev/null)
END
[ "${__prefix-}" = pixi ] || return 1
if [ "${__major:=0}" = "$__req_major" ]; then
if [ "${__minor:=0}" = "$__req_minor" ]; then
[ "${__patch:=0}" -ge "$__req_patch" ]
else
[ "$__minor" -gt "$__req_minor" ]
fi
else
[ "$__major" -gt "$__req_major" ]
fi
}
__download_to_stdin() {
if hash curl 2>/dev/null; then
curl -sfSL --compressed "$1"
elif hash wget 2>/dev/null; then
wget -qO- "$1"
else
echo echo "\"[ERROR] you need either 'curl' or 'wget' installed.\""
echo exit 1
fi
}
__install_pixi() (
# require curl, bash and sed commands
if ! hash bash 2>/dev/null; then
echo "[ERROR] you do not have 'bash' installed."
return 1
fi
unset PIXI_VERSION PIXI_HOME
export PIXI_NO_PATH_UPDATE=true
if [ -n "${URL_MIRROR_github_com-}" ]; then
if ! hash sed 2>/dev/null; then
echo "[WARN] you do not have 'sed' installed to use URL_MIRROR_github_com, ignore the mirror."
unset URL_MIRROR_github_com
fi
fi
: "${PIXI_INSTALLER_URL:=https://raw.githubusercontent.com/prefix-dev/pixi/main/install/install.sh}"
if [ -n "${URL_MIRROR_github_com-}" ]; then
__download_to_stdin "${PIXI_INSTALLER_URL-}" | sed "s|https://github.com/|$URL_MIRROR_github_com|g"
else
__download_to_stdin "${PIXI_INSTALLER_URL-}"
fi | bash
)
pixi_prj_rc="${0%/*}/.pixi/rc.sh"
# shellcheck source=/dev/null
[ ! -r "$pixi_prj_rc" ] || PIXIW_INSTALL=1 PIXI_PROJECT_ROOT="${0%/*}" . "$pixi_prj_rc"
if __check_pixi pixi; then
exec pixi "$@"
elif ! __check_pixi "${HOME:-}/.pixi/bin/pixi"; then
if __install_pixi; then
if ! __check_pixi "${HOME:-}/.pixi/bin/pixi"; then
echo "[ERROR] After install/update, pixi version still does not meet the requirement '${require_ver-}' ." >&2
exit 1
fi
else
echo "[ERROR] Fail to install/update pixi" >&2
exit 1
fi
fi
exec "${HOME:-}/.pixi/bin/pixi" "$@"