Repository navigation
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·50 lines (42 loc) · 1.5 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·50 lines (42 loc) · 1.5 KB
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
#!/usr/bin/env bash
# Reticle installer — sets up the `scancode` CLI in ~/.local/bin with a
# self-contained Python venv under ~/.local/share/reticle.
#
# ./install.sh install / update scancode
# ./install.sh --uninstall remove scancode and its venv
set -euo pipefail
SRC="$(cd "$(dirname "$0")" && pwd)"
BIN="$HOME/.local/bin"
SHARE="$HOME/.local/share/reticle"
PYBIN="${PYTHON:-python3}"
if [ "${1:-}" = "--uninstall" ]; then
rm -f "$BIN/scancode"
rm -rf "$SHARE"
echo ">> removed scancode and $SHARE"
exit 0
fi
command -v "$PYBIN" >/dev/null 2>&1 || { echo "!! $PYBIN not found" >&2; exit 1; }
mkdir -p "$BIN" "$SHARE"
if [ ! -x "$SHARE/venv/bin/python" ]; then
echo ">> creating venv at $SHARE/venv"
"$PYBIN" -m venv "$SHARE/venv"
fi
echo ">> installing Python deps (zxing-cpp, numpy, opencv-headless)"
"$SHARE/venv/bin/pip" install -q --upgrade pip
"$SHARE/venv/bin/pip" install -q -r "$SRC/requirements.txt"
install -m 0644 "$SRC/lib/scancode.py" "$SHARE/scancode.py"
install -m 0755 "$SRC/bin/scancode" "$BIN/scancode"
echo ">> installed scancode -> $BIN/scancode"
case ":$PATH:" in
*":$BIN:"*) ;;
*)
for rc in "$HOME/.zshrc" "$HOME/.bashrc" "$HOME/.bash_profile"; do
[ -e "$rc" ] || continue
grep -q '\.local/bin' "$rc" && continue
printf '\nexport PATH="$HOME/.local/bin:$PATH"\n' >> "$rc"
echo ">> added ~/.local/bin to PATH in $rc"
done
echo ">> open a new shell for PATH to take effect"
;;
esac
echo ">> done. Try: scancode --formats"