Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Narvaez <dwnarvaez@gmail.com>2012-07-11 13:02:06 (GMT)
committer Daniel Narvaez <dwnarvaez@gmail.com>2012-07-11 13:02:06 (GMT)
commit253ff4075507d7d4d3e858c37915ff3cbbbd6cfa (patch)
tree5eb095fccaa7be7a29498fc070eedc074bdf8fcc
parent5f89123080e3b35e34cbdc9e2f05cd705c812a74 (diff)
Find a free display rather than hardcoding it
-rw-r--r--.gitignore1
-rw-r--r--Makefile21
-rw-r--r--scripts/find-free-display.c25
-rwxr-xr-xscripts/run-dogtail-tests3
-rwxr-xr-xscripts/shell/start-sugar3
5 files changed, 41 insertions, 12 deletions
diff --git a/.gitignore b/.gitignore
index e47df0f..ed6ca46 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,4 +6,5 @@ logs/*.log
logs/*.tar
logs/all-logs.tar.bz2
scripts/list-outputs
+scripts/find-free-display
config
diff --git a/Makefile b/Makefile
index 11677ce..e5e781b 100644
--- a/Makefile
+++ b/Makefile
@@ -3,12 +3,7 @@ LOGFILE = $(CURDIR)/logs/build-$(TIMESTAMP).log
SCRIPTS = $(CURDIR)/scripts
JHBUILD = $(CURDIR)/install/bin/jhbuild -f $(SCRIPTS)/jhbuildrc
LOG = $(SCRIPTS)/log-command
-
-ifdef SUGAR_SESSION
-XINITDISPLAY = :100
-else
-XINITDISPLAY = :99
-endif
+XINITDISPLAY = `$(SCRIPTS)/find-free-display`
# The buildbot shell does not handle script properly. It's unnecessary
# anyway because we can't use interactive scripts there.
@@ -25,10 +20,16 @@ submodules:
git submodule update
XRANDR_LIBS = $(shell pkg-config --libs xrandr x11)
+X11_LIBS = $(shell pkg-config --libs x11)
-scripts/list-outputs:
+scripts/list-outputs: scripts/list-outputs.c
gcc -o scripts/list-outputs scripts/list-outputs.c $(XRANDR_LIBS)
+scripts/find-free-display: scripts/find-free-display.c
+ gcc -o scripts/find-free-display scripts/find-free-display.c $(X11_LIBS)
+
+x11-utils: scripts/list-outputs scripts/find-free-display
+
check-system:
$(TYPESCRIPT) $(SCRIPTS)/check-system $(LOGFILE)
@@ -48,13 +49,13 @@ build: build-glucose build-fructose
build-%:
$(TYPESCRIPT) "$(JHBUILD) buildone $*" $(LOGFILE)
-run: scripts/list-outputs
+run: x11-utils
xinit $(SCRIPTS)/xinitrc -- $(XINITDISPLAY) &>>$(LOGFILE)
-test: scripts/list-outputs
+test: x11-utils
$(LOG) "$(SCRIPTS)/run-dogtail-tests" $(LOGFILE)
-shell:
+shell: x11-utils
@cd source; \
PS1="[sugar-build \W]$$ " \
PATH=$(PATH):$(SCRIPTS)/shell \
diff --git a/scripts/find-free-display.c b/scripts/find-free-display.c
new file mode 100644
index 0000000..4a07131
--- /dev/null
+++ b/scripts/find-free-display.c
@@ -0,0 +1,25 @@
+#include <stdio.h>
+#include <X11/extensions/Xrandr.h>
+
+int main(int argc, char **argv)
+{
+ int port;
+
+ for (port = 99; port < 1000; port++) {
+ char display_name[255];
+
+ sprintf(display_name, ":%d", port);
+ Display *dpy = XOpenDisplay(display_name);
+
+ if (!dpy) {
+ printf(display_name);
+ return 0;
+ } else {
+ XCloseDisplay(dpy);
+ }
+ }
+
+ printf("No free display found");
+
+ return 0;
+}
diff --git a/scripts/run-dogtail-tests b/scripts/run-dogtail-tests
index dcef0b8..e588645 100755
--- a/scripts/run-dogtail-tests
+++ b/scripts/run-dogtail-tests
@@ -3,8 +3,9 @@
scriptsdir=`dirname "$0"`
rootdir=`dirname "$scriptsdir"`
testsdir=$rootdir/tests
+scriptsdir=$rootdir/scripts
logsdir=$rootdir/logs
-display=:99
+display=`$scriptsdir/find-free-display`
resolution=1024x768x16
minver="0.8.0"
diff --git a/scripts/shell/start-sugar b/scripts/shell/start-sugar
index 86766fa..0bb1b5c 100755
--- a/scripts/shell/start-sugar
+++ b/scripts/shell/start-sugar
@@ -2,5 +2,6 @@
shelldir=`dirname "$0"`
scriptsdir=`dirname "$shelldir"`
+display=`$scriptsdir/find-free-display`
-xinit $scriptsdir/xinitrc -- :99
+xinit $scriptsdir/xinitrc -- $display