What are differences between real and rpmbuild's environment?

Panu Matilainen pmatilai at laiskiainen.org
Tue Nov 9 15:30:17 UTC 2010


On Tue, 9 Nov 2010, Michal Hlavinka wrote:

> On Monday, November 08, 2010 15:49:28 Michal Hlavinka wrote:
>> Hi,
>>
>> I'm trying to find out what are differences between environment for local
>> rpm build and usual user's environment. I've added regression tests to
>> %check section of ksh spec file. These tests never fails when executed in
>> user's environment, but some of them always fail when executed as part of
>> rpm build process. I've tried to compare variable in the environment and
>> ulimit values, but there does not seem to be any significant difference.
>> I've also tried to use the same script generated by rpmbuild for %check
>> section (from
>> /var/tmp/rpm.*), but still it does not reproduce the problem. Any ideas?
>>
>> Michal
>
> Ok, I've forgot to mention a few things and I'll also add new information I've
> found.
>
> - Tests that are failing are all about pipe and sigpipe/pipefail.
>
> - I've tried to reproduce this just with "empty" spec file - I've moved the
> tests in %prep section just after sources are unpacked and patched (required
> for running tests) and it still fails
>
> - I've prepared simple script with just the first failing test and. I've
> modified this test slightly so it can be used with bash too. BASH has no
> problem with this test when executed from terminal. When it's executed from
> prep section in rpmbuild it fails too.
>
>
> This is the test script (defined as Source6:)
> #########################
> s=$SECONDS
> set -o pipefail
> for ((i=0; i < 30; i++))
> do      printf hello 2>/dev/null
>        sleep .1
> done |  /bin/sleep 1
> (( (SECONDS-s) < 2 )) || printf >&2 'early termination not causing broken
> pipe'
> #########################
>
> and it's being executed from %prep section:
> #########################
> %prep
> export SHELL=/bin/bash
> time $SHELL %{SOURCE6}
> exit 1
> #########################
>
> Correct real time is 1 sec something, when broken, time is 3 seconds something
> and error message is produced.
>
> So it seems rpmbuild has a bug and breaks sigpipe somehow...
> Any comments before I file bug?

Oh, SIGPIPE. That explains... nspr (to which rpm is indirectly married to 
through nss) quietly sets SIG_IGN on SIGPIPE on initialization, triggering 
these kind of obscure misbehaviors in rpm-related scripts. Ain't the first 
time for sure, but the first time somebody manages to trigger the issue in 
build.

Fixing is easy enough, but do file a bug so I wont forget. Extra bonus for 
minimal reproducer.

 	- Panu -


More information about the devel mailing list