[pacman-dev] [PATCH] Ensure build failure if a single build() command fails

Allan McRae allan at archlinux.org
Fri Jul 3 11:29:10 EDT 2009


Allan McRae wrote:
> Jürgen Hötzel wrote:
>> Hi,
>>
>> I doubt this was by intention:
>>
>> errors in build() functions are only fatal, if "--log" is enabled.
>> I just made a buggy pkg because some "install ..." commands
>> where not handled by "|| return 1".
>>
>> Our PKGBUILDs are cluttert full of "|| return 1". Failing commands in
>> build functions should always result in an build error.
>>  
>> Signed-off-by: Juergen Hoetzel <juergen at archlinux.org>
>> ---
>>  scripts/makepkg.sh.in |    7 ++++---
>>  1 files changed, 4 insertions(+), 3 deletions(-)
>>
>> diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
>> index f46b7f8..84d4599 100644
>> --- a/scripts/makepkg.sh.in
>> +++ b/scripts/makepkg.sh.in
>> @@ -703,6 +703,7 @@ run_build() {
>>      local ret=0
>>      if [ "$LOGGING" -eq 1 ]; then
>>          
>> BUILDLOG="${startdir}/${pkgbase}-${pkgver}-${pkgrel}-${CARCH}-build.log"
>> +        BUILDLOG_CMD="tee $BUILDLOG"
>>          if [ -f "$BUILDLOG" ]; then
>>              local i=1
>>              while true; do
>> @@ -714,11 +715,11 @@ run_build() {
>>              done
>>              mv "$BUILDLOG" "$BUILDLOG.$i"
>>          fi
>> -
>> -        build 2>&1 | tee "$BUILDLOG"; ret=${PIPESTATUS[0]}
>>      else
>> -        build 2>&1 || ret=$?
>> +        BUILDLOG_CMD="cat -"
>>      fi
>> +
>> +    build 2>&1 | ${BUILDLOG_CMD}; ret=${PIPESTATUS[0]}
>>      # reset our shell options
>>      eval "$shellopts"
>
> Seems fine.  We will want to do the "cat -" thing in run_package too 
> to catch packaging errors.   In fact, as the tee mechanism is so 
> different there, we will need to check that it actually catches errors...

I was right about needing to check the run_package function.  It does 
not catch errors even when run with logging.  I am working on fixing up 
this patch.

Allan





More information about the pacman-dev mailing list