Bug 684670 - Impossible %postun for package erasure
Summary: Impossible %postun for package erasure
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: bash
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
low
Target Milestone: ---
Assignee: Roman Rakus
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-03-14 08:17 UTC by Panu Matilainen
Modified: 2014-01-13 00:13 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2011-03-14 16:28:01 UTC
Type: ---


Attachments (Terms of Use)

Description Panu Matilainen 2011-03-14 08:17:16 UTC
Description of problem:

%postun
if [ "$1" = 0 ]; then
    /bin/grep -v '^/bin/bash$' < /etc/shells | \
      /bin/grep -v '^/bin/sh$' > /etc/shells.new
    /bin/mv /etc/shells.new /etc/shells
fi

This scriptlet tries to handle the case when bash is removed, but consider the circumstances where the if is ever true: the scriptlet is a shell script using /bin/sh as the interpreter, and gets executed /after/ bash has already been removed. So there's no /bin/sh anymore (because bash is what provides it), and the script can never be executed. 

Version-Release number of selected component (if applicable):
All versions that I can remember up to and including bash-4.2.7-1.fc16.

How reproducible:
Always

Steps to Reproduce:
1. yum --disablerepo="*" --enablerepo="rawhide" --installroot=/home/test/ -y install bash
2. rpm -e --root /home/test/ bash glibc-common glibc ncurses-libs nss-softokn-freebl

(step 2 uses rpm because yum blows up there but that's another bug...)
  
Actual results:
warning: %postun(bash-4.2.7-1.fc16.x86_64) scriptlet failed, exit status 127

Expected results:
Package is removed without scriptlet errors.

Additional info:
This is quite obviously a low-priority item, bash being removed is pretty much a never happens situation, just filing this for "correctness' sake" since it actually tries to handle this case. Couple of easy options:
1) use %preun instead of %postun for removing bash from /etc/shells
2) rewrite the scriptlet to use -p <lua> like %post does

There's also an rpm bug here: rpm should realize the %postun dependencies cannot be satisfied on removal and issue an error, but that's my headache...

Comment 1 Roman Rakus 2011-03-14 12:44:35 UTC
(In reply to comment #0)
> Description of problem:
> 
> %postun
> if [ "$1" = 0 ]; then
>     /bin/grep -v '^/bin/bash$' < /etc/shells | \
>       /bin/grep -v '^/bin/sh$' > /etc/shells.new
>     /bin/mv /etc/shells.new /etc/shells
> fi
> 
> This scriptlet tries to handle the case when bash is removed, but consider the
> circumstances where the if is ever true: the scriptlet is a shell script using
> /bin/sh as the interpreter, and gets executed /after/ bash has already been
> removed. So there's no /bin/sh anymore (because bash is what provides it), and
> the script can never be executed. 
Thanks for the report.
> 
> Version-Release number of selected component (if applicable):
> All versions that I can remember up to and including bash-4.2.7-1.fc16.
> 
> How reproducible:
> Always
> 
> Steps to Reproduce:
> 1. yum --disablerepo="*" --enablerepo="rawhide" --installroot=/home/test/ -y
> install bash
> 2. rpm -e --root /home/test/ bash glibc-common glibc ncurses-libs
> nss-softokn-freebl
> 
> (step 2 uses rpm because yum blows up there but that's another bug...)
> 
> Actual results:
> warning: %postun(bash-4.2.7-1.fc16.x86_64) scriptlet failed, exit status 127
> 
> Expected results:
> Package is removed without scriptlet errors.
> 
> Additional info:
> This is quite obviously a low-priority item, bash being removed is pretty much
> a never happens situation, just filing this for "correctness' sake" since it
> actually tries to handle this case. Couple of easy options:
> 1) use %preun instead of %postun for removing bash from /etc/shells
Does not work.
# rpm -e --root /home/test/ bash glibc-common glibc ncurses-libs nss-softokn-freebl/bin/sh: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory
error: %preun(bash-4.2.7-2.fc16.x86_64) scriptlet failed, exit status 127
warning: %postun(glibc-2.13.90-6.x86_64) scriptlet failed, exit status 127

> 2) rewrite the scriptlet to use -p <lua> like %post does
I have to go this way.
> 
> There's also an rpm bug here: rpm should realize the %postun dependencies
> cannot be satisfied on removal and issue an error, but that's my headache...

Comment 2 Panu Matilainen 2011-03-14 13:29:30 UTC
(In reply to comment #1)
> (In reply to comment #0)
> > 1) use %preun instead of %postun for removing bash from /etc/shells
> Does not work.
> # rpm -e --root /home/test/ bash glibc-common glibc ncurses-libs
> nss-softokn-freebl/bin/sh: error while loading shared libraries: libtinfo.so.5:
> cannot open shared object file: No such file or directory
> error: %preun(bash-4.2.7-2.fc16.x86_64) scriptlet failed, exit status 127
> warning: %postun(glibc-2.13.90-6.x86_64) scriptlet failed, exit status 127

Hmm, technically it /should/ to work... but then the bash - glibc - ncurses etc loop is a tricky one, quite possibly even more problematic on erase. I'll try to have a look at it.

> > 2) rewrite the scriptlet to use -p <lua> like %post does
> I have to go this way.

Nod, using lua largely frees it from dependency loop issues.

Comment 3 Roman Rakus 2011-03-14 16:28:01 UTC
Should be fixed in bash-4.2.7-2.fc16. Rewritten in lua. Feel free to reopen if it doesn't work.


Note You need to log in before you can comment on or make changes to this bug.