discover/udev: Don't require ID_NET_NAME_PATH property
[petitboot] / docker / build-pb
index ce6c41fc9aa207f78d07ca74503f6528be46c690..ad08ef9e3cd586e5addd320fffc21df1944b8260 100755 (executable)
@@ -12,20 +12,21 @@ usage () {
        echo "${name} - Builds the petitboot programs using a pb-builder container." >&2
        echo "Usage: ${name} [flags]" >&2
        echo "Option flags:" >&2
-       echo "  -c --check    - Run 'make check'." >&2
-       echo "  -d --dry-run  - Do not run docker commands." >&2
-       echo "  -h --help     - Show this help and exit." >&2
-       echo "  -t --tag      - Print Docker tag to stdout and exit." >&2
-       echo "  -v --verbose  - Verbose execution." >&2
+       echo "  -c --check       - Run 'make check'." >&2
+       echo "  -d --dry-run     - Do not run docker commands." >&2
+       echo "  -h --help        - Show this help and exit." >&2
+       echo "  -i --interactive - Run an interactive pb-builder container." >&2
+       echo "  -t --tag         - Print Docker tag to stdout and exit." >&2
+       echo "  -v --verbose     - Verbose execution." >&2
        echo "Environment:" >&2
-       echo "  DOCKER_TAG    - Default: '${DOCKER_TAG}'" >&2
+       echo "  DOCKER_TAG       - Default: '${DOCKER_TAG}'" >&2
        echo "Examples:" >&2
        echo "  ${name} -vc"
        echo "  ${name} -v"
 }
 
-short_opts="cdhtv"
-long_opts="check,dry-run,help,tag,verbose"
+short_opts="cdhitv"
+long_opts="check,dry-run,help,interactive,tag,verbose"
 
 opts=$(getopt --options ${short_opts} --long ${long_opts} -n "${name}" -- "$@")
 
@@ -50,6 +51,10 @@ while true ; do
                usage=1
                shift
                ;;
+       -i | --interactive)
+               interactive=1
+               shift
+               ;;
        -t | --tag)
                tag=1
                shift
@@ -80,15 +85,24 @@ if [[ -n "${tag}" ]]; then
        exit 0
 fi
 
-docker_args="--rm \
-       -u $(id -u):$(id -g) \
+docker_base_args="\
+       --rm \
        -v /etc/group:/etc/group:ro \
        -v /etc/passwd:/etc/passwd:ro \
        -v ${TOP_DIR}:/opt/pb \
        -w /opt/pb \
 "
 
-if [[ -n "$verbose}" ]]; then
+docker_user_args="-u $(id -u):$(id -g)"
+
+if [[ -n "${interactive}" ]]; then
+       cd "${TOP_DIR}"
+       docker_args="${docker_base_args}"
+       run_cmd "docker run -it ${docker_args} ${DOCKER_TAG} /bin/bash"
+       exit
+fi
+
+if [[ -n "${verbose}" ]]; then
        bash_debug="-x"
 fi
 
@@ -99,6 +113,7 @@ else
 fi
 
 cd "${TOP_DIR}"
+docker_args="${docker_base_args} ${docker_user_args}"
 run_cmd "docker run ${docker_args} ${DOCKER_TAG} /bin/bash \
        -e ${bash_debug} \
        -c './bootstrap && ./configure --with-ncurses && make && ${docker_extra}'"