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
722
make_symlink_sane () {
789
723
# syntax: make_symlink_sane symlink target