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

xorg: Changes to 'ubuntu'



 debian/changelog                                       |   25 +++++++++++---
 debian/local/Xsession.d/20x11-common_process-args      |    6 ++-
 debian/local/Xsession.d/30x11-common_xresources        |   30 +++++++----------
 debian/local/Xsession.d/50x11-common_determine-startup |    4 +-
 debian/local/Xsession.d/90x11-common_ssh-agent         |    2 -
 5 files changed, 42 insertions(+), 25 deletions(-)

New commits:
commit 41e5a31b82a4dfe441a35d886c3949da26a338aa
Author: Bryce Harrington <bryce@bryceharrington.org>
Date:   Thu Feb 18 19:27:12 2010 -0800

    Martin's patch

diff --git a/debian/changelog b/debian/changelog
index d7ac53e..8baeb35 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,18 @@
+xorg (1:7.5+1ubuntu3) lucid; urgency=low
+
+  * Improve startup speed of Xsession.d scripts by eliminating all unnecessary
+    external program calls:
+    - In 20x11-common_process-args, cat $OPTIONFILE once into a variable and
+      use POSIX variable substitution in all scripts instead of calling grep
+      for every single test.
+    - Use shell built in "type" instead of external "which" to test for
+      programs.
+    - 30x11-common_xresources: Swap the order of tests to keep the most
+      unlikely (like "~/.Xresources exists") outside, to avoid running the
+      other tests (like "xrdb exists") on systems which don't use Xresources.
+
+ -- Martin Pitt <martin.pitt@ubuntu.com>  Thu, 18 Feb 2010 23:02:22 +0100
+
 xorg (1:7.5+1ubuntu2) lucid; urgency=low
 
   [ David Planella ]
diff --git a/debian/local/Xsession.d/20x11-common_process-args b/debian/local/Xsession.d/20x11-common_process-args
index 33696ad..7395c15 100644
--- a/debian/local/Xsession.d/20x11-common_process-args
+++ b/debian/local/Xsession.d/20x11-common_process-args
@@ -2,6 +2,10 @@
 
 # This file is sourced by Xsession(5), not executed.
 
+# read OPTIONFILE
+OPTIONS=$(cat "$OPTIONFILE") || true
+
+
 # Determine how many arguments were provided.
 case $# in
   0)
@@ -12,7 +16,7 @@ case $# in
     case "$1" in
       failsafe)
         # Failsafe session was requested.
-        if grep -qs ^allow-failsafe "$OPTIONFILE"; then
+        if [ "${OPTIONS#*allow-failsafe}" != "$OPTIONS" ]; then
           if [ -e /usr/bin/x-terminal-emulator ]; then
             if [ -x /usr/bin/x-terminal-emulator ]; then
               exec x-terminal-emulator -geometry +1+1
diff --git a/debian/local/Xsession.d/30x11-common_xresources b/debian/local/Xsession.d/30x11-common_xresources
index f9f6e13..9f39de9 100644
--- a/debian/local/Xsession.d/30x11-common_xresources
+++ b/debian/local/Xsession.d/30x11-common_xresources
@@ -4,25 +4,23 @@
 
 # If xrdb (from xbase-clients) is installed, merge system-wide X resources.
 # Then merge the user's X resources, if the options file is so configured.
-if /usr/bin/which xrdb >/dev/null 2>&1; then
-  if [ -d "$SYSRESOURCES" ]; then
-    RESOURCEFILES=$(run-parts --list $SYSRESOURCES)
-    if [ -n "$RESOURCEFILES" ]; then
-      for RESOURCEFILE in $RESOURCEFILES; do
-        xrdb -merge $RESOURCEFILE
-      done
-    fi
+if [ -d "$SYSRESOURCES" ] && type xrdb >/dev/null 2>&1; then
+  RESOURCEFILES=$(run-parts --list $SYSRESOURCES)
+  if [ -n "$RESOURCEFILES" ]; then
+    for RESOURCEFILE in $RESOURCEFILES; do
+      xrdb -merge $RESOURCEFILE
+    done
   fi
+fi
 
-  if grep -qs ^allow-user-resources "$OPTIONFILE"; then
-    if [ -f "$USRRESOURCES" ]; then
-      xrdb -merge $USRRESOURCES
-    fi
+if [ "${OPTIONS#*allow-user-resources}" != "$OPTIONS" ] && [ -f "$USRRESOURCES" ]; then
+  if type xrdb >/dev/null 2>&1; then
+    xrdb -merge $USRRESOURCES
+  else
+    # Comment out this command if you desire a legacy-free X environment, and find
+    # the warning spurious.
+    message "warning: xrdb command not found; X resources not merged."
   fi
-else
-  # Comment out this command if you desire a legacy-free X environment, and find
-  # the warning spurious.
-  message "warning: xrdb command not found; X resources not merged."
 fi
 
 # vim:set ai et sts=2 sw=2 tw=80:
diff --git a/debian/local/Xsession.d/50x11-common_determine-startup b/debian/local/Xsession.d/50x11-common_determine-startup
index 2a669a0..e2479fd 100644
--- a/debian/local/Xsession.d/50x11-common_determine-startup
+++ b/debian/local/Xsession.d/50x11-common_determine-startup
@@ -7,7 +7,7 @@
 # executable, fall back to looking for a user's custom X session script, if
 # allowed by the options file.
 if [ -z "$STARTUP" ]; then
-  if grep -qs ^allow-user-xsession "$OPTIONFILE"; then
+  if [ "${OPTIONS#*allow-user-session}" != "$OPTIONS" ]; then
     for STARTUPFILE in "$USERXSESSION" "$ALTUSERXSESSION"; do
       if [ -e "$STARTUPFILE" ]; then
         if [ -x "$STARTUPFILE" ]; then
@@ -36,7 +36,7 @@ fi
 # If we still have not found a startup program, give up.
 if [ -z "$STARTUP" ]; then
   ERRMSG="unable to start X session ---"
-  if grep -qs ^allow-user-xsession "$OPTIONFILE"; then
+  if [ "${OPTIONS#*allow-user-session}" != "$OPTIONS" ]; then
     ERRMSG="$ERRMSG no \"$USERXSESSION\" file, no \"$ALTUSERXSESSION\" file,"
   fi
   errormsg "$ERRMSG no session managers, no window managers, and no terminal" \
diff --git a/debian/local/Xsession.d/90x11-common_ssh-agent b/debian/local/Xsession.d/90x11-common_ssh-agent
index 05a16c5..bc9b2a0 100644
--- a/debian/local/Xsession.d/90x11-common_ssh-agent
+++ b/debian/local/Xsession.d/90x11-common_ssh-agent
@@ -6,7 +6,7 @@ STARTSSH=
 SSHAGENT=/usr/bin/ssh-agent
 SSHAGENTARGS=
 
-if grep -qs ^use-ssh-agent "$OPTIONFILE"; then
+if [ "${OPTIONS#*use-ssh-agent}" != "$OPTIONS" ]; then
   if [ -x "$SSHAGENT" ] && [ -z "$SSH_AUTH_SOCK" ] \
      && [ -z "$SSH2_AUTH_SOCK" ]; then
     STARTSSH=yes


Reply to: