docker: Add strace for interactive debugging
[petitboot] / docker / builder-include
1 #!/usr/bin/env bash
2
3 arch() {
4         local m="$(uname -m)"
5
6         case "${m}" in
7                 aarch64) echo "arm64" ;;
8                 x86_64)  echo "amd64" ;;
9                 *)       echo "${m}" ;;
10         esac
11 }
12
13 arch_tag() {
14         local a="$(arch)"
15
16         case "${a}" in
17                 amd64) echo "" ;;
18                 *)     echo "-${a}" ;;
19         esac
20 }
21
22 docker_from() {
23         local a="$(arch)"
24
25         case "${a}" in
26                 amd64) echo "ubuntu:17.10" ;;
27                 arm64) echo "arm64v8/ubuntu:17.10" ;;
28                 *)
29                         echo "${name}: ERROR: Unknown arch ${a}" >&2
30                         exit 1
31                 ;;
32         esac
33 }
34
35 run_cmd () {
36         local cmd="${*}"
37
38         if [[ -n ${verbose} || -n "${dry_run}" ]]; then
39                 echo "==> ${cmd}"
40         fi
41
42         if [[ -n "${dry_run}" ]]; then
43                 true
44         else
45                 eval "${cmd}"
46         fi
47 }
48
49 show_tag () {
50         echo "${DOCKER_TAG}"
51 }
52
53 : ${VERSION:="3"}
54 : ${ARCH_TAG:="$(arch_tag)"}
55 : ${DOCKER_NAME:="pb-builder"}
56 : ${DOCKER_TAG:="${DOCKER_NAME}:${VERSION}${ARCH_TAG}"}