Re: %install section script problem...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 2004-07-21 at 16:07, James Olin Oden wrote:
> On Wed, 21 Jul 2004, Valery Reznic wrote:
> 
> > --- Greg Allen <GAllen@xxxxxxxxxxxx> wrote:
> > > I am doing the following in the %install section of
> > > my spec file:
> > > 
> > >    source <script>
> > >    func <x> <y> <z>
> > >  
> > > The shell function "func" is contained in <script>
> > > and runs fine outside of 
> > > the rpmbuild call.  When rpmbuild runs, however, I
> > > get this:
> > >  
> > >    + read -a line
> > >    + echo SunOS
> > >    + egrep -qs '^Linux$|^Linux,|,Linux,|,Linux$'

Why is there not a line here with 
  
         + '[' 1 -eq 0 ']'

?

> > >    + '[' 1 -ne 0 ']' 
> > >    + return 1111
> > >    error: Bad exit status from /var/tmp/rpm-tmp.5856
> > > (%install)
> > >  
> > > Here's the snippet of code from "func":
> > >  
> > >     cat $file | egrep -v '^#' |  \
> > >     while read -a line; do
> > >         echo ${line[$platform_idx]} | egrep $egrep_flags "^$platform$|^$platform,|,$platform,|,$platform$"
> > >         if [ $? -eq 0 ]; then
> > >            # Do some stuff here.
> > >         fi
> > >     done    
> > >     # Check if file processing succeeded.
> > >     if [ $? -ne 0 ]; then
> > >         return 1111
> > >     fi
> > >  
> > > For some reason, when run inside rpmbuild, the
> > > failure of the egrep call is causing the 
> > > while loop to be exited!  I have no idea why.

There are more portability issues here:

On my system: 

  bash$ while false; do doesn't'matter; done && echo yes || echo no
  yes
  bash$ while true; do false; break; done && echo yes || echo no
  yes

How can you come out of a while loop other than with $? = 0 ?

Perhaps the Bourne shell is different, could anyone with access to a
really archaic Bourne shell try the above commands?

Even if /bin/sh is a link to /bin/bash on my system, bash behaves
differently in some ways when called as */sh, but I cannot remember the
differences. In any case, the above commands gave the same results on my
system when running under bash alias "/bin/sh".


Also be aware that 

  bash$ echo | read -a line && echo yes || echo no
  yes
  bash$ cat /dev/null | read -a line && echo yes || echo no
  no

> > >  
> > > I have also run the rpmbuild generated script
> > > (/var/tmp/rpm-tmp.5856) standalone, and
> > > it runs just fine.
> > >  
> > > Can anyone tell me what is wrong?
> > As long as I remember rpm's shell scriplets run with
> > '-e' flag, i.e, script will be aborted after
> > FIRSTcommand with non-zero exit status.
> > You can try to run this script standalone but with -e
> > and see what's happened.
> I think that is only true of build scriptlets (thanks for letting me know
> how rpm does this by the way).  Install scriplets do not behave this way.

If it were to abort after the first command with nonzero exit status, it
would not reach the "return 1111" statement. It would not even reach the
statement that produced "+ '[' 1 -ne 0 ']'"

Regards,
Enrique


_______________________________________________
Rpm-list mailing list
Rpm-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/rpm-list

[Index of Archives]     [RPM Ecosystem]     [Linux Kernel]     [Red Hat Install]     [PAM]     [Red Hat Watch]     [Red Hat Development]     [Red Hat]     [Gimp]     [Yosemite News]     [IETF Discussion]

  Powered by Linux