On Tue, 20 Jul 2004, Greg Allen 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$' > + '[' 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 > Two things. One, my guess is egrep is not in your path when running from rpm. You can fix this by either specifying the full path to egrep or altering your PATH in the scriptlet. The second thing, that you may or may not realize is that you can only return values 0-255 from shell function. The reason is it follows the same symantics as the return code of from an executable, and the return code from that can only be 0-255. Cheers...james > 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. > > I have also run the rpmbuild generated script (/var/tmp/rpm-tmp.5856) standalone, and > it runs just fine. > Yep your environment when your run the script is not altered. Pretty sure that rpm actually sets the PATH before execing the script. Here is the code snippet from psm.c in the runScript() call: { const char *ipath = rpmExpand("PATH=%{_install_script_path}", NULL); const char *path = SCRIPT_PATH; if (ipath && ipath[5] != '%') path = ipath; ... Basically, that says try to set the path to the value of the macro %{_install_script_path} if its defined on the local system, or set it to the value of the variable SCRIPT_PATH which is defined as: static char * SCRIPT_PATH = "PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin"; This actually shows another options for you which is to setup a /etc/rpm/macros file that defines %_install_script_path such that egrep is in the path. Note, unlike a macros inside the scriptlet this is resolved at install time, not build time. Finally, I wasn't around when someone made the decision to limit the PATH of scriptlets, but its probably a pretty good thing, because it keeps someone from introduce, shall we say, trecherous paths into root's path via someone not thinking and doing just "su" and not "su -" or some other mechanism, and then hijacking your system when you install an rpm. Not completely fool proof of course, but security is best served in layers (-; Cheers...james > Can anyone tell me what is wrong? > > Thanks, > > -- Greg Allen > gallen@xxxxxxxxxxxx > > > > > > > > > _______________________________________________ > Rpm-list mailing list > Rpm-list@xxxxxxxxxx > https://www.redhat.com/mailman/listinfo/rpm-list > _______________________________________________ Rpm-list mailing list Rpm-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/rpm-list