-
Notifications
You must be signed in to change notification settings - Fork 2
/
mkhockeybundle
executable file
·63 lines (57 loc) · 1.42 KB
/
mkhockeybundle
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
#!/bin/env bash
if [[ -z "${1}" ]]; then
if [[ -z "${PYVERSION}" ]]; then
export PYVER="3"
else
export PYVER="${PYVERSION}"
fi
else
export PYVER="${1}"
fi
#export PYTHONPATH="$(which python${PYVER})"
export PYTHONPATH="$(command -v python${PYVER})"
if [[ -z "${2}" ]]; then
infile="mkhockeydata.py"
outfilebin="${infile%.*}"
outfilezip="${infile%.*}.zip"
else
if [[ -f "./${2}" ]]; then
infile="${2}"
outfilebin="${infile%.*}"
outfilezip="${infile%.*}.zip"
else
infile="mkhockeydata.py"
outfilebin="${infile%.*}"
outfilezip="${infile%.*}.zip"
fi
fi
if ! [ -x "$(command -v python${PYVER})" ]; then
echo "Error: python${PYVER} is not installed." >&2
exit 1
fi
if [[ -f "./mkhockeybundle.py" ]]; then
${PYTHONPATH} ./mkhockeybundle.py "${infile}"
exit 0
fi
mkdir -p -v /tmp/pybundle
cp -r -v ./${infile} /tmp/pybundle/__main__.py
cp -r -v ./libhockeydata /tmp/pybundle/libhockeydata
export OLDPATH="$(pwd)"
cd ./bundle/python${PYVER}
rm -rfv *
cd ${OLDPATH}
cd /tmp/pybundle
zip -v ./${outfilezip} -r .
echo '#!/usr/bin/env python'${PYVER} > ./${outfilebin}
echo '' >> ./${outfilebin}
cat ./${outfilezip} >> ./${outfilebin}
chmod -v +x ./${outfilebin}
cd ${OLDPATH}
mv -v /tmp/pybundle/${outfilebin} ./bundle/python${PYVER}/${outfilebin}
rm -rfv /tmp/pybundle
cd ./bundle/python${PYVER}
if [[ ${infile} = "mkhockeydata.py" ]]; then
${PYTHONPATH} ./${outfilebin} mksymlinks
fi
chmod -v +x ./${outfilebin}
cd ${OLDPATH}