[libx11-keyboard-perl] 04/06: debian/rules: Get unit tests working with launching an Xvfb during package build.

Mike Gabriel sunweaver at debian.org
Sun Sep 21 19:08:13 UTC 2014


This is an automated email from the git hooks/post-receive script.

sunweaver pushed a commit to branch master
in repository libx11-keyboard-perl.

commit 3ae5cbb225c80de83b0fe6a5ec955546eeb5db71
Author: Mike Gabriel <mike.gabriel at das-netzwerkteam.de>
Date:   Sat Sep 20 17:49:47 2014 +0200

    debian/rules: Get unit tests working with launching an Xvfb during package build.
---
 debian/control                            |  3 ++-
 debian/helpers/X11_get_unused_socket      | 15 +++++++++++++++
 debian/helpers/X11_launch_Xvfb            |  9 +++++++++
 debian/helpers/X11_used_namespace_sockets | 13 +++++++++++++
 debian/rules                              | 13 +++++++++++++
 5 files changed, 52 insertions(+), 1 deletion(-)

diff --git a/debian/control b/debian/control
index cd8bb2a..5c8cca6 100644
--- a/debian/control
+++ b/debian/control
@@ -7,8 +7,9 @@ Uploaders:
  Mike Gabriel <sunweaver at debian.org>,
 Build-Depends:
  debhelper (>= 9),
-Build-Depends-Indep:
  perl,
+ libx11-protocol-perl,
+ xvfb,
 Standards-Version: 3.9.5
 Homepage: https://metacpan.org/release/X11-Keyboard
 Vcs-Git: git://anonscm.debian.org/collab-maint/libx11-keybord-perl.git
diff --git a/debian/helpers/X11_get_unused_socket b/debian/helpers/X11_get_unused_socket
new file mode 100755
index 0000000..8fa8422
--- /dev/null
+++ b/debian/helpers/X11_get_unused_socket
@@ -0,0 +1,15 @@
+#!/usr/bin/perl
+
+my $X11_PORT = shift;
+my $X11_USED_NAMESPACE_SOCKETS = shift;
+
+for ($i=$X11_PORT; $displ_found ne "true"; $i++) {
+
+	if( "$X11_USED_NAMESPACE_SOCKETS" =~ m/\|$i\|/) {
+		$displ_found="false";
+	} else {
+	    $displ_found="true";
+	    print $i;
+	}
+
+}
diff --git a/debian/helpers/X11_launch_Xvfb b/debian/helpers/X11_launch_Xvfb
new file mode 100755
index 0000000..4edfb71
--- /dev/null
+++ b/debian/helpers/X11_launch_Xvfb
@@ -0,0 +1,9 @@
+#!/bin/bash
+
+set -x
+
+DISPLAY=$1
+XVFB_BINARY=$(type -p Xvfb)
+
+${XVFB_BINARY} -nolisten TCP :${DISPLAY} 1>/dev/null 2>/dev/null &
+echo $$
\ No newline at end of file
diff --git a/debian/helpers/X11_used_namespace_sockets b/debian/helpers/X11_used_namespace_sockets
new file mode 100755
index 0000000..09b5b58
--- /dev/null
+++ b/debian/helpers/X11_used_namespace_sockets
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+ss -xl | grep @/tmp/.X11-unix | \
+awk '
+{
+	n=split($0,lines,"\n");
+	for(i=1;i<=n;i++){
+		line_delim=split(lines[i],cols," ");
+		col_delim=split(cols[5],sockets,"/X");
+		printf ("|%s|\n",sockets[col_delim]);
+	};
+};
+'
diff --git a/debian/rules b/debian/rules
index 2d33f6a..4d86780 100755
--- a/debian/rules
+++ b/debian/rules
@@ -1,4 +1,17 @@
 #!/usr/bin/make -f
 
+X11_PORT=40
+X11_USED_NAMESPACE_SOCKETS = $(shell debian/helpers//X11_used_namespace_sockets)
+export DISPLAY=$(shell debian/helpers/X11_get_unused_socket $(X11_PORT) "$(X11_USED_NAMESPACE_SOCKETS)")
+XVFB_PID=$(shell debian/helpers/X11_launch_Xvfb $(DISPLAY))
+
 %:
 	dh $@
+
+override_dh_auto_test:
+	DISPLAY=":$(DISPLAY)" dh_auto_test
+	# if the below fails, the build chroot will tear down the running Xvfb process...
+	-kill -SIGKILL $(XVFB_PID)
+
+get-orig-source:
+	uscan --noconf --force-download --rename --download-current-version --destdir=..

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libx11-keyboard-perl.git



More information about the Pkg-perl-cvs-commits mailing list