reassign 233645 xfree86 retitle 233645 xfree86: [shell-lib.sh] deregister_x_lib_dir_with_ld_so() calls fgrep with no second arg, causing maintainer scripts to hang forever trying to read from STDIN thanks
On Thu, Feb 19, 2004 at 09:24:59AM +0100, Filip Van Raemdonck wrote: > When removing libxpm4 (but I guess that depending on the order in which > apt removes them, any library from xfree86 could do this) the postrm > script hangs, waiting on input (observed from the fact that when it is > backgrounded it immediately goes to STOPPED state). > > A quick look at the postrm script shows a few suspicious *greps, which > might get called with no file arguments and hence cause the hang. > Adding a set -x confirms this: > > Removing libxpm4 ... > + '[' remove = remove ']' > + deregister_x_lib_dir_with_ld_so > + local dir ldsoconf > + dir=/usr/X11R6/lib > + ldsoconf=/etc/ld.so.conf > + fgrep -qsx /usr/X11R6/lib /etc/ld.so.conf > ++ echo '/usr/X11R6/lib/lib*.so.*.*' > + '[' '/usr/X11R6/lib/lib*.so.*.*' = '/usr/X11R6/lib/lib*.so.*.*' ']' > + observe 'removing /usr/X11R6/lib directory from /etc/ld.so.conf' > + '[' -n '' ']' > + fgrep -qsvx /usr/X11R6/lib > dpkg: error processing libxpm4 (--purge): > > So, in this case it's the second fgrep in deregister_x_lib_dir_with_ld_so. > > Small note: I have only superficially looked at the postrm, but the > smoking_guns=$(grep ...) in find_culprits also looks suspicuous; I've > tried and if any of xbase-clients|xfree86-common|xfs|xlibs is installed > the possible_culprits variable is empty and so would cause the grep above > to hang, too, I believe. You may want to check that. Well, let's tackle deregister_x_lib_dir_with_ld_so() first, since it's the problem you're having. Here's the source of the shell function in question: deregister_x_lib_dir_with_ld_so () { # syntax: deregister_x_lib_dir_with_ld_so # # Configure dynamic loader ld.so to not search /usr/X11R6/lib for shared # libraries, if and only if no shared libaries remain there. # # Call this function from the postrm script of a package that places a shared # library in /usr/X11R6/lib, in the event "$1" is "remove", and before # invoking ldconfig. local dir ldsoconf dir="/usr/X11R6/lib" ldsoconf="/etc/ld.so.conf" # is the line present? if fgrep -qsx "$dir" "$ldsoconf"; then # are there any shared objects in the directory? if [ "$(echo "$dir"/lib*.so.*.*)" = "$dir/lib*.so.*.*" ]; then # glob expansion produced nothing, so no shared libraries are present observe "removing $dir directory from $ldsoconf" fgrep -qsvx "$dir" > "$ldsoconf.dpkg-tmp" mv "$ldsoconf.dpkg-tmp" "$ldsoconf" fi fi } Hmm, yup. I didn't give the second fgrep a second argument. The first fgrep will never block waiting on STDIN. Thanks for catching this. I'll fix it right away. -- G. Branden Robinson | The more ridiculous a belief Debian GNU/Linux | system, the higher the probability [EMAIL PROTECTED] | of its success. http://people.debian.org/~branden/ | -- Wayne R. Bartz
signature.asc
Description: Digital signature