Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions flow/util/docker_shell
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ set -ex
# -i, --image IMAGE Docker image (overrides $OR_IMAGE and default)
# --user Map host UID/GID into the container via entrypoint.sh
# -p, --port SPEC Forward a port, e.g. --port 8265:8265 (repeatable)
# --dry-run Print the docker command without executing it
# --dry-run Print the commands (xauth setup + docker run) without executing them
# -h|--help Show this help and exit

#
Expand Down Expand Up @@ -39,7 +39,7 @@ IMAGE=""
CMD_ARGS=()

usage() {
grep '^#' "$0" | sed 's/^# \{0,1\}//'
sed -n '3,/^$/s/^# \{0,1\}//p' "$0"
exit 0
}

Expand Down Expand Up @@ -67,9 +67,14 @@ OPENROAD_EXE=${OPENROAD_EXE:-/OpenROAD-flow-scripts/tools/install/OpenROAD/bin/o
KLAYOUT_CMD=${KLAYOUT_CMD:-/usr/bin/klayout}

XSOCK=/tmp/.X11-unix
XAUTH=/tmp/.docker.xauth
if ! $DRY_RUN; then
xauth nlist ${DISPLAY:-:0} | sed -e 's/^..../ffff/' | xauth -f $XAUTH nmerge -

if $DRY_RUN; then
# Use a fixed path so the printed commands work when run by hand
XAUTH=/tmp/.docker.xauth.dry-run
else
XAUTH=$(mktemp /tmp/.docker.xauth.XXXXXXXXXX)
trap 'rm -f "$XAUTH"' EXIT
xauth nlist "${DISPLAY:-:0}" | sed -e 's/^..../ffff/' | xauth -f "$XAUTH" nmerge -
fi

if test -t 0; then
Expand Down Expand Up @@ -99,7 +104,7 @@ CMD_STR=

ENV_SH_CMD='if [ -f ../env.sh ]; then . ../env.sh; fi;'

# Build the command once; dry-run prints it, otherwise exec it.
# Build the command once; dry-run prints it, otherwise run it.
DOCKER_CMD=(
"$container_engine" run --rm -i
$DOCKER_INTERACTIVE
Expand All @@ -125,8 +130,11 @@ DOCKER_CMD=(
)

if $DRY_RUN; then
echo "${DOCKER_CMD[*]}"
echo "# Run both lines; the first creates $XAUTH for X forwarding"
echo "xauth nlist '${DISPLAY:-:0}' | sed -e 's/^..../ffff/' | xauth -f '$XAUTH' nmerge -"
printf '%q ' "${DOCKER_CMD[@]}"
echo
exit 0
fi

exec "${DOCKER_CMD[@]}"
"${DOCKER_CMD[@]}"