[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#444138: Support for other xservers than xvfb in xfvb-run



Package: xvfb
Version: 2:1.3.0.0.dfsg-12
Severity: wishlist
File: /usr/bin/xvfb-run
Tags: patch

I had the need to use the xvfb-run script with another xserver. With the
attached patch, you can choose e.g. Xephyr over xvfb, to actually watch
your testscript. This way, it is more easy to debug the testscripts.

Find attached my modifications to xvfb-run and the manpage, both as
derived versions x-run and x-run.1 in full and diff format.

Feel free to submit this upstream and/or apply this to the debian
package.

-- System Information:
Debian Release: lenny/sid
  APT prefers testing
  APT policy: (500, 'testing'), (50, 'unstable')
Architecture: i386 (x86_64)

Kernel: Linux 2.6.20.4-gernoth-64bit (SMP w/4 CPU cores)
Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages xvfb depends on:
ii  libc6                         2.6.1-1+b1 GNU C Library: Shared libraries
ii  libfontenc1                   1:1.0.4-2  X11 font encoding library
ii  libxau6                       1:1.0.3-2  X11 authorisation library
ii  libxdmcp6                     1:1.0.2-2  X11 Display Manager Control Protoc
ii  libxfont1                     1:1.3.1-1  X11 font rasterisation library

Versions of packages xvfb recommends:
ii  xbase-clients                1:7.2.ds2-2 miscellaneous X clients
ii  xfonts-base                  1:1.0.0-5   standard fonts for X

-- no debconf information

Attachment: x-run
Description: application/shellscript

--- /usr/bin/xvfb-run	2007-08-09 19:39:25.000000000 +0200
+++ x-run	2007-09-26 11:21:01.837891000 +0200
@@ -9,9 +9,12 @@
 # If anyone is using this to build a Debian package, make sure the package
 # Build-Depends on xvfb, xbase-clients, and xfonts-base.
 
+# This script is heavily based on /usr/bin/xvfb-run as found on debian
+# systems
+
 set -e
 
-PROGNAME=xvfb-run
+PROGNAME=x-run
 SERVERNUM=99
 AUTHFILE=
 ERRORFILE=/dev/null
@@ -19,6 +22,7 @@
 XVFBARGS="-screen 0 640x480x8"
 LISTENTCP="-nolisten tcp"
 XAUTHPROTO=.
+XSERVER="/usr/bin/Xvfb"
 
 # 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
@@ -64,6 +68,8 @@
                                     (default: "$XVFBARGS")
 -w DELAY  --wait=DELAY              delay in seconds to wait for Xvfb to start
                                     before running COMMAND (default: $STARTWAIT)
+-x XSERVER --xserver=XSERVER        use alternative xserver binary (like Xephyr
+                                    or Xnest)
 EOF
 }
 
@@ -95,8 +101,8 @@
 }
 
 # 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: \
+ARGS=$(getopt --options +ae:f:hn:lp:s:w:x: \
+       --long auto-servernum,error-file:,auth-file:,help,server-num:,listen-tcp,xauth-protocol:,server-args:,wait:,xserver: \
        --name "$PROGNAME" -- "$@")
 GETOPT_STATUS=$?
 
@@ -118,6 +124,7 @@
         -p|--xauth-protocol) XAUTHPROTO="$2"; shift ;;
         -s|--server-args) XVFBARGS="$2"; shift ;;
         -w|--wait) STARTWAIT="$2"; shift ;;
+        -x|--xserver) XSERVER="$2"; shift ;;
         --) shift; break ;;
         *) error "internal error; getopt permitted \"$1\" unexpectedly"
            exit 6
@@ -155,16 +162,16 @@
     AUTHFILE=$(tempfile -n "$XVFB_RUN_TMPDIR/Xauthority")
 fi
 
-# Start Xvfb.
+# Start $XSERVER
 MCOOKIE=$(mcookie)
 XAUTHORITY=$AUTHFILE xauth add ":$SERVERNUM" "$XAUTHPROTO" "$MCOOKIE" \
   >"$ERRORFILE" 2>&1
-XAUTHORITY=$AUTHFILE Xvfb ":$SERVERNUM" $XVFBARGS $LISTENTCP >"$ERRORFILE" \
-  2>&1 &
+XAUTHORITY=$AUTHFILE $XSERVER ":$SERVERNUM" $XVFBARGS -auth $AUTHFILE \
+  $LISTENTCP >"$ERRORFILE" 2>&1 &
 XVFBPID=$!
 sleep "$STARTWAIT"
 if ! kill -0 $XVFBPID 2>/dev/null; then
-  echo "Xvfb failed to start" >&2
+  echo "$XSERVER failed to start" >&2
   exit 1
 fi
 
@@ -174,7 +181,7 @@
 RETVAL=$?
 set -e
 
