build: add freebsd support (#4049)

This commit is contained in:
David Lane
2025-11-11 23:46:11 -05:00
committed by GitHub
parent 2dbe837ebc
commit 1d6d916b7a
31 changed files with 1055 additions and 39 deletions

View File

@@ -0,0 +1,64 @@
#!/bin/sh
# FreeBSD post-install script for Sunshine
# This script sets up the necessary permissions for virtual input devices
echo "Configuring permissions for virtual input devices..."
# Create the 'input' group if it doesn't exist
if ! pw groupshow input >/dev/null 2>&1; then
echo "Creating 'input' group..."
pw groupadd input
if [ $? -eq 0 ]; then
echo "Successfully created 'input' group."
else
echo "Warning: Failed to create 'input' group. You may need to create it manually."
fi
else
echo "'input' group already exists."
fi
# Set permissions on /dev/uinput if it exists
if [ -e /dev/uinput ]; then
echo "Setting permissions on /dev/uinput..."
chown root:input /dev/uinput
chmod 660 /dev/uinput
echo "Permissions set on /dev/uinput."
else
echo "Note: /dev/uinput does not exist. It will be created when needed."
fi
# Create devfs rules for persistent permissions
echo "Creating devfs rules for persistent permissions..."
DEVFS_RULESET_FILE="/etc/devfs.rules"
RULESET_NUM=47989
# Check if our rules already exist
if ! grep -q "\[sunshine=$RULESET_NUM\]" "$DEVFS_RULESET_FILE" 2>/dev/null; then
cat >> "$DEVFS_RULESET_FILE" << EOF
[sunshine=$RULESET_NUM]
add path 'uinput' mode 0660 group input
EOF
echo "Devfs rules added to $DEVFS_RULESET_FILE"
else
echo "Devfs rules already exist in $DEVFS_RULESET_FILE"
fi
# Apply the devfs ruleset immediately (without waiting for reboot)
echo "Applying devfs ruleset to current system..."
if [ -e /dev/uinput ]; then
devfs -m /dev rule -s $RULESET_NUM apply
fi
echo ""
echo "Post-installation configuration complete!"
echo ""
echo "IMPORTANT: To use virtual input devices (keyboard, mouse, gamepads),"
echo "you must add your user to the 'input' group:"
echo ""
echo " pw groupmod input -m \$USER"
echo ""
echo "After adding yourself to the group, log out and log back in for the"
echo "changes to take effect."
echo ""

View File

@@ -0,0 +1,32 @@
#!/bin/sh
# FreeBSD pre-deinstall script for Sunshine
# This script cleans up configuration added during installation
echo "Cleaning up Sunshine configuration..."
# Remove devfs rules
DEVFS_RULESET_FILE="/etc/devfs.rules"
RULESET_NUM=47989
# Remove rules from /etc/devfs.rules
if [ -f "$DEVFS_RULESET_FILE" ]; then
if grep -q "\[sunshine=$RULESET_NUM\]" "$DEVFS_RULESET_FILE"; then
echo "Removing devfs rules from $DEVFS_RULESET_FILE..."
# Remove the [sunshine=47989] section and its rules (match the section header and the next line)
sed -i.bak '/^\[sunshine='"$RULESET_NUM"'\]$/,/^add path.*uinput/d' "$DEVFS_RULESET_FILE"
echo "Devfs rules removed from file."
fi
fi
echo "Removing devfs ruleset from memory..."
devfs rule -s $RULESET_NUM delset 2>/dev/null || true
# Note: We intentionally do NOT:
# - Remove the 'input' group (other software may use it)
echo "Cleanup complete."
echo ""
echo "NOTE: The 'input' group has not been removed as other software may use it."
echo "If you wish to remove it manually, run: pw groupdel input"
echo ""

View File

@@ -12,6 +12,10 @@ const props = defineProps({
<slot name="windows"></slot>
</template>
<template v-if="$slots.freebsd && platform === 'freebsd'">
<slot name="freebsd"></slot>
</template>
<template v-if="$slots.linux && platform === 'linux'">
<slot name="linux"></slot>
</template>

View File

@@ -331,7 +331,7 @@
<div class="form-text" v-if="platform === 'windows'"><b>{{ $t('apps.env_qres_example') }}</b>
<pre>cmd /C &lt;{{ $t('apps.env_qres_path') }}&gt;\QRes.exe /X:%SUNSHINE_CLIENT_WIDTH% /Y:%SUNSHINE_CLIENT_HEIGHT% /R:%SUNSHINE_CLIENT_FPS%</pre>
</div>
<div class="form-text" v-else-if="platform === 'linux'"><b>{{ $t('apps.env_xrandr_example') }}</b>
<div class="form-text" v-else-if="platform === 'freebsd' || platform === 'linux'"><b>{{ $t('apps.env_xrandr_example') }}</b>
<pre>sh -c "xrandr --output HDMI-1 --mode \"${SUNSHINE_CLIENT_WIDTH}x${SUNSHINE_CLIENT_HEIGHT}\" --rate ${SUNSHINE_CLIENT_FPS}"</pre>
</div>
<div class="form-text" v-else-if="platform === 'macos'"><b>{{ $t('apps.env_displayplacer_example') }}</b>
@@ -442,8 +442,8 @@
if (resp) {
fetch("./api/apps/" + id, {
method: "DELETE",
headers: {
"Content-Type": "application/json"
headers: {
"Content-Type": "application/json"
},
}).then((r) => {
if (r.status === 200) document.location.reload();

View File

@@ -305,7 +305,7 @@
return el.id !== "vt" && el.id !== "vaapi";
});
}
if (this.platform === "linux") {
if (this.platform === "freebsd" || this.platform === "linux") {
this.tabs = this.tabs.filter((el) => {
return el.id !== "amd" && el.id !== "qsv" && el.id !== "vt";
});

View File

@@ -64,6 +64,10 @@ const config = ref(props.config)
<select id="capture" class="form-select" v-model="config.capture">
<option value="">{{ $t('_common.autodetect') }}</option>
<PlatformLayout :platform="platform">
<template #freebsd>
<option value="wlr">wlroots</option>
<option value="x11">X11</option>
</template>
<template #linux>
<option value="nvfbc">NvFBC</option>
<option value="wlr">wlroots</option>
@@ -90,6 +94,9 @@ const config = ref(props.config)
<option value="quicksync">Intel QuickSync</option>
<option value="amdvce">AMD AMF/VCE</option>
</template>
<template #freebsd>
<option value="vaapi">VA-API</option>
</template>
<template #linux>
<option value="nvenc">NVIDIA NVENC</option>
<option value="vaapi">VA-API</option>

View File

@@ -30,6 +30,10 @@ const config = ref(props.config)
<template #windows>
<pre>tools\audio-info.exe</pre>
</template>
<template #freebsd>
<pre>pacmd list-sinks | grep "name:"</pre>
<pre>pactl info | grep Source</pre>
</template>
<template #linux>
<pre>pacmd list-sinks | grep "name:"</pre>
<pre>pactl info | grep Source</pre>

View File

@@ -28,12 +28,17 @@ const config = ref(props.config)
<option value="auto">{{ $t('_common.auto') }}</option>
<PlatformLayout :platform="platform">
<template #freebsd>
<option value="switch">{{ $t("config.gamepad_switch") }}</option>
<option value="xone">{{ $t("config.gamepad_xone") }}</option>
</template>
<template #linux>
<option value="ds5">{{ $t("config.gamepad_ds5") }}</option>
<option value="switch">{{ $t("config.gamepad_switch") }}</option>
<option value="xone">{{ $t("config.gamepad_xone") }}</option>
</template>
<template #windows>
<option value="ds4">{{ $t('config.gamepad_ds4') }}</option>
<option value="x360">{{ $t('config.gamepad_x360') }}</option>

View File

@@ -23,6 +23,16 @@ const config = ref(props.config)
{{ $t('config.adapter_name_desc_windows') }}<br>
<pre>tools\dxgi-info.exe</pre>
</template>
<template #freebsd>
{{ $t('config.adapter_name_desc_linux_1') }}<br>
<pre>ls /dev/dri/renderD* # {{ $t('config.adapter_name_desc_linux_2') }}</pre>
<pre>
vainfo --display drm --device /dev/dri/renderD129 | \
grep -E "((VAProfileH264High|VAProfileHEVCMain|VAProfileHEVCMain10).*VAEntrypointEncSlice)|Driver version"
</pre>
{{ $t('config.adapter_name_desc_linux_3') }}<br>
<i>VAProfileH264High : VAEntrypointEncSlice</i>
</template>
<template #linux>
{{ $t('config.adapter_name_desc_linux_1') }}<br>
<pre>ls /dev/dri/renderD* # {{ $t('config.adapter_name_desc_linux_2') }}</pre>

View File

@@ -241,6 +241,8 @@ function addRemappingEntry() {
</div>
</div>
</template>
<template #freebsd>
</template>
<template #linux>
</template>
<template #macos>

View File

@@ -30,6 +30,16 @@ const outputNamePlaceholder = (props.platform === 'windows') ? '{de9bb7e2-186e-5
<b>&nbsp;&nbsp;}</b>
</pre>
</template>
<template #freebsd>
<pre style="white-space: pre-line;">
Info: Detecting displays
Info: Detected display: DVI-D-0 (id: 0) connected: false
Info: Detected display: HDMI-0 (id: 1) connected: true
Info: Detected display: DP-0 (id: 2) connected: true
Info: Detected display: DP-1 (id: 3) connected: false
Info: Detected display: DVI-D-1 (id: 4) connected: false
</pre>
</template>
<template #linux>
<pre style="white-space: pre-line;">
Info: Detecting displays