2
# Debian xdm package post-installation script
3
# Copyright 1998--2001, 2003, 2004 Branden Robinson.
4
# Licensed under the GNU General Public License, version 2. See the file
5
# /usr/share/common-licenses/GPL or <http://www.gnu.org/copyleft/gpl.txt>.
6
# Acknowledgements to Stephen Early, Mark Eichin, and Manoj Srivastava.
8
# $Id: xdm.postinst.in 1594 2004-07-07 12:46:10Z branden $
12
# source debconf library
13
. /usr/share/debconf/confmodule
18
# $Id: shell-lib.sh 1760 2004-08-28 07:53:52Z branden $
20
SOURCE_VERSION=6.8.2-10
23
# Use special abnormal exit codes so that problems with this library are more
24
# easily tracked down.
25
SHELL_LIB_INTERNAL_ERROR=86
26
SHELL_LIB_THROWN_ERROR=74
27
SHELL_LIB_USAGE_ERROR=99
29
# old -> new variable names
30
if [ -z "$DEBUG_XORG_PACKAGE" ] && [ -n "$DEBUG_XFREE86_PACKAGE" ]; then
31
DEBUG_XORG_PACKAGE="$DEBUG_XFREE86_PACKAGE"
33
if [ -z "$DEBUG_XORG_DEBCONF" ] && [ -n "$DEBUG_XFREE86_DEBCONF" ]; then
34
DEBUG_XORG_DEBCONF="$DEBUG_XFREE86_DEBCONF"
37
# initial sanity checks
38
if [ -z "$THIS_PACKAGE" ]; then
40
Error: package maintainer script attempted to use shell library without
41
definining \$THIS_PACKAGE shell variable. Please report the package name,
42
version, and the text of this error message to the Debian Bug Tracking System.
43
Visit <http://www.debian.org/Bugs/Reporting> on the World Wide Web for
44
instructions, read the file /usr/share/doc/debian/bug-reporting.txt from the
45
"doc-debian" package, or install the "reportbug" package and use the command of
46
the same name to file a report against version $SOURCE_VERSION of this package.
48
exit $SHELL_LIB_USAGE_ERROR
51
if [ -z "$THIS_SCRIPT" ]; then
53
Error: package maintainer script attempted to use shell library without
54
definining \$THIS_SCRIPT shell variable. Please report the package name,
55
version, and the text of this error message to the Debian Bug Tracking System.
56
Visit <http://www.debian.org/Bugs/Reporting> on the World Wide Web for
57
instructions, read the file /usr/share/doc/debian/bug-reporting.txt from the
58
"doc-debian" package, or install the "reportbug" package and use the command of
59
the same name to file a report against version $SOURCE_VERSION of the
60
"$THIS_PACKAGE" package.
62
exit $SHELL_LIB_USAGE_ERROR
66
message \"Received signal. Aborting $THIS_PACKAGE package $THIS_SCRIPT script.\";\
68
exit 1" HUP INT QUIT TERM
71
# syntax: reject_nondigits [ operand ... ]
73
# scan operands (typically shell variables whose values cannot be trusted) for
74
# characters other than decimal digits and barf if any are found
76
# does the operand contain anything but digits?
77
if ! expr "$1" : "[[:digit:]]\+$" > /dev/null 2>&1; then
78
# can't use die(), because it wraps message() which wraps this function
79
echo "$THIS_PACKAGE $THIS_SCRIPT error: reject_nondigits() encountered" \
80
"possibly malicious garbage \"$1\"" >&2
81
exit $SHELL_LIB_THROWN_ERROR
87
reject_whitespace () {
88
# syntax: reject_whitespace [ operand ]
90
# scan operand (typically a shell variable whose value cannot be trusted) for
91
# whitespace characters and barf if any are found
93
# does the operand contain any whitespace?
94
if expr "$1" : "[[:space:]]" > /dev/null 2>&1; then
95
# can't use die(), because I want to avoid forward references
96
echo "$THIS_PACKAGE $THIS_SCRIPT error: reject_whitespace() encountered" \
97
"possibly malicious garbage \"$1\"" >&2
98
exit $SHELL_LIB_THROWN_ERROR
103
reject_unlikely_path_chars () {
104
# syntax: reject_unlikely_path_chars [ operand ... ]
106
# scan operands (typically shell variables whose values cannot be trusted) for
107
# characters unlikely to be seen in a path and which the shell might
108
# interpret and barf if any are found
109
while [ -n "$1" ]; do
110
# does the operand contain any funny characters?
111
if expr "$1" : '.*[!$&()*;<>?|].*' > /dev/null 2>&1; then
112
# can't use die(), because I want to avoid forward references
113
echo "$THIS_PACKAGE $THIS_SCRIPT error: reject_unlikely_path_chars()" \
114
"encountered possibly malicious garbage \"$1\"" >&2
115
exit $SHELL_LIB_THROWN_ERROR
121
# Query the terminal to establish a default number of columns to use for
122
# displaying messages to the user. This is used only as a fallback in the
123
# event the COLUMNS variable is not set. ($COLUMNS can react to SIGWINCH while
124
# the script is running, and this cannot, only being calculated once.)
125
DEFCOLUMNS=$(stty size 2> /dev/null | awk '{print $2}') || true
126
if ! expr "$DEFCOLUMNS" : "[[:digit:]]\+$" > /dev/null 2>&1; then
131
# pretty-print messages of arbitrary length
132
reject_nondigits "$COLUMNS"
133
echo "$*" | fmt -t -w ${COLUMNS:-$DEFCOLUMNS} >&2
137
# syntax: observe message ...
139
# issue observational message suitable for logging someday when support for
141
if [ -n "$DEBUG_XORG_PACKAGE" ]; then
142
message "$THIS_PACKAGE $THIS_SCRIPT note: $*"
147
# syntax: warn message ...
149
# issue warning message suitable for logging someday when support for
150
# it exists in dpkg; also send to standard error
151
message "$THIS_PACKAGE $THIS_SCRIPT warning: $*"
155
# syntax: die message ...
157
# exit script with error message
158
message "$THIS_PACKAGE $THIS_SCRIPT error: $*"
159
exit $SHELL_LIB_THROWN_ERROR
163
# exit script with error; essentially a "THIS SHOULD NEVER HAPPEN" message
164
message "internal error: $*"
165
if [ -n "$OFFICIAL_BUILD" ]; then
166
message "Please report a bug in the $THIS_SCRIPT script of the" \
167
"$THIS_PACKAGE package, version $SOURCE_VERSION to the Debian Bug" \
168
"Tracking System. Include all messages above that mention the" \
169
"$THIS_PACKAGE package. Visit " \
170
"<http://www.debian.org/Bugs/Reporting> on the World Wide Web for" \
171
"instructions, read the file" \
172
"/usr/share/doc/debian/bug-reporting.txt from the doc-debian" \
173
"package, or install the reportbug package and use the command of" \
174
"the same name to file a report."
176
exit $SHELL_LIB_INTERNAL_ERROR
180
message "usage error: $*"
181
message "Please report a bug in the $THIS_SCRIPT script of the" \
182
"$THIS_PACKAGE package, version $SOURCE_VERSION to the Debian Bug" \
183
"Tracking System. Include all messages above that mention the" \
184
"$THIS_PACKAGE package. Visit " \
185
"<http://www.debian.org/Bugs/Reporting> on the World Wide Web for" \
186
"instructions, read the file" \
187
"/usr/share/doc/debian/bug-reporting.txt from the doc-debian" \
188
"package, or install the reportbug package and use the command of" \
189
"the same name to file a report."
190
exit $SHELL_LIB_USAGE_ERROR
195
# returns what symlink should point to; i.e., what the "sane" answer is
196
# Keep this in sync with the debian/*.links files.
197
# This is only needed for symlinks to directories.
199
/etc/X11/xkb/compiled) echo /var/lib/xkb ;;
200
/etc/X11/xkb/xkbcomp) echo /usr/X11R6/bin/xkbcomp ;;
201
/usr/X11R6/lib/X11/app-defaults) echo /etc/X11/app-defaults ;;
202
/usr/X11R6/lib/X11/fs) echo /etc/X11/fs ;;
203
/usr/X11R6/lib/X11/lbxproxy) echo /etc/X11/lbxproxy ;;
204
/usr/X11R6/lib/X11/proxymngr) echo /etc/X11/proxymngr ;;
205
/usr/X11R6/lib/X11/rstart) echo /etc/X11/rstart ;;
206
/usr/X11R6/lib/X11/twm) echo /etc/X11/twm ;;
207
/usr/X11R6/lib/X11/xdm) echo /etc/X11/xdm ;;
208
/usr/X11R6/lib/X11/xinit) echo /etc/X11/xinit ;;
209
/usr/X11R6/lib/X11/xkb) echo /etc/X11/xkb ;;
210
/usr/X11R6/lib/X11/xserver) echo /etc/X11/xserver ;;
211
/usr/X11R6/lib/X11/xsm) echo /etc/X11/xsm ;;
212
/usr/bin/X11) echo ../X11R6/bin ;;
213
/usr/bin/rstartd) echo ../X11R6/bin/rstartd ;;
214
/usr/include/X11) echo ../X11R6/include/X11 ;;
215
/usr/lib/X11) echo ../X11R6/lib/X11 ;;
216
*) internal_error "maplink() called with unknown path \"$1\"" ;;
221
# given a supplied set of pathnames, break each one up by directory and do an
222
# ls -dl on each component, cumulatively; i.e.
223
# analyze_path /usr/X11R6/bin -> ls -dl /usr /usr/X11R6 /usr/X11R6/bin
224
# Thanks to Randolph Chung for this clever hack.
228
while [ -n "$1" ]; do
229
reject_whitespace "$1"
231
message "Analyzing $1:"
232
for f in $(echo "$1" | tr / \ ); do
233
if [ -e /$g$f ]; then
234
ls -dl /$g$f /$g$f.dpkg-* 2> /dev/null || true
237
message "/$g$f: nonexistent; directory contents of /$g:"
247
local f p dpkg_info_dir possible_culprits smoking_guns bad_packages package \
250
reject_whitespace "$1"
251
message "Searching for overlapping packages..."
252
dpkg_info_dir=/var/lib/dpkg/info
253
if [ -d $dpkg_info_dir ]; then
254
if [ "$(echo $dpkg_info_dir/*.list)" != "$dpkg_info_dir/*.list" ]; then
255
possible_culprits=$(ls -1 $dpkg_info_dir/*.list | egrep -v \
256
"(xbase-clients|xorg-common|xfs|xlibs)")
257
if [ -n "$possible_culprits" ]; then
258
smoking_guns=$(grep -l "$1" $possible_culprits)
259
if [ -n "$smoking_guns" ]; then
260
bad_packages=$(printf "\\n")
261
for f in $smoking_guns; do
262
# too bad you can't nest parameter expansion voodoo
263
p=${f%*.list} # strip off the trailing ".list"
264
package=${p##*/} # strip off the directories
265
bad_packages=$(printf "%s\n%s" "$bad_packages" "$package")
268
The following packages appear to have file overlaps with the XFree86 packages;
269
these packages are either very old, or in violation of Debian Policy. Try
270
upgrading each of these packages to the latest available version if possible:
271
for example, with the command "apt-get install". If no newer version of a
272
package is available, you will have to remove it; for example, with the command
273
"apt-get remove". If even the latest available version of the package has
274
this file overlap, please file a bug against that package with the Debian Bug
275
Tracking System. You may want to refer the package maintainer to section 12.8
276
of the Debian Policy manual.
280
message "The overlapping packages are: $bad_packages"
282
message "no overlaps found."
286
message "cannot search; no matches for $dpkg_info_dir/*.list."
289
message "cannot search; $dpkg_info_dir does not exist."
293
# we require a readlink command or shell function
294
if ! which readlink > /dev/null 2>&1; then
295
message "The readlink command was not found. Please install version" \
296
"1.13.1 or later of the debianutils package."
298
# returns what symlink in $1 actually points to
299
perl -e '$l = shift; exit 1 unless -l $l; $r = readlink $l; exit 1 unless $r; print "$r\n"' "$1"
304
# syntax: check_symlink symlink
306
# See if specified symlink points where it is supposed to. Return 0 if it
307
# does, and 1 if it does not.
309
# Primarily used by check_symlinks_and_warn() and check_symlinks_and_bomb().
314
if [ $# -ne 1 ]; then
315
usage_error "check_symlink() called with wrong number of arguments;" \
317
exit $SHELL_LIB_USAGE_ERROR
322
if [ "$(maplink "$symlink")" = "$(readlink "$symlink")" ]; then
329
check_symlinks_and_warn () {
330
# syntax: check_symlinks_and_warn symlink ...
332
# For each argument, check for symlink sanity, and warn if it isn't sane.
334
# Call this function from a preinst script in the event $1 is "upgrade" or
340
if [ $# -lt 1 ]; then
341
usage_error "check_symlinks_and_warn() called with wrong number of" \
342
"arguments; expected at least 1, got $#"
343
exit $SHELL_LIB_USAGE_ERROR
346
while [ -n "$1" ]; do
348
if [ -L "$symlink" ]; then
349
if ! check_symlink "$symlink"; then
350
observe "$symlink symbolic link points to wrong location" \
351
"$(readlink "$symlink"); removing"
354
elif [ -e "$symlink" ]; then
355
errmsg="$symlink exists and is not a symbolic link; this package cannot"
356
errmsg="$errmsg be installed until this"
357
if [ -f "$symlink" ]; then
358
errmsg="$errmsg file"
359
elif [ -d "$symlink" ]; then
360
errmsg="$errmsg directory"
362
errmsg="$errmsg thing"
364
errmsg="$errmsg is removed"
371
check_symlinks_and_bomb () {
372
# syntax: check_symlinks_and_bomb symlink ...
374
# For each argument, check for symlink sanity, and bomb if it isn't sane.
376
# Call this function from a postinst script.
378
local problem symlink
381
if [ $# -lt 1 ]; then
382
usage_error "check_symlinks_and_bomb() called with wrong number of"
383
"arguments; expected at least 1, got $#"
384
exit $SHELL_LIB_USAGE_ERROR
387
while [ -n "$1" ]; do
390
if [ -L "$symlink" ]; then
391
if ! check_symlink "$symlink"; then
393
warn "$symlink symbolic link points to wrong location" \
394
"$(readlink "$symlink")"
396
elif [ -e "$symlink" ]; then
398
warn "$symlink is not a symbolic link"
401
warn "$symlink symbolic link does not exist"
403
if [ -n "$problem" ]; then
404
analyze_path "$symlink" "$(readlink "$symlink")"
405
find_culprits "$symlink"
406
die "bad symbolic links on system"
413
# run $UPDATECMDS in $FONTDIRS
415
local dir cmd shortcmd x_font_dir_prefix
417
x_font_dir_prefix="/usr/X11R6/lib/X11/fonts"
419
if [ -z "$UPDATECMDS" ]; then
420
usage_error "font_update() called but \$UPDATECMDS not set"
422
if [ -z "$FONTDIRS" ]; then
423
usage_error "font_update() called but \$FONTDIRS not set"
426
reject_unlikely_path_chars "$UPDATECMDS"
427
reject_unlikely_path_chars "$FONTDIRS"
429
for dir in $FONTDIRS; do
430
if [ -d "$x_font_dir_prefix/$dir" ]; then
431
for cmd in $UPDATECMDS; do
432
if which "$cmd" > /dev/null 2>&1; then
434
observe "running $shortcmd in $dir font directory"
435
if [ "$shortcmd" = "xftcache" ]; then
436
if [ "$dir" = "Speedo" ]; then
437
# do nothing; xftcache SEGVs (*sometimes*) when asked to process
438
# the Speedo directory
441
# KLUDGE: xftcache needs to be handed the full path; the command
442
# goes away anyway in XFree86 4.3.0
443
dir="$x_font_dir_prefix/$dir"
445
$cmd $dir || warn "$cmd $dir failed; font directory data may not" \
448
warn "$cmd not found; not updating corresponding $dir font" \
453
warn "$dir is not a directory; not updating font directory data"
458
remove_conffile_prepare () {
459
# syntax: remove_conffile_prepare filename official_md5sum ...
461
# Check a conffile "filename" against a list of canonical MD5 checksums.
462
# If the file's current MD5 checksum matches one of the "official_md5sum"
463
# operands provided, then prepare the conffile for removal from the system.
464
# We defer actual deletion until the package is configured so that we can
465
# roll this operation back if package installation fails.
467
# Call this function from a preinst script in the event $1 is "upgrade" or
468
# "install" and verify $2 to ensure the package is being upgraded from a
469
# version (or installed over a version removed-but-not-purged) prior to the
470
# one in which the conffile was obsoleted.
472
local conffile current_checksum
475
if [ $# -lt 2 ]; then
476
usage_error "remove_conffile_prepare() called with wrong number of" \
477
"arguments; expected at least 2, got $#"
478
exit $SHELL_LIB_USAGE_ERROR
484
# does the conffile even exist?
485
if [ -e "$conffile" ]; then
486
# calculate its checksum
487
current_checksum=$(md5sum < "$conffile" | sed 's/[[:space:]].*//')
488
# compare it to each supplied checksum
489
while [ -n "$1" ]; do
490
if [ "$current_checksum" = "$1" ]; then
491
# we found a match; move the confffile and stop looking
492
observe "preparing obsolete conffile $conffile for removal"
493
mv "$conffile" "$conffile.$THIS_PACKAGE-tmp"
501
remove_conffile_commit () {
502
# syntax: remove_conffile_commit filename
504
# Complete the removal of a conffile "filename" that has become obsolete.
506
# Call this function from a postinst script after having used
507
# remove_conffile_prepare() in the preinst.
512
if [ $# -ne 1 ]; then
513
usage_error "remove_conffile_commit() called with wrong number of" \
514
"arguments; expected 1, got $#"
515
exit $SHELL_LIB_USAGE_ERROR
520
# if the temporary file created by remove_conffile_prepare() exists, remove it
521
if [ -e "$conffile.$THIS_PACKAGE-tmp" ]; then
522
observe "committing removal of obsolete conffile $conffile"
523
rm "$conffile.$THIS_PACKAGE-tmp"
527
remove_conffile_rollback () {
528
# syntax: remove_conffile_rollback filename
530
# Roll back the removal of a conffile "filename".
532
# Call this function from a postrm script in the event $1 is "abort-upgrade"
533
# or "abort-install" is after having used remove_conffile_prepare() in the
539
if [ $# -ne 1 ]; then
540
usage_error "remove_conffile_rollback() called with wrong number of" \
541
"arguments; expected 1, got $#"
542
exit $SHELL_LIB_USAGE_ERROR
547
# if the temporary file created by remove_conffile_prepare() exists, move it
549
if [ -e "$conffile.$THIS_PACKAGE-tmp" ]; then
550
observe "rolling back removal of obsolete conffile $conffile"
551
mv "$conffile.$THIS_PACKAGE-tmp" "$conffile"
556
# syntax: run command [ argument ... ]
558
# Run specified command with optional arguments and report its exit status.
559
# Useful for commands whose exit status may be nonzero, but still acceptable,
560
# or commands whose failure is not fatal to us.
562
# NOTE: Do *not* use this function with db_get or db_metaget commands; in
563
# those cases the return value of the debconf command *must* be checked
564
# before the string returned by debconf is used for anything.
569
if [ $# -lt 1 ]; then
570
usage_error "run() called with wrong number of arguments; expected at" \
572
exit $SHELL_LIB_USAGE_ERROR
577
if [ ${retval:-0} -ne 0 ]; then
578
observe "command \"$*\" exited with status $retval"
582
register_x_lib_dir_with_ld_so () {
583
# syntax: register_x_lib_dir_with_ld_so
585
# Configure the dynamic loader ld.so to search /usr/X11R6/lib for shared
588
# Call this function from the postinst script of a package that places a
589
# shared library in /usr/X11R6/lib, before invoking ldconfig.
594
ldsoconf="/etc/ld.so.conf"
596
# is the line not already present?
597
if ! fgrep -qsx "$dir" "$ldsoconf"; then
598
observe "adding $dir directory to $ldsoconf"
599
echo "$dir" >> "$ldsoconf"
603
deregister_x_lib_dir_with_ld_so () {
604
# syntax: deregister_x_lib_dir_with_ld_so
606
# Configure dynamic loader ld.so to not search /usr/X11R6/lib for shared
607
# libraries, if and only if no shared libaries remain there.
609
# Call this function from the postrm script of a package that places a shared
610
# library in /usr/X11R6/lib, in the event "$1" is "remove", and before
613
local dir ldsoconf fgrep_status cmp_status
616
ldsoconf="/etc/ld.so.conf"
618
# is the line present?
619
if fgrep -qsx "$dir" "$ldsoconf"; then
620
# are there any shared objects in the directory?
621
if [ "$(echo "$dir"/lib*.so.*.*)" = "$dir/lib*.so.*.*" ]; then
622
# glob expansion produced nothing, so no shared libraries are present
623
observe "removing $dir directory from $ldsoconf"
624
# rewrite the file (very carefully)
626
fgrep -svx "$dir" "$ldsoconf" > "$ldsoconf.dpkg-tmp"
629
case $fgrep_status in
630
0|1) ;; # we don't actually care if any lines matched or not
631
*) die "error reading \"$ldsoconf\"; fgrep exited with status" \
635
cmp -s "$ldsoconf.dpkg-tmp" "$ldsoconf"
639
0) rm "$ldsoconf.dpkg-tmp" ;; # files are identical
640
1) mv "$ldsoconf.dpkg-tmp" "$ldsoconf" ;; # files differ
641
*) die "error comparing \"$ldsoconf.dpkg-tmp\" to \"$ldsoconf\"; cmp" \
642
"exited with status $cmp_status" ;;
648
make_symlink_sane () {
649
# syntax: make_symlink_sane symlink target
651
# Ensure that the symbolic link symlink exists, and points to target.
653
# If symlink does not exist, create it and point it at target.
655
# If symlink exists but is not a symbolic link, back it up.
657
# If symlink exists, is a symbolic link, but points to the wrong location, fix
660
# If symlink exists, is a symbolic link, and already points to target, do
663
# This function wouldn't be needed if ln had an -I, --idempotent option.
665
# Validate arguments.
666
if [ $# -ne 2 ]; then
667
usage_error "make_symlink_sane() called with wrong number of arguments;" \
669
exit $SHELL_LIB_USAGE_ERROR
672
# We could just use the positional parameters as-is, but that makes things
679
if [ -L "$symlink" ] && [ "$(readlink "$symlink")" = "$target" ]; then
680
observe "link from $symlink to $target already exists"
682
observe "creating symbolic link from $symlink to $target"
683
mkdir -p "${target%/*}" "${symlink%/*}"
684
ln -s -b -S ".dpkg-old" "$target" "$symlink"
688
migrate_dir_to_symlink () {
689
# syntax: migrate_dir_to_symlink old_location new_location
691
# Per Debian Policy section 6.5.4, "A directory will never be replaced by a
692
# symbolic link to a directory or vice versa; instead, the existing state
693
# (symlink or not) will be left alone and dpkg will follow the symlink if
696
# We have to do it ourselves.
698
# This function moves the contents of old_location, a directory, into
699
# new_location, a directory, then makes old_location a symbolic link to
702
# old_location need not exist, but if it does, it must be a directory (or a
703
# symlink to a directory). If it is not, it is backed up. If new_location
704
# exists already and is not a directory, it is backed up.
706
# This function should be called from a package's preinst so that other
707
# packages unpacked after this one --- but before this package's postinst runs
708
# --- are unpacked into new_location even if their payloads contain
709
# old_location filespecs.
711
# Validate arguments.
712
if [ $# -ne 2 ]; then
713
usage_error "migrate_dir_to_symlink() called with wrong number of"
714
"arguments; expected 2, got $#"
715
exit $SHELL_LIB_USAGE_ERROR
718
# We could just use the positional parameters as-is, but that makes things
725
# Is old location a symlink?
726
if [ -L "$old" ]; then
727
# Does it already point to new location?
728
if [ "$(readlink "$old")" = "$new" ]; then
729
# Nothing to do; migration has already been done.
730
observe "migration of $old to $new already done"
734
warn "backing up symbolic link $old as $old.dpkg-old"
735
mv -b "$old" "$old.dpkg-old"
739
# Does old location exist, but is not a directory?
740
if [ -e "$old" ] && ! [ -d "$old" ]; then
742
warn "backing up non-directory $old as $old.dpkg-old"
743
mv -b "$old" "$old.dpkg-old"
746
observe "migrating $old to $new"
748
# Is new location a symlink?
749
if [ -L "$new" ]; then
750
# Does it point the wrong way, i.e., back to where we're migrating from?
751
if [ "$(readlink "$new")" = "$old" ]; then
753
observe "removing symbolic link $new which points to $old"
757
warn "backing up symbolic link $new as $new.dpkg-old"
758
mv -b "$new" "$new.dpkg-old"
762
# Does new location exist, but is not a directory?
763
if [ -e "$new" ] && ! [ -d "$new" ]; then
764
warn "backing up non-directory $new as $new.dpkg-old"
765
mv -b "$new" "$new.dpkg-old"
768
# Create new directory if it does not yet exist.
769
if ! [ -e "$new" ]; then
770
observe "creating $new"
774
# Copy files in old location to new location. Back up any filenames that
775
# already exist in the new location with the extension ".dpkg-old".
776
observe "copying files from $old to $new"
777
if ! (cd "$old" && cp -a -b -S ".dpkg-old" . "$new"); then
778
die "error(s) encountered while copying files from $old to $new"
781
# Remove files at old location.
782
observe "removing $old"
785
# Create symlink from old location to new location.
786
make_symlink_sane "$old" "$new"
789
# vim:set ai et sts=2 sw=2 tw=80:
791
# check_symlinks_and_bomb /usr/X11R6/lib/X11/xdm
793
# now safe to remove old xserver dir
794
if [ -e /usr/X11R6/lib/X11/xdm.moved-by-preinst ] \
795
&& [ -L /usr/X11R6/lib/X11/xdm ]; then
796
rm -r /usr/X11R6/lib/X11/xdm.moved-by-preinst
799
# now safe to remove obsolete conffiles
800
for F in /etc/X11/xdm/Xreset /etc/X11/xdm/Xsetup /etc/X11/xdm/pixmaps/XFree86.xpm /etc/X11/xdm/pixmaps/XFree86bw.xpm; do
801
remove_conffile_commit "$F"
804
# debconf is not a registry, so we only fiddle with the default file if it
806
DEFAULT_DISPLAY_MANAGER_FILE=/etc/X11/default-display-manager
807
if ! [ -e "$DEFAULT_DISPLAY_MANAGER_FILE" ]; then
808
DEFAULT_DISPLAY_MANAGER=
809
if db_get shared/default-x-display-manager; then
810
DEFAULT_DISPLAY_MANAGER="$RET"
812
if [ -n "$DEFAULT_DISPLAY_MANAGER" ]; then
814
if db_get "$DEFAULT_DISPLAY_MANAGER"/daemon_name; then
817
if [ -z "$DAEMON_NAME" ]; then
818
# if we were unable to determine the name of the selected daemon (for
819
# instance, if the selected default display manager doesn't provide a
820
# daemon_name question), guess
821
DAEMON_NAME=$(which "$DEFAULT_DISPLAY_MANAGER" 2>/dev/null)
822
if [ -z "$DAEMON_NAME" ]; then
823
warn "unable to determine path to default X display manager" \
824
"$DEFAULT_DISPLAY_MANAGER; not updating" \
825
"$DEFAULT_DISPLAY_MANAGER_FILE"
828
if [ -n "$DAEMON_NAME" ]; then
829
observe "committing change of default X display manager"
830
echo "$DAEMON_NAME" > "$DEFAULT_DISPLAY_MANAGER_FILE"
835
# remove the displaced old default display manager file if it exists
836
if [ -e "$DEFAULT_DISPLAY_MANAGER_FILE.dpkg-tmp" ]; then
837
rm "$DEFAULT_DISPLAY_MANAGER_FILE.dpkg-tmp"
840
# Registering the init scripts or starting the daemon may cause output to
841
# stdout, which can confuse debconf.
844
if [ -e /etc/init.d/xdm ]; then
845
update-rc.d xdm defaults 99 01
848
# Whether we are installing or upgrading, we check the options file to see if
849
# the user wants the daemon (re-)started.
852
if [ -e /var/run/xdm.install ]; then
853
# Don't start the daemon if the options file says not to.
854
if ! grep -qs ^start-on-install /etc/X11/xdm/xdm.options; then
858
# We are upgrading. Don't start the daemon if it wasn't stopped...
859
if [ -e /var/run/xdm.daemon-not-stopped ]; then
862
# ...or if the options file says not to.
863
if ! grep -qs ^restart-on-upgrade /etc/X11/xdm/xdm.options; then
868
# At this point we may think we *should* be starting the daemon, but we need to
869
# do some more checks. Clean up the old, obsolete /var/state/xdm directory
870
# (which we can only do if the daemon isn't running).
873
# Don't start the daemon if it's already running...
874
if start-stop-daemon --stop --quiet --signal 0 --pid /var/run/xdm.pid \
875
--exec /usr/bin/X11/xdm; then
876
# Note our refusal to start the daemon if we were supposed to start it.
877
[ -n "$NOSTART" ] || DENYSTART=yes
878
DENIAL_REASON="xdm is already running at pid $(cat /var/run/xdm.pid)"
879
if [ -d /var/state/xdm ]; then
880
warn "obsolete directory /var/state/xdm cannot be removed because" \
881
"$DENIAL_REASON; reinstall the xdm package (or remove the directory" \
882
"manually) when xdm is not running"
885
if [ -d /var/state/xdm ]; then
888
# ...or if we're currently in X on any of the displays it attempts to manage
890
if [ -s /etc/X11/xdm/Xservers ]; then
891
MANAGED_DISPLAYS="$(egrep -v '^[[:space:]]*#' /etc/X11/xdm/Xservers \
892
| sed 's/[[:space:]].*//')"
893
if [ -n "$MANAGED_DISPLAYS" ]; then
894
for MANAGED_DISPLAY in $MANAGED_DISPLAYS; do
895
if echo "$DISPLAY" | grep -q "^$MANAGED_DISPLAY"; then
896
# Note our refusal to start the daemon if we were supposed to start
898
[ -n "$NOSTART" ] || DENYSTART=yes
899
DENIAL_REASON="an X server is already running at $DISPLAY, which"
900
DENIAL_REASON="$DENIAL_REASON xdm is configured to to manage"
908
# If the user wanted us to start the daemon but we refuse, explain why.
909
if [ -n "$DENYSTART" ]; then
910
warn "not starting xdm because $DENIAL_REASON"
914
[ -n "$NOSTART" ] || invoke-rc.d xdm start || true
918
# Remove install flag file. Leave the "daemon not stopped" flag file, if it
919
# exists, so that it will be seen by the init script.
920
rm -f /var/run/xdm.install
924
# vim:set ai et sts=2 sw=2 tw=80: