Download chips/openroad_flow_scripts/flow/util/docker_shell from STAR-future/Trinity-SciData: direct link, hf CLI and curl.
- Browser
- Download file 4.18 kB
-
https://huggingface.co/datasets/STAR-future/Trinity-SciData/resolve/992e905da3c8d758a593ca8714ea499ba0182649/chips/openroad_flow_scripts/flow/util/docker_shell
- Command line
-
hf download hf://datasets/STAR-future/Trinity-SciData@992e905da3c8d758a593ca8714ea499ba0182649/chips/openroad_flow_scripts/flow/util/docker_shell
-
curl -L -o docker_shell https://huggingface.co/datasets/STAR-future/Trinity-SciData/resolve/992e905da3c8d758a593ca8714ea499ba0182649/chips/openroad_flow_scripts/flow/util/docker_shell
4.18 kB
| set -ex | |
| # docker_shell — unified launcher for AutoTuner / OpenROAD | |
| # | |
| # Usage: etc/docker_shell [OPTIONS] [-- CMD [ARGS...]] | |
| # | |
| # Options: | |
| # -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 commands (xauth setup + docker run) without executing them | |
| # -h|--help Show this help and exit | |
| # | |
| # Method to use docker CLI to determine if we're using docker or podman | |
| # | |
| # Sets container_engine global variable with either "docker" or "podman" | |
| # | |
| get_container_engine () { | |
| local DOCKER_VERSION_STRING=$(docker --version 2> /dev/null) | |
| if [[ "$DOCKER_VERSION_STRING" == *"Docker"* ]]; then | |
| container_engine="docker" | |
| elif [[ "$DOCKER_VERSION_STRING" == *"podman"* ]]; then | |
| container_engine="podman" | |
| else | |
| echo "Unable to determine container engine using docker CLI" | |
| exit 1 | |
| fi | |
| } | |
| DEFAULT_IMAGE="openroad/orfs:latest" | |
| FLOW_DIR="/OpenROAD-flow-scripts/flow" | |
| USE_USER=false | |
| DRY_RUN=false | |
| PORTS=() | |
| IMAGE="" | |
| CMD_ARGS=() | |
| usage() { | |
| sed -n '3,/^$/s/^# \{0,1\}//p' "$0" | |
| exit 0 | |
| } | |
| while [[ $# -gt 0 ]]; do | |
| case "$1" in | |
| -i|--image) IMAGE="$2"; shift 2 ;; | |
| --user) USE_USER=true; shift ;; | |
| -p|--port) PORTS+=("$2"); shift 2 ;; | |
| --dry-run) DRY_RUN=true; shift ;; | |
| -h|--help) usage ;; | |
| --) shift; CMD_ARGS=("$@"); break ;; | |
| -*) echo "Unknown option: $1" >&2; exit 1 ;; | |
| *) CMD_ARGS=("$@"); break ;; | |
| esac | |
| done | |
| # Image resolution: --image > $OR_IMAGE > default | |
| IMAGE="${IMAGE:-${OR_IMAGE:-$DEFAULT_IMAGE}}" | |
| get_container_engine | |
| WORKSPACE=$(pwd) | |
| YOSYS_EXE=${YOSYS_EXE:-/OpenROAD-flow-scripts/tools/install/yosys/bin/yosys} | |
| OPENROAD_EXE=${OPENROAD_EXE:-/OpenROAD-flow-scripts/tools/install/OpenROAD/bin/openroad} | |
| # KLAYOUT_CMD only when the caller sets it; otherwise the flow looks for | |
| # klayout on the image's PATH. | |
| KLAYOUT_ENV=() | |
| if [[ -n "${KLAYOUT_CMD:-}" ]]; then | |
| KLAYOUT_ENV=(-e "KLAYOUT_CMD=$KLAYOUT_CMD") | |
| fi | |
| XSOCK=/tmp/.X11-unix | |
| 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 | |
| DOCKER_INTERACTIVE=-ti | |
| else | |
| DOCKER_INTERACTIVE= | |
| fi | |
| if $USE_USER; then | |
| user_args="--entrypoint=entrypoint.sh --user=root" | |
| user_env="-e CUSTOM_USER=$(id --user --name) -e CUSTOM_USER_ID=$(id --user) -e CUSTOM_GROUP_ID=$(id --group)" | |
| elif [[ $container_engine == "podman" ]]; then | |
| user_args="--privileged --userns=keep-id --user $(id -u):$(id -g)" | |
| user_env= | |
| else | |
| user_args="-u $(id -u ${USER}):$(id -g ${USER})" | |
| user_env= | |
| fi | |
| PORT_ARGS=() | |
| for port in "${PORTS[@]}"; do | |
| PORT_ARGS+=(-p "$port") | |
| done | |
| CMD_STR= | |
| [[ ${#CMD_ARGS[@]} -gt 0 ]] && CMD_STR="${CMD_ARGS[*]}" | |
| ENV_SH_CMD='if [ -f ../env.sh ]; then . ../env.sh; fi;' | |
| # Build the command once; dry-run prints it, otherwise run it. | |
| DOCKER_CMD=( | |
| "$container_engine" run --rm -i | |
| $DOCKER_INTERACTIVE | |
| $user_env $user_args | |
| -e LIBGL_ALWAYS_SOFTWARE=1 | |
| -e QT_X11_NO_MITSHM=1 | |
| -e XDG_RUNTIME_DIR=/tmp/xdg-run | |
| -e "DISPLAY=${DISPLAY:-:0}" | |
| -e QT_XKB_CONFIG_ROOT=/usr/share/X11/xkb | |
| -v "$XSOCK:$XSOCK" | |
| -v "$XAUTH:$XAUTH" | |
| -e "XAUTHORITY=$XAUTH" | |
| -e FLOW_HOME=/OpenROAD-flow-scripts/flow/ | |
| -e WORK_HOME=/work | |
| -e "YOSYS_EXE=$YOSYS_EXE" | |
| -e "OPENROAD_EXE=$OPENROAD_EXE" | |
| "${KLAYOUT_ENV[@]}" | |
| -v "$WORKSPACE:/work:Z" | |
| --network host | |
| "${PORT_ARGS[@]}" | |
| "$IMAGE" | |
| bash -c "set -ex; mkdir /tmp/xdg-run; cd ${FLOW_DIR}; ${ENV_SH_CMD}$CMD_STR" | |
| ) | |
| if $DRY_RUN; then | |
| 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 | |
| "${DOCKER_CMD[@]}" | |