-# Kill Xvfb now that the command has exited.
+# Kill $XSERVER now that the command has exited.
 kill $XVFBPID
 
 # Return the executed command's exit status.
.\" Copyright 1998-2004 Branden Robinson <branden@debian.org>.
.\"
.\" This is free software; you may redistribute it and/or modify
.\" it under the terms of the GNU General Public License as
.\" published by the Free Software Foundation; either version 2,
.\" or (at your option) any later version.
.\"
.\" This is distributed in the hope that it will be useful, but
.\" WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
.\" GNU General Public License for more details.
.\"
.\" You should have received a copy of the GNU General Public License with
.\" the Debian operating system, in /usr/share/common-licenses/GPL;  if
.\" not, write to the Free Software Foundation, Inc., 59 Temple Place,
.\" Suite 330, Boston, MA 02111-1307 USA
.\"
.\" We need the URL macro from groff's www macro package, but also want
.\" things to work all right for people who don't have it.  So we define
.\" our own URL macro and let the www macro package override it if it's
.\" available.
.de URL
\\$2 \(laURL: \\$1 \(ra\\$3
..
.if \n[.g] .mso www.tmac
.TH x\-run 1 "2004\-11\-12" "Debian Project"
.SH NAME
x\-run \- run specified X client or command in a virtual X server environment
.SH SYNOPSIS
.B x\-run
[
.I options
]
.I command
.SH DESCRIPTION
.B x\-run
is a wrapper for the
.BR Xvfb (1x)
command which simplifies the task of running commands (typically an X
client, or a script containing a list of clients to be run) within a virtual
X server environment.
.PP
.B x\-run
sets up an X authority file (or uses an existing user\-specified one),
writes a cookie to it (see
.BR xauth (1x))
and then starts the
.B Xvfb
X server as a background process.
The process ID of
.B Xvfb
is stored for later use.
The specified
.I command
is then run using the X display corresponding to the
.B Xvfb
server
just started and the X authority file created earlier.
.PP
When the
.I command
exits, its status is saved, the
.B Xvfb
server is killed (using the process ID stored earlier), the X authority
cookie removed, and the authority file deleted (if the user did not specify
one to use).
.B x\-run
then exits with the exit status of
.IR command .
.PP
.B x\-run
requires the
.B xauth
command to function.
.SH OPTIONS
.TP
.B \-a\fR,\fB \-\-auto\-servernum
Try to get a free server number, starting at 99, or the argument to
.BR \-\-server\-num .
.TP
.BI \-e\  file \fR,\fB\ \-\-error\-file= file
Store output from
.B xauth
and
.B Xvfb
in
.IR file .
The default is
.IR /dev/null .
.TP
.BI \-f\  file \fR,\fB\ \-\-auth\-file= file
Store X authentication data in
.IR file .
By default, a temporary directory called
.IR x\-run. PID
(where PID is the process ID of
.B x\-run
itself) is created in the directory specified by the environment variable
.B TMPDIR
(or
.I /tmp
if that variable is null or unset), and the
.BR tempfile (1)
command is used to create a file in that temporary directory called
.IR Xauthority .
.TP
.B \-h\fR,\fB \-\-help
Display a usage message and exit.
.TP
.BI \-n\  servernumber \fR,\fB\ \-\-server\-num= servernumber
Use
.I servernumber
as the server number (but see the
.B \-a\fR,\fB \-\-auto\-servernum
option above).
The default is 99.
.TP
.B \-l\fR,\fB \-\-listen\-tcp
Enable TCP port listening in the X server.
For security reasons (to avoid denial\-of\-service attacks or exploits),
TCP port listening is disabled by default.
.TP
.BI \-p\  protocolname \fR,\fB\ \-\-xauth\-protocol= protocolname
Use
.I protocolname
as the X authority protocol to use.
The default is \(oq.\(cq, which
.B xauth
interprets as its own default protocol, which is MIT\-MAGIC\-COOKIE\-1.
.TP
.BI \-s\  arguments \fR,\fB\ \-\-server\-args= arguments
Pass
.I arguments
to the
.B Xvfb
server.
Be careful to quote any whitespace characters that may occur within
.I arguments
to prevent them from regarded as separators for
.BR x\-run 's
own arguments.
Also, note that specification of \(oq\-nolisten tcp\(cq in
.I arguments
may override the function of
.BR x\-run 's
own
.B \-l\fR,\fB \-\-listen\-tcp
option, and that specification of the server number (e.g., \(oq:1\(cq) may
be ignored because of the way the X server parses its argument list.
Use the
.B x\-run
option
.BI \-n\  servernumber \fR,\fB\ \-\-server\-num= servernumber
to achieve the latter function.
The default is \(oq\-screen 0 640x480x8\(cq.
.TP
.BI \-w\  delay \fR,\fB\ \-\-wait= delay
Wait
.I delay
seconds after launching
.B Xvfb
before attempting to start the specified command.
The default is 3.
.TP
.BI \-x\  xserver \fR,\fB\ \-\-xserver= xserver
Use the alternative Xserver
.I xserver
instead of
.B xvfb,
which is used by default.
.SH ENVIRONMENT
.TP
.B COLUMNS
indicates the width of the terminal device in character cells.
This value is used for formatting diagnostic messages.
If not set, the terminal is queried using
.BR stty (1)
to determine its width.
If that fails, a value of \(oq80\(cq is assumed.
.TP
.B TMPDIR
specifies the directory in which to place
.BR x\-run 's
temporary directory for storage of the X authority file; only used if the
.B \-f
or
.B \-\-auth\-file
options are not specified.
.SH "OUTPUT FILES"
.PP
Unless the
.B \-f
or
.B \-\-auth\-file
options are specified, a temporary
directory and file within it are created (and deleted) to store the X
authority cookies used by the
.B Xvfb
server and client(s) run under it.
See
.BR tempfile (1).
If \-f or \-\-auth\-file are used, then the specified X authority file is
only written to, not created or deleted (though
.B xauth
creates an authority file itself if told to use use that does not already
exist).
.PP
An error file with a user\-specified name is also created if the
.B \-e
or
.B \-\-error\-file
options are specifed; see above.
.SH "EXIT STATUS"
.B x\-run
uses its exit status as well as output to standard error to communicate
diagnostics.
The exit status of \(oq1\(cq is not used, and should be interpreted as failure
of the specified command.
.TP
0
.B x\-run
only uses this exit status if the
.B \-h\fR,\fB \-\-help
option is given.
In all other situations, this may be interpreted as success of the specified
command.
.TP
2
No command to run was specified.
.TP
3
The
.B xauth
command is not available.
.TP
4
The temporary directory that was going to be used already exists; since
.B x\-run
produces a uniquely named directory, this may indicate an attempt by another
process on the system to exploit a temporary file race condition.
.TP
5
A problem was encountered while cleaning up the temporary directory.
.TP
6
A problem was encountered while using
.BR getopt (1)
to parse the command\-line arguments.
.SH EXAMPLES
.TP
.B x\-run \-\-auto\-servernum \-\-server\-num=1 xlogo
runs the
.BR xlogo (1x)
demonstration client inside the
.B Xvfb
X server on the first available server number greater than or equal to 1.
.TP
.B x\-run \-\-server\-args="\-screen 0 1024x768x24" ico \-faces
runs the
.BR ico (1x)
demonstration client (and passes it the
.B \-faces
argument) inside the
.B Xvfb
X server, configured with a root window of 1024 by 768 pixels and a color
depth of 24 bits.
.PP
Note that the demo X clients used in the above examples will not exit on
their own, so they will have to be killed before
.B x\-run
will exit.
.SH BUGS
See
.URL "http://bugs.debian.org/xvfb"; "the Debian Bug Tracking System" .
If you wish to report a bug in
.BR xvfb\-run ,
please see
.I /usr/share/doc/debian/bug\-reporting.txt
or the
.BR reportbug (1)
command.
.SH AUTHOR
.B x\-run
is a modified version of
.B xvfb\-run
found in the Debian Operating system.
Reinhard Tartler renamed the script and added the
.I -x
Switch.
.B xvfb\-run
was written by Branden Robinson and Jeff Licquia with sponsorship from
Progeny Linux Systems.
.SH "SEE ALSO"
.BR Xvfb (1x),
.BR xauth (1x)
.\" vim:set et tw=80:
--- xvfb-run.1	2007-09-26 11:23:16.384451000 +0200
+++ x-run.1	2007-09-26 11:22:18.333818000 +0200
@@ -1,5 +1,3 @@
-.\" $Id: xvfb-run.1 2138 2005-01-17 23:40:27Z branden $
-.\"
 .\" Copyright 1998-2004 Branden Robinson <branden@debian.org>.
 .\"
 .\" This is free software; you may redistribute it and/or modify
@@ -25,24 +23,24 @@
 \\$2 \(laURL: \\$1 \(ra\\$3
 ..
 .if \n[.g] .mso www.tmac
-.TH xvfb\-run 1 "2004\-11\-12" "Debian Project"
+.TH x\-run 1 "2004\-11\-12" "Debian Project"
 .SH NAME
-xvfb\-run \- run specified X client or command in a virtual X server environment
+x\-run \- run specified X client or command in a virtual X server environment
 .SH SYNOPSIS
-.B xvfb\-run
+.B x\-run
 [
 .I options
 ]
 .I command
 .SH DESCRIPTION
-.B xvfb\-run
+.B x\-run
 is a wrapper for the
 .BR Xvfb (1x)
 command which simplifies the task of running commands (typically an X
 client, or a script containing a list of clients to be run) within a virtual
 X server environment.
 .PP
-.B xvfb\-run
+.B x\-run
 sets up an X authority file (or uses an existing user\-specified one),
 writes a cookie to it (see
 .BR xauth (1x))
@@ -66,11 +64,11 @@
 server is killed (using the process ID stored earlier), the X authority
 cookie removed, and the authority file deleted (if the user did not specify
 one to use).
-.B xvfb\-run
+.B x\-run
 then exits with the exit status of
 .IR command .
 .PP
-.B xvfb\-run
+.B x\-run
 requires the
 .B xauth
 command to function.
@@ -94,9 +92,9 @@
 Store X authentication data in
 .IR file .
 By default, a temporary directory called
-.IR xvfb\-run. PID
+.IR x\-run. PID
 (where PID is the process ID of
-.B xvfb\-run
+.B x\-run
 itself) is created in the directory specified by the environment variable
 .B TMPDIR
 (or
@@ -139,18 +137,18 @@
 Be careful to quote any whitespace characters that may occur within
 .I arguments
 to prevent them from regarded as separators for
-.BR xvfb\-run 's
+.BR x\-run 's
 own arguments.
 Also, note that specification of \(oq\-nolisten tcp\(cq in
 .I arguments
 may override the function of
-.BR xvfb\-run 's
+.BR x\-run 's
 own
 .B \-l\fR,\fB \-\-listen\-tcp
 option, and that specification of the server number (e.g., \(oq:1\(cq) may
 be ignored because of the way the X server parses its argument list.
 Use the
-.B xvfb\-run
+.B x\-run
 option
 .BI \-n\  servernumber \fR,\fB\ \-\-server\-num= servernumber
 to achieve the latter function.
@@ -163,6 +161,13 @@
 .B Xvfb
 before attempting to start the specified command.
 The default is 3.
+.TP
+.BI \-x\  xserver \fR,\fB\ \-\-xserver= xserver
+Use the alternative Xserver
+.I xserver
+instead of
+.B xvfb,
+which is used by default.
 .SH ENVIRONMENT
 .TP
 .B COLUMNS
@@ -175,7 +180,7 @@
 .TP
 .B TMPDIR
 specifies the directory in which to place
-.BR xvfb\-run 's
+.BR x\-run 's
 temporary directory for storage of the X authority file; only used if the
 .B \-f
 or
@@ -206,14 +211,14 @@
 .B \-\-error\-file
 options are specifed; see above.
 .SH "EXIT STATUS"
-.B xvfb\-run
+.B x\-run
 uses its exit status as well as output to standard error to communicate
 diagnostics.
 The exit status of \(oq1\(cq is not used, and should be interpreted as failure
 of the specified command.
 .TP
 0
-.B xvfb\-run
+.B x\-run
 only uses this exit status if the
 .B \-h\fR,\fB \-\-help
 option is given.
@@ -230,7 +235,7 @@
 .TP
 4
 The temporary directory that was going to be used already exists; since
-.B xvfb\-run
+.B x\-run
 produces a uniquely named directory, this may indicate an attempt by another
 process on the system to exploit a temporary file race condition.
 .TP
@@ -243,14 +248,14 @@
 to parse the command\-line arguments.
 .SH EXAMPLES
 .TP
-.B xvfb\-run \-\-auto\-servernum \-\-server\-num=1 xlogo
+.B x\-run \-\-auto\-servernum \-\-server\-num=1 xlogo
 runs the
 .BR xlogo (1x)
 demonstration client inside the
 .B Xvfb
 X server on the first available server number greater than or equal to 1.
 .TP
-.B xvfb\-run \-\-server\-args="\-screen 0 1024x768x24" ico \-faces
+.B x\-run \-\-server\-args="\-screen 0 1024x768x24" ico \-faces
 runs the
 .BR ico (1x)
 demonstration client (and passes it the
@@ -262,7 +267,7 @@
 .PP
 Note that the demo X clients used in the above examples will not exit on
 their own, so they will have to be killed before
-.B xvfb\-run
+.B x\-run
 will exit.
 .SH BUGS
 See
@@ -275,7 +280,14 @@
 .BR reportbug (1)
 command.
 .SH AUTHOR
-.B xfvb\-run
+.B x\-run
+is a modified version of
+.B xvfb\-run
+found in the Debian Operating system.
+Reinhard Tartler renamed the script and added the
+.I -x
+Switch.
+.B xvfb\-run
 was written by Branden Robinson and Jeff Licquia with sponsorship from
 Progeny Linux Systems.
 .SH "SEE ALSO"

Reply to: