~ubuntu-branches/ubuntu/trusty/xorg/trusty-updates

« back to all changes in this revision

Viewing changes to debian/local/Failsafe/failsafeXinit

  • 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
 
# This provides a stripped down 'failsafe' mode for situations
3
 
# where X is failing to start up.
4
 
 
5
 
# Author: Bryce W. Harrington <bryce@canonical.com>
6
 
 
7
 
# Copyright 2007, 2008 Canonical, Ltd
8
 
#
9
 
# This is free software; you may redistribute it and/or modify
10
 
# it under the terms of the GNU General Public License as
11
 
# published by the Free Software Foundation; either version 2,
12
 
# or (at your option) any later version.
13
 
#
14
 
# This is distributed in the hope that it will be useful, but
15
 
# WITHOUT ANY WARRANTY; without even the implied warranty of
16
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 
# GNU General Public License for more details.
18
 
#
19
 
# You should have received a copy of the GNU General Public License with
20
 
# the Debian operating system, in /usr/share/common-licenses/GPL;  if
21
 
# not, write to the Free Software Foundation, Inc., 59 Temple Place,
22
 
# Suite 330, Boston, MA 02111-1307 USA
23
 
 
24
 
xorg_conf=$1
25
 
with_gdm=$2
26
 
 
27
 
display=0
28
 
xorg_log="/var/log/Xorg.${display}.log"
29
 
gdm_log="/var/log/gdm/:${display}.log"
30
 
gdm_log_1="/var/log/gdm/:${display}.log.1"
31
 
gdm_log_2="/var/log/gdm/:${display}.log.2"
32
 
apport_hook="/usr/share/apport/xserver_hook"
33
 
 
34
 
app_width=600
35
 
app_height=300
36
 
app_title="$(gettext 'Ubuntu Failsafe-X')"
37
 
 
38
 
timestamp=$(date +%y%m%d%H%M%S)
39
 
 
40
 
. gettext.sh
41
 
TEXTDOMAIN=failsafexinit
42
 
export TEXTDOMAIN
43
 
TEXTDOMAINDIR=/usr/share/locale-langpack
44
 
export TEXTDOMAINDIR
45
 
 
46
 
display_main_menu() {
47
 
    zenity --list \
48
 
        --radiolist \
49
 
        --title "$app_title" \
50
 
        --width $app_width --height $app_height \
51
 
        --text "$(gettext 'What would you like to do?')" \
52
 
        --column "" --column "$(gettext 'Choice')" --column "" \
53
 
          TRUE   LOW_RES_MODE "$(gettext 'Run Ubuntu in low-graphics mode for just one session')" \
54
 
          FALSE  RECONFIGURE "$(gettext 'Reconfigure graphics')" \
55
 
          FALSE  TROUBLESHOOT "$(gettext 'Troubleshoot the error')" \
56
 
          FALSE  EXIT_TO_CONSOLE "$(gettext 'Exit to console login')" \
57
 
          FALSE  RESTART_X "$(gettext 'Restart X')" \
58
 
        --hide-column 2
59
 
 
60
 
# TODO:          3 FILE_BUG "Report a bug about this failure" \
61
 
}
62
 
 
63
 
display_reconfigure_menu() {
64
 
    # TODO:  Only display SELECT_BACKUP if backups are available
65
 
 
66
 
    zenity --list \
67
 
        --radiolist \
68
 
        --title "$app_title : $(gettext 'Reconfiguration')" \
69
 
        --text "$(gettext 'How would you like to reconfigure your display?')" \
70
 
        --width $app_width --height $app_height \
71
 
        --column "" --column "$(gettext 'Choice')" --column "" \
72
 
          TRUE   DEFAULT_CONFIG "$(gettext 'Use default (generic) configuration')" \
73
 
          FALSE  RUN_XORGCONF "$(gettext 'Create new configuration for this hardware')" \
74
 
          FALSE  SELECT_BACKUP "$(gettext 'Use your backed-up configuration')" \
75
 
        --hide-column 2
76
 
}
77
 
 
78
 
