1+ #! /usr/bin/env bash
2+
3+ set -e
4+ set -x
5+
6+ OUTPUT_PATH=" ${1:- .} "
7+
8+ function build_from_pypi {
9+ PACKAGE_NAME=" $1 "
10+
11+ if [ -z " $2 " ]; then
12+ PACKAGE_VERSION=" "
13+ # Get the most recent package version from PyPI to be included in the package name of the Debian artifact
14+ curl -X GET " https://pypi.org/pypi/${PACKAGE_NAME} /json" > " ${PACKAGE_NAME} .json"
15+ PACKAGE_VERSION=" ==$( cat " ${PACKAGE_NAME} .json" | jq --raw-output ' .info.version' ) "
16+ rm " ${PACKAGE_NAME} .json"
17+ else
18+ PACKAGE_VERSION=" ==$2 "
19+ fi
20+ POSTINST_TMP=" postinst-${PACKAGE_NAME} "
21+ PREREM_TMP=" prerm-${PACKAGE_NAME} "
22+ cp postinst " ${POSTINST_TMP} "
23+ cp prerm " ${PREREM_TMP} "
24+ sed -i " s/{package_name}/python3-${PACKAGE_NAME} /" " ${POSTINST_TMP} "
25+ sed -i " s/{package_name}/python3-${PACKAGE_NAME} /" " ${PREREM_TMP} "
26+
27+ fpm --input-type " python" \
28+ --output-type " deb" \
29+ --architecture " amd64" \
30+ --verbose \
31+ --python-package-name-prefix " python3" \
32+ --python-bin " /usr/bin/python3" \
33+ --exclude " *.pyc" \
34+ --exclude " *.pyo" \
35+ --maintainer
" Hyperledger <[email protected] >" \
36+ --after-install " ${POSTINST_TMP} " \
37+ --before-remove " ${PREREM_TMP} " \
38+ --package " ${OUTPUT_PATH} " \
39+ " ${PACKAGE_NAME}${PACKAGE_VERSION} "
40+
41+ rm " ${POSTINST_TMP} "
42+ rm " ${PREREM_TMP} "
43+ }
44+
45+ # build 3rd parties:
46+ # build_from_pypi <pypi-name> <version>
47+ # TODO duplicates list from Jenkinsfile.cd
48+
49+ SCRIPT_PATH=" ${BASH_SOURCE[0]} "
50+ pushd ` dirname ${SCRIPT_PATH} ` > /dev/null
51+
52+ build_from_pypi importlib-metadata 3.10.1
53+ build_from_pypi timeout-decorator
54+ build_from_pypi distro 1.7.0
55+
56+ popd > /dev/null
0 commit comments