diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..da15a5e --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +# The .deb package is large and proprietary — don't commit it +packages/*.deb +packages/*.rpm diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..8cb734f --- /dev/null +++ b/Dockerfile @@ -0,0 +1,27 @@ +FROM ubuntu:16.04 + +# Install GTK2 and X11 runtime dependencies needed by the bundled wxWidgets 2.9 +RUN apt-get update && apt-get install -y --no-install-recommends \ + libgtk2.0-0 \ + libsm6 \ + libxxf86vm1 \ + libxinerama1 \ + libxrandr2 \ + libxcursor1 \ + libxi6 \ + libxdamage1 \ + libxcomposite1 \ + libxext6 \ + && rm -rf /var/lib/apt/lists/* + +# Copy and install the crash cart software +# Place the .deb in packages/crash-cart.deb before building +COPY packages/crash-cart.deb /tmp/crash-cart.deb +RUN dpkg -i /tmp/crash-cart.deb && rm /tmp/crash-cart.deb + +# Prefer bundled libs (libpng12, libpython2.7, libwx*, etc.) over system ones +ENV LD_LIBRARY_PATH=/opt/usb-crash-cart-adapter/20240517/guts + +ENV DISPLAY=:0 + +ENTRYPOINT ["/opt/usb-crash-cart-adapter/20240517/wrapper"] diff --git a/README.md b/README.md index b9d2222..3ddb797 100644 --- a/README.md +++ b/README.md @@ -1 +1,48 @@ # usb-crash-cart + +Docker container wrapper for the NOTECONS02 USB Crash Cart Adapter software. + +The vendor software (`usb-crash-cart-adapter` v20240517) was built against Ubuntu 16.04 +(Python 2.7, wxWidgets 2.9/GTK2) and is incompatible with modern Fedora. This repo runs +it inside an Ubuntu 16.04 container with X11 passthrough. + +## Setup + +### 1. Install udev rules (once, on the host) + +```bash +sudo ./install-udev-rules.sh +``` + +This allows the crash cart adapter (USB vendor `152a`, products `8460`/`8463`) to be +accessed without root. + +### 2. Place the .deb package + +Copy the vendor `.deb` to `packages/crash-cart.deb`: + +```bash +cp /path/to/"Linux-X64 Crash Cart Software_1240415.deb" packages/crash-cart.deb +``` + +### 3. Build the image + +```bash +docker build -t usb-crash-cart . +``` + +### 4. Run + +```bash +./docker-run.sh +``` + +This handles X11 socket sharing and USB device passthrough automatically. + +## Notes + +- The container uses `ubuntu:16.04` to match the build environment. +- The app bundles its own `libpython2.7`, `libwx_gtk2u-2.9`, `libpng12`, etc. — the + container only needs GTK2 and X11 system libs from the OS. +- `LD_LIBRARY_PATH` is set to prefer the bundled libs over system ones. +- The `.deb` is excluded from git (`.gitignore`) — obtain it from the vendor package. diff --git a/docker-run.sh b/docker-run.sh new file mode 100755 index 0000000..ef002ab --- /dev/null +++ b/docker-run.sh @@ -0,0 +1,31 @@ +#!/bin/bash +set -euo pipefail + +IMAGE="usb-crash-cart" + +# On Fedora with Wayland, XWayland provides X11 compatibility. +# DISPLAY is still set (e.g. :0 or :1) and /tmp/.X11-unix still exists. +if [ -z "${DISPLAY:-}" ]; then + echo "Error: DISPLAY is not set. Ensure XWayland is running (it should be by default on Fedora)." + exit 1 +fi + +# xhost grants the container access via hostname-based access control, +# bypassing the need to pass the raw cookie in some setups. +xhost +local:docker 2>/dev/null || echo "Warning: xhost failed — display access may not work" + +# Under XWayland, X11 auth is cookie-based (XAUTHORITY file). +# Pass it into the container so the app can authenticate with XWayland. +XAUTH_ARGS=() +if [ -n "${XAUTHORITY:-}" ] && [ -f "${XAUTHORITY}" ]; then + XAUTH_ARGS=(-e XAUTHORITY="${XAUTHORITY}" -v "${XAUTHORITY}:${XAUTHORITY}:ro") +fi + +# Pass all USB bus devices so the app can find the crash cart adapter. +# The udev rules (install via install-udev-rules.sh) set permissions on the host. +docker run --rm \ + -e DISPLAY="${DISPLAY}" \ + "${XAUTH_ARGS[@]}" \ + -v /tmp/.X11-unix:/tmp/.X11-unix \ + --device /dev/bus/usb \ + "${IMAGE}" "$@" diff --git a/install-udev-rules.sh b/install-udev-rules.sh new file mode 100755 index 0000000..5e37405 --- /dev/null +++ b/install-udev-rules.sh @@ -0,0 +1,11 @@ +#!/bin/bash +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + +echo "Installing udev rules for USB Crash Cart Adapter (vendor 152a, products 8460/8463)..." +sudo cp "$SCRIPT_DIR/udev-rules/"*.rules /etc/udev/rules.d/ +sudo udevadm control --reload-rules +sudo udevadm trigger + +echo "Done. If the crash cart adapter is already plugged in, unplug and reconnect it." diff --git a/packages/.gitkeep b/packages/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/udev-rules/12-dcc-install.rules b/udev-rules/12-dcc-install.rules new file mode 100644 index 0000000..4b284f8 --- /dev/null +++ b/udev-rules/12-dcc-install.rules @@ -0,0 +1,8 @@ +# Copy this file into: /etc/udev/rules.d/ +# (/lib/udev/ isn't consistent between ubuntu and debian) +# +# Change the permissions and create alternative name as a +# handle into our device... +# + +SUBSYSTEM=="usb", ACTION=="add", ENV{DEVTYPE}=="usb_device", ATTRS{idProduct}=="8460", ATTRS{idVendor}=="152a", MODE:="0666", NAME:="DCC_%k" diff --git a/udev-rules/12-dcc2-install.rules b/udev-rules/12-dcc2-install.rules new file mode 100644 index 0000000..4e3d868 --- /dev/null +++ b/udev-rules/12-dcc2-install.rules @@ -0,0 +1,8 @@ +# Copy this file into: /etc/udev/rules.d/ +# (/lib/udev/ isn't consistent between ubuntu and debian) +# +# Change the permissions and create alternative name as a +# handle into our device... +# + +SUBSYSTEM=="usb", ACTION=="add", ENV{DEVTYPE}=="usb_device", ATTRS{idProduct}=="8463", ATTRS{idVendor}=="152a", MODE:="0666", NAME:="DCC_%k"