display_troubleshooting_menu() {
79
 
    zenity --list \
80
 
        --radiolist \
81
 
        --title "$app_title : $(gettext 'Troubleshooting')" \
82
 
        --text "$(gettext 'What information would you like to review?')" \
83
 
        --width $app_width --height $app_height \
84
 
        --column "" --column "$(gettext 'Choice')" --column "" \
85
 
          TRUE   VIEW_XORG_LOG "$(gettext 'Review the xserver log file')" \
86
 
          FALSE  VIEW_GDM_LOG  "$(gettext 'Review the startup errors')" \
87
 
          FALSE  EDIT_CONFIG   "$(gettext 'Edit configuration file')" \
88
 
          FALSE  SAVE_CONFIG_LOGS   "$(gettext 'Archive configuration and logs')" \
89
 
        --hide-column 2
90
 
# TODO:          5 VERIFY_XORGCONF "Check configuration file"
91
 
}
92
 
 
93
 
# TODO:  Should we just go ahead and file a bug for them without presenting an option?
94
 
display_filebug_menu() {
95
 
    # Run apport to file a bug
96
 
    if [ -e $apport_hook ]; then
97
 
        $apport_hook
98
 
        if [ $? == 0 ]; then
99
 
            zenity --info --text "$(gettext 'A bug report has been written.\nYou can send it next time you log in.')"
100
 
        else
101
 
            zenity --error --text "$(gettext 'Your bug could not be recorded successfully.\n')"
102
 
        fi
103
 
    else
104
 
        zenity --error --text "$(eval_gettext 'Cannot file bug:  \$apport_hook is not present.')"
105
 
    fi
106
 
}
107
 
 
108
 
backup_xorg_conf() {
109
 
    # TODO: backup xorg.conf more elegantly...
110
 
    xorg_conf_backup="/etc/X11/xorg.conf-backup-${timestamp}"
111
 
    cp /etc/X11/xorg.conf ${xorg_conf_backup}
112
 
    if [ $? != 0 ]; then
113
 
        return zenity --question --text "$(gettext 'Your config could not be backed up.\nDo you want to continue anyway?\n')"
114
 
    fi
115
 
}
116
 
 
117
 
default_config() {
118
 
    backup_xorg_conf || return 1
119
 
 
120
 
    rm /etc/X11/xorg.conf
121
 
    if [ $? == 0 ]; then
122
 
        zenity --info --text "$(gettext 'Your configuration has been restored to default,\nand your old configuration backed up.\nPlease restart.\n')"
123
 
    else
124
 
        zenity --error --text "$(gettext 'Failure restoring configuration to default.\nYour config has not been changed.')"
125
 
    fi
126
 
}
127
 
 
128
 
run_xorgconf() {
129
 
    backup_xorg_conf || return 1
130
 
 
131
 
    Xorg :99 -configure
132
 
    if [ $? == 0 ]; then
133
 
        zenity --info --text "$(gettext 'A new configuration has been generated,\nand your old configuration backed up.\nPlease restart.\n')"
134
 
    else
135
 
        zenity --error --text "$(gettext 'Could not generate a new configuration')"
136
 
    fi
137
 
}
138
 
 
139
 
view_xorg_log() {
140
 
    zenity --text-info --filename=$xorg_log --width=640 --height=480
141
 
}
142
 
 
143
 
view_gdm_log() {
144
 
    zenity --text-info --filename=${gdm_log_1} --width=640 --height=480
145
 
}
146
 
 
147
 
verify_xorgconf() {
148
 
    # Run Alberto's xorg.conf checker (once it's available in main)
149
 
    zenity --error --text "$(gettext 'Sorry, this option is not implemented yet')"
150
 
}
151
 
 
152
 
edit_config() {
153
 
    backup_xorg_conf || return 1
154
 
 
155
 
    xorg_conf_tmp=$(mktemp -t xorg.conf.XXXXXXXX)
156
 
    zenity --text-info --editable --filename=/etc/X11/xorg.conf --width=640 --height=480 > "${xorg_conf_tmp}" && mv "${xorg_conf_tmp}" /etc/X11/xorg.conf
157
 
    chmod 644 /etc/X11/xorg.conf
158
 
}
159
 
 
160
 
save_config_logs() {
161
 
    xorg_backup_name=failsafeX-backup-${timestamp}
162
 
    xorg_backup_dir=$(mktemp -d -t ${xorg_backup_name}.XXX)
163
 
    xorg_backup_file=/var/log/${xorg_backup_name}.tar
164
 
 
165
 
    # cp $xorg_conf $xorg_backup_dir
166
 
    cp /etc/X11/xorg.conf $xorg_backup_dir
167
 
    cp ${xorg_log} $xorg_backup_dir
168
 
    cp ${xorg_log}.old $xorg_backup_dir
169
 
    cp ${gdm_log} $xorg_backup_dir
170
 
    cp ${gdm_log_1} $xorg_backup_dir
171
 
    cp ${gdm_log_2} $xorg_backup_dir
172
 
    lspci -vvnn > ${xorg_backup_dir}/lspci-vvnn.txt
173
 
    xrandr --verbose > ${xorg_backup_dir}/xrandr-verbose.txt
174
 
    tar -cf ${xorg_backup_file} ${xorg_backup_dir}
175
 
    rm -rf ${xorg_backup_dir}
176
 
 
177
 
    zenity --info --text "$(eval_gettext 'Relevant configuration and log files have been saved to:\n')"$xorg_backup_file"\n$(gettext 'Bug reports can be submitted at http://www.launchpad.net/ubuntu/.\n')"
178
 
}
179
 
 
180
 
# Scan Xorg.0.log for errors
181
 
LOG_ERRORS=$(grep -e "^(EE)" $xorg_log)
182
 
 
183
 
if [ -z "$LOG_ERRORS" ]; then
184
 
    zenity --warning --text "$(gettext '<big><b>Ubuntu is running in low-graphics mode</b></big>\n\nYour screen, graphics card, and input device settings\ncould not be detected correctly.  You will need to configure these yourself.')"
185
 
else
186
 
    zenity --warning --text "$(gettext '<big><b>Ubuntu is running in low-graphics mode</b></big>\n\nThe following error was encountered.  You may need\nto update your configuration to solve this.\n\n')""${LOG_ERRORS}"
187
 
fi
188
 
 
189
 
# TODO: Add --window-icon "$app_icon" to all zenity windows
190
 
 
191
 
while : ; do
192
 
    case "$choice" in
193
 
        ## Main Menu ##
194
 
        LOW_RES_MODE )    with_gdm="low-res"; break ;;
195
 
        RECONFIGURE )     choice=$(display_reconfigure_menu) ;;
196
 
        TROUBLESHOOT )    choice=$(display_troubleshooting_menu) ;;
197
 
        FILE_BUG )        choice=$(display_filebug_menu) ;;
198
 
        RESTART_X )       with_gdm="restart"; break ;;
199
 
 
200
 
        ## Reconfigure Menu ##
201
 
        DEFAULT_CONFIG )  choice="RECONFIGURE"; default_config ;;
202
 
        RUN_XORGCONF )    choice="RECONFIGURE"; run_xorgconf ;;
203
 
        SELECT_BACKUP )   choice="RECONFIGURE"; ;;
204
 
 
205
 
        ## Troubleshooting Menu ##
206
 
        VIEW_XORG_LOG )   choice="TROUBLESHOOT"; view_xorg_log ;;
207
 
        VIEW_GDM_LOG )    choice="TROUBLESHOOT"; view_gdm_log ;;
208
 
        VERIFY_XORGCONF ) choice="TROUBLESHOOT"; verify_xorgconf ;;
209
 
        EDIT_CONFIG )     choice="TROUBLESHOOT"; edit_config ;;
210
 
        SAVE_CONFIG_LOGS ) choice="TROUBLESHOOT"; save_config_logs ;;
211
 
        EXIT_TO_CONSOLE ) with_gdm=""; break ;;
212
 
 
213
 
        EXIT )          break ;;
214
 
        *)              choice=$(display_main_menu) || break ;;
215
 
    esac
216
 
done
217
 
 
218
 
if [ "x$with_gdm" = "xwith-gdm" ]; then
219
 
    XORGCONFIG="/etc/X11/xorg.conf"
220
 
elif [ "x$with_gdm" = "xlow-res" ]; then
221
 
    XORGCONFIG=${xorg_conf}
222
 
elif [ "x$with_gdm" = "xrestart" ]; then
223
 
    XORGCONFIG=""
224
 
else
225
 
    chvt 2
226
 
    exit
227
 
fi
228
 
 
229
 
start gdm XORGCONFIG=$XORGCONFIG | \
230
 
    zenity --progress --pulsate --text "$(gettext 'Stand by one minute while the display restarts...')"
231