forked from mozilla/apk-signer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build
executable file
·84 lines (69 loc) · 1.65 KB
/
build
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/bin/bash
set -e
set -x
cd "$(dirname "${0}")"
ROOT="${PWD}"
RPMNAME=${RPMNAME-"$(basename "${ROOT}")"}
PYREPO=${PYREPO:-"https://pyrepo.addons.mozilla.org/"}
BUILD_ID=$(date +%Y%m%d%H%M%S)
pip_install() {
./venv/bin/pip install \
--exists-action=w \
--no-deps \
--no-index \
--download-cache=/tmp/pip-cache \
-f "${PYREPO}" \
"$@"
}
build_env() {
local req_file="${ROOT}/requirements/${1}"
pushd "${ROOT}"
rm -rf ./venv
virtualenv --python=python \
--distribute \
--never-download \
./venv
pip_install -r "${req_file}"
pip_install virtualenv
rm -f ./venv/lib/python2.{6,7}/no-global-site-packages.txt
./venv/bin/python ./venv/bin/virtualenv --relocatable ./venv
popd
}
build_rpm() {
local package_file="${1}"
local ref=$(cd "${ROOT}"; git rev-parse --short=12 HEAD)
pushd "${ROOT}"/../
fpm -s dir -t rpm \
-n "${RPMNAME}" \
--provides moz-deploy-app \
--rpm-compression none \
-v "${BUILD_ID}" \
-p "${package_file}" \
--iteration "${ref}" \
--directories / \
-x "*.git" -x "*.pyc" \
-C . --prefix "/opt/${RPMNAME}" \
./"${RPMNAME}"
popd
}
case "${1}" in
env)
req="prod.txt"
if [[ "${2}" == "dev" ]]; then
req="dev.txt"
fi
build_env "${req}"
;;
rpm)
if [ $# -lt 2 ]; then
echo "Usage: ./build rpm <outfile>"
exit 1
fi
build_env "prod.txt"
build_rpm "${2}"
;;
*)
echo "Please specify an action."
exit 1
;;
esac