launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #04923
[Merge] lp:~allenap/launchpad/with-xvfb into lp:launchpad
Gavin Panella has proposed merging lp:~allenap/launchpad/with-xvfb into lp:launchpad.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~allenap/launchpad/with-xvfb/+merge/74754
Convenience command to do what Curtis suggests in:
https://lists.launchpad.net/launchpad-dev/msg07879.html
Additionally, it makes it convenient to run other commands in bin/
without having to specify their full path.
For example, instead of:
bin/with-xvfb bin/iharness
you can just do:
bin/with-xvfb iharness
4 whole keypresses!
Also, if invoked with no arguments it will run a shell.
--
https://code.launchpad.net/~allenap/launchpad/with-xvfb/+merge/74754
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~allenap/launchpad/with-xvfb into lp:launchpad.
=== added file 'buildout-templates/bin/with-xvfb.in'
--- buildout-templates/bin/with-xvfb.in 1970-01-01 00:00:00 +0000
+++ buildout-templates/bin/with-xvfb.in 2011-09-09 11:12:31 +0000
@@ -0,0 +1,43 @@
+#!/bin/bash
+#
+# Copyright 2011 Canonical Ltd. This software is licensed under the
+# GNU Affero General Public License version 3 (see the file LICENSE).
+#
+# Wrapper that provides a default Xvfb environment for the given
+# command.
+#
+# If the command is not found it is searched for in the same directory
+# as this script. This lets you do `bin/with-xvfb iharness` for
+# example.
+#
+
+set -eu
+
+# Look for $1 - i.e. the command to run - in the current directory if
+# it's not found along the default PATH.
+if [ $# -ge 1 ] && ! type -P "$1" > /dev/null
+then
+ if command="$(PATH="$(dirname "$0")" type -P "$1")"
+ then
+ # Shift $1 off and set new positional arguments.
+ shift && set -- "$${command}" "$@"
+ fi
+# If no command has been given and SHELL is set, spawn a shell.
+elif [ $# -eq 0 -a -n "$${SHELL:-}" ]
+then
+ set -- "$${SHELL}"
+fi
+
+#
+# --auto-servernum
+# Try to get a free server number, starting at 99. See xvfb-run(1).
+#
+# --server-args=
+# -ac disables host-based access control mechanisms. See Xserver(1).
+# -screen forces a screen configuration. At the time of writing
+# there is some disagreement between xvfb-run(1) and Xvfb(1)
+# about what the default is.
+#
+exec xvfb-run \
+ --server-args="-ac -screen 0 1024x768x24" \
+ --auto-servernum -- "$@"