~ubuntu-branches/ubuntu/precise/xdm/precise

« back to all changes in this revision

Viewing changes to debian/xsfbs/xsfbs.sh

  • Committer: Bazaar Package Importer
  • Author(s): Artur Rona
  • Date: 2011-01-30 00:53:09 UTC
  • mfrom: (9.1.4 sid)
  • Revision ID: james.westby@ubuntu.com-20110130005309-30mjjyk7div7d494
Tags: 1:1.1.10-3ubuntu1
* Merge from debian unstable.  Remaining changes: (LP: #682196)
  - debian/{rules, xdm.install, local/ubuntu*}:
    + Add Ubuntu graphics and configure xdm to use them by default.
  - debian/patches/ubuntu_no_whiteglass.diff: Don't hardcode
    the default Xcursor theme to whiteglass. Use the Ubuntu
    default x-cursor-theme instead.
* debian/patches/ftbfs_binutils-gold.diff: Fix FTBFS with binutils-gold
  and ld --as-needed. (Closes: #556694)
* Dropped changes, no longer applicable:
  - debian/{xdm.postinst.in, xdm.postrm.in, xdm.preinst.in}

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# $Id$
2
 
 
3
1
# This is the X Strike Force shell library for X Window System package
4
2
# maintainer scripts.  It serves to define shell functions commonly used by
5
3
# such packages, and performs some error checking necessary for proper operation
8
6
# removal tasks.
9
7
 
10
8
# If you are reading this within a Debian package maintainer script (e.g.,
11
 
# /var/lib/dpkg)info/PACKAGE.{config,preinst,postinst,prerm,postrm}), you can
 
9
# /var/lib/dpkg/info/PACKAGE.{config,preinst,postinst,prerm,postrm}), you can
12
10
# skip past this library by scanning forward in this file to the string
13
11
# "GOBSTOPPER".
14
12
 
93
91
  done
94
92
}
95
93
 
96
 
reject_whitespace () {
97
 
  # syntax: reject_whitespace [ operand ]
98
 
  #
99
 
  # scan operand (typically a shell variable whose value cannot be trusted) for
100
 
  # whitespace characters and barf if any are found
101
 
  if [ -n "$1" ]; then
102
 
    # does the operand contain any whitespace?
103
 
    if expr "$1" : "[[:space:]]" > /dev/null 2>&1; then
104
 
      # can't use die(), because I want to avoid forward references
105
 
      echo "$THIS_PACKAGE $THIS_SCRIPT error: reject_whitespace() encountered" \
106
 
           "possibly malicious garbage \"$1\"" >&2
107
 
      exit $SHELL_LIB_THROWN_ERROR
108
 
    fi
109
 
  fi
110
 
}
111
 
 
112
94
reject_unlikely_path_chars () {
113
95
  # syntax: reject_unlikely_path_chars [ operand ... ]
114
96
  #
199
181
  exit $SHELL_LIB_USAGE_ERROR
200
182
}
201
183
 
202
 
 
203
 
maplink () {
204
 
  # returns what symlink should point to; i.e., what the "sane" answer is
205
 
  # Keep this in sync with the debian/*.links files.
206
 
  # This is only needed for symlinks to directories.
207
 
  #
208
 
  # XXX: Most of these look wrong in the X11R7 world and need to be fixed.
209
 
  # If we've stopped using this function, fixing it might enable us to re-enable
210
 
  # it again and catch more errors.
211
 
  case "$1" in
212
 
    /etc/X11/xkb/compiled) echo /var/lib/xkb ;;
213
 
    /etc/X11/xkb/xkbcomp) echo /usr/X11R6/bin/xkbcomp ;;
214
 
    /usr/X11R6/lib/X11/app-defaults) echo /etc/X11/app-defaults ;;
215
 
    /usr/X11R6/lib/X11/fs) echo /etc/X11/fs ;;
216
 
    /usr/X11R6/lib/X11/lbxproxy) echo /etc/X11/lbxproxy ;;
217
 
    /usr/X11R6/lib/X11/proxymngr) echo /etc/X11/proxymngr ;;
218
 
    /usr/X11R6/lib/X11/rstart) echo /etc/X11/rstart ;;
219
 
    /usr/X11R6/lib/X11/twm) echo /etc/X11/twm ;;
220
 
    /usr/X11R6/lib/X11/xdm) echo /etc/X11/xdm ;;
221
 
    /usr/X11R6/lib/X11/xinit) echo /etc/X11/xinit ;;
222
 
    /usr/X11R6/lib/X11/xkb) echo /etc/X11/xkb ;;
223
 
    /usr/X11R6/lib/X11/xserver) echo /etc/X11/xserver ;;
224
 
    /usr/X11R6/lib/X11/xsm) echo /etc/X11/xsm ;;
225
 
    /usr/bin/X11) echo ../X11R6/bin ;;
226
 
    /usr/bin/rstartd) echo ../X11R6/bin/rstartd ;;
227
 
    /usr/include/X11) echo ../X11R6/include/X11 ;;
228
 
    /usr/lib/X11) echo ../X11R6/lib/X11 ;;
229
 
    *) internal_error "maplink() called with unknown path \"$1\"" ;;
230
 
  esac
231
 
}
232
 
 
233
 
analyze_path () {
234
 
  # given a supplied set of pathnames, break each one up by directory and do an
235
 
  # ls -dl on each component, cumulatively; i.e.
236
 
  # analyze_path /usr/X11R6/bin -> ls -dl /usr /usr/X11R6 /usr/X11R6/bin
237
 
  # Thanks to Randolph Chung for this clever hack.
238
 
 
239
 
  local f g
240
 
 
241
 
  while [ -n "$1" ]; do
242
 
    reject_whitespace "$1"
243
 
    g=
244
 
    message "Analyzing $1:"
245
 
    for f in $(echo "$1" | tr / \  ); do
246
 
      if [ -e /$g$f ]; then
247
 
        ls -dl /$g$f /$g$f.dpkg-* 2> /dev/null || true
248
 
        g=$g$f/
249
 
      else
250
 
        message "/$g$f: nonexistent; directory contents of /$g:"
251
 
        ls -l /$g
252
 
        break
253
 
      fi
254
 
    done
255
 
    shift
256
 
  done
257
 
}
258
 
 
259
 
find_culprits () {
260
 
  local f p dpkg_info_dir possible_culprits smoking_guns bad_packages package \
261
 
    msg
262
 
 
263
 
  reject_whitespace "$1"
264
 
  message "Searching for overlapping packages..."
265
 
  dpkg_info_dir=/var/lib/dpkg/info
266
 
  if [ -d $dpkg_info_dir ]; then
267
 
    if [ "$(echo $dpkg_info_dir/*.list)" != "$dpkg_info_dir/*.list" ]; then
268
 
      possible_culprits=$(ls -1 $dpkg_info_dir/*.list | egrep -v \
269
 
        "(xbase-clients|x11-common|xfs|xlibs)")
270
 
      if [ -n "$possible_culprits" ]; then
271
 
        smoking_guns=$(grep -l "$1" $possible_culprits || true)
272
 
        if [ -n "$smoking_guns" ]; then
273
 
          bad_packages=$(printf "\\n")
274
 
          for f in $smoking_guns; do
275
 
            # too bad you can't nest parameter expansion voodoo
276
 
            p=${f%*.list}      # strip off the trailing ".list"
277
 
            package=${p##*/}   # strip off the directories
278
 
            bad_packages=$(printf "%s\n%s" "$bad_packages" "$package")
279
 
          done
280
 
          msg=$(cat <<EOF
281
 
The following packages appear to have file overlaps with the X.Org packages;
282
 
these packages are either very old, or in violation of Debian Policy.  Try
283
 
upgrading each of these packages to the latest available version if possible:
284
 
for example, with the command "apt-get install".  If no newer version of a
285
 
package is available, you will have to remove it; for example, with the command
286
 
"apt-get remove".  If even the latest available version of the package has
287
 
this file overlap, please file a bug against that package with the Debian Bug
288
 
Tracking System.  You may want to refer the package maintainer to section 12.8
289
 
of the Debian Policy manual.
290
 
EOF
291
 
)
292
 
          message "$msg"
293
 
          message "The overlapping packages are: $bad_packages"
294
 
        else
295
 
          message "no overlaps found."
296
 
        fi
297
 
      fi
298
 
    else
299
 
      message "cannot search; no matches for $dpkg_info_dir/*.list."
300
 
    fi
301
 
  else
302
 
    message "cannot search; $dpkg_info_dir does not exist."
303
 
  fi
304
 
}
305
 
 
306
 
