Package: xorg Version: 7.5+3 Severity: wishlist Tags: patch User: ubuntu-de...@lists.ubuntu.com Usertags: origin-ubuntu lucid ubuntu-patch
Hello, In our vendetta for faster boot I examined x11-common's Xsession.d scripts and noticed that they call a lot of external programs (grep several times, which) and run some code which is unlikely to be useful on many machines (such as ~/.Xresources). Attached patch streamlines the scripts to prefer shell builtins over external programs. (Details see changelog). Thanks for considering! Martin -- Martin Pitt | http://www.piware.de Ubuntu Developer (www.ubuntu.com) | Debian Developer (www.debian.org)
diff -Nru xorg-7.5+1ubuntu2/debian/changelog xorg-7.5+1ubuntu3/debian/changelog --- xorg-7.5+1ubuntu2/debian/changelog 2010-01-26 00:38:13.000000000 +0100 +++ xorg-7.5+1ubuntu3/debian/changelog 2010-02-18 23:14:11.000000000 +0100 @@ -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.p...@ubuntu.com> Thu, 18 Feb 2010 23:02:22 +0100 + xorg (1:7.5+1ubuntu2) lucid; urgency=low [ David Planella ] diff -Nru xorg-7.5+1ubuntu2/debian/local/Xsession.d/20x11-common_process-args xorg-7.5+1ubuntu3/debian/local/Xsession.d/20x11-common_process-args --- xorg-7.5+1ubuntu2/debian/local/Xsession.d/20x11-common_process-args 2010-01-25 10:53:09.000000000 +0100 +++ xorg-7.5+1ubuntu3/debian/local/Xsession.d/20x11-common_process-args 2010-02-18 23:13:59.000000000 +0100 @@ -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 "$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 -Nru xorg-7.5+1ubuntu2/debian/local/Xsession.d/30x11-common_xresources xorg-7.5+1ubuntu3/debian/local/Xsession.d/30x11-common_xresources --- xorg-7.5+1ubuntu2/debian/local/Xsession.d/30x11-common_xresources 2008-06-25 04:05:17.000000000 +0200 +++ xorg-7.5+1ubuntu3/debian/local/Xsession.d/30x11-common_xresources 2010-02-18 22:58:38.000000000 +0100 @@ -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 -Nru xorg-7.5+1ubuntu2/debian/local/Xsession.d/50x11-common_determine-startup xorg-7.5+1ubuntu3/debian/local/Xsession.d/50x11-common_determine-startup --- xorg-7.5+1ubuntu2/debian/local/Xsession.d/50x11-common_determine-startup 2008-06-25 04:05:17.000000000 +0200 +++ xorg-7.5+1ubuntu3/debian/local/Xsession.d/50x11-common_determine-startup 2010-02-18 22:59:32.000000000 +0100 @@ -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 @@ # 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 -Nru xorg-7.5+1ubuntu2/debian/local/Xsession.d/90x11-common_ssh-agent xorg-7.5+1ubuntu3/debian/local/Xsession.d/90x11-common_ssh-agent --- xorg-7.5+1ubuntu2/debian/local/Xsession.d/90x11-common_ssh-agent 2008-08-06 01:37:18.000000000 +0200 +++ xorg-7.5+1ubuntu3/debian/local/Xsession.d/90x11-common_ssh-agent 2010-02-18 23:00:35.000000000 +0100 @@ -6,7 +6,7 @@ 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
signature.asc
Description: Digital signature