~ubuntu-branches/ubuntu/precise/xorg/precise

« back to all changes in this revision

Viewing changes to debian/local/Failsafe/failsafeXServer

  • Committer: Bazaar Package Importer
  • Author(s): Timo Aaltonen, Bryce Harrington, Timo Aaltonen
  • Date: 2011-06-14 15:39:40 UTC
  • mfrom: (6.3.18 sid)
  • Revision ID: james.westby@ubuntu.com-20110614153940-b9i0fr1v2kchiozh
Tags: 1:7.6+7ubuntu1
* Merge from Debian unstable, remaining changes:
  - Add apport hook
  - Demote xfonts-{75DPI,100DPI} to Suggests. Demote xfonts-scalable to
    Recommends.
  - debian/local/Xsession:
    Truncate xsession-errors on startup if too big
  - debian/local/Xsession.d/20x11-common_process-args:
    Add support for session command containing args.
  - debian/local/Xsession.d/60x11-common_localhost:
    Authorise all processes running with the user's credentials to connect
    to the server.
  - debian/rules, debian/control:
    Add dependencies on x11-common, and symlink /usr/share/doc directories
    of all packages to x11-common's.
  - debian/scripts/vars.*:
    + Don't drop wacom from input-all.
    + Add -vmmouse to input-all for amd64 and i386.
    + Add -qxl to video-all for amd64 and i386.
    + Add -geode to video-all for i386.
    + Drop video drivers that are likely irrelevant for ARM.
  - debian/xserver-xorg.postinst.in: Also migrate users from psb → vesa.

