feat(linux): ship DRM capture in every Linux package behind allow-drm-capture (#17089)

* feat(drm): add allow-drm-capture and stop probing _drm when it is off

DRM capture is about to be compiled into every Linux build, so it needs a
runtime switch. `drm_capture_enabled()` reads the new `allow-drm-capture`
option (default off) or `RUSTDESK_DRM_CAPTURE=Y`, which the root service will
set for a greeter `--server`. While it is off the consumer never probes `_drm`:
`availability()` and `availability_cached()` answer Unavailable and the
startup warm returns at once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P1grQ39ByRWPUtTBdTzEBF

* feat(drm): keep the stock greeter, uinput and cursor paths while allow-drm-capture is off

With drm compiled in, these paths changed even when DRM capture was never
used: a Wayland greeter read as Wayland, the uinput range was set on the
apply thread, `wayland_has_compositor` said no at a greeter, every Wayland
login ran loginctl for the settle, and the cursor cache had a ceiling.
Each now checks `drm_capture_enabled()` and, while it is off, runs the code
a build without drm runs. `check_init`'s stock `match` is only re-indented
under its new `if`; see `git diff -w`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P1grQ39ByRWPUtTBdTzEBF

* feat(drm): start the _drm producer and greeter paths only with allow-drm-capture, restart --server on change

The root service used to start the `_drm` producer at boot, which dlopens
libdrmtap, opens the DRM device and grabs a frame, and to treat a Wayland
greeter as a DRM login screen. Both now wait for allow-drm-capture:

- the producer starts the first time the option is seen on, and
  `handle_drm_conn` refuses peers while it is off;
- when the option changes, the service restarts `--server` and re-reads the
  seat, because every `--server` decides its paths when it starts;
- a greeter `--server` runs as the greeter uid only with the option on, and
  is passed RUSTDESK_DRM_CAPTURE=Y, since its own config has not synced from
  root when `IS_X11` is computed;
- `get_active_userid_fresh`, the greetd detection and the login-Wayland HOME
  lookup follow the option, so with it off they match a build without drm.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P1grQ39ByRWPUtTBdTzEBF

* feat(flutter): add the DRM capture switch to the Wayland settings card and home warnings

Settings > General > Wayland gets a "Use DRM screen capture" checkbox on an
installed Linux client, with the explanation shown below it: it skips the
Wayland screen sharing prompt (the login screen too), may not work on every
device, and switching it disconnects current sessions. Flatpak and AppImage
are not installed builds, so they do not show it.

On the home page, an installed client with the option off now offers an
"Enable" button on the Wayland session and Wayland login screen warnings,
and shows neither warning once it is on. Builds that are not installed, and
clients where the option is fixed, keep the existing warnings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P1grQ39ByRWPUtTBdTzEBF

* feat(lang): add the DRM screen capture strings

"Use DRM screen capture", its settings explanation and the two home-page
warnings that offer it. it.rs is left for its translator, and sc.rs is
left empty rather than guessed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P1grQ39ByRWPUtTBdTzEBF

* build(linux): bundle libdrmtap into the stock packages and drop the unattended-wayland variant

DRM capture is now a runtime option, so the package name no longer has to be
the consent. build.py compiles `drm,drm-wake` into every Linux Flutter build
on the deb and pacman paths (`--no-drm` opts out), and the stock `rustdesk`
deb carries libdrmtap. The yum and zypper paths only build Sciter rpms and
are left alone.

- The variant rename, its Conflicts/Provides on `rustdesk`, the extra
  Depends and the measured libc6 floor are gone: libdrmtap is dlopen-ed and
  falls back to PipeWire when it cannot load, so it must not stop the
  package installing on older systems.
- The stock deb Conflicts/Replaces `rustdesk-unattended-wayland`, so
  installing it takes over from that package.
- `--package` decides from the staged binary whether it is a drm build,
  since it compiles nothing; a Sciter bundle stays as it was.
- The Flutter rpm specs and PKGBUILD install libdrmtap into
  /usr/lib/rustdesk, and the rpms exclude it from auto-generated
  Requires/Provides.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P1grQ39ByRWPUtTBdTzEBF

* ci(linux): build every Linux package with drm and run the drm tests in the main job

build-rustdesk-linux now builds libdrmtap on the runner (x86_64 and
aarch64), compiles `drm,drm-wake` into the release library and packages the
library into the deb and both rpms; arch gets it through PKGBUILD. The
separate build-rustdesk-linux-drm job is gone, along with the
rustdesk-unattended-wayland deb it published.

- The drm-gated unit tests (`run_drm_tests`) move into the x86_64 build
  container unchanged.
- A step checks that the deb carries libdrmtap and a binary that dlopens
  it, and each rpm is checked for the library and, on x86_64, for a glibc
  requirement newer than the build container's.
- x86_64 uploads its deb on a PR too, as the drm job did, so a PR's build
  can be installed and tested.

AGENTS.md now points the drm test rule at the x86_64 build job.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P1grQ39ByRWPUtTBdTzEBF

* refactor(drm): keep start_os_service's diff to the producer move, check the cursor ceiling cheaply first

DrmCaptureSwitch now sits after start_os_service, so the diff there reads as
the producer spawn leaving and the poll arriving. The cursor-cache ceiling
compares the cache length before it locks DRM_STATE.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P1grQ39ByRWPUtTBdTzEBF

* fix(drm): load the custom client before is_x11() can read Config, offer DRM only where it is compiled in

`IS_X11` now asks `drm_capture_enabled()`, which reads Config, and it is
computed in `global_init()`. `core_main()` ran that before
`load_custom_client()`, so on a Linux custom client the config loaded from
the stock "RustDesk" path before the app name was set and was never
reloaded; the root then synced that copy over the client's own settings.
Load the custom client first. On Windows and macOS `global_init()` does
nothing, so only the Linux startup order changes.

The DRM checkbox and the home-page "Enable" cards also showed on installed
builds without the drm feature (NixOS, source builds, --no-drm), where the
option has no effect. They now also need `is-drm-capture-supported`, a new
`main_get_common` key that reports whether drm is compiled in.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P1grQ39ByRWPUtTBdTzEBF

* fix(flutter): keep the DRM switch behind disable-settings, ask loginctl once per build

disable-settings hides the Security tab but not General, so the Wayland card's
checkbox and the home Enable button both stayed reachable on a locked custom
client. With settings disabled the home page falls back to the stock Wayland
warnings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P1grQ39ByRWPUtTBdTzEBF

* fix(drm): offer DRM only where libdrmtap loads, keep the stock check_init apply verbatim

- is-drm-capture-supported also requires the bundled libdrmtap to load, so a
  host whose glibc is older than its build is not offered a switch that does
  nothing.
- Dispatch the Wayland probe before load_custom_client: the probe child must
  run before any other startup work.
- check_init keeps master's not(drm) apply untouched; the drm build carries its
  own copy for allow-drm-capture off.
- drm_capture_enabled's doc names the Wayland enumeration in base and scrap,
  which does not read the option.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P1grQ39ByRWPUtTBdTzEBF

* ci(linux): catch any glibc 2.28+ requirement in the rpm drm check

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P1grQ39ByRWPUtTBdTzEBF

* fix(drm): initialize libsodium before the custom client's signature check

core_main now loads the custom client ahead of global_init, which since
#16974 starts with init_sodium so nothing uses libsodium before it. Run it
first there too; a second sodium_init() is a no-op.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P1grQ39ByRWPUtTBdTzEBF

* fix(drm): follow allow-drm-capture in the startup warm and in running streams

- warm_availability reads the option inside its retry loop. It starts
  before the initial config sync from root, so a --server whose account
  config does not hold the option yet (a greeter account that gets no
  RUSTDESK_DRM_CAPTURE, or an account not yet synced) skipped the warm
  for its whole life and paid the cold probe on its first connection.
- handle_drm_conn checks the option per frame, next to the peer re-auth,
  so turning it off ends a stream that is already running rather than
  only refusing new ones.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P1grQ39ByRWPUtTBdTzEBF

* test(drm): skip the option-off test where the option is on

drm_capture_enabled() reads the real config and RUSTDESK_DRM_CAPTURE, so
the test failed on a machine that has DRM capture turned on.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P1grQ39ByRWPUtTBdTzEBF

* fix(drm): leave running streams to the --server restart

Drop the per-frame allow-drm-capture check added in 3d1469255. The root
sees the option flip before its service loop restarts the --server, so
the check ended the stream up to one loop pass early and the consumer
spent that time failing to rebuild a capturer before the restart
disconnected the session anyway. It also took CONFIG2's read lock on
every frame, which Config2::set_options holds for writing across its
disk write. The comment now says what turning the option off does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P1grQ39ByRWPUtTBdTzEBF

* ci: run the drm and unix-file-copy-paste tests in the CI workflow

Move them out of the Linux package build into ci.yml's x86_64 Linux job,
which already has vcpkg and the build dependencies. The drm feature only
dlopens libdrmtap, so the tests need neither the bionic container nor
the library. A failing test no longer stops the deb, rpm and Arch
packages or skips appimage and flatpak.

The step runs every test of each package with the feature on instead of
selecting modules by name, so run_drm_tests and its guard against a
filter that matches nothing are gone, and so is the AGENTS.md rule
about it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P1grQ39ByRWPUtTBdTzEBF

* fix(drm): hand an allow-drm-capture change made as root to the service

The service decides on DRM from its own copy of the config, which only a
non-root --server syncs. A root process that changed the option -- the CLI
(`sudo rustdesk --option`), or a root --server at a login screen applying a
strategy -- left the service on the old value, so the change never took effect
there, and the next store by the service overwrote it in the file.

Such a process now sends its config to the service over the existing SyncConfig
when the option changed. Non-root processes and changes to other options do
nothing more.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P1grQ39ByRWPUtTBdTzEBF

* build(drm): recommend the GL libraries the old variant depended on

rustdesk-unattended-wayland depended on libdrm2, libegl1 and libgles2. The
package that replaces it now recommends them: libdrmtap opens EGL lazily, so they
stay optional, but apt still installs them by default and autoremove keeps them.

AGENTS.md keeps the rule that a test behind a feature no CI build enables needs a
cargo test line, now pointing at ci.yml.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P1grQ39ByRWPUtTBdTzEBF

* build(drm): recommend the GL libraries in the rpm and Arch packages too

The rpm specs recommend libdrm, libEGL and libGLESv2 by soname, since Fedora and
openSUSE name the packages that provide them differently; dnf and zypper install
weak dependencies by default. PKGBUILD lists libdrm and libglvnd as optdepends,
which pacman only reports.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P1grQ39ByRWPUtTBdTzEBF

* fix(drm): hand the option to the service only from a current copy of the config

SyncConfig carries the whole config, and the service stores it and takes its
trusted-device grants as authoritative. A root UI held the copy it loaded at
startup, so turning the option on or off there could restore a revoked trusted
device or an older permanent password. Its view of the option could also differ
from the service's, so a change could be skipped.

The push now runs in the root --server's handler of an options update, the
process that holds the config, also when the update is rejected after the
options were applied. `sudo rustdesk --option` still pushes by itself, since it
has just loaded the config and can run before any --server is up. A UI never
pushes, including a GUI started with sudo that hosts the IPC itself: a change
made there does not reach the service.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P1grQ39ByRWPUtTBdTzEBF

* ci: check the archlinux package carries libdrmtap

PKGBUILD skips libdrmtap when it finds none, so a tag or nightly build could
publish an Arch package without it while every step passed. Check its contents
as the deb and rpm steps do.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P1grQ39ByRWPUtTBdTzEBF

* fix(drm): send the service the trusted-device grants on disk

SyncConfig(Some(..)) makes the service write the sender's grants as
authoritative. `sudo rustdesk --option allow-drm-capture ...` loads its
config at start and pushes only after its IPC round trips with the
--server, so a grant written in that window (a 2FA trust just granted, a
device just removed) was reverted by the push.

Read the grants from disk, as the service's own SyncConfig(None) reply
does; the service then finds them equal to what it holds and writes
nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P1grQ39ByRWPUtTBdTzEBF

* fix(lang): say unattended access in the Lithuanian wayland-drm-tip

"Automatinis prisijungimas" is this file's "Auto Login", so the tip read
as advice about automatic login. "Neprižiūrima prieiga" matches the
English source and the file's "prieiga" for access.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P1grQ39ByRWPUtTBdTzEBF

* fix(core_main): load the custom client early only with drm

Only a Linux drm build reads Config in global_init (the IS_X11 greeter
override reads allow-drm-capture), so only there must the custom client
load first. Every other build keeps master's order.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P1grQ39ByRWPUtTBdTzEBF

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
RustDeskandClaude Opus 5.5 authored and GitHub committed 2026-11-23 13:24:48 +08:00
1 parent 66fabdf305
commit 9724512429
76 files changed
+679 -524

No files matched your search

+9
View File
@@ -248,3 +248,12 @@ jobs:
use-cross: ${{ matrix.job.use-cross }}
command: test
args: --locked --target=${{ matrix.job.target }} ${{ steps.test-options.outputs.CARGO_TEST_OPTIONS}}
# drm and unix-file-copy-paste are off by default, so the run above compiles none of their tests.
- name: Run drm and unix-file-copy-paste tests
if: matrix.job.target == 'x86_64-unknown-linux-gnu'
shell: bash
run: |
cargo test --locked --target=${{ matrix.job.target }} --lib --features drm,drm-wake
cargo test --locked --target=${{ matrix.job.target }} -p scrap --features drm
cargo test --locked --target=${{ matrix.job.target }} -p clipboard --features unix-file-copy-paste
+92 -326
View File
@@ -2045,6 +2045,23 @@ jobs:
name: bridge-artifact
path: ./
# The container's meson is too old to build libdrmtap, so build it here from the pin in
# build.py and hand the .so to the container below via DRMTAP_PREBUILT_DIR.
- name: Build libdrmtap
if: matrix.job.arch == 'x86_64' || env.UPLOAD_ARTIFACT == 'true'
run: |
sudo apt-get install -y meson ninja-build pkg-config \
libdrm-dev libegl1-mesa-dev libgles2-mesa-dev
python3 - <<'PY'
import importlib.util, sys
spec = importlib.util.spec_from_file_location("b", "build.py")
b = importlib.util.module_from_spec(spec)
sys.argv = ["build.py"]
spec.loader.exec_module(b)
print(f"::notice::built {b.build_libdrmtap_so()}")
PY
shell: bash
- uses: rustdesk-org/run-on-arch-action@d3fcfbb632b84cf7f6bc772bfaaa2c2f4f8789a8 # no release tag; commit 2026-05-26
name: Build rustdesk
id: vcpkg
@@ -2120,13 +2137,15 @@ jobs:
# start build
pushd /workspace
export VCPKG_ROOT=/opt/artifacts/vcpkg
# use the .so built on the runner; build.py checks it is the pinned checkout
export DRMTAP_PREBUILT_DIR=/workspace/third_party/libdrmtap/build-pkg
if [[ "${{ matrix.job.arch }}" == "aarch64" ]]; then
export JOBS="--jobs 3"
else
export JOBS=""
fi
echo $JOBS
cargo build --locked --lib $JOBS --features hwcodec,flutter,unix-file-copy-paste --release
cargo build --locked --lib $JOBS --features hwcodec,flutter,unix-file-copy-paste,drm,drm-wake --release
rm -rf target/release/deps target/release/build
rm -rf ~/.cargo
@@ -2193,6 +2212,22 @@ jobs:
mv "$name" "${name%%.deb}-${{ matrix.job.arch }}.deb"
done
# The rpm must carry libdrmtap, and must not inherit its glibc requirement: the spec
# excludes /usr/lib/rustdesk from auto-requires, so hosts whose glibc is older than the
# runner's still install it. Everything else here is built against this container's
# glibc 2.27 (the x86_64 Flutter engine needs 2.18), so on x86_64 any 2.28+ requirement
# can only have come from libdrmtap; the aarch64 flutter-elinux engine is not measured.
check_rpm_drm() {
if ! rpm -qlp "$1" | grep -qx /usr/lib/rustdesk/libdrmtap.so.0; then
echo "::error::$1 has no /usr/lib/rustdesk/libdrmtap.so.0"
exit 1
fi
if [[ "${{ matrix.job.arch }}" == "x86_64" ]] && rpm -qpR "$1" | grep -E 'GLIBC_2\.(2[89]|[3-9][0-9])'; then
echo "::error::$1 requires a newer glibc than its build container; libdrmtap's requirements leaked in"
exit 1
fi
}
# rpm package
echo -e "start packaging fedora package"
pushd /workspace
@@ -2204,6 +2239,7 @@ jobs:
HBB=`pwd` rpmbuild ./res/rpm-flutter.spec -bb
pushd ~/rpmbuild/RPMS/${{ matrix.job.arch }}
for name in rustdesk*??.rpm; do
check_rpm_drm "$name"
mv "$name" /workspace/"${name%%.rpm}.rpm"
done
@@ -2218,9 +2254,41 @@ jobs:
HBB=`pwd` rpmbuild ./res/rpm-flutter-suse.spec -bb
pushd ~/rpmbuild/RPMS/${{ matrix.job.arch }}
for name in rustdesk*??.rpm; do
check_rpm_drm "$name"
mv "$name" /workspace/"${name%%.rpm}-suse.rpm"
done
# build.py can exit 0 on some inner failures, so check the artifact rather than the status:
# the deb must carry libdrmtap and a binary that dlopens it.
- name: Check the deb carries libdrmtap
if: matrix.job.arch == 'x86_64' || env.UPLOAD_ARTIFACT == 'true'
run: |
set -euo pipefail
# Resolve by glob, not from env.VERSION: build.py names the deb from Cargo.toml, so a
# hardcoded name fails with a bare exit 1 the first time those two drift.
shopt -s nullglob
debs=(rustdesk-*-${{ matrix.job.arch }}.deb)
if [ "${#debs[@]}" -ne 1 ]; then
echo "::error::expected one rustdesk-*-${{ matrix.job.arch }}.deb, found ${#debs[@]}: ${debs[*]-none}"
exit 1
fi
deb="${debs[0]}"
contents="$(dpkg -c "$deb")"
if [[ ! "$contents" =~ usr/lib/rustdesk/libdrmtap\.so\.0\.[0-9]+\.[0-9]+ ]]; then
echo "::error::$deb has no versioned libdrmtap.so.0.x.y"
exit 1
fi
if [[ "$contents" != *"usr/lib/rustdesk/libdrmtap.so.0 ->"* ]]; then
echo "::error::$deb has no libdrmtap.so.0 soname symlink"
exit 1
fi
rm -rf /tmp/deb && dpkg-deb -R "$deb" /tmp/deb
if ! grep -qF /usr/lib/rustdesk/libdrmtap.so.0 /tmp/deb/usr/share/rustdesk/lib/librustdesk.so; then
echo "::error::$deb was not built with the drm feature"
exit 1
fi
shell: bash
- name: Publish debian/rpm package
if: env.UPLOAD_ARTIFACT == 'true'
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v1
@@ -2231,9 +2299,11 @@ jobs:
rustdesk-*.deb
rustdesk-*.rpm
# x86_64 also uploads on a PR (upload-artifact false), where it is the only way to get at the
# deb that was just built.
- name: Upload deb
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
if: env.UPLOAD_ARTIFACT == 'true'
if: env.UPLOAD_ARTIFACT == 'true' || matrix.job.arch == 'x86_64'
with:
name: rustdesk-${{ env.VERSION }}-${{ matrix.job.arch }}.deb
path: rustdesk-${{ env.VERSION }}-${{ matrix.job.arch }}.deb
@@ -2257,6 +2327,26 @@ jobs:
scripts: |
cd res && HBB=`pwd`/.. FLUTTER=1 makepkg -f
# PKGBUILD skips libdrmtap when it finds none, so check the package like the deb and the rpms.
- name: Check the archlinux package carries libdrmtap
if: matrix.job.arch == 'x86_64' && env.UPLOAD_ARTIFACT == 'true'
run: |
set -euo pipefail
shopt -s nullglob
pkgs=(res/rustdesk-${{ env.VERSION }}*.zst)
if [ "${#pkgs[@]}" -eq 0 ]; then
echo "::error::no archlinux package was built"
exit 1
fi
for pkg in "${pkgs[@]}"; do
contents="$(tar --zstd -tf "$pkg")"
if ! grep -qx 'usr/lib/rustdesk/libdrmtap.so.0' <<<"$contents"; then
echo "::error::$pkg has no /usr/lib/rustdesk/libdrmtap.so.0"
exit 1
fi
done
shell: bash
- name: Publish archlinux package
if: matrix.job.arch == 'x86_64' && env.UPLOAD_ARTIFACT == 'true'
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v1
@@ -2266,330 +2356,6 @@ jobs:
files: |
res/rustdesk-${{ env.VERSION }}*.zst
# Same build as build-rustdesk-linux x86_64 -- same vcpkg/ffmpeg, same ubuntu18.04 container, same
# rust and flutter -- only with the drm feature on, so it ships as the separate
# rustdesk-unattended-wayland deb. libdrmtap is built on the runner because bionic's meson is too
# old for it. A separate job rather than a matrix entry of build-rustdesk-linux: appimage and
# flatpak need that job, and a failure here must not skip them.
build-rustdesk-linux-drm:
needs: [generate-bridge]
name: build rustdesk linux drm x86_64
runs-on: ubuntu-22.04
steps:
- name: Export GitHub Actions cache environment variables
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6
with:
script: |
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
- name: Maximize build space
run: |
sudo rm -rf /opt/ghc
sudo rm -rf /usr/local/lib/android
sudo rm -rf /usr/share/dotnet
sudo apt-get update -y
sudo apt-get install -y nasm
sudo apt-get install -y qemu-user-static
- name: Checkout source code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
submodules: recursive
- name: Set Swap Space
uses: pierotofy/set-swap-space@49819abfb41bd9b44fb781159c033dba90353a7c # v1.0
with:
swap-size-gb: 12
- name: Free Space
run: |
df -h
free -m
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9 # v1
with:
toolchain: ${{ env.RUST_VERSION }}
targets: x86_64-unknown-linux-gnu
components: "rustfmt"
- name: Save Rust toolchain version
run: |
RUST_TOOLCHAIN_VERSION=$(cargo --version | awk '{print $2}')
echo "RUST_TOOLCHAIN_VERSION=$RUST_TOOLCHAIN_VERSION" >> $GITHUB_ENV
- name: Disable rust bridge build
run: |
# only build cdylib
sed -i "s/\[\"cdylib\", \"staticlib\", \"rlib\"\]/\[\"cdylib\"\]/g" Cargo.toml
- name: Restore bridge files
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: bridge-artifact
path: ./
- name: Setup vcpkg with Github Actions binary cache
uses: lukka/run-vcpkg@b1a0dd252f06b9e25b3c022a9a03bd7a427fb6a2 # v11
with:
vcpkgDirectory: /opt/artifacts/vcpkg
vcpkgGitCommitId: ${{ env.VCPKG_COMMIT_ID }}
doNotCache: false
- name: Install vcpkg dependencies
run: |
sudo apt install -y libva-dev && apt show libva-dev
if ! $VCPKG_ROOT/vcpkg \
install \
--triplet x64-linux \
--x-install-root="$VCPKG_ROOT/installed"; then
find "${VCPKG_ROOT}/" -name "*.log" | while read -r _1; do
echo "$_1:"
echo "======"
cat "$_1"
echo "======"
echo ""
done
exit 1
fi
head -n 100 "${VCPKG_ROOT}/buildtrees/ffmpeg/build-x64-linux-rel-out.log" || true
shell: bash
# The container's meson is too old to build libdrmtap, so build it here from the pin in
# build.py and hand the .so to the container below via DRMTAP_PREBUILT_DIR.
- name: Build libdrmtap
run: |
sudo apt-get install -y meson ninja-build pkg-config \
libdrm-dev libegl1-mesa-dev libgles2-mesa-dev
python3 - <<'PY'
import importlib.util, sys
spec = importlib.util.spec_from_file_location("b", "build.py")
b = importlib.util.module_from_spec(spec)
sys.argv = ["build.py"]
spec.loader.exec_module(b)
print(f"::notice::built {b.build_libdrmtap_so()}")
PY
shell: bash
- uses: rustdesk-org/run-on-arch-action@d3fcfbb632b84cf7f6bc772bfaaa2c2f4f8789a8 # no release tag; commit 2026-05-26
name: Build rustdesk
id: vcpkg
with:
arch: x86_64
distro: ubuntu18.04
githubToken: ${{ github.token }}
setup: |
ls -l "${PWD}"
ls -l /opt/artifacts/vcpkg/installed
dockerRunArgs: |
--volume "${PWD}:/workspace"
--volume "/opt/artifacts:/opt/artifacts"
shell: /bin/bash
install: |
apt-get update -y
echo -e "installing deps"
apt-get install -y \
build-essential \
clang \
cmake \
curl \
gcc \
git \
g++ \
libayatana-appindicator3-dev \
libasound2-dev \
libclang-10-dev \
libgstreamer1.0-dev \
libgstreamer-plugins-base1.0-dev \
libgtk-3-dev \
libpulse-dev \
libva-dev \
libxcb-randr0-dev \
libxcb-shape0-dev \
libxcb-xfixes0-dev \
libxdo-dev \
libxfixes-dev \
llvm-10-dev \
nasm \
ninja-build \
pkg-config \
tree \
python3 \
rpm \
unzip \
wget \
xz-utils \
libssl-dev
# we have libopus compiled by us.
apt-get remove -y libopus-dev || true
# output devs
ls -l ./
tree -L 3 /opt/artifacts/vcpkg/installed
run: |
# disable git safe.directory
git config --global --add safe.directory "*"
# rust
pushd /opt
# do not use rustup, because memory overflow in qemu
wget -O rust.tar.gz https://static.rust-lang.org/dist/rust-${{env.RUST_TOOLCHAIN_VERSION}}-x86_64-unknown-linux-gnu.tar.gz
tar -zxvf rust.tar.gz > /dev/null && rm rust.tar.gz
cd rust-${{env.RUST_TOOLCHAIN_VERSION}}-x86_64-unknown-linux-gnu && ./install.sh
rm -rf rust-${{env.RUST_TOOLCHAIN_VERSION}}-x86_64-unknown-linux-gnu
# edit config
mkdir -p ~/.cargo/
echo """
[source.crates-io]
registry = 'https://github.com/rust-lang/crates.io-index'
""" > ~/.cargo/config
cat ~/.cargo/config
# start build
pushd /workspace
export VCPKG_ROOT=/opt/artifacts/vcpkg
# use the .so built on the runner; build.py checks it is the pinned checkout
export DRMTAP_PREBUILT_DIR=/workspace/third_party/libdrmtap/build-pkg
# ask build.py for the features so this line and the packaging line cannot drift
FEATURES=$(python3 ./build.py --flutter --drm --hwcodec --unix-file-copy-paste --print-features)
# an empty or error-shaped value would silently build a stock binary
for want in drm drm-wake; do
case ",$FEATURES," in
*",$want,"*) ;;
*) echo "::error::build.py returned no '$want' feature: $FEATURES"; exit 1 ;;
esac
done
# Run the drm-gated unit tests HERE, because nowhere else does. The ordinary linux CI
# runs the suite, but `drm` is opt-in, so every test behind that feature -- the cursor
# rotation and hotspot ones especially -- has no continuous coverage at all otherwise.
# Debug rather than --release: these are pure logic tests and the release build is
# already the slow part of this job.
# A MINIMAL feature set, not the production $FEATURES: these are pure logic tests of
# the drm paths, and pulling hwcodec in makes the test binary fail to link at all
# (undefined reference to fcntl64 in this container), so the tests never run.
#
# Two packages, because `cargo test --lib` at the root builds the ROOT package only:
# the provenance tests live in libs/scrap and would never be selected from here. The
# ordinary linux CI runs --workspace but without the drm feature, so these are not
# covered there either.
#
# awk sums the counts rather than bc, which this container does not install.
#
# A cargo test FILTER that matches nothing exits 0, so a rename would turn this into a
# green no-op. Assert each command actually ran something.
run_drm_tests() {
local desc="$1"; shift
local out
out=$("$@" 2>&1) || { echo "$out"; echo "::error::drm tests failed: $desc"; exit 1; }
local ran
ran=$(echo "$out" | awk '/^running [0-9]+ tests?$/ { n += $2 } END { print n+0 }')
echo "$desc ran $ran tests"
if [ "$ran" -lt 1 ]; then
echo "::error::$desc selected no tests; it was renamed or removed"
exit 1
fi
}
run_drm_tests "rustdesk drm_capturer_tests" \
cargo test --locked --lib --features drm drm_capturer_tests
run_drm_tests "rustdesk ipc::test" \
cargo test --locked --lib --features drm ipc::test
run_drm_tests "rustdesk cursor_pos_tests" \
cargo test --locked --lib --features drm cursor_pos_tests
run_drm_tests "rustdesk peer_abs_sample_tests" \
cargo test --locked --lib --features drm peer_abs_sample_tests
run_drm_tests "rustdesk input_map_tests" \
cargo test --locked --lib --features drm input_map_tests
run_drm_tests "rustdesk drm_pacing_tests" \
cargo test --locked --lib --features drm drm_pacing_tests
run_drm_tests "scrap hotspot_provenance_tests" \
cargo test --locked -p scrap --features drm hotspot_provenance_tests
run_drm_tests "scrap hotspot_guess_tests" \
cargo test --locked -p scrap --features drm hotspot_guess_tests
run_drm_tests "scrap crtc_refresh_tests" \
cargo test --locked -p scrap --features drm crtc_refresh_tests
run_drm_tests "scrap plane_rotation_tests" \
cargo test --locked -p scrap --features drm plane_rotation_tests
run_drm_tests "scrap drmtap_dl::tests" \
cargo test --locked -p scrap --features drm drmtap_dl::tests
# Opt-in like drm, and this container already builds with it.
run_drm_tests "clipboard unix-file-copy-paste" \
cargo test --locked -p clipboard --features unix-file-copy-paste
cargo build --locked --lib --features "$FEATURES" --release
rm -rf target/release/deps target/release/build
rm -rf ~/.cargo
# Setup Flutter
# disable git safe.directory
git config --global --add safe.directory "*"
export PATH=/opt/flutter/bin:$PATH
pushd /opt
wget https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_${{ env.FLUTTER_VERSION }}-stable.tar.xz
tar xf flutter_linux_${{ env.FLUTTER_VERSION }}-stable.tar.xz
flutter doctor -v
if [[ "3.24.5" == ${{ env.FLUTTER_VERSION }} ]]; then
pushd /opt/flutter
git apply ${{ github.workspace }}/.github/patches/flutter_3.24.4_dropdown_menu_enableFilter.diff
popd
fi
# build flutter
pushd /workspace
export CARGO_INCREMENTAL=0
export DEB_ARCH=amd64
python3 ./build.py --flutter --drm --hwcodec --unix-file-copy-paste --skip-cargo
for name in rustdesk*??.deb; do
mv "$name" "${name%%.deb}-x86_64.deb"
done
# build.py can exit 0 on some inner failures, so check the artifact rather than the status.
# The package name is the informed consent for consent-free capture, so a stock binary must
# never ship under it: assert the bundled library AND the dlopen path in the binary.
- name: Check the deb is a drm build
run: |
set -euo pipefail
# Resolve by glob, not from env.VERSION: build.py names the deb from Cargo.toml, so a
# hardcoded name fails with a bare exit 1 the first time those two drift.
shopt -s nullglob
debs=(rustdesk-unattended-wayland-*-x86_64.deb)
if [ "${#debs[@]}" -ne 1 ]; then
echo "::error::expected one rustdesk-unattended-wayland-*-x86_64.deb, found ${#debs[@]}: ${debs[*]-none}"
exit 1
fi
deb="${debs[0]}"
echo "DRM_DEB=$deb" >> "$GITHUB_ENV"
contents="$(dpkg -c "$deb")"
if [[ ! "$contents" =~ usr/lib/rustdesk/libdrmtap\.so\.0\.[0-9]+\.[0-9]+ ]]; then
echo "::error::$deb has no versioned libdrmtap.so.0.x.y"
exit 1
fi
if [[ "$contents" != *"usr/lib/rustdesk/libdrmtap.so.0 ->"* ]]; then
echo "::error::$deb has no libdrmtap.so.0 soname symlink"
exit 1
fi
rm -rf /tmp/deb && dpkg-deb -R "$deb" /tmp/deb
if ! grep -qF /usr/lib/rustdesk/libdrmtap.so.0 /tmp/deb/usr/share/rustdesk/lib/librustdesk.so; then
echo "::error::$deb was not built with the drm feature"
exit 1
fi
shell: bash
- name: Publish debian package
if: env.UPLOAD_ARTIFACT == 'true'
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v1
with:
prerelease: true
tag_name: ${{ env.TAG_NAME }}
files: |
${{ env.DRM_DEB }}
# No UPLOAD_ARTIFACT gate: on a PR this is the only way to get at the deb that was just built.
# always(), because a deb that failed the check above is the one most worth downloading.
- name: Upload deb
if: always() && env.DRM_DEB != ''
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: ${{ env.DRM_DEB }}
path: ${{ env.DRM_DEB }}
build-rustdesk-linux-sciter:
if: ${{ inputs.upload-artifact }}
needs: [validate-update-metadata-keys]