check_symlink () {
307
 
  # syntax: check_symlink symlink
308
 
  #
309
 
  # See if specified symlink points where it is supposed to.  Return 0 if it
310
 
  # does, and 1 if it does not.
311
 
  #
312
 
  # Primarily used by check_symlinks_and_warn() and check_symlinks_and_bomb().
313
 
 
314
 
  local symlink
315
 
 
316
 
  # validate arguments
317
 
  if [ $# -ne 1 ]; then
318
 
    usage_error "check_symlink() called with wrong number of arguments;" \
319
 
                "expected 1, got $#"
320
 
    exit $SHELL_LIB_USAGE_ERROR
321
 
  fi
322
 
 
323
 
  symlink="$1"
324
 
 
325
 
  if [ "$(maplink "$symlink")" = "$(readlink "$symlink")" ]; then
326
 
    return 0
327
 
  else
328
 
    return 1
329
 
  fi
330
 
}
331
 
 
332
 
check_symlinks_and_warn () {
333
 
  # syntax: check_symlinks_and_warn symlink ...
334
 
  #
335
 
  # For each argument, check for symlink sanity, and warn if it isn't sane.
336
 
  #
337
 
  # Call this function from a preinst script in the event $1 is "upgrade" or
338
 
  # "install".
339
 
 
340
 
  local errmsg symlink
341
 
 
342
 
  # validate arguments
343
 
  if [ $# -lt 1 ]; then
344
 
    usage_error "check_symlinks_and_warn() called with wrong number of" \
345
 
                "arguments; expected at least 1, got $#"
346
 
    exit $SHELL_LIB_USAGE_ERROR
347
 
  fi
348
 
 
349
 
  while [ -n "$1" ]; do
350
 
    symlink="$1"
351
 
    if [ -L "$symlink" ]; then
352
 
      if ! check_symlink "$symlink"; then
353
 
        observe "$symlink symbolic link points to wrong location" \
354
 
                "$(readlink "$symlink"); removing"
355
 
        rm "$symlink"
356
 
      fi
357
 
    elif [ -e "$symlink" ]; then
358
 
      errmsg="$symlink exists and is not a symbolic link; this package cannot"
359
 
      errmsg="$errmsg be installed until this"
360
 
      if [ -f "$symlink" ]; then
361
 
        errmsg="$errmsg file"
362
 
      elif [ -d "$symlink" ]; then
363
 
        errmsg="$errmsg directory"
364
 
      else
365
 
        errmsg="$errmsg thing"
366
 
      fi
367
 
      errmsg="$errmsg is removed"
368
 
      die "$errmsg"
369
 
    fi
370
 
    shift
371
 
  done
372
 
}
373
 
 
374
 
check_symlinks_and_bomb () {
375
 
  # syntax: check_symlinks_and_bomb symlink ...
376
 
  #
377
 
  # For each argument, check for symlink sanity, and bomb if it isn't sane.
378
 
  #
379
 
  # Call this function from a postinst script.
380
 
 
381
 
  local problem symlink
382
 
 
383
 
  # validate arguments
384
 
  if [ $# -lt 1 ]; then
385
 
    usage_error "check_symlinks_and_bomb() called with wrong number of"
386
 
                "arguments; expected at least 1, got $#"
387
 
    exit $SHELL_LIB_USAGE_ERROR
388
 
  fi
389
 
 
390
 
  while [ -n "$1" ]; do
391
 
    problem=
392
 
    symlink="$1"
393
 
    if [ -L "$symlink" ]; then
394
 
      if ! check_symlink "$symlink"; then
395
 
        problem=yes
396
 
        warn "$symlink symbolic link points to wrong location" \
397
 
             "$(readlink "$symlink")"
398
 
      fi
399
 
    elif [ -e "$symlink" ]; then
400
 
      problem=yes
401
 
      warn "$symlink is not a symbolic link"
402
 
    else
403
 
      problem=yes
404
 
      warn "$symlink symbolic link does not exist"
405
 
    fi
406
 
    if [ -n "$problem" ]; then
407
 
      analyze_path "$symlink" "$(readlink "$symlink")"
408
 
      find_culprits "$symlink"
409
 
      die "bad symbolic links on system"
410
 
    fi
411
 
    shift
412
 
  done
413
 
}
414
 
 
415
184
font_update () {
416
185
  # run $UPDATECMDS in $FONTDIRS
417
186