From b7bf9b3033d30d60e4b7563a7f95bddd73f8922f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Sat, 7 Dec 2024 03:55:38 +0100 Subject: [PATCH] Add qubes-builder integration and CI --- .gitignore | 2 + .gitlab-ci.yml | 5 + .qubesbuilder | 8 + Makefile | 53 +++ Makefile.builder | 4 + rel | 1 + version | 1 + ...x11-server.spec => xorg-x11-server.spec.in | 370 +----------------- xvfb-run.sh | 200 ++++++++++ 9 files changed, 277 insertions(+), 367 deletions(-) create mode 100644 .gitignore create mode 100644 .gitlab-ci.yml create mode 100644 .qubesbuilder create mode 100644 Makefile create mode 100644 Makefile.builder create mode 100644 rel create mode 100644 version rename xorg-x11-server.spec => xorg-x11-server.spec.in (55%) create mode 100644 xvfb-run.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..623be75 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +pkgs/ +xorg-server-*.tar.xz diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..30615e2 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,5 @@ +include: +- file: /r4.2/gitlab-base.yml + project: QubesOS/qubes-continuous-integration +- file: /r4.2/gitlab-host.yml + project: QubesOS/qubes-continuous-integration diff --git a/.qubesbuilder b/.qubesbuilder new file mode 100644 index 0000000..625e9c2 --- /dev/null +++ b/.qubesbuilder @@ -0,0 +1,8 @@ +host: + rpm: + build: + - xorg-x11-server.spec +source: + files: + - url: https://www.x.org/pub/individual/xserver/xorg-server-@VERSION@.tar.xz + sha512: xorg-server-@VERSION@.tar.xz.sha512 diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..7f12897 --- /dev/null +++ b/Makefile @@ -0,0 +1,53 @@ +.DEFAULT_GOAL = get-sources +.SECONDEXPANSION: + +DIST ?= fc32 +VERSION := $(shell cat version) + +FEDORA_SOURCES := https://src.fedoraproject.org/rpms/xorg-x11-server/raw/f$(subst fc,,$(DIST))/f/sources +SRC_FILES := \ + xorg-server-$(VERSION).tar.xz + + +BUILDER_DIR ?= ../.. +SRC_DIR ?= qubes-src + +SRC_URLS := \ + https://www.x.org/pub/individual/xserver/xorg-server-$(VERSION).tar.xz + + +UNTRUSTED_SUFF := .UNTRUSTED + +SHELL := bash + +.PHONY: get-sources verify-sources clean clean-sources + +ifeq ($(FETCH_CMD),) +$(error "You can not run this Makefile without having FETCH_CMD defined") +endif + +%: %.sha512 + @$(FETCH_CMD) $@$(UNTRUSTED_SUFF) -- $(filter %/$@,$(SRC_URLS)) + @sha512sum --status -c <(printf "$$(cat $<) -\n") <$@$(UNTRUSTED_SUFF) || \ + { echo "Wrong SHA512 checksum on $@$(UNTRUSTED_SUFF)!"; exit 1; } + @mv $@$(UNTRUSTED_SUFF) $@ + +get-sources: $(SRC_FILES) + @true + +verify-sources: + @true + +clean: + @true + +clean-sources: + rm -f $(SRC_FILES) *$(UNTRUSTED_SUFF) + +# This target is generating content locally from upstream project +# # 'sources' file. Sanitization is done but it is encouraged to perform +# # update of component in non-sensitive environnements to prevent +# # any possible local destructions due to shell rendering +# .PHONY: update-sources +update-sources: + @$(BUILDER_DIR)/$(SRC_DIR)/builder-rpm/scripts/generate-hashes-from-sources $(FEDORA_SOURCES) diff --git a/Makefile.builder b/Makefile.builder new file mode 100644 index 0000000..9a4506e --- /dev/null +++ b/Makefile.builder @@ -0,0 +1,4 @@ +ifeq ($(PACKAGE_SET),dom0) +RPM_SPEC_FILES := xorg-x11-server.spec +endif +NO_ARCHIVE := 1 diff --git a/rel b/rel new file mode 100644 index 0000000..6f4247a --- /dev/null +++ b/rel @@ -0,0 +1 @@ +26 diff --git a/version b/version new file mode 100644 index 0000000..0e80c92 --- /dev/null +++ b/version @@ -0,0 +1 @@ +1.20.14 diff --git a/xorg-x11-server.spec b/xorg-x11-server.spec.in similarity index 55% rename from xorg-x11-server.spec rename to xorg-x11-server.spec.in index 947af50..1aaf63f 100644 --- a/xorg-x11-server.spec +++ b/xorg-x11-server.spec.in @@ -45,8 +45,8 @@ Summary: X.Org X11 X server Name: xorg-x11-server -Version: 1.20.14 -Release: 26%{?gitdate:.%{gitdate}}%{?dist} +Version: @VERSION@ +Release: @REL@%{?gitdate:.%{gitdate}}%{?dist} URL: http://www.x.org # SPDX License: MIT @@ -567,368 +567,4 @@ find %{inst_srcdir}/hw/xfree86 -name \*.c -delete %changelog -* Wed Oct 25 2023 Peter Hutterer - 1.20.14-26 -- CVE fix for: CVE-2023-5367, CVE-2023-5380 - -* Fri Oct 20 2023 José Expósito -- SPDX migration: license is already SPDX compatible - -* Fri Sep 29 2023 Orion Poplawski - 1.20.14-25 -- Fix xvfb-run --error-file / auth-file options - -* Sat Jul 22 2023 Fedora Release Engineering - 1.20.14-24 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild - -* Tue Apr 25 2023 Olivier Fourdan - 1.20.14-23 -- Backport fix for a deadlock with DRI3 (#2189434) - -* Thu Apr 13 2023 Florian Weimer - 1.20.14-22 -- Make more functions available in fb.h with !FB_ACCESS_WRAPPER - -* Wed Mar 29 2023 Olivier Fourdan - 1.20.14-21 -- CVE fix for: CVE-2023-1393 - -* Thu Feb 23 2023 Olivier Fourdan - 1.20.14-20 -- Fix xvfb-run script with --listen-tcp - -* Thu Feb 09 2023 Iker Pedrosa - 1.20.14-19 -- Remove pam_console from service file (#1822209) - -* Thu Feb 02 2023 Peter Hutterer - 1.20.14-18 -- CVE-2023-0494: potential use-after-free - -* Wed Feb 01 2023 Peter Hutterer - 1.20.14-17 -- Updated conditional fedora statement - -* Tue Jan 17 2023 Olivier Fourdan - 1.20.14-16 -- Use the recommended way to apply conditional patches without - conditionalizing the sources (for byte-swapped clients). - -* Fri Jan 13 2023 Leif Liddy 1.20.14-15 -- Xorg server does not correctly select the DCP for the display - without a quirk on Apple silicon machines (#2152414) - -* Fri Jan 13 2023 Peter Hutterer - 1.20.14-14 -- Disallow byte-swapped clients (#2159489) - -* Wed Jan 11 2023 Olivier Fourdan - 1.20.14-13 -- Rename boolean config value field from bool to boolean to fix drivers - build failures due to a conflict with C++ and stdbool.h - -* Mon Dec 19 2022 Peter Hutterer - 1.20.14-12 -- Fix buggy patch to CVE-2022-46340 - -* Wed Dec 14 2022 Peter Hutterer 1.20.14-11 -- CVE fix for: CVE-2022-4283, CVE-2022-46340, CVE-2022-46341, - CVE-2022-46342, CVE-2022-46343, CVE-2022-46344 - -* Wed Nov 23 2022 Peter Hutterer - 1.20.14-10 -- Drop dependency on xorg-x11-font-utils, it was only there for on - build-time variable that's always the same value anyway (#2145088) - -* Tue Nov 8 2022 Olivier Fourdan - 1.20.14-9 -- Fix CVE-2022-3550, CVE-2022-3551 - -* Sat Jul 23 2022 Fedora Release Engineering - 1.20.14-8 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild - -* Tue Jul 12 2022 Olivier Fourdan - 1.20.14-7 -- Fix CVE-2022-2319/ZDI-CAN-16062, CVE-2022-2320/ZDI-CAN-16070 - -* Wed Apr 13 2022 Dominik Mierzejewski - 1.20.14-6 -- Don't hardcode fps for fake screen (#2054188) - -* Fri Apr 8 2022 Jocelyn Falempe - 1.20.14-5 -- Fix basic graphic mode not working with simpledrm (#2067151) - -* Fri Jan 28 2022 Olivier Fourdan - 1.20.14-4 -- Fix build with GCC 12 (#2047134) - -* Tue Jan 25 2022 Olivier Fourdan - 1.20.14-3 -- Fix crash with NVIDIA proprietary driver with Present (#2046147) - -* Sat Jan 22 2022 Fedora Release Engineering - 1.20.14-2 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild - -* Fri Dec 17 2021 Olivier - 1.20.14-1 -- xserver 1.20.14 - CVE-2021-4008/ZDI-CAN-14192 (#2026059, #2032941) - CVE-2021-4009/ZDI-CAN-14950 (#2026072, #2032943) - CVE-2021-4010/ZDI-CAN-14951 (#2026073, #2032944) - CVE-2021-4011/ZDI-CAN-14952 (#2026074, #2032945) - -* Tue Sep 14 2021 Sahana Prasad - 1.20.11-3 -- Rebuilt with OpenSSL 3.0.0 - -* Fri Jul 23 2021 Fedora Release Engineering - 1.20.11-2 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild - -* Wed Apr 14 2021 Olivier Fourdan - 1.20.11-1 -- xserver 1.20.11 (CVE-2021-3472 / ZDI-CAN-1259) - -* Wed Feb 03 2021 Peter Hutterer 1.20.10-5 -- Drop BuildRequires for flex-devel (#1871101) - -* Mon Feb 1 2021 Olivier Fourdan - 1.20.10-4 -- Remove Xwayland from the xserver builds - -* Thu Jan 28 2021 Fedora Release Engineering - 1.20.10-3 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild - -* Tue Jan 19 2021 Adam Jackson - 1.20.10-2 -- Disable int10 and vbe on RHEL -- Disable DRI1 -- Stop overriding the vendor name - -* Wed Dec 2 2020 Olivier Fourdan - 1.20.10-1 -- xserver 1.20.10 (CVE-2020-14360, CVE-2020-25712) - -* Thu Nov 5 10:35:09 AEST 2020 Peter Hutterer - 1.20.9-3 -- Add BuildRequires for make - -* Wed Nov 04 2020 Peter Hutterer 1.20.9-2 -- Drop BuildRequires to git-core only - -* Thu Oct 8 2020 Olivier Fourdan - 1.20.9-1 -- xserver 1.20.9 + all current fixes from upstream - -* Wed Aug 12 2020 Adam Jackson - 1.20.8-4 -- Enable XC-SECURITY - -* Fri Jul 31 2020 Adam Jackson - 1.20.8-3 -- Fix information disclosure bug in pixmap allocation (CVE-2020-14347) - -* Wed Jul 29 2020 Fedora Release Engineering - 1.20.8-2 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild - -* Mon Mar 30 2020 Olivier Fourdan - 1.20.8-1 -- xserver 1.20.8 -- Backport latest Xwayland randr resolution change emulation support - patches. - -* Wed Mar 18 2020 Olivier Fourdan - 1.20.7-2 -- Fix a crash on closing a window using Present found upstream: - https://gitlab.freedesktop.org/xorg/xserver/issues/1000 - -* Fri Mar 13 2020 Olivier Fourdan - 1.20.7-1 -- xserver 1.20.7 -- backport from stable "xserver-1.20-branch" up to commit ad7364d8d - (for mutter fullscreen unredirect on Wayland) -- Update videodrv minor ABI as 1.20.7 changed the minor ABI version - (backward compatible, API addition in glamor) -- Rebase Xwayland randr resolution change emulation support patches - -* Fri Jan 31 2020 Fedora Release Engineering - 1.20.6-2 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild - -* Mon Nov 25 2019 Olivier Fourdan - 1.20.6-1 -- xserver 1.20.6 - -* Mon Nov 4 2019 Hans de Goede - 1.20.5-9 -- Fix building with new libglvnd-1.2.0 (E)GL headers and pkgconfig files - -* Mon Nov 4 2019 Hans de Goede - 1.20.5-8 -- Backport Xwayland randr resolution change emulation support - -* Thu Aug 29 2019 Olivier Fourdan 1.20.5-7 -- Pick latest fixes from xserver stable branch upstream (rhbz#1729925) - -* Sat Jul 27 2019 Fedora Release Engineering - 1.20.5-6 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild - -* Mon Jul 8 2019 Olivier Fourdan 1.20.5-5 -- Do not include on ARM with glibc to avoid compilation failure. -- Do not force vbe and int10 sdk headers as this enables int10 which does - not build on ARM without - -* Mon Jul 8 2019 Olivier Fourdan 1.20.5-4 -- Fix regression causing screen tearing with upstream xserver 1.20.5 - (rhbz#1726419) - -* Fri Jun 28 2019 Olivier Fourdan 1.20.5-3 -- Remove atomic downstream patches causing regressions (#1714981, #1723715) -- Xwayland crashes (#1708119, #1691745) -- Cursor issue with tablet on Xwayland -- Xorg/modesetting issue with flipping pixmaps with Present (#1645553) - -* Thu Jun 06 2019 Peter Hutterer 1.20.5-2 -- Return AlreadyGrabbed for keycodes > 255 (#1697804) - -* Thu May 30 2019 Adam Jackson - 1.20.5-1 -- xserver 1.20.5 - -* Tue Apr 23 2019 Adam Jackson - 1.20.4-4 -- Fix some non-atomic modesetting calls to be atomic - -* Wed Mar 27 2019 Peter Hutterer 1.20.4-3 -- Fix a Qt scrolling bug, don't reset the valuator on slave switch - -* Thu Mar 21 2019 Adam Jackson - 1.20.4-2 -- Backport an Xwayland crash fix in the Present code - -* Tue Feb 26 2019 Adam Jackson - 1.20.4-1 -- xserver 1.20.4 - -* Sun Feb 03 2019 Fedora Release Engineering - 1.20.3-4 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild - -* Fri Jan 11 2019 Olivier Fourdan - 1.20.3-3 -- More Xwayland/Present fixes from upstream (rhbz#1609181, rhbz#1661748) - -* Thu Dec 06 2018 Olivier Fourdan - 1.20.3-2 -- Xwayland/Present fixes from master upstream - -* Thu Nov 01 2018 Adam Jackson - 1.20.3-1 -- xserver 1.20.3 - -* Mon Oct 15 2018 Adam Jackson - 1.20.2-1 -- xserver 1.20.2 - -* Thu Oct 4 2018 Hans de Goede - 1.20.1-4 -- Rebase patch to use va_gl as vdpau driver on i965 GPUs, re-fix rhbz#1413733 - -* Thu Sep 13 2018 Dave Airlie - 1.20.1-3 -- Build with PIE enabled (this doesn't enable bind now) - -* Mon Sep 10 2018 Olivier Fourdan - 1.20.1-2 -- Include patches from upstream to fix Xwayland crashes - -* Thu Aug 09 2018 Adam Jackson - 1.20.1-1 -- xserver 1.20.1 - -* Sat Jul 14 2018 Fedora Release Engineering - 1.20.0-5 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild - -* Tue Jun 12 2018 Adam Jackson - 1.20.0-4 -- Xorg and Xwayland Requires: libEGL - -* Fri Jun 01 2018 Adam Williamson - 1.20.0-3 -- Backport fixes for RHBZ#1579067 - -* Wed May 16 2018 Adam Jackson - 1.20.0-2 -- Xorg Requires: xorg-x11-drv-libinput - -* Thu May 10 2018 Adam Jackson - 1.20.0-1 -- xserver 1.20 - -* Wed Apr 25 2018 Adam Jackson - 1.19.99.905-2 -- Fix xvfb-run's default depth to be 24 - -* Tue Apr 24 2018 Adam Jackson - 1.19.99.905-1 -- xserver 1.20 RC5 - -* Thu Apr 12 2018 Olivier Fourdan - 1.19.99.904-2 -- Re-fix "use type instead of which in xvfb-run (rhbz#1443357)" which - was overridden inadvertently - -* Tue Apr 10 2018 Adam Jackson - 1.19.99.904-1 -- xserver 1.20 RC4 - -* Mon Apr 02 2018 Adam Jackson - 1.19.99.903-1 -- xserver 1.20 RC3 - -* Tue Feb 13 2018 Olivier Fourdan 1.19.6-5 -- xwayland: avoid race condition on new keymap -- xwayland: Keep separate variables for pointer and tablet foci (rhbz#1519961) -- xvfb-run now support command line option “--auto-display” - -* Fri Feb 09 2018 Fedora Release Engineering - 1.19.6-4 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild - -* Tue Jan 30 2018 Olivier Fourdan 1.19.6-3 -- Avoid generating a core file when the Wayland compositor is gone. - -* Thu Jan 11 2018 Peter Hutterer 1.19.6-2 -- Fix handling of devices with ID_INPUT=null - -* Wed Dec 20 2017 Adam Jackson - 1.19.6-1 -- xserver 1.19.6 - -* Thu Oct 12 2017 Adam Jackson - 1.19.5-1 -- xserver 1.19.5 - -* Thu Oct 05 2017 Olivier Fourdan - 1.19.4-1 -- xserver-1.19.4 -- Backport tablet support for Xwayland - -* Fri Sep 08 2017 Troy Dawson - 1.19.3-9 -- Cleanup spec file conditionals - -* Thu Aug 03 2017 Fedora Release Engineering - 1.19.3-8 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild - -* Thu Jul 27 2017 Fedora Release Engineering - 1.19.3-7 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild - -* Sun Jul 2 2017 Ville Skyttä - 1.19.3-6 -- Use type instead of which in xvfb-run (rhbz#1443357) - -* Thu May 04 2017 Orion Poplawski - 1.19.3-5 -- Enable full build for s390/x - -* Mon Apr 24 2017 Ben Skeggs - 1.19.3-4 -- Default to xf86-video-modesetting on GeForce 8 and newer - -* Fri Apr 07 2017 Adam Jackson - 1.19.3-3 -- Inoculate against a versioning bug with libdrm 2.4.78 - -* Thu Mar 23 2017 Hans de Goede - 1.19.3-2 -- Use va_gl as vdpau driver on i965 GPUs (rhbz#1413733) - -* Wed Mar 15 2017 Adam Jackson - 1.19.3-1 -- xserver 1.19.3 - -* Thu Mar 02 2017 Adam Jackson - 1.19.2-1 -- xserver 1.19.2 - -* Sat Feb 11 2017 Fedora Release Engineering - 1.19.1-4 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild - -* Wed Feb 01 2017 Peter Hutterer 1.19.1-3 -- Fix a few input thread lock issues causing intel crashes (#1384486) - -* Mon Jan 16 2017 Adam Jackson - 1.19.1-2 -- Limit the intel driver only on F26 and up - -* Wed Jan 11 2017 Adam Jackson - 1.19.1-1 -- xserver 1.19.1 - -* Tue Jan 10 2017 Hans de Goede - 1.19.0-4 -- Follow Debian and only default to the intel ddx on gen4 or older intel GPUs - -* Tue Dec 20 2016 Hans de Goede - 1.19.0-3 -- Add one more patch for better integration with the nvidia binary driver - -* Thu Dec 15 2016 Hans de Goede - 1.19.0-2 -- Add some patches for better integration with the nvidia binary driver -- Add a patch from upstream fixing a crash (rhbz#1389886) - -* Wed Nov 23 2016 Olivier Fourdan 1.19.0-1 -- xserver 1.19.0 -- Fix use after free of cursors in Xwayland (rhbz#1385258) -- Fix an issue where some monitors would show only black, or - partially black when secondary GPU outputs are used - -* Tue Nov 15 2016 Peter Hutterer 1.19.0-0.8.rc2 -- Update device barriers for new master devices (#1384432) - -* Thu Nov 3 2016 Hans de Goede - 1.19.0-0.7.rc2 -- Update to 1.19.0-rc2 -- Fix (hopefully) various crashes in FlushAllOutput() (rhbz#1382444) -- Fix Xwayland crashing in glamor on non glamor capable hw (rhbz#1390018) - -* Tue Nov 1 2016 Ben Crocker - 1.19.0-0.6.20161028 -- Fix Config record allocation during startup: if xorg.conf.d directory -- was absent, a segfault resulted. - -* Mon Oct 31 2016 Adam Jackson - 1.19.0-0.5.20161026 -- Use %%autopatch instead of doing our own custom git-am trick - -* Fri Oct 28 2016 Hans de Goede - 1.19.0-0.4.20161026 -- Add missing Requires: libXfont2-devel to -devel sub-package (rhbz#1389711) - -* Wed Oct 26 2016 Hans de Goede - 1.19.0-0.3.20161026 -- Sync with upstream git, bringing in a bunch if bug-fixes -- Add some extra fixes which are pending upstream -- This also adds PointerWarping emulation to Xwayland, which should improve - compatiblity with many games +@CHANGELOG@ diff --git a/xvfb-run.sh b/xvfb-run.sh new file mode 100644 index 0000000..dec7dfc --- /dev/null +++ b/xvfb-run.sh @@ -0,0 +1,200 @@ +#!/bin/sh +# --- T2-COPYRIGHT-NOTE-BEGIN --- +# This copyright note is auto-generated by ./scripts/Create-CopyPatch. +# +# T2 SDE: package/.../xorg-server/xvfb-run.sh +# Copyright (C) 2005 The T2 SDE Project +# Copyright (C) XXXX - 2005 Debian +# +# More information can be found in the files COPYING and README. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License. A copy of the +# GNU General Public License can be found in the file COPYING. +# --- T2-COPYRIGHT-NOTE-END --- + +# $Id$ +# from: http://necrotic.deadbeast.net/xsf/XFree86/trunk/debian/local/xvfb-run + +# 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, xbase-clients, and xfonts-base. + +set -e + +PROGNAME=xvfb-run +SERVERNUM=99 +AUTHFILE= +ERRORFILE=/dev/null +STARTWAIT=3 +XVFBARGS="-screen 0 640x480x24" +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 +if ! expr "$DEFCOLUMNS" : "[[:digit:]]\+$" >/dev/null 2>&1; then + DEFCOLUMNS=80 +fi + +# 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 <&2 + exit 2 +fi + +if ! type xauth >/dev/null; then + error "xauth command not found" + exit 3 +fi + +# Set up the temp dir for the pid and X authorization file +XVFB_RUN_TMPDIR="$(mktemp --directory --tmpdir $PROGNAME.XXXXXX)" +# If the user did not specify an X authorization file to use, set up a temporary +# directory to house one. +if [ -z "$AUTHFILE" ]; then + AUTHFILE=$(mktemp -p "$XVFB_RUN_TMPDIR" Xauthority.XXXXXX) +fi + +# Start Xvfb. +MCOOKIE=$(mcookie) + +if [ -z "$AUTO_DISPLAY" ]; then + # Old style using a pre-computed SERVERNUM + XAUTHORITY=$AUTHFILE Xvfb ":$SERVERNUM" $XVFBARGS $LISTENTCP >>"$ERRORFILE" \ + 2>&1 & + XVFBPID=$! +else + # New style using Xvfb to provide a free display + PIDFILE=$(mktemp -p "$XVFB_RUN_TMPDIR" pid.XXXXXX) + SERVERNUM=$(XAUTHORITY=$AUTHFILE Xvfb -displayfd 1 $XVFBARGS $LISTENTCP \ + 2>"$ERRORFILE" & echo $! > $PIDFILE) + XVFBPID=$(cat $PIDFILE) +fi +sleep "$STARTWAIT" + +XAUTHORITY=$AUTHFILE xauth source - << EOF >>"$ERRORFILE" 2>&1 +add :$SERVERNUM $XAUTHPROTO $MCOOKIE +EOF + +# Start the command and save its exit status. +set +e +DISPLAY=:$SERVERNUM XAUTHORITY=$AUTHFILE "$@" 2>&1 +RETVAL=$? +set -e + +# Kill Xvfb now that the command has exited. +kill $XVFBPID + +# Clean up. +XAUTHORITY=$AUTHFILE xauth remove ":$SERVERNUM" >"$ERRORFILE" 2>&1 +if [ -n "$XVFB_RUN_TMPDIR" ]; then + if ! rm -r "$XVFB_RUN_TMPDIR"; then + error "problem while cleaning up temporary directory" + exit 5 + fi +fi + +# Return the executed command's exit status. +exit $RETVAL + +# vim:set ai et sts=4 sw=4 tw=80: