summaryrefslogtreecommitdiff
path: root/debian/xserver-xorg.postinst.in
blob: 5b38145810ebefbbbd5b5ba24b0c91ba47e93bac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#!/bin/sh
# Debian xserver-xorg package post-installation script
# Copyright 1998-2004 Branden Robinson.
# Copyright 2004-2005 Canonical Ltd.
# Licensed under the GNU General Public License, version 2.  See the file
# /usr/share/common-licenses/GPL or <http://www.gnu.org/copyleft/gpl.txt>.
# Acknowledgements to Stephen Early, Mark Eichin, and Manoj Srivastava.

set -e

# source debconf library
. /usr/share/debconf/confmodule

THIS_PACKAGE=xserver-xorg
THIS_SCRIPT=postinst

#INCLUDE_SHELL_LIB#

if [ -e /etc/default/xorg ]; then
  . /etc/default/xorg
fi

# the error-out function
bomb () {
  echo "$PROGNAME: error: $*" | fold -s -w "${COLUMNS:-80}" >&2
  exit 1
}

debug_echo () {
  # Syntax: debug_echo message ...
  if [ -n "$DEBUG_XORG_DEBCONF" ] || [ "$DEBCONF_DEBUG" = "user" ] \
    || [ "$DEBCONF_DEBUG" = '.*' ]; then
    DEBUG_XORG_PACKAGE="yes" observe "$*"
  fi
}

CONFIG_DIR="/etc/X11"
CONFIG_AUX_DIR=/var/lib/x11
SERVER_SYMLINK="$CONFIG_DIR/X"
XORGCONFIG="$CONFIG_DIR/xorg.conf"
CONFIG_AUX_DIR="/var/lib/x11"
SERVER_SYMLINK_CHECKSUM="$CONFIG_AUX_DIR/${SERVER_SYMLINK##*/}.md5sum"
SERVER_SYMLINK_ROSTER="$CONFIG_AUX_DIR/${SERVER_SYMLINK##*/}.roster"
XORGCONFIG_CHECKSUM="$CONFIG_AUX_DIR/${XORGCONFIG##*/}.md5sum"
XORGCONFIG_ROSTER="$CONFIG_AUX_DIR/${XORGCONFIG##*/}.roster"
THIS_SERVER=/usr/bin/Xorg

debug_report_status () {
  # Syntax: debug_report_status command exit_status
  debug_echo "$1 exited with status $2"
}

debug_echo "Configuring $THIS_PACKAGE."

#DEBHELPER#

# only mess with the server symlink file if it does not exist.  otherwise,
# assume that's the way the user wants it.
if ! [ -e "$SERVER_SYMLINK" ]; then
  ln -s "$THIS_SERVER" "$SERVER_SYMLINK"
# recover from an old bug
elif [ `readlink "$SERVER_SYMLINK"` = "/bin/true" ]; then
  rm -f "$SERVER_SYMLINK"
  ln -s "$THIS_SERVER" "$SERVER_SYMLINK"
fi

if [ -n "$UPGRADE" ]; then
    if dpkg --compare-versions "$2" le "1:7.3+5"; then
        # Clean up our old crap
        for QUESTION in "shared/default-x-server" \
                        "xserver-xorg/autodetect_mouse" \
                        "xserver-xorg/autodetect_monitor" \
                        "xserver-xorg/autodetect_video_card" \
                        "xserver-xorg/config/device/identifier" \
                        "xserver-xorg/config/monitor/selection-method" \
                        "xserver-xorg/config/monitor/screen-size" \
                        "xserver-xorg/config/monitor/mode-list" \
                        "xserver-xorg/config/monitor/default-identifier" \
                        "xserver-xorg/config/monitor/horiz-sync" \
                        "xserver-xorg/config/monitor/vert-refresh" \
                        "xserver-xorg/config/monitor/range_input_error" \
                        "xserver-xorg/config/display/modes" \
                        "xserver-xorg/config/device/video_ram" \
                        "xserver-xorg/config/display/default_depth" \
                        "xserver-xorg/config/inputdevice/mouse/port" \
                        "xserver-xorg/config/inputdevice/mouse/protocol" \
                        "xserver-xorg/config/inputdevice/mouse/emulate3buttons" \
                        "xserver-xorg/config/modules" \
                        "xserver-xorg/config/monitor/default-identifier" \
                        "xserver-xorg/config/monitor/identifier" \
                        "xserver-xorg/config/write_files_section" \
                        "xserver-xorg/multiple_possible_x-drivers"; do
          db_unregister "$QUESTION" || true
        done
    fi
    if dpkg --compare-versions "$2" lt-nl 1:7.4; then
      for QUESTION in \
        xserver-xorg/config/null_string_error \
        xserver-xorg/config/doublequote_in_string_error \
        xserver-xorg/config/nonnumeric_string_error \
        xserver-xorg/config/device/use_fbdev \
        xserver-xorg/config/device/driver \
        xserver-xorg/config/inputdevice/keyboard/rules \
        xserver-xorg/config/inputdevice/keyboard/model \
        xserver-xorg/config/inputdevice/keyboard/layout \
        xserver-xorg/config/inputdevice/keyboard/variant \
        xserver-xorg/config/inputdevice/keyboard/options \
        xserver-xorg/autodetect_keyboard; do
	db_unregister $QUESTION || true
      done
    fi
    if dpkg --compare-versions "$2" lt-nl 1:7.4+2; then
      db_unregister xserver-xorg/config/device/bus_id || true
      db_unregister xserver-xorg/config/device/bus_id_error || true
      rm -f "$XORGCONFIG_ROSTER" "$XORGCONFIG_CHECKSUM"
      rm -f "$SERVER_SYMLINK_CHECKSUM" "$SERVER_SYMLINK_ROSTER"
    fi
fi

if dpkg --compare-versions "$2" lt-nl "1:7.4~3"; then
  # We're upgrading from pre-7.4.  We need to replace i810 with intel, and
  # via with openchrome.
  if [ -e "$XORGCONFIG" ]; then
    LC_ALL=C sed -e'
	/^[[:space:]]*Section[[:space:]]\+"Device"[[:space:]]*$/I,/^[[:space:]]*EndSection[[:space:]]*$/I {
	/^[[:space:]]*Driver[[:space:]]\+"i810"/I s/i810/intel/I
	/^[[:space:]]*Driver[[:space:]]\+"via"/I s/via/openchrome/I
	}
	' $XORGCONFIG > ${XORGCONFIG}.madwizard-new
    if ! cmp -s $XORGCONFIG ${XORGCONFIG}.madwizard-new; then
      chown --reference=$XORGCONFIG ${XORGCONFIG}.madwizard-new
      chmod --reference=$XORGCONFIG ${XORGCONFIG}.madwizard-new
      mv ${XORGCONFIG}.madwizard-new $XORGCONFIG
    else
      rm ${XORGCONFIG}.madwizard-new
    fi
  fi
fi

case "$1" in
  configure)
    if dpkg --compare-versions "$2" lt-nl "1:7.3+11"; then
      remove_conffile_commit "/etc/init.d/xserver-xorg"
    fi
    if dpkg --compare-versions "$2" lt-nl "1:7.3+13"; then
      update-rc.d xserver-xorg remove || true
    fi
    if dpkg --compare-versions "$2" lt "1:7.5~3"; then
      if [ `uname -s` = "GNU/kFreeBSD" ]; then
        invoke-rc.d hal restart >/dev/null
      fi
    fi
    ;;
esac

db_stop

exit 0

# vim:set ai et sts=2 sw=2 tw=0: