-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.sh
executable file
·65 lines (58 loc) · 1.87 KB
/
deploy.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
#!/bin/bash
# Deploy PAKET servers.
# Get base source of repository.
DEFAULT_SOURCE=https://github.com/paket-core
SOURCE="$(grep -Pm1 'url\W*=\W*git@' .git/config 2> /dev/null | grep -Po 'git@.*(?=/manager)')"
SOURCE="${SOURCE:-$(grep -Pm1 'url\W*=\W*http' .git/config 2> /dev/null | grep -Po 'http.*(?=/manager)')}"
SOURCE="${SOURCE:-$DEFAULT_SOURCE}"
# Get our single CLI flag.
if [ "$(printf "%s\n" "$1" | cut -c1)" = '-' ]; then
UPDATE="$(printf "%s\n" "$1" | cut -c2)"
shift
fi
update_repo() {
echo "$1:"
if [ -d "../$1" ]; then
if [ "$UPDATE" ]; then
q=$UPDATE
else
read -n 1 -p "Update local package at $1? [Y|n] " q < /dev/tty; echo
fi
[ "$q" = n ] || git -C "../$1" pull
else
git clone "$SOURCE/$1" "../$1"
fi
clean_package_name="$(tr '-' '_' <<<$1)"
git_state_var_name="PAKET_GIT_STATE_${clean_package_name^^}"
git_state="${!git_state_var_name:-master}"
if [ "$UPDATE" ]; then
q=$UPDATE
else
read -n 1 -p "Checkout $git_state? [Y|n] " q < /dev/tty; echo
fi
if ! [ "$q" = n ]; then
git -C "../$1" pull
git -C "../$1" checkout "$git_state"
git -C "../$1" pull
fi
}
# Get or update PAKET servers, collect requirements, and install them.
set -e
if ! [ -d venv ]; then
python3 -m venv venv
fi
. paket.env
pip install --upgrade pip pycodestyle pylint
servers=( "$(basename "$(pwd)")" "${PAKET_SERVERS[@]}" )
for server in ${servers[@]}; do
update_repo $server
requirements="$(cat "../$server/requirements.txt" <(echo "$requirements") | sort -u)"
done
while read package; do
if [ "${package:0:3}" = '../' ]; then
update_repo "${package:3}"
requirements="$(cat "$package/requirements.txt" 2> /dev/null <(echo "$requirements") | sort -u)"
fi
done <<<"$requirements"
pip install -r <(echo "$requirements")
set +e