201
181
exit $SHELL_LIB_USAGE_ERROR
206
# returns what symlink should point to; i.e., what the "sane" answer is
207
# Keep this in sync with the debian/*.links files.
208
# This is only needed for symlinks to directories.
210
# XXX: Most of these look wrong in the X11R7 world and need to be fixed.
211
# If we've stopped using this function, fixing it might enable us to re-enable
212
# it again and catch more errors.
214
/etc/X11/xkb/compiled) echo /var/lib/xkb ;;
215
/etc/X11/xkb/xkbcomp) echo /usr/X11R6/bin/xkbcomp ;;
216
/usr/X11R6/lib/X11/app-defaults) echo /etc/X11/app-defaults ;;
217
/usr/X11R6/lib/X11/fs) echo /etc/X11/fs ;;
218
/usr/X11R6/lib/X11/lbxproxy) echo /etc/X11/lbxproxy ;;
219
/usr/X11R6/lib/X11/proxymngr) echo /etc/X11/proxymngr ;;
220
/usr/X11R6/lib/X11/rstart) echo /etc/X11/rstart ;;
221
/usr/X11R6/lib/X11/twm) echo /etc/X11/twm ;;
222
/usr/X11R6/lib/X11/xdm) echo /etc/X11/xdm ;;
223
/usr/X11R6/lib/X11/xinit) echo /etc/X11/xinit ;;
224
/usr/X11R6/lib/X11/xkb) echo /etc/X11/xkb ;;
225
/usr/X11R6/lib/X11/xserver) echo /etc/X11/xserver ;;
226
/usr/X11R6/lib/X11/xsm) echo /etc/X11/xsm ;;
227
/usr/bin/X11) echo ../X11R6/bin ;;
228
/usr/bin/rstartd) echo ../X11R6/bin/rstartd ;;
229
/usr/include/X11) echo ../X11R6/include/X11 ;;
230
/usr/lib/X11) echo ../X11R6/lib/X11 ;;
231
*) internal_error "maplink() called with unknown path \"$1\"" ;;
236
# given a supplied set of pathnames, break each one up by directory and do an
237
# ls -dl on each component, cumulatively; i.e.
238
# analyze_path /usr/X11R6/bin -> ls -dl /usr /usr/X11R6 /usr/X11R6/bin
239
# Thanks to Randolph Chung for this clever hack.
243
while [ -n "$1" ]; do
244
reject_whitespace "$1"
246
message "Analyzing $1:"
247
for f in $(echo "$1" | tr / \ ); do
248
if [ -e /$g$f ]; then
249
ls -dl /$g$f /$g$f.dpkg-* 2> /dev/null || true
252
message "/$g$f: nonexistent; directory contents of /$g:"
262
local f p dpkg_info_dir possible_culprits smoking_guns bad_packages package \
265
reject_whitespace "$1"
266
message "Searching for overlapping packages..."
267
dpkg_info_dir=/var/lib/dpkg/info
268
if [ -d $dpkg_info_dir ]; then
269
if [ "$(echo $dpkg_info_dir/*.list)" != "$dpkg_info_dir/*.list" ]; then
270
possible_culprits=$(ls -1 $dpkg_info_dir/*.list | egrep -v \
271
"(xbase-clients|x11-common|xfs|xlibs)")
272
if [ -n "$possible_culprits" ]; then
273
smoking_guns=$(grep -l "$1" $possible_culprits || true)
274
if [ -n "$smoking_guns" ]; then
275
bad_packages=$(printf "\\n")
276
for f in $smoking_guns; do
277
# too bad you can't nest parameter expansion voodoo
278
p=${f%*.list} # strip off the trailing ".list"
279
package=${p##*/} # strip off the directories
280
bad_packages=$(printf "%s\n%s" "$bad_packages" "$package")
283
The following packages appear to have file overlaps with the X.Org packages;
284
these packages are either very old, or in violation of Debian Policy. Try
285
upgrading each of these packages to the latest available version if possible:
286
for example, with the command "apt-get install". If no newer version of a
287
package is available, you will have to remove it; for example, with the command
288
"apt-get remove". If even the latest available version of the package has
289
this file overlap, please file a bug against that package with the Debian Bug
290
Tracking System. You may want to refer the package maintainer to section 12.8
291
of the Debian Policy manual.
295
message "The overlapping packages are: $bad_packages"
297
message "no overlaps found."
301
message "cannot search; no matches for $dpkg_info_dir/*.list."
304
message "cannot search; $dpkg_info_dir does not exist."
308
# we require a readlink command or shell function
309
if ! which readlink > /dev/null 2>&1; then
310
message "The readlink command was not found. Please install version" \
311
"1.13.1 or later of the debianutils package."
313
# returns what symlink in $1 actually points to
314
perl -e '$l = shift; exit 1 unless -l $l; $r = readlink $l; exit 1 unless $r; print "$r\n"' "$1"
319
# syntax: check_symlink symlink
321
# See if specified symlink points where it is supposed to. Return 0 if it
322
# does, and 1 if it does not.
324
# Primarily used by check_symlinks_and_warn() and check_symlinks_and_bomb().
329
if [ $# -ne 1 ]; then
330
usage_error "check_symlink() called with wrong number of arguments;" \
332
exit $SHELL_LIB_USAGE_ERROR
337
if [ "$(maplink "$symlink")" = "$(readlink "$symlink")" ]; then
344
check_symlinks_and_warn () {
345
# syntax: check_symlinks_and_warn symlink ...
347
# For each argument, check for symlink sanity, and warn if it isn't sane.
349
# Call this function from a preinst script in the event $1 is "upgrade" or
355
if [ $# -lt 1 ]; then
356
usage_error "check_symlinks_and_warn() called with wrong number of" \
357
"arguments; expected at least 1, got $#"
358
exit $SHELL_LIB_USAGE_ERROR
361
while [ -n "$1" ]; do
363
if [ -L "$symlink" ]; then
364
if ! check_symlink "$symlink"; then
365
observe "$symlink symbolic link points to wrong location" \
366
"$(readlink "$symlink"); removing"
369
elif [ -e "$symlink" ]; then
370
errmsg="$symlink exists and is not a symbolic link; this package cannot"
371
errmsg="$errmsg be installed until this"
372
if [ -f "$symlink" ]; then
373
errmsg="$errmsg file"
374
elif [ -d "$symlink" ]; then
375
errmsg="$errmsg directory"
377
errmsg="$errmsg thing"
379
errmsg="$errmsg is removed"
386
check_symlinks_and_bomb () {
387
# syntax: check_symlinks_and_bomb symlink ...
389
# For each argument, check for symlink sanity, and bomb if it isn't sane.
391
# Call this function from a postinst script.
393
local problem symlink
396
if [ $# -lt 1 ]; then
397
usage_error "check_symlinks_and_bomb() called with wrong number of"
398
"arguments; expected at least 1, got $#"
399
exit $SHELL_LIB_USAGE_ERROR
402
while [ -n "$1" ]; do
405
if [ -L "$symlink" ]; then
406
if ! check_symlink "$symlink"; then
408
warn "$symlink symbolic link points to wrong location" \
409
"$(readlink "$symlink")"
411
elif [ -e "$symlink" ]; then
413
warn "$symlink is not a symbolic link"
416
warn "$symlink symbolic link does not exist"
418
if [ -n "$problem" ]; then
419
analyze_path "$symlink" "$(readlink "$symlink")"
420
find_culprits "$symlink"
421
die "bad symbolic links on system"
428
185
# run $UPDATECMDS in $FONTDIRS
722
register_x_lib_dir_with_ld_so () {
723
# syntax: register_x_lib_dir_with_ld_so
725
# Configure the dynamic loader ld.so to search /usr/X11R6/lib for shared
728
# Call this function from the postinst script of a package that places a
729
# shared library in /usr/X11R6/lib, before invoking ldconfig.
734
ldsoconf="/etc/ld.so.conf"
736
# is the line not already present?
737
if ! fgrep -qsx "$dir" "$ldsoconf"; then
738
observe "adding $dir directory to $ldsoconf"
739
echo "$dir" >> "$ldsoconf"
743
deregister_x_lib_dir_with_ld_so () {
744
# syntax: deregister_x_lib_dir_with_ld_so
746
# Configure dynamic loader ld.so to not search /usr/X11R6/lib for shared
747
# libraries, if and only if no shared libaries remain there.
749
# Call this function from the postrm script of a package that places a shared
750
# library in /usr/X11R6/lib, in the event "$1" is "remove", and before
753
local dir ldsoconf fgrep_status cmp_status
756
ldsoconf="/etc/ld.so.conf"
758
# is the line present?
759
if fgrep -qsx "$dir" "$ldsoconf"; then
760
# are there any shared objects in the directory?
761
if [ "$(echo "$dir"/lib*.so.*.*)" = "$dir/lib*.so.*.*" ]; then
762
# glob expansion produced nothing, so no shared libraries are present
763
observe "removing $dir directory from $ldsoconf"
764
# rewrite the file (very carefully)
766
fgrep -svx "$dir" "$ldsoconf" > "$ldsoconf.dpkg-tmp"
769
case $fgrep_status in
770
0|1) ;; # we don't actually care if any lines matched or not
771
*) die "error reading \"$ldsoconf\"; fgrep exited with status" \
775
cmp -s "$ldsoconf.dpkg-tmp" "$ldsoconf"
779
0) rm "$ldsoconf.dpkg-tmp" ;; # files are identical
780
1) mv "$ldsoconf.dpkg-tmp" "$ldsoconf" ;; # files differ
781
*) die "error comparing \"$ldsoconf.dpkg-tmp\" to \"$ldsoconf\";" \
782
"cmp exited with status $cmp_status" ;;
788
479
make_symlink_sane () {
789
480
# syntax: make_symlink_sane symlink target