-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathinstall
41 lines (32 loc) · 972 Bytes
/
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
#!/usr/bin/env sh
URL="https://github.com/kriszyp/cpm/tarball/master"
if [ -z "$CPM_INSTALL_LIB" ]; then
CPM_INSTALL_LIB="/usr/local/lib"
fi
if [ ! -e "$CPM_INSTALL_LIB" ]; then
CPM_INSTALL_LIB="/usr/lib"
fi
if [ -z "$CPM_INSTALL_BIN" ]; then
CPM_INSTALL_BIN="/usr/local/bin"
fi
if [ ! -e "$CPM_INSTALL_BIN" ]; then
CPM_INSTALL_BIN="/usr/bin"
fi
rm -rf "/tmp/cpm"
mkdir -p "/tmp/cpm/archive"
cd "/tmp/cpm"
curl -kL $URL > cpm.tar.gz
# ungzip and untar, stripping base directory and
# putting everything into "archive" directory
tar xzf cpm.tar.gz --strip-components=1 -C archive
if [ -e "$CPM_INSTALL_LIB/cpm" ]; then
rm -rf "$CPM_INSTALL_LIB/cpm"
fi
mv -f "archive" "$CPM_INSTALL_LIB/cpm"
# if the file exists (whether it's an actual file or
# a symlink, remove it because `ln` won't replace it
if [ -e "$CPM_INSTALL_BIN/cpm" ]; then
rm "$CPM_INSTALL_BIN/cpm"
fi
chmod +x "$CPM_INSTALL_LIB/cpm/cpm"
ln -fs "$CPM_INSTALL_LIB/cpm/cpm" "$CPM_INSTALL_BIN/cpm"