-
Notifications
You must be signed in to change notification settings - Fork 7
/
build.sh
executable file
·37 lines (32 loc) · 982 Bytes
/
build.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
#! /usr/bin/env bash
#
# Build Debian package in a Docker container
#
set -e
if test $# -eq 0; then
for distro in debian:stretch debian:buster ubuntu:xenial ubuntu:bionic; do
$0 $distro
done
exit 0
fi
# Get build platform as 1st argument, and collect project metadata
image="${1:?You MUST provide a docker image name}"; shift
dist_id=${image%%:*}
codename=${image#*:}
pypi_name="$(./setup.py --name)"
pypi_version="$(./setup.py --version)"
pkgname="$(dh_listpackages)"
tag=$pypi_name-$dist_id-$codename
build_opts=(
-f Dockerfile.build
--tag $tag
--build-arg "DIST_ID=$dist_id"
--build-arg "CODENAME=$codename"
--build-arg "PKGNAME=$pkgname"
)
# Build in Docker container, save results, and show package info
rm -f dist/${pkgname}?*${pypi_version//./?}*${codename}*.*
docker build "${build_opts[@]}" "$@" .
mkdir -p dist
docker run --rm $tag tar -C /dpkg -c . | tar -C dist -x
ls -lh dist/${pkgname}?*${pypi_version//./?}*${codename}*.*