diff --git a/README.md b/README.md index 443e6c6..efa4836 100644 --- a/README.md +++ b/README.md @@ -82,6 +82,7 @@ Cell/Module placement | Routing ## Requirements +We are using the excelent docker container maintained by Harald Pretl. If you get stuck with installing the tools, we urge you to check the [Tool Repository](https://github.com/iic-jku/IIC-OSIC-TOOLS) or consult the [Guide](https://kwantaekim.github.io/2024/05/25/OSE-Docker). ### ETHZ systems An environment setup for bash is provided. @@ -90,21 +91,27 @@ source ethz.env ``` ### Other systems -**Note: this has currently only been tested on Ubuntu Linux.** +**Note: this has currently only been tested on Ubuntu and RHEL Linux.** #### Docker (easy) -There are two possible ways, the easiest way is to install docker and work in the docker container, you can follow the install guides on the [Docker Website](https://docs.docker.com/desktop/): +There are two possible ways, the easiest way is to install docker and work in the docker container, you can follow the install guides on the [Docker Website](https://docs.docker.com/desktop/). +**Note:** We may not support the latest version. The currently supported version (tag) is **2024.09**. It is a good idea to grant non-root (`sudo`) users access to docker, this is decribed in the [Docker Article](https://docs.docker.com/engine/install/linux-postinstall/#manage-docker-as-a-non-root-user). Finally, you can navigate to this directory, open a terminal and type: ```sh -# Linux/Mac -./docker.sh -# Windows -./start_x.bat +# Linux only (starts and enters docker container in shell) +./start_linux.sh +# Linux/Mac (starts VNC server on localhost:5901) +./start_vnc.sh +# Windows (starts VNC server on localhost:5901) +./start_vnc.bat ``` +If you use the VNC option, open a browser and type `localhost` in the address bar. +This should connect you to the VNC server (test by right-clicking somewhere). + Now you should be in a Ubuntu environment with all tools pre-installed for you. If something does not work, refer to the upstream [IIC-OSIC-Tools](https://github.com/iic-jku/IIC-OSIC-TOOLS/tree/main) diff --git a/docker-compose.yml b/docker-compose.yml index 06aa405..41926d3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,7 +9,7 @@ version: '3' services: pulp-docker: - image: hpretl/iic-osic-tools:pulp + image: hpretl/iic-osic-tools:2024.09 environment: - UID=${UID} - GID=${GID} diff --git a/docker.sh b/start_linux.sh similarity index 93% rename from docker.sh rename to start_linux.sh index 0ee54d8..c6b503e 100755 --- a/docker.sh +++ b/start_linux.sh @@ -6,7 +6,7 @@ # Authors: # - Philippe Sauter -IMG=hpretl/iic-osic-tools:pulp +IMG=hpretl/iic-osic-tools:2024.09 docker pull $IMG diff --git a/start_x.bat b/start_vnc.bat similarity index 76% rename from start_x.bat rename to start_vnc.bat index 65cc01c..68eb33e 100644 --- a/start_x.bat +++ b/start_vnc.bat @@ -19,7 +19,8 @@ REM ======================================================================== SETLOCAL -SET DESIGNS=%CD% +SET DESIGNS=%~dp0 + SET DEFAULT_DESIGNS=%USERPROFILE%\eda\designs IF DEFINED DRY_RUN ( @@ -30,24 +31,57 @@ IF DEFINED DRY_RUN ( IF "%DESIGNS%"=="" ( SET DESIGNS=%DEFAULT_DESIGNS% ) + echo Using/creating designs directory: %DESIGNS% if not exist "%DESIGNS%" %ECHO_IF_DRY_RUN% mkdir "%DESIGNS%" IF "%DOCKER_USER%"=="" SET DOCKER_USER=hpretl IF "%DOCKER_IMAGE%"=="" SET DOCKER_IMAGE=iic-osic-tools -IF "%DOCKER_TAG%"=="" SET DOCKER_TAG=pulp +IF "%DOCKER_TAG%"=="" SET DOCKER_TAG=2024.09 IF "%CONTAINER_USER%"=="" SET CONTAINER_USER=1000 IF "%CONTAINER_GROUP%"=="" SET CONTAINER_GROUP=1000 -IF "%CONTAINER_NAME%"=="" SET CONTAINER_NAME=iic-osic-tools_xserver +IF "%CONTAINER_NAME%"=="" SET CONTAINER_NAME=iic-osic-tools_xvnc -IF "%DISP%"=="" SET DISP=host.docker.internal:0 +IF "%WEBSERVER_PORT%"=="" ( + SET /a WEBSERVER_PORT=80 +) ELSE ( + SET /a WEBSERVER_PORT=%WEBSERVER_PORT% +) +echo Webserver port set to %WEBSERVER_PORT% + +IF "%VNC_PORT%"=="" ( + SET /a VNC_PORT=5901 +) ELSE ( + SET /a VNC_PORT=%VNC_PORT% +) +echo VNC port set to %VNC_PORT% IF %CONTAINER_USER% NEQ 0 if %CONTAINER_USER% LSS 1000 echo WARNING: Selected User ID %CONTAINER_USER% is below 1000. This ID might interfere with User-IDs inside the container and cause undefined behaviour! IF %CONTAINER_GROUP% NEQ 0 if %CONTAINER_GROUP% LSS 1000 echo WARNING: Selected Group ID %CONTAINER_GROUP% is below 1000. This ID might interfere with Group-IDs inside the container and cause undefined behaviour! +SET PARAMS= + +IF %WEBSERVER_PORT% GTR 0 ( + SET PARAMS=%PARAMS% -p %WEBSERVER_PORT%:80 +) + +IF %VNC_PORT% GTR 0 ( + SET PARAMS=%PARAMS% -p %VNC_PORT%:5901 +) + +IF DEFINED VNC_PW ( + SET PARAMS=%PARAMS% -e VNC_PW=%VNC_PW% +) + +IF DEFINED DOCKER_EXTRA_PARAMS ( + SET PARAMS=%PARAMS% %DOCKER_EXTRA_PARAMS% +) + +IF "%DISP%"=="" SET DISP=host.docker.internal:0 + where /q xhost IF ERRORLEVEL 1 ( ECHO xhost is not detected / not in PATH. Please verify X-server access control! @@ -64,8 +98,7 @@ IF NOT ERRORLEVEL 1 ( IF NOT ERRORLEVEL 1 ( echo Container %CONTAINER_NAME% exists. Restart with \"docker start %CONTAINER_NAME%\" or remove with \"docker rm %CONTAINER_NAME%\" if required. ) ELSE ( - echo Container does not exist, pulling %DOCKER_USER%/%DOCKER_IMAGE%:%DOCKER_TAG and creating %CONTAINER_NAME% ... - %ECHO_IF_DRY_RUN% docker pull %DOCKER_USER%/%DOCKER_IMAGE%:%DOCKER_TAG - %ECHO_IF_DRY_RUN% docker run -d --user %CONTAINER_USER%:%CONTAINER_GROUP% -e DISPLAY=%DISP% -e LIBGL_ALWAYS_INDIRECT=1 %DOCKER_EXTRA_PARAMS% -v "%DESIGNS%":/foss/designs --name %CONTAINER_NAME% %DOCKER_USER%/%DOCKER_IMAGE%:%DOCKER_TAG% + echo Container does not exist, creating %CONTAINER_NAME% ... + %ECHO_IF_DRY_RUN% docker run -d --user %CONTAINER_USER%:%CONTAINER_GROUP% %PARAMS% -v "%DESIGNS%":/foss/designs --name %CONTAINER_NAME% %DOCKER_USER%/%DOCKER_IMAGE%:%DOCKER_TAG% ) -) +) \ No newline at end of file diff --git a/start_vnc.sh b/start_vnc.sh new file mode 100644 index 0000000..b05823e --- /dev/null +++ b/start_vnc.sh @@ -0,0 +1,150 @@ +#!/bin/bash +# ======================================================================== +# Start script for IIC docker images (VNC) +# +# SPDX-FileCopyrightText: 2022-2023 Harald Pretl and Georg Zachl +# Johannes Kepler University, Institute for Integrated Circuits +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# SPDX-License-Identifier: Apache-2.0 +# ======================================================================== + +if [ -n "${DRY_RUN}" ]; then + echo "[INFO] This is a dry run, all commands will be printed to the shell (Commands printed but not executed are marked with $)!" + ECHO_IF_DRY_RUN="echo $" +fi + +# SET YOUR DESIGN PATH RIGHT! +DESIGNS="$(realpath $(dirname "${BASH_SOURCE[0]}"))" + +if [ -z ${DESIGNS+z} ]; then + DESIGNS=$HOME/eda/designs + if [ ! -d "$DESIGNS" ]; then + ${ECHO_IF_DRY_RUN} mkdir -p "$DESIGNS" + fi + echo "[INFO] Design directory auto-set to $DESIGNS." +fi + +# Set the host ports, and disable them with 0. Only used if not set as shell variables! +if [ -z ${WEBSERVER_PORT+z} ]; then + WEBSERVER_PORT=80 +fi +if [ -z ${VNC_PORT+z} ]; then + VNC_PORT=5901 +fi + +if [ -z ${DOCKER_USER+z} ]; then + DOCKER_USER="hpretl" +fi + +if [ -z ${DOCKER_IMAGE+z} ]; then + DOCKER_IMAGE="iic-osic-tools" +fi + +if [ -z ${DOCKER_TAG+z} ]; then + DOCKER_TAG="2024.09" +fi + +if [ -z ${CONTAINER_NAME+z} ]; then + CONTAINER_NAME="iic-osic-tools_xvnc_uid_"$(id -u) +fi + +if [[ "$OSTYPE" == "linux"* ]]; then + if [ -z ${CONTAINER_USER+z} ]; then + CONTAINER_USER=$(id -u) + fi + + if [ -z ${CONTAINER_GROUP+z} ]; then + CONTAINER_GROUP=$(id -g) + fi +else + if [ -z ${CONTAINER_USER+z} ]; then + CONTAINER_USER=1000 + fi + + if [ -z ${CONTAINER_GROUP+z} ]; then + CONTAINER_GROUP=1000 + fi +fi + +# Check for UIDs and GIDs below 1000, except 0 (root) +if [[ ${CONTAINER_USER} -ne 0 ]] && [[ ${CONTAINER_USER} -lt 1000 ]]; then + prt_str="# [WARNING] Selected User ID ${CONTAINER_USER} is below 1000. This ID might interfere with User-IDs inside the container and cause undefined behavior! #" + printf -- '#%.0s' $(seq 1 ${#prt_str}) + echo + echo "${prt_str}" + printf -- '#%.0s' $(seq 1 ${#prt_str}) + echo +fi + +if [[ ${CONTAINER_GROUP} -ne 0 ]] && [[ ${CONTAINER_GROUP} -lt 1000 ]]; then + prt_str="# [WARNING] Selected Group ID ${CONTAINER_GROUP} is below 1000. This ID might interfere with Group-IDs inside the container and cause undefined behavior! #" + printf -- '#%.0s' $(seq 1 ${#prt_str}) + echo + echo "${prt_str}" + printf -- '#%.0s' $(seq 1 ${#prt_str}) + echo +fi + +# Processing ports and other parameters +PARAMS="" +if [ "$WEBSERVER_PORT" -gt 0 ]; then + PARAMS="$PARAMS -p $WEBSERVER_PORT:80" +fi +if [ "$VNC_PORT" -gt 0 ]; then + PARAMS="$PARAMS -p $VNC_PORT:5901" +fi + +if [ -n "${VNC_PW}" ]; then + PARAMS="${PARAMS} -e VNC_PW=${VNC_PW}" +fi + +if [ -n "${DOCKER_EXTRA_PARAMS}" ]; then + PARAMS="${PARAMS} ${DOCKER_EXTRA_PARAMS}" +fi + +# Check if the container exists and if it is running. +if [ "$(docker ps -q -f name="${CONTAINER_NAME}")" ]; then + echo "[WARNING] Container is running!" + echo "[HINT] It can also be stopped with \"docker stop ${CONTAINER_NAME}\" and removed with \"docker rm ${CONTAINER_NAME}\" if required." + echo + echo -n "Press \"s\" to stop, and \"r\" to stop & remove: " + read -r -n 1 k <&1 + echo + if [[ $k = s ]] ; then + ${ECHO_IF_DRY_RUN} docker stop "${CONTAINER_NAME}" + elif [[ $k = r ]] ; then + ${ECHO_IF_DRY_RUN} docker stop "${CONTAINER_NAME}" + ${ECHO_IF_DRY_RUN} docker rm "${CONTAINER_NAME}" + fi +# If the container exists but is exited, it is restarted. +elif [ "$(docker ps -aq -f name="${CONTAINER_NAME}")" ]; then + echo "[WARNING] Container ${CONTAINER_NAME} exists." + echo "[HINT] It can also be restarted with \"docker start ${CONTAINER_NAME}\" or removed with \"docker rm ${CONTAINER_NAME}\" if required." + echo + echo -n "Press \"s\" to start, and \"r\" to remove: " + read -r -n 1 k <&1 + echo + if [[ $k = s ]] ; then + ${ECHO_IF_DRY_RUN} docker start "${CONTAINER_NAME}" + elif [[ $k = r ]] ; then + ${ECHO_IF_DRY_RUN} docker rm "${CONTAINER_NAME}" + fi +else + echo "[INFO] Container does not exist, creating ${CONTAINER_NAME} ..." + # Finally, run the container, and sets DISPLAY to the local display number + #${ECHO_IF_DRY_RUN} docker pull "${DOCKER_USER}/${DOCKER_IMAGE}:${DOCKER_TAG}" + # Disable SC2086, $PARAMS must be globbed and splitted. + # shellcheck disable=SC2086 + ${ECHO_IF_DRY_RUN} docker run -d --user "${CONTAINER_USER}:${CONTAINER_GROUP}" $PARAMS -v "$DESIGNS:/foss/designs:rw" --name "${CONTAINER_NAME}" "${DOCKER_USER}/${DOCKER_IMAGE}:${DOCKER_TAG}" +fi \ No newline at end of file