mirror of
https://github.com/LizardByte/Sunshine.git
synced 2025-02-06 00:39:54 +00:00
build(flatpak): add xvfb locally (#2797)
This commit is contained in:
parent
9b5a04634e
commit
0b2487d022
@ -37,6 +37,7 @@ elseif(UNIX)
|
||||
if(${SUNSHINE_CONFIGURE_FLATPAK_MAN})
|
||||
configure_file(packaging/linux/flatpak/dev.lizardbyte.sunshine.yml dev.lizardbyte.sunshine.yml @ONLY)
|
||||
file(COPY packaging/linux/flatpak/deps/ DESTINATION ${CMAKE_BINARY_DIR})
|
||||
file(COPY packaging/linux/flatpak/modules DESTINATION ${CMAKE_BINARY_DIR})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
@ -34,7 +34,7 @@ build-options:
|
||||
prepend-ld-library-path: /usr/lib/sdk/vala/lib
|
||||
|
||||
modules:
|
||||
- "org.flatpak.Builder.BaseApp/xvfb.json"
|
||||
- "modules/xvfb/xvfb.json"
|
||||
|
||||
- name: avahi
|
||||
disabled: false
|
||||
|
191
packaging/linux/flatpak/modules/xvfb/xvfb-run
Normal file
191
packaging/linux/flatpak/modules/xvfb/xvfb-run
Normal file
@ -0,0 +1,191 @@
|
||||
#!/bin/sh
|
||||
|
||||
# This script starts an instance of Xvfb, the "fake" X server, runs a command
|
||||
# with that server available, and kills the X server when done. The return
|
||||
# value of the command becomes the return value of this script.
|
||||
#
|
||||
# If anyone is using this to build a Debian package, make sure the package
|
||||
# Build-Depends on xvfb and xauth.
|
||||
|
||||
set -e
|
||||
|
||||
PROGNAME=xvfb-run
|
||||
SERVERNUM=99
|
||||
AUTHFILE=
|
||||
ERRORFILE=/dev/null
|
||||
XVFBARGS="-screen 0 1280x1024x24"
|
||||
LISTENTCP="-nolisten tcp"
|
||||
XAUTHPROTO=.
|
||||
|
||||
# Query the terminal to establish a default number of columns to use for
|
||||
# displaying messages to the user. This is used only as a fallback in the event
|
||||
# the COLUMNS variable is not set. ($COLUMNS can react to SIGWINCH while the
|
||||
# script is running, and this cannot, only being calculated once.)
|
||||
DEFCOLUMNS=$(stty size 2>/dev/null | awk '{print $2}') || true
|
||||
case "$DEFCOLUMNS" in
|
||||
*[!0-9]*|'') DEFCOLUMNS=80 ;;
|
||||
esac
|
||||
|
||||
# Display a message, wrapping lines at the terminal width.
|
||||
message () {
|
||||
echo "$PROGNAME: $*" | fmt -t -w ${COLUMNS:-$DEFCOLUMNS}
|
||||
}
|
||||
|
||||
# Display an error message.
|
||||
error () {
|
||||
message "error: $*" >&2
|
||||
}
|
||||
|
||||
# Display a usage message.
|
||||
usage () {
|
||||
if [ -n "$*" ]; then
|
||||
message "usage error: $*"
|
||||
fi
|
||||
cat <<EOF
|
||||
Usage: $PROGNAME [OPTION ...] COMMAND
|
||||
Run COMMAND (usually an X client) in a virtual X server environment.
|
||||
Options:
|
||||
-a --auto-servernum try to get a free server number, starting at
|
||||
--server-num
|
||||
-e FILE --error-file=FILE file used to store xauth errors and Xvfb
|
||||
output (default: $ERRORFILE)
|
||||
-f FILE --auth-file=FILE file used to store auth cookie
|
||||
(default: ./.Xauthority)
|
||||
-h --help display this usage message and exit
|
||||
-n NUM --server-num=NUM server number to use (default: $SERVERNUM)
|
||||
-l --listen-tcp enable TCP port listening in the X server
|
||||
-p PROTO --xauth-protocol=PROTO X authority protocol name to use
|
||||
(default: xauth command's default)
|
||||
-s ARGS --server-args=ARGS arguments (other than server number and
|
||||
"-nolisten tcp") to pass to the Xvfb server
|
||||
(default: "$XVFBARGS")
|
||||
EOF
|
||||
}
|
||||
|
||||
# Find a free server number by looking at .X*-lock files in /tmp.
|
||||
find_free_servernum() {
|
||||
# Sadly, the "local" keyword is not POSIX. Leave the next line commented in
|
||||
# the hope Debian Policy eventually changes to allow it in /bin/sh scripts
|
||||
# anyway.
|
||||
#local i
|
||||
|
||||
i=$SERVERNUM
|
||||
while [ -f /tmp/.X$i-lock ]; do
|
||||
i=$(($i + 1))
|
||||
done
|
||||
echo $i
|
||||
}
|
||||
|
||||
# Clean up files
|
||||
clean_up() {
|
||||
if [ -e "$AUTHFILE" ]; then
|
||||
XAUTHORITY=$AUTHFILE xauth remove ":$SERVERNUM" >>"$ERRORFILE" 2>&1
|
||||
fi
|
||||
if [ -n "$XVFB_RUN_TMPDIR" ]; then
|
||||
if ! rm -r "$XVFB_RUN_TMPDIR"; then
|
||||
error "problem while cleaning up temporary directory"
|
||||
exit 5
|
||||
fi
|
||||
fi
|
||||
if [ -n "$XVFBPID" ]; then
|
||||
kill "$XVFBPID" >>"$ERRORFILE" 2>&1
|
||||
fi
|
||||
}
|
||||
|
||||
# Parse the command line.
|
||||
ARGS=$(getopt --options +ae:f:hn:lp:s:w: \
|
||||
--long auto-servernum,error-file:,auth-file:,help,server-num:,listen-tcp,xauth-protocol:,server-args:,wait: \
|
||||
--name "$PROGNAME" -- "$@")
|
||||
GETOPT_STATUS=$?
|
||||
|
||||
if [ $GETOPT_STATUS -ne 0 ]; then
|
||||
error "internal error; getopt exited with status $GETOPT_STATUS"
|
||||
exit 6
|
||||
fi
|
||||
|
||||
eval set -- "$ARGS"
|
||||
|
||||
while :; do
|
||||
case "$1" in
|
||||
-a|--auto-servernum) SERVERNUM=$(find_free_servernum); AUTONUM="yes" ;;
|
||||
-e|--error-file) ERRORFILE="$2"; shift ;;
|
||||
-f|--auth-file) AUTHFILE="$2"; shift ;;
|
||||
-h|--help) SHOWHELP="yes" ;;
|
||||
-n|--server-num) SERVERNUM="$2"; shift ;;
|
||||
-l|--listen-tcp) LISTENTCP="" ;;
|
||||
-p|--xauth-protocol) XAUTHPROTO="$2"; shift ;;
|
||||
-s|--server-args) XVFBARGS="$2"; shift ;;
|
||||
-w|--wait) shift ;;
|
||||
--) shift; break ;;
|
||||
*) error "internal error; getopt permitted \"$1\" unexpectedly"
|
||||
exit 6
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
if [ "$SHOWHELP" ]; then
|
||||
usage
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ -z "$*" ]; then
|
||||
usage "need a command to run" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
if ! command -v xauth >/dev/null; then
|
||||
error "xauth command not found"
|
||||
exit 3
|
||||
fi
|
||||
|
||||
# tidy up after ourselves
|
||||
trap clean_up EXIT
|
||||
|
||||
# If the user did not specify an X authorization file to use, set up a temporary
|
||||
# directory to house one.
|
||||
if [ -z "$AUTHFILE" ]; then
|
||||
XVFB_RUN_TMPDIR="$(mktemp -d -t $PROGNAME.XXXXXX)"
|
||||
AUTHFILE="$XVFB_RUN_TMPDIR/Xauthority"
|
||||
# Create empty file to avoid xauth warning
|
||||
touch "$AUTHFILE"
|
||||
fi
|
||||
|
||||
# Start Xvfb.
|
||||
MCOOKIE=$(mcookie)
|
||||
tries=10
|
||||
while [ $tries -gt 0 ]; do
|
||||
tries=$(( $tries - 1 ))
|
||||
XAUTHORITY=$AUTHFILE xauth source - << EOF >>"$ERRORFILE" 2>&1
|
||||
add :$SERVERNUM $XAUTHPROTO $MCOOKIE
|
||||
EOF
|
||||
# handle SIGUSR1 so Xvfb knows to send a signal when it's ready to accept
|
||||
# connections
|
||||
trap : USR1
|
||||
(trap '' USR1; exec Xvfb ":$SERVERNUM" $XVFBARGS $LISTENTCP -auth $AUTHFILE >>"$ERRORFILE" 2>&1) &
|
||||
XVFBPID=$!
|
||||
|
||||
wait || :
|
||||
if kill -0 $XVFBPID 2>/dev/null; then
|
||||
break
|
||||
elif [ -n "$AUTONUM" ]; then
|
||||
# The display is in use so try another one (if '-a' was specified).
|
||||
SERVERNUM=$((SERVERNUM + 1))
|
||||
SERVERNUM=$(find_free_servernum)
|
||||
continue
|
||||
fi
|
||||
error "Xvfb failed to start" >&2
|
||||
XVFBPID=
|
||||
exit 1
|
||||
done
|
||||
|
||||
# Start the command and save its exit status.
|
||||
set +e
|
||||
DISPLAY=:$SERVERNUM XAUTHORITY=$AUTHFILE "$@"
|
||||
RETVAL=$?
|
||||
set -e
|
||||
|
||||
# Return the executed command's exit status.
|
||||
exit $RETVAL
|
||||
|
||||
# vim:set ai et sts=4 sw=4 tw=80:
|
147
packaging/linux/flatpak/modules/xvfb/xvfb.json
Normal file
147
packaging/linux/flatpak/modules/xvfb/xvfb.json
Normal file
@ -0,0 +1,147 @@
|
||||
{
|
||||
"name": "xvfb",
|
||||
"buildsystem": "meson",
|
||||
"config-opts": [
|
||||
"-Dxorg=true",
|
||||
"-Dxvfb=true",
|
||||
"-Dhal=false"
|
||||
],
|
||||
"build-commands": [
|
||||
"install -Dm755 ../xvfb-run /app/bin/xvfb-run"
|
||||
],
|
||||
"sources": [
|
||||
{
|
||||
"type": "archive",
|
||||
"url": "https://gitlab.freedesktop.org/xorg/xserver/-/archive/xorg-server-21.1.13/xserver-xorg-server-21.1.13.tar.bz2",
|
||||
"sha256": "ee2bf6d65f4b111ce86ca817c3327dc1e70d9c958aa16876f2820caf7bf7cffa",
|
||||
"x-checker-data": {
|
||||
"type": "anitya",
|
||||
"project-id": 5250,
|
||||
"stable-only": true,
|
||||
"url-template": "https://gitlab.freedesktop.org/xorg/xserver/-/archive/xorg-server-$version/xserver-xorg-server-$version.tar.bz2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "file",
|
||||
"path": "xvfb-run"
|
||||
}
|
||||
],
|
||||
"modules": [
|
||||
{
|
||||
"name": "libxcvt",
|
||||
"buildsystem": "meson",
|
||||
"sources": [
|
||||
{
|
||||
"type": "archive",
|
||||
"url": "https://gitlab.freedesktop.org/xorg/lib/libxcvt/-/archive/libxcvt-0.1.2/libxcvt-libxcvt-0.1.2.tar.bz2",
|
||||
"sha256": "590e5a6da87ace7aa7857026b207a2c4d378620035441e20ea97efedd15d6d4a",
|
||||
"x-checker-data": {
|
||||
"type": "anitya",
|
||||
"project-id": 235147,
|
||||
"stable-only": true,
|
||||
"url-template": "https://gitlab.freedesktop.org/xorg/lib/libxcvt/-/archive/libxcvt-$version/libxcvt-libxcvt-$version.tar.bz2"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "libXmu",
|
||||
"sources": [
|
||||
{
|
||||
"type": "archive",
|
||||
"url": "https://xorg.freedesktop.org/archive/individual/lib/libXmu-1.2.1.tar.gz",
|
||||
"sha256": "bf0902583dd1123856c11e0a5085bd3c6e9886fbbd44954464975fd7d52eb599",
|
||||
"x-checker-data": {
|
||||
"type": "anitya",
|
||||
"project-id": 1785,
|
||||
"stable-only": true,
|
||||
"url-template": "https://xorg.freedesktop.org/archive/individual/lib/libXmu-$version.tar.gz"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "libfontenc",
|
||||
"sources": [
|
||||
{
|
||||
"type": "archive",
|
||||
"url": "https://xorg.freedesktop.org/archive/individual/lib/libfontenc-1.1.8.tar.xz",
|
||||
"sha256": "7b02c3d405236e0d86806b1de9d6868fe60c313628b38350b032914aa4fd14c6",
|
||||
"x-checker-data": {
|
||||
"type": "anitya",
|
||||
"project-id": 1613,
|
||||
"stable-only": true,
|
||||
"url-template": "https://xorg.freedesktop.org/archive/individual/lib/libfontenc-$version.tar.xz"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "libtirpc",
|
||||
"config-opts": [
|
||||
"--disable-gssapi"
|
||||
],
|
||||
"sources": [
|
||||
{
|
||||
"type": "archive",
|
||||
"url": "https://downloads.sourceforge.net/sourceforge/libtirpc/libtirpc-1.3.4.tar.bz2",
|
||||
"sha256": "1e0b0c7231c5fa122e06c0609a76723664d068b0dba3b8219b63e6340b347860",
|
||||
"x-checker-data": {
|
||||
"type": "anitya",
|
||||
"project-id": 1740,
|
||||
"stable-only": true,
|
||||
"url-template": "https://downloads.sourceforge.net/sourceforge/libtirpc/libtirpc-$version.tar.bz2"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "font-util",
|
||||
"sources": [
|
||||
{
|
||||
"type": "archive",
|
||||
"url": "https://xorg.freedesktop.org/archive/individual/font/font-util-1.4.1.tar.gz",
|
||||
"sha256": "f029ae80cdd75d89bee7f7af61c21e07982adfb9f72344a158b99f91f77ef5ed",
|
||||
"x-checker-data": {
|
||||
"type": "anitya",
|
||||
"project-id": 15055,
|
||||
"stable-only": true,
|
||||
"url-template": "https://xorg.freedesktop.org/archive/individual/font/font-util-$version.tar.gz"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "xvfb-libXfont2",
|
||||
"sources": [
|
||||
{
|
||||
"type": "archive",
|
||||
"url": "https://xorg.freedesktop.org/archive/individual/lib/libXfont2-2.0.6.tar.gz",
|
||||
"sha256": "a944df7b6837c8fa2067f6a5fc25d89b0acc4011cd0bc085106a03557fb502fc",
|
||||
"x-checker-data": {
|
||||
"type": "anitya",
|
||||
"project-id": 17165,
|
||||
"stable-only": true,
|
||||
"url-template": "https://xorg.freedesktop.org/archive/individual/lib/libXfont2-$version.tar.gz"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "xvfb-xauth",
|
||||
"sources": [
|
||||
{
|
||||
"type": "archive",
|
||||
"url": "https://gitlab.freedesktop.org/xorg/app/xauth/-/archive/xauth-1.1.1/xauth-xauth-1.1.3.tar.bz2",
|
||||
"sha256": "3cee16ebe9de0e85c62513f6d6353710407c8ebb1f855b18d03807c27d38a215",
|
||||
"x-checker-data": {
|
||||
"type": "anitya",
|
||||
"project-id": 5253,
|
||||
"stable-only": true,
|
||||
"url-template": "https://gitlab.freedesktop.org/xorg/app/xauth/-/archive/xauth-1.1.1/xauth-xauth-$version.tar.bz2"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user