# mdm-lab: Linux builds and window shots on WSL2 `mdm-lab` is a WSL2 distribution (Ubuntu 24.04) of its own. It builds MDM for Linux at the PC's full speed and screenshots its windows on a virtual screen (Xvfb) that never shows on Windows. The VirtualBox machines in [`../linux-vm/`](../linux-vm/) run on top of Hyper-V here (VirtualBox's NEM mode), about three times slower: builds there took 15 to 60 minutes and a shot about 40 s. Here a build of main takes under 5 minutes from scratch and about 35 s after a one-line change, and a window shot about 1.2 s. This lab takes over those two jobs, and `deploy.ps1` hands its builds to the VMs for the checks only a real desktop can do. ## Setting it up From PowerShell on the Windows host, once: ```powershell wsl --install -d Ubuntu-24.04 --name mdm-lab --location C:\mdm-wsl --no-launch wsl -d mdm-lab -u root -- bash /mnt/d/Projects/misterdownloadmanager/tools/lab/wsl/setup.sh wsl --terminate mdm-lab # its wsl.conf applies at the next start ``` `setup.sh` (as root) writes the distribution's `/etc/wsl.conf` (systemd, the `lab` user, and no interop: nothing in mdm-lab can start a Windows program), installs the build's libraries (those of `ci.yml` and the VMs), Xvfb, Metacity, ImageMagick, xwd, xdotool, wmctrl, Mesa's software OpenGL and Vulkan (llvmpipe, lavapipe), ffmpeg, 7-Zip and an Ubuntu desktop's fonts with every script MDM's languages need, then, as `lab`: Rust, the VMs' `vmtest` cargo profile, the checkout in `~/src/mdm` (the distribution's own ext4 disk: building from `/mnt/c` or `/mnt/d` goes through 9P and is many times slower) and the lab scripts in `~/lab/tools/`. Running it again only adds what's missing and refreshes the scripts. After a change to these scripts, the same `setup.sh` line copies them in again (a minute: the packages are there already). From Git Bash rather than PowerShell, prefix `MSYS_NO_PATHCONV=1` (or Git Bash rewrites `/mnt/...` and `~/...` paths) and use `wsl -d mdm-lab --exec bash -c '...'` when the command has `$VARIABLES`: without `--exec`, `wsl.exe` hands the line to a shell that expands them first. It changes nothing outside mdm-lab: never `%USERPROFILE%\.wslconfig` and never another distribution. Never run `wsl --shutdown` for it (that stops every distribution): `wsl --terminate mdm-lab` stops this one. ## Building ```powershell wsl -d mdm-lab -- bash ~/lab/tools/build.sh main # ~/lab/bin/main/ wsl -d mdm-lab -- bash ~/lab/tools/build.sh pr/167 pr-167 # a pull request, labelled wsl -d mdm-lab -- bash ~/lab/tools/build.sh --release main # fat LTO, what ships: main-release ``` A branch, `pr/` or a commit is fetched and checked out (detached), built with the `vmtest` profile (release without LTO, incremental) on every core, and its four programs (`misterdownloadmanager`, `-nmhost`, `-cli`, `labserver`) copied to `~/lab/bin/