7 : ${TOP_DIR:="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )"}
9 source ${TOP_DIR}/docker/builder-include
12 echo "${name} - Builds the petitboot programs using a pb-builder container." >&2
13 echo "Usage: ${name} [flags]" >&2
14 echo "Option flags:" >&2
15 echo " -c --check - Run 'make check'." >&2
16 echo " -d --dry-run - Do not run docker commands." >&2
17 echo " -h --help - Show this help and exit." >&2
18 echo " -i --interactive - Run an interactive pb-builder container." >&2
19 echo " -m --make-command - Set a specific command to be called for 'make'.">&2
20 echo " -o --configure-opts - Extra arguments for configure." >&2
21 echo " -t --tag - Print Docker tag to stdout and exit." >&2
22 echo " -v --verbose - Verbose execution." >&2
23 echo "Environment:" >&2
24 echo " DOCKER_TAG - Default: '${DOCKER_TAG}'" >&2
25 echo " CFLAGS - Default: '${CFLAGS}'" >&2
26 echo " LDFLAGS - Default: '${LDFLAGS}'" >&2
27 echo " CC - Default: '${CC}'" >&2
33 short_opts="cdhim:o:tv"
34 long_opts="check,dry-run,help,interactive,make-command:,configure-opts:,tag,verbose"
36 opts=$(getopt --options ${short_opts} --long ${long_opts} -n "${name}" -- "$@")
39 echo "${name}: ERROR: Internal getopt" >&2
68 -o | --configure-opts)
87 echo "${name}: ERROR: Internal opts" >&2
93 if [[ -n "${usage}" ]]; then
98 if [[ -n "${tag}" ]]; then
105 -v /etc/group:/etc/group:ro \
106 -v /etc/passwd:/etc/passwd:ro \
107 -v ${TOP_DIR}:/opt/pb \
111 docker_user_args="-u $(id -u):$(id -g)"
113 if [[ -n "${interactive}" ]]; then
115 docker_args="${docker_base_args} --privileged"
116 run_cmd "docker run -it ${docker_args} ${DOCKER_TAG} /bin/bash"
120 if [[ -n "${verbose}" ]]; then
124 if [[ -n "${check}" ]]; then
125 docker_extra="make check"
130 if [[ -z "${makecmd}" ]]; then
134 flags="CFLAGS=${CFLAGS} LDFLAGS=${LDFLAGS} CC=${CC}"
137 docker_args="${docker_base_args} ${docker_user_args}"
138 run_cmd "docker run ${docker_args} ${DOCKER_TAG} /bin/bash \
140 -c './bootstrap && ${flags} ./configure ${configure_opts[@]} && ${makecmd} && ${docker_extra}'"