[ Bryce Harrington ]
* apport/source_xorg.py:
  - Move Failsafe-X out of the xorg package to xdiagnose
    (LP: #480744)
  - Simplify answers for bug reporters filing post-release reports.
    (LP: #778758)
  - Remove attach_drm_info().  This is useful info but we use it very
    infrequently, and it is already available in other log files.  But the
    call makes bug reports a bit cluttered since it adds a lot of lines to
    the report itself.

[ Timo Aaltonen ]
* rules: A stampfile generation was commented out by mistake, uncomment
  it.
* Rework the x11-common.{postinst,postrm,preinst} failsafe conffile
  handling, the previous ones added in 1:7.6+4ubuntu1 were wrong too.
* scripts/vars.{amd64,i386,powerpc}: Remove apm, ark, chips, i128, i740,
  rendition, s3virge, tseng, voodoo from xserver-xorg-video-all
  dependencies. They are unmaintained and obsolete.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/bin/bash
2
 
 
3
 
# $Id:$
4
 
#
5
 
# This provides a stripped down 'failsafe' mode for situations
6
 
# where X is failing to start up.
7
 
 
8
 
# Author: Bryce W. Harrington <bryce@canonical.com>
9
 
 
10
 
# Copyright 2007 Canonical, Ltd
11
 
#
12
 
# This is free software; you may redistribute it and/or modify
13
 
# it under the terms of the GNU General Public License as
14
 
# published by the Free Software Foundation; either version 2,
15
 
# or (at your option) any later version.
16
 
#
17
 
# This is distributed in the hope that it will be useful, but
18
 
# WITHOUT ANY WARRANTY; without even the implied warranty of
19
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
 
# GNU General Public License for more details.
21
 
#
22
 
# You should have received a copy of the GNU General Public License with
23
 
# the Debian operating system, in /usr/share/common-licenses/GPL;  if
24
 
# not, write to the Free Software Foundation, Inc., 59 Temple Place,
25
 
# Suite 330, Boston, MA 02111-1307 USA
26
 
 
27
 
# Upstart jobs don't have a particular environment, we need to source the
28
 
# variables needed for localization ourselves
29
 
if [ -r /etc/default/locale ]; then
30
 
    . /etc/default/locale
31
 
    export LANG LANGUAGE
32
 
elif [ -r /etc/environment ]; then
33
 
    . /etc/environment
34
 
    export LANG LANGUAGE
35
 
fi
36
 
 
37
 
xorg_conf_failsafe=${BPX_XORG_CONF_FAILSAFE:-"/etc/X11/xorg.conf.failsafe"}
38
 
xorg_conf=${BPX_XORG_CONF:-"/etc/X11/xorg.conf"}
39
 
fallback_driver=${BPX_FALLBACK_DRIVER:-"vesa"}
40
 
client=${BPX_CLIENT:-"/etc/gdm/failsafeXinit"}
41
 
clientargs=${BPX_CLIENTARGS:-$xorg_conf_failsafe}
42
 
blacklist=${BPX_BLACKLIST:-"/etc/gdm/failsafeBlacklist"}
43
 
main_driver=${BPX_DRIVER:-"vesa"}
44
 
checkduration=${BPX_CHECK_DURATION:-30}
45
 
failsafe_log=${BPX_LOG:-"/var/log/gdm/failsafe.log"}
46
 
 
47
 
server=${BPX_SERVER:-/usr/bin/X}
48
 
serverargs=${BPX_SERVERARGS:-"$*"}
49
 
serverargs="${serverargs} -br -once -config $xorg_conf_failsafe -logfile /var/log/Xorg.failsafe.log"
50
 
   # -br:      Black background
51
 
   # -once:    Terminate server after one session
52
 
   # -config:  Specify location of xorg.conf file to use
53
 
   #           Note: Only root can specify absolute paths
54
 
   # -logfile: Don't overwrite Xorg.0.log
55
 
 
56
 
warn() {
57
 
    echo "Warning:  $1" 1>&2
58
 
}
59
 
 
60
 
is_installed() {
61
 
    prog=$1
62
 
    need=$2
63
 
    /usr/bin/which $prog > /dev/null 2>&1
64
 
    err=$?
65
 
    if [ ! $err = 0 ]; then
66
 
        warn "Could not $need because $prog is not installed ($err)"
67
 
        return $err
68
 
    fi
69
 
    return 0
70
 
}
71
 
 
72
 
# Tests if the given pciids are in numerical order from least to greatest
73
 
# (e.g., $a <= $b <= $c <= ...)
74
 
pciids_in_order() {
75
 
    lastid=0
76
 
    for pciid in $* ; do
77
 
        # Strip embedded : and convert hex to dec
78
 
        id=$((0x${pciid/:/}))
79
 
        if [ $id -lt $lastid ]; then
80
 
            return 1
81
 
        fi
82
 
        lastid=$id
83
 
    done
84
 
    return 0
85
 
}
86
 
 
87
 
get_driver() {
88
 
    machine=$(uname -m)
89
 
    if grep -q -E '(nouveau|drm)fb' /proc/fb; then
90
 
        echo "fbdev"
91
 
    elif [ $machine = "ppc" ]; then
92
 
        echo "fbdev"
93
 
    elif [ $machine = "powerpc" ]; then
94
 
        echo "fbdev"
95
 
    elif [ $machine = "ppc64" ]; then
96
 
        echo "fbdev"
97
 
    else
98
 
        echo $fallback_driver
99
 
    fi
100
 
    return 0
101
 
}
102
 
 
103
 
# Check if we've already attempted a failsafe session without success
104
 
if [ -e "$failsafe_log" ]; then
105
 
    cur_time=$(date +"%s")
106
 
    last_run=$(tail -n 1 $failsafe_log | cut -d' ' -f1)
107
 
    time_diff=$(expr $cur_time - $last_run)
108
 
    if [ $time_diff -lt $checkduration ]; then
109
 
        warn "Failsafe mode was already attempted within $checkduration seconds."
110
 
        warn "Falling back to gdm to report the issue."
111
 
        exit 1
112
 
    fi
113
 
fi
114
 
 
115
 
# When failsafe mode is activated, check the blacklist for systems we
116
 
# know do not support VESA 800x600/256
117
 
#      Use EDID + PCI IDs as key to lookup (Can get PCI IDs from discover)
118
 
#      If the display does not give EDID info, then use VGA 640x480/16 mode
119
 
#      If a matching entry is found, then use VGA 640x480/16 mode
120
 
driver=$(get_driver)
121
 
 
122
 
# Generate a fresh xorg.conf.failsafe using identified driver
123
 
cat > $xorg_conf_failsafe <<EOF
124
 
Section "Device"
125
 
        Identifier      "Configured Video Device"
126
 
        Driver          "$driver"
127
 
EndSection
128
 
 
129
 
Section "Monitor"
130
 
        Identifier      "Configured Monitor"
131
 
EndSection
132
 
 
133
 
Section "Screen"
134
 
        Identifier      "Default Screen"
135
 
        Monitor         "Configured Monitor"
136
 
        Device          "Configured Video Device"
137
 
EndSection
138
 
EOF
139
 
 
140
 
md5xorg=$(md5sum $xorg_conf)
141
 
date +"%s $md5xorg" >> $failsafe_log
142
 
if [ $? -ne 0 ]; then
143
 
    warn "Cannot write to $failsafe_log"
144
 
fi
145
 
 
146
 
if pidof /usr/sbin/gdm ; then
147
 
    clientargs="${clientargs} with-gdm"
148
 
fi
149
 
 
150
 
# Stop gdm if it's running, otherwise it will attempt to manage the display
151
 
# out from under us
152
 
if pidof /usr/sbin/gdm ; then
153
 
    exec kill -STOP $PPID
154
 
fi
155
 
 
156
 
echo "xinit $client $clientargs -- $server $serverargs"
157
 
xinit $client $clientargs -- $server $serverargs
158
 
 
159
 
# This seems to cause gdm to attempt to start a new x session
160
 
#exec kill -USR1 `cat /var/run/gdm.pid`