-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpyb
executable file
·60 lines (48 loc) · 1.35 KB
/
pyb
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
#!/bin/bash
# fail on errors and intermediate non-zero exit-codes in pipes
# also called bash safe-mode
set -eo pipefail
# set default variables
# can be overwritten by setting the environment variable
version=${version:-3.7.2}
cache="${cache:-${PWD}}"
prefix="${prefix:-${PWD}/target}"
_build() {
mkdir -p "$cache" "$prefix"
cores_num=$(nproc --all)
# download, extract and verfiy signature in one-step
curl --silent --fail "https://www.python.org/ftp/python/$version/Python-$version.tar.xz"\
| tee >(tar --extract --xz -C "$cache")\
| gpg --verify <(curl --fail "https://www.python.org/ftp/python/$version/Python-$version.tar.xz.asc") -
# push directory on stack
pushd "${cache}/Python-$version"
./configure --prefix=$prefix --enable-optimizations
make -j $cores_num
make -j $cores_num install
# pop directory from stack
popd
}
_help() {
cat<<EOF
version=$version cache=$cache prefix=$prefix $0 build
version: python version to build
cache: directory for build cache
prefix: package prefix directory
Default values are shown, setting variables is optional
EOF
}
case "$1" in
"help"|"-h"|"--help")
_help
exit 0
;;
"build")
# fail on unset variables
set -u
_build
;;
""|"*")
_help
exit 1
;;
esac