~ubuntu-branches/ubuntu/lucid/libxpm/lucid

« back to all changes in this revision

Viewing changes to debian/xsfbs/xsfbs.sh

  • Committer: Bazaar Package Importer
  • Author(s): Julien Cristau, Julien Cristau, Brice Goglin
  • Date: 2009-06-10 14:59:30 UTC
  • mfrom: (3.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090610145930-4n7qeoquz7swwwn6
Tags: 1:3.5.7-2
[ Julien Cristau ]
* Drop -1 debian revisions from build-deps.
* Bump Standards-Version to 3.7.3.
* Drop the XS- prefix from Vcs-* control fields.
* libxpm4{,-dbg} don't need to depend on x11-common.
* Add xpm.PS.gz to the -dev package (closes: #525551).
* Don't handle nostrip in DEB_BUILD_OPTIONS explicitly, dh_strip does the
  right thing.
* Use filter instead of findstring to parse DEB_BUILD_OPTIONS in
  debian/rules.
* Add README.source, bump Standards-Version to 3.8.1.
* Run autoreconf at build time.
* Allow parallel builds.
* Move -dbg package to new debug section.
* Don't pass -l and -L options to dh_shlibdeps, it seems to be useless
  nowadays.

[ Brice Goglin ]
* Add a link to www.X.org and a reference to the upstream module
  in the long description.

Show diffs side-by-side

added added

removed removed

Lines of Context:
57
57
  exit $SHELL_LIB_USAGE_ERROR
58
58
fi
59
59
 
60
 
ARCHITECTURE="$(dpkg --print-installation-architecture)"
61
 
 
62
 
LAPTOP=""
63
 
if [ -n "$(which laptop-detect)" ]; then
64
 
    if laptop-detect >/dev/null; then
65
 
        LAPTOP=true
66
 
    fi
67
 
fi
68
 
 
69
60
if [ "$1" = "reconfigure" ] || [ -n "$DEBCONF_RECONFIGURE" ]; then
70
61
  RECONFIGURE="true"
71
62
else
245
236
  # analyze_path /usr/X11R6/bin -> ls -dl /usr /usr/X11R6 /usr/X11R6/bin
246
237
  # Thanks to Randolph Chung for this clever hack.
247
238
 
248
 
  #local f g
 
239
  local f g
249
240
 
250
241
  while [ -n "$1" ]; do
251
242
    reject_whitespace "$1"
252
 
    _g=
 
243
    g=
253
244
    message "Analyzing $1:"
254
 
    for _f in $(echo "$1" | tr / \  ); do
255
 
      if [ -e /$_g$_f ]; then
256
 
        ls -dl /$_g$_f /$_g$_f.dpkg-* 2> /dev/null || true
257
 
        _g=$_g$_f/
 
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/
258
249
      else
259
 
        message "/$_g$_f: nonexistent; directory contents of /$_g:"
260
 
        ls -l /$_g
 
250
        message "/$g$f: nonexistent; directory contents of /$g:"
 
251
        ls -l /$g
261
252
        break
262
253
      fi
263
254
    done
266
257
}
267
258
 
268
259
find_culprits () {
269
 
  #local f p dpkg_info_dir possible_culprits smoking_guns bad_packages package \
270
 
  #  msg
 
260
  local f p dpkg_info_dir possible_culprits smoking_guns bad_packages package \
 
261
    msg
271
262
 
272
263
  reject_whitespace "$1"
273
264
  message "Searching for overlapping packages..."
274
 
  _dpkg_info_dir=/var/lib/dpkg/info
275
 
  if [ -d $_dpkg_info_dir ]; then
276
 
    if [ "$(echo $_dpkg_info_dir/*.list)" != "$_dpkg_info_dir/*.list" ]; then
277
 
      _possible_culprits=$(ls -1 $_dpkg_info_dir/*.list | egrep -v \
 
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 \
278
269
        "(xbase-clients|x11-common|xfs|xlibs)")
279
 
      if [ -n "$_possible_culprits" ]; then
280
 
        _smoking_guns=$(grep -l "$1" $_possible_culprits || true)
281
 
        if [ -n "$_smoking_guns" ]; then
282
 
          _bad_packages=$(printf "\\n")
283
 
          for f in $_smoking_guns; do
 
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
284
275
            # too bad you can't nest parameter expansion voodoo
285
276
            p=${f%*.list}      # strip off the trailing ".list"
286
 
            _package=${p##*/}   # strip off the directories
287
 
            _bad_packages=$(printf "%s\n%s" "$_bad_packages" "$_package")
 
277
            package=${p##*/}   # strip off the directories
 
278
            bad_packages=$(printf "%s\n%s" "$bad_packages" "$package")
288
279
          done
289
 
          _msg=$(cat <<EOF
 
280
          msg=$(cat <<EOF
290
281
The following packages appear to have file overlaps with the X.Org packages;
291
282
these packages are either very old, or in violation of Debian Policy.  Try
292
283
upgrading each of these packages to the latest available version if possible:
298
289
of the Debian Policy manual.
299
290
EOF
300
291
)
301
 
          message "$_msg"
302
 
          message "The overlapping packages are: $_bad_packages"
 
292
          message "$msg"
 
293
          message "The overlapping packages are: $bad_packages"
303
294
        else
304
295
          message "no overlaps found."
305
296
        fi
306
297
      fi
307
298
    else
308
 
      message "cannot search; no matches for $_dpkg_info_dir/*.list."
 
299
      message "cannot search; no matches for $dpkg_info_dir/*.list."
309
300
    fi
310
301
  else
311
 
    message "cannot search; $_dpkg_info_dir does not exist."
 
302
    message "cannot search; $dpkg_info_dir does not exist."
312
303
  fi
313
304
}
314
305
 
315
 
# we require a readlink command or shell function
316
 
if ! which readlink > /dev/null 2>&1; then
317
 
  message "The readlink command was not found.  Please install version" \
318
 
          "1.13.1 or later of the debianutils package."
319
 
  readlink () {
320
 
    # returns what symlink in $1 actually points to
321
 
    perl -e '$l = shift; exit 1 unless -l $l; $r = readlink $l; exit 1 unless $r; print "$r\n"' "$1"
322
 
  }
323
 
fi
324
 
 
325
306
check_symlink () {
326
307
  # syntax: check_symlink symlink
327
308
  #
330
311
  #
331
312
  # Primarily used by check_symlinks_and_warn() and check_symlinks_and_bomb().
332
313
 
333
 
  #local symlink
 
314
  local symlink
334
315
 
335
316
  # validate arguments
336
317
  if [ $# -ne 1 ]; then
339
320
    exit $SHELL_LIB_USAGE_ERROR
340
321
  fi
341
322
 
342
 
  _symlink="$1"
 
323
  symlink="$1"
343
324
 
344
 
  if [ "$(maplink "$_symlink")" = "$(readlink "$_symlink")" ]; then
 
325
  if [ "$(maplink "$symlink")" = "$(readlink "$symlink")" ]; then
345
326
    return 0
346
327
  else
347
328
    return 1
356
337
  # Call this function from a preinst script in the event $1 is "upgrade" or
357
338
  # "install".
358
339
 
359
 
  #local errmsg symlink
 
340
  local errmsg symlink
360
341
 
361
342
  # validate arguments
362
343
  if [ $# -lt 1 ]; then
366
347
  fi
367
348
 
368
349
  while [ -n "$1" ]; do
369
 
    _symlink="$1"
370
 
    if [ -L "$_symlink" ]; then
371
 
      if ! check_symlink "$_symlink"; then
372
 
        observe "$_symlink symbolic link points to wrong location" \
373
 
                "$(readlink "$_symlink"); removing"
374
 
        rm "$_symlink"
 
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"
375
356
      fi
376
 
    elif [ -e "$_symlink" ]; then
377
 
      _errmsg="$_symlink exists and is not a symbolic link; this package cannot"
378
 
      _errmsg="$_errmsg be installed until this"
379
 
      if [ -f "$_symlink" ]; then
380
 
        _errmsg="$_errmsg file"
381
 
      elif [ -d "$_symlink" ]; then
382
 
        _errmsg="$_errmsg directory"
 
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"
383
364
      else
384
 
        _errmsg="$_errmsg thing"
 
365
        errmsg="$errmsg thing"
385
366
      fi
386
 
      _errmsg="$_errmsg is removed"
387
 
      die "$_errmsg"
 
367
      errmsg="$errmsg is removed"
 
368
      die "$errmsg"
388
369
    fi
389
370
    shift
390
371
  done
397
378
  #
398
379
  # Call this function from a postinst script.
399
380
 
400
 
  #local problem symlink
 
381
  local problem symlink
401
382
 
402
383
  # validate arguments
403
384
  if [ $# -lt 1 ]; then
407
388
  fi
408
389
 
409
390
  while [ -n "$1" ]; do
410
 
    _problem=
411
 
    _symlink="$1"
412
 
    if [ -L "$_symlink" ]; then
413
 
      if ! check_symlink "$_symlink"; then
414
 
        _problem=yes
415
 
        warn "$_symlink symbolic link points to wrong location" \
416
 
             "$(readlink "$_symlink")"
 
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")"
417
398
      fi
418
 
    elif [ -e "$_symlink" ]; then
419
 
      _problem=yes
420
 
      warn "$_symlink is not a symbolic link"
 
399
    elif [ -e "$symlink" ]; then
 
400
      problem=yes
 
401
      warn "$symlink is not a symbolic link"
421
402
    else
422
 
      _problem=yes
423
 
      warn "$_symlink symbolic link does not exist"
 
403
      problem=yes
 
404
      warn "$symlink symbolic link does not exist"
424
405
    fi
425
 
    if [ -n "$_problem" ]; then
426
 
      analyze_path "$_symlink" "$(readlink "$_symlink")"
427
 
      find_culprits "$_symlink"
 
406
    if [ -n "$problem" ]; then
 
407
      analyze_path "$symlink" "$(readlink "$symlink")"
 
408
      find_culprits "$symlink"
428
409
      die "bad symbolic links on system"
429
410
    fi
430
411
    shift
434
415
font_update () {
435
416
  # run $UPDATECMDS in $FONTDIRS
436
417
 
437
 
  #local dir cmd shortcmd x_font_dir_prefix
 
418
  local dir cmd shortcmd x_font_dir_prefix
438
419
 
439
 
  _x_font_dir_prefix="/usr/share/fonts/X11"
 
420
  x_font_dir_prefix="/usr/share/fonts/X11"
440
421
 
441
422
  if [ -z "$UPDATECMDS" ]; then
442
423
    usage_error "font_update() called but \$UPDATECMDS not set"
448
429
  reject_unlikely_path_chars "$UPDATECMDS"
449
430
  reject_unlikely_path_chars "$FONTDIRS"
450
431
 
451
 
  for _dir in $FONTDIRS; do
452
 
    if [ -d "$_x_font_dir_prefix/$_dir" ]; then
453
 
      for _cmd in $UPDATECMDS; do
454
 
        if which "$_cmd" > /dev/null 2>&1; then
455
 
          _shortcmd=${_cmd##*/}
456
 
          observe "running $_shortcmd in $_dir font directory"
457
 
          _cmd_opts=
458
 
          if [ "$_shortcmd" = "update-fonts-alias" ]; then
459
 
            _cmd_opts=--x11r7-layout
460
 
          fi
461
 
          if [ "$_shortcmd" = "update-fonts-dir" ]; then
462
 
            _cmd_opts=--x11r7-layout
463
 
          fi
464
 
          if [ "$_shortcmd" = "update-fonts-scale" ]; then
465
 
            _cmd_opts=--x11r7-layout
466
 
          fi
467
 
          $_cmd $_cmd_opts $_dir || warn "$_cmd $_cmd_opts $_dir" \
 
432
  for dir in $FONTDIRS; do
 
433
    if [ -d "$x_font_dir_prefix/$dir" ]; then
 
434
      for cmd in $UPDATECMDS; do
 
435
        if which "$cmd" > /dev/null 2>&1; then
 
436
          shortcmd=${cmd##*/}
 
437
          observe "running $shortcmd in $dir font directory"
 
438
          cmd_opts=
 
439
          if [ "$shortcmd" = "update-fonts-alias" ]; then
 
440
            cmd_opts=--x11r7-layout
 
441
          fi
 
442
          if [ "$shortcmd" = "update-fonts-dir" ]; then
 
443
            cmd_opts=--x11r7-layout
 
444
          fi
 
445
          if [ "$shortcmd" = "update-fonts-scale" ]; then
 
446
            cmd_opts=--x11r7-layout
 
447
          fi
 
448
          $cmd $cmd_opts $dir || warn "$cmd $cmd_opts $dir" \
468
449
                              "failed; font directory data may not" \
469
450
                              "be up to date"
470
451
        else
471
 
          warn "$_cmd not found; not updating corresponding $_dir font" \
 
452
          warn "$cmd not found; not updating corresponding $dir font" \
472
453
               "directory data"
473
454
        fi
474
455
      done
475
456
    else
476
 
      warn "$_dir is not a directory; not updating font directory data"
 
457
      warn "$dir is not a directory; not updating font directory data"
477
458
    fi
478
459
  done
479
460
}
492
473
  # version (or installed over a version removed-but-not-purged) prior to the
493
474
  # one in which the conffile was obsoleted.
494
475
 
495
 
  #local conffile current_checksum
 
476
  local conffile current_checksum
496
477
 
497
478
  # validate arguments
498
479
  if [ $# -lt 2 ]; then
501
482
    exit $SHELL_LIB_USAGE_ERROR
502
483
  fi
503
484
 
504
 
  _conffile="$1"
 
485
  conffile="$1"
505
486
  shift
506
487
 
507
 
  # does the _conffile even exist?
508
 
  if [ -e "$_conffile" ]; then
 
488
  # does the conffile even exist?
 
489
  if [ -e "$conffile" ]; then
509
490
    # calculate its checksum
510
 
    _current_checksum=$(md5sum < "$_conffile" | sed 's/[[:space:]].*//')
 
491
    current_checksum=$(md5sum < "$conffile" | sed 's/[[:space:]].*//')
511
492
    # compare it to each supplied checksum
512
493
    while [ -n "$1" ]; do
513
 
      if [ "$_current_checksum" = "$1" ]; then
 
494
      if [ "$current_checksum" = "$1" ]; then
514
495
        # we found a match; move the confffile and stop looking
515
 
        observe "preparing obsolete conffile $_conffile for removal"
516
 
        mv "$_conffile" "$_conffile.$THIS_PACKAGE-tmp"
 
496
        observe "preparing obsolete conffile $conffile for removal"
 
497
        mv "$conffile" "$conffile.$THIS_PACKAGE-tmp"
517
498
        break
518
499
      fi
519
500
      shift
521
502
  fi
522
503
}
523
504
 
 
505
remove_conffile_lookup () {
 
506
  # syntax: remove_conffile_lookup package filename
 
507
  #
 
508
  # Lookup the md5sum of a conffile in dpkg's database, and prepare for removal
 
509
  # if it matches the actual file's md5sum.
 
510
  #
 
511
  # Call this function when you would call remove_conffile_prepare but only
 
512
  # want to check against dpkg's status database instead of known checksums.
 
513
 
 
514
  local package conffile old_md5sum
 
515
 
 
516
  # validate arguments
 
517
  if [ $# -ne 2 ]; then
 
518
    usage_error "remove_conffile_lookup() called with wrong number of" \
 
519
                "arguments; expected 1, got $#"
 
520
    exit $SHELL_LIB_USAGE_ERROR
 
521
  fi
 
522
 
 
523
  package="$1"
 
524
  conffile="$2"
 
525
 
 
526
  if ! [ -e "$conffile" ]; then
 
527
    return
 
528
  fi
 
529
  old_md5sum="$(dpkg-query -W -f='${Conffiles}' "$package" | \
 
530
    awk '{ if (match($0, "^ '"$conffile"' ")) print $2}')"
 
531
  if [ -n "$old_md5sum" ]; then
 
532
    remove_conffile_prepare "$conffile" "$old_md5sum"
 
533
  fi
 
534
}
 
535
 
524
536
remove_conffile_commit () {
525
537
  # syntax: remove_conffile_commit filename
526
538
  #
529
541
  # Call this function from a postinst script after having used
530
542
  # remove_conffile_prepare() in the preinst.
531
543
 
532
 
  #local conffile
 
544
  local conffile
533
545
 
534
546
  # validate arguments
535
547
  if [ $# -ne 1 ]; then
538
550
    exit $SHELL_LIB_USAGE_ERROR
539
551
  fi
540
552
 
541
 
  _conffile="$1"
 
553
  conffile="$1"
542
554
 
543
555
  # if the temporary file created by remove_conffile_prepare() exists, remove it
544
 
  if [ -e "$_conffile.$THIS_PACKAGE-tmp" ]; then
545
 
    observe "committing removal of obsolete conffile $_conffile"
546
 
    rm "$_conffile.$THIS_PACKAGE-tmp"
 
556
  if [ -e "$conffile.$THIS_PACKAGE-tmp" ]; then
 
557
    observe "committing removal of obsolete conffile $conffile"
 
558
    rm "$conffile.$THIS_PACKAGE-tmp"
547
559
  fi
548
560
}
549
561
 
556
568
  # or "abort-install" is  after having used remove_conffile_prepare() in the
557
569
  # preinst.
558
570
 
559
 
  #local conffile
 
571
  local conffile
560
572
 
561
573
  # validate arguments
562
574
  if [ $# -ne 1 ]; then
565
577
    exit $SHELL_LIB_USAGE_ERROR
566
578
  fi
567
579
 
568
 
  _conffile="$1"
 
580
  conffile="$1"
569
581
 
570
582
  # if the temporary file created by remove_conffile_prepare() exists, move it
571
583
  # back
572
 
  if [ -e "$_conffile.$THIS_PACKAGE-tmp" ]; then
573
 
    observe "rolling back removal of obsolete conffile $_conffile"
574
 
    mv "$_conffile.$THIS_PACKAGE-tmp" "$_conffile"
 
584
  if [ -e "$conffile.$THIS_PACKAGE-tmp" ]; then
 
585
    observe "rolling back removal of obsolete conffile $conffile"
 
586
    mv "$conffile.$THIS_PACKAGE-tmp" "$conffile"
575
587
  fi
576
588
}
577
589
 
591
603
  # version (or installed over a version removed-but-not-purged) prior to the
592
604
  # one in which the conffile was obsoleted.
593
605
 
594
 
  #local conffile current_checksum
 
606
  local conffile current_checksum
595
607
 
596
608
  # validate arguments
597
609
  if [ $# -lt 3 ]; then
600
612
    exit $SHELL_LIB_USAGE_ERROR
601
613
  fi
602
614
 
603
 
  _oldconffile="$1"
 
615
  oldconffile="$1"
604
616
  shift
605
 
  _newconffile="$1"
 
617
  newconffile="$1"
606
618
  shift
607
619
 
608
620
  remove_conffile_prepare "$_oldconffile" "$@"
609
 
  # If $_oldconffile still exists, then md5sums didn't match.
 
621
  # If $oldconffile still exists, then md5sums didn't match.
610
622
  # Copy it to new one.
611
 
  if [ -f "$_oldconffile" ]; then
612
 
    cp "$_oldconffile" "$_newconffile"
 
623
  if [ -f "$oldconffile" ]; then
 
624
    cp "$oldconffile" "$newconffile"
613
625
  fi
614
626
 
615
627
}
623
635
  # Call this function from a postinst script after having used
624
636
  # replace_conffile_with_symlink_prepare() in the preinst.
625
637
 
626
 
  #local conffile
 
638
  local conffile
627
639
 
628
640
  # validate arguments
629
641
  if [ $# -ne 1 ]; then
632
644
    exit $SHELL_LIB_USAGE_ERROR
633
645
  fi
634
646
 
635
 
  _conffile="$1"
 
647
  conffile="$1"
636
648
 
637
 
  remove_conffile_commit "$_conffile"
 
649
  remove_conffile_commit "$conffile"
638
650
}
639
651
 
640
652
replace_conffile_with_symlink_rollback () {
650
662
  # You should have  used replace_conffile_with_symlink_prepare() in the
651
663
  # preinst.
652
664
 
653
 
  #local conffile
 
665
  local conffile
654
666
 
655
667
  # validate arguments
656
668
  if [ $# -ne 2 ]; then
659
671
    exit $SHELL_LIB_USAGE_ERROR
660
672
  fi
661
673
 
662
 
  _oldconffile="$1"
663
 
  _newconffile="$2"
 
674
  oldconffile="$1"
 
675
  newconffile="$2"
664
676
 
665
677
  remove_conffile_rollback "$_oldconffile"
666
 
  if [ -f "$_newconffile" ]; then
667
 
    rm "$_newconffile"
 
678
  if [ -f "$newconffile" ]; then
 
679
    rm "$newconffile"
668
680
  fi
669
681
}
670
682
 
679
691
  # those cases the return value of the debconf command *must* be checked
680
692
  # before the string returned by debconf is used for anything.
681
693
 
682
 
  #local retval
 
694
  local retval
683
695
 
684
696
  # validate arguments
685
697
  if [ $# -lt 1 ]; then
688
700
    exit $SHELL_LIB_USAGE_ERROR
689
701
  fi
690
702
 
691
 
  "$@" || _retval=$?
692
 
 
693
 
  if [ ${_retval:-0} -ne 0 ]; then
694
 
    observe "command \"$*\" exited with status $_retval"
695
 
  fi
696
 
}
697
 
 
698
 
register_x_lib_dir_with_ld_so () {
699
 
  # syntax: register_x_lib_dir_with_ld_so
700
 
  #
701
 
  # Configure the dynamic loader ld.so to search /usr/X11R6/lib for shared
702
 
  # libraries.
703
 
  #
704
 
  # Call this function from the postinst script of a package that places a
705
 
  # shared library in /usr/X11R6/lib, before invoking ldconfig.
706
 
 
707
 
  #local dir ldsoconf
708
 
 
709
 
  _dir="/usr/X11R6/lib"
710
 
  _ldsoconf="/etc/ld.so.conf"
711
 
 
712
 
  # is the line not already present?
713
 
  if ! fgrep -qsx "$_dir" "$_ldsoconf"; then
714
 
    observe "adding $_dir directory to $_ldsoconf"
715
 
    echo "$_dir" >> "$_ldsoconf"
716
 
  fi
717
 
}
718
 
 
719
 
deregister_x_lib_dir_with_ld_so () {
720
 
  # syntax: deregister_x_lib_dir_with_ld_so
721
 
  #
722
 
  # Configure dynamic loader ld.so to not search /usr/X11R6/lib for shared
723
 
  # libraries, if and only if no shared libaries remain there.
724
 
  #
725
 
  # Call this function from the postrm script of a package that places a shared
726
 
  # library in /usr/X11R6/lib, in the event "$1" is "remove", and before
727
 
  # invoking ldconfig.
728
 
 
729
 
  #local dir ldsoconf fgrep_status cmp_status
730
 
 
731
 
  _dir="/usr/X11R6/lib"
732
 
  _ldsoconf="/etc/ld.so.conf"
733
 
 
734
 
  # is the line present?
735
 
  if fgrep -qsx "$_dir" "$_ldsoconf"; then
736
 
    # are there any shared objects in the directory?
737
 
    if [ "$(echo "$_dir"/lib*.so.*.*)" = "$_dir/lib*.so.*.*" ]; then
738
 
      # glob expansion produced nothing, so no shared libraries are present
739
 
      observe "removing $_dir directory from $_ldsoconf"
740
 
      # rewrite the file (very carefully)
741
 
      set +e
742
 
      fgrep -svx "$_dir" "$_ldsoconf" > "$_ldsoconf.dpkg-tmp"
743
 
      _fgrep_status=$?
744
 
      set -e
745
 
      case $_fgrep_status in
746
 
        0|1) ;; # we don't actually care if any lines matched or not
747
 
        *) die "error reading \"$_ldsoconf\"; fgrep exited with status" \
748
 
          "$_fgrep_status" ;;
749
 
      esac
750
 
      set +e
751
 
      cmp -s "$_ldsoconf.dpkg-tmp" "$_ldsoconf"
752
 
      _cmp_status=$?
753
 
      set -e
754
 
      case $_cmp_status in
755
 
        0) rm "$_ldsoconf.dpkg-tmp" ;; # files are identical
756
 
        1) mv "$_ldsoconf.dpkg-tmp" "$_ldsoconf" ;; # files differ
757
 
        *) die "error comparing \"$_ldsoconf.dpkg-tmp\" to \"$_ldsoconf\";" \
758
 
          "cmp exited with status $_cmp_status" ;;
759
 
      esac
760
 
    fi
 
703
  "$@" || retval=$?
 
704
 
 
705
  if [ ${retval:-0} -ne 0 ]; then
 
706
    observe "command \"$*\" exited with status $retval"
761
707
  fi
762
708
}
763
709
 
787
733
 
788
734
  # We could just use the positional parameters as-is, but that makes things
789
735
  # harder to follow.
790
 
  #local symlink target
791
 
 
792
 
  _symlink="$1"
793
 
  _target="$2"
794
 
 
795
 
  if [ -L "$_symlink" ] && [ "$(readlink "$_symlink")" = "$_target" ]; then
796
 
      observe "link from $_symlink to $_target already exists"
 
736
  local symlink target
 
737
 
 
738
  symlink="$1"
 
739
  target="$2"
 
740
 
 
741
  if [ -L "$symlink" ] && [ "$(readlink "$symlink")" = "$target" ]; then
 
742
      observe "link from $symlink to $target already exists"
797
743
  else
798
 
    observe "creating symbolic link from $_symlink to $_target"
799
 
    mkdir -p "${_target%/*}" "${_symlink%/*}"
800
 
    ln -s -b -S ".dpkg-old" "$_target" "$_symlink"
 
744
    observe "creating symbolic link from $symlink to $target"
 
745
    mkdir -p "${target%/*}" "${symlink%/*}"
 
746
    ln -s -b -S ".dpkg-old" "$target" "$symlink"
801
747
  fi
802
748
}
803
749
 
833
779
 
834
780
  # We could just use the positional parameters as-is, but that makes things
835
781
  # harder to follow.
836
 
  local _new _old
 
782
  local new old
837
783
 
838
 
  _old="$1"
839
 
  _new="$2"
 
784
  old="$1"
 
785
  new="$2"
840
786
 
841
787
  # Is old location a symlink?
842
 
  if [ -L "$_old" ]; then
 
788
  if [ -L "$old" ]; then
843
789
    # Does it already point to new location?
844
 
    if [ "$(readlink "$_old")" = "$_new" ]; then
 
790
    if [ "$(readlink "$old")" = "$new" ]; then
845
791
      # Nothing to do; migration has already been done.
846
 
      observe "migration of $_old to $_new already done"
 
792
      observe "migration of $old to $new already done"
847
793
      return 0
848
794
    else
849
795
      # Back it up.
850
 
      warn "backing up symbolic link $_old as $_old.dpkg-old"
851
 
      mv -b "$_old" "$_old.dpkg-old"
 
796
      warn "backing up symbolic link $old as $old.dpkg-old"
 
797
      mv -b "$old" "$old.dpkg-old"
852
798
    fi
853
799
  fi
854
800
 
855
801
  # Does old location exist, but is not a directory?
856
 
  if [ -e "$_old" ] && ! [ -d "$_old" ]; then
 
802
  if [ -e "$old" ] && ! [ -d "$old" ]; then
857
803
      # Back it up.
858
 
      warn "backing up non-directory $_old as $_old.dpkg-old"
859
 
      mv -b "$_old" "$_old.dpkg-old"
 
804
      warn "backing up non-directory $old as $old.dpkg-old"
 
805
      mv -b "$old" "$old.dpkg-old"
860
806
  fi
861
807
 
862
 
  observe "migrating $_old to $_new"
 
808
  observe "migrating $old to $new"
863
809
 
864
810
  # Is new location a symlink?
865
 
  if [ -L "$_new" ]; then
 
811
  if [ -L "$new" ]; then
866
812
    # Does it point the wrong way, i.e., back to where we're migrating from?
867
 
    if [ "$(readlink "$_new")" = "$_old" ]; then
 
813
    if [ "$(readlink "$new")" = "$old" ]; then
868
814
      # Get rid of it.
869
 
      observe "removing symbolic link $_new which points to $_old"
870
 
      rm "$_new"
 
815
      observe "removing symbolic link $new which points to $old"
 
816
      rm "$new"
871
817
    else
872
818
      # Back it up.
873
 
      warn "backing up symbolic link $_new as $_new.dpkg-old"
874
 
      mv -b "$_new" "$_new.dpkg-old"
 
819
      warn "backing up symbolic link $new as $new.dpkg-old"
 
820
      mv -b "$new" "$new.dpkg-old"
875
821
    fi
876
822
  fi
877
823
 
878
824
  # Does new location exist, but is not a directory?
879
 
  if [ -e "$_new" ] && ! [ -d "$_new" ]; then
880
 
    warn "backing up non-directory $_new as $_new.dpkg-old"
881
 
    mv -b "$_new" "$_new.dpkg-old"
 
825
  if [ -e "$new" ] && ! [ -d "$new" ]; then
 
826
    warn "backing up non-directory $new as $new.dpkg-old"
 
827
    mv -b "$new" "$new.dpkg-old"
882
828
  fi
883
829
 
884
830
  # Create new directory if it does not yet exist.
885
 
  if ! [ -e "$_new" ]; then
886
 
    observe "creating $_new"
887
 
    mkdir -p "$_new"
 
831
  if ! [ -e "$new" ]; then
 
832
    observe "creating $new"
 
833
    mkdir -p "$new"
888
834
  fi
889
835
 
890
836
  # Copy files in old location to new location.  Back up any filenames that
891
837
  # already exist in the new location with the extension ".dpkg-old".
892
 
  observe "copying files from $_old to $_new"
893
 
  if ! (cd "$_old" && cp -a -b -S ".dpkg-old" . "$_new"); then
894
 
    die "error(s) encountered while copying files from $_old to $_new"
 
838
  observe "copying files from $old to $new"
 
839
  if ! (cd "$old" && cp -a -b -S ".dpkg-old" . "$new"); then
 
840
    die "error(s) encountered while copying files from $old to $new"
895
841
  fi
896
842
 
897
843
  # Remove files at old location.
898
 
  observe "removing $_old"
899
 
  rm -r "$_old"
 
844
  observe "removing $old"
 
845
  rm -r "$old"
900
846
 
901
847
  # Create symlink from old location to new location.
902
 
  make_symlink_sane "$_old" "$_new"
 
848
  make_symlink_sane "$old" "$new"
903
849
}
904
850
 
905
851
# vim:set ai et sw=2 ts=2 tw=80: