Bug 1577161 - dubious shell logic in macros.pesign, kernel rpmbuild fails for non-bash /bin/sh
Summary: dubious shell logic in macros.pesign, kernel rpmbuild fails for non-bash /bin/sh
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: pesign
Version: 7.7-Alt
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Peter Jones
QA Contact: Erico Nunes
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-05-11 11:16 UTC by Petr Benes
Modified: 2021-02-15 07:38 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2021-02-15 07:38:50 UTC
Target Upstream Version:


Attachments (Terms of Use)

Description Petr Benes 2018-05-11 11:16:07 UTC
When testing whether kernel could be build from its SRPM if one sets
/bin/sh to ksh I've found that it doesn't work.

The process ends up with:

+ mkdir -p
/home/builder/rpmbuild/BUILDROOT/kernel-uek-4.14.32-1.el7uek.aarch64/usr/lib/d
ebug/boot
+ mkdir -p
/home/builder/rpmbuild/BUILDROOT/kernel-uek-4.14.32-1.el7uek.aarch64/usr/lib/d
ebug/boot
+ mkdir -p
/home/builder/rpmbuild/BUILDROOT/kernel-uek-4.14.32-1.el7uek.aarch64/boot
+ install -m 644 .config
/home/builder/rpmbuild/BUILDROOT/kernel-uek-4.14.32-1.el7uek.aarch64/boot/conf
ig-4.14.32-1.el7uek.aarch64.debug
+ install -m 644 System.map
/home/builder/rpmbuild/BUILDROOT/kernel-uek-4.14.32-1.el7uek.aarch64/boot/Syst
em.map-4.14.32-1.el7uek.aarch64.debug
+ touch
/home/builder/rpmbuild/BUILDROOT/kernel-uek-4.14.32-1.el7uek.aarch64/boot/init
ramfs-4.14.32-1.el7uek.aarch64.debug.img
+ [ -f arch/arm64/boot/zImage.stub ]
+ [ -x /usr/bin/pesign ]
+ [ aarch64 '==' x86_64 -o aarch64 '==' aarch64 ]
+ [ 07 -ge 7 -a -f /usr/bin/rpm-sign ]
+ [ -S /var/run/pesign/socket ]
+ /usr/bin/pesign -c 'Oracle Linux Test Certificate' -i arch/arm64/boot/Image
-o arch/arm64/boot/Image.signed -s
+ [ ! -s -o arch/arm64/boot/Image.signed ]
+ [ -e arch/arm64/boot/Image.signed ]
+ rm -f arch/arm64/boot/Image.signed
+ exit 1
error: Bad exit status from /var/tmp/rpm-tmp.2u96Jp (%build)


RPM build errors:
    Bad exit status from /var/tmp/rpm-tmp.2u96Jp (%build)

Inspecting where the construct [ ! -s -o arch/arm64/boot/Image.signed ] comes
from points to /etc/rpm/macros.pesign and this snippet of the macro's code:

  if [ ! -s %{-o} ]; then \
    if [ -e "%{-o*}" ]; then \
      rm -f %{-o*} \
    fi \
    exit 1 \
  fi ;

Perhaps the author wanted to verify there is a non-zero length output file.
Otherwise remove it if it exists with zero length and fail. Unfortunately
%{-o} expands to the full flag not only the value. That is it produced
[ ! -s -o arch/arm64/boot/Image.signed ] that is wrong and moreover behaves
differently in bash and ksh:

[builder@g0 ~]$ echo "xxxx" > /tmp/a
[builder@g0 ~]$ [ ! -s -o /tmp/a ] ; echo $?
1
[builder@g0 ~]$ ksh
$ [ ! -s -o /tmp/a ] ; echo $?
0

The correction is to use "%{-o*}".

Comment 4 RHEL Program Management 2021-02-15 07:38:50 UTC
After evaluating this issue, there are no plans to address it further or fix it in an upcoming release.  Therefore, it is being closed.  If plans change such that this issue will be fixed in an upcoming release, then the bug can be reopened.


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