Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
Bug 1686413 - /usr/lib/rpm/redhat/brp-mangle-shebangs fails for non-existing RPM_BUILD_ROOT
Summary: /usr/lib/rpm/redhat/brp-mangle-shebangs fails for non-existing RPM_BUILD_ROOT
Keywords:
Status: NEW
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: redhat-rpm-config
Version: 8.0
Hardware: Unspecified
OS: Unspecified
low
medium
Target Milestone: rc
: 8.0
Assignee: Packaging Maintenance Team
QA Contact: BaseOS QE Security Team
URL:
Whiteboard:
Depends On: 1681082
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-03-07 12:04 UTC by Karel Srot
Modified: 2019-03-17 19:21 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed:
Type: Bug
Target Upstream Version:


Attachments (Terms of Use)

Description Karel Srot 2019-03-07 12:04:20 UTC
Description of problem:

# head /usr/lib/rpm/redhat/brp-mangle-shebangs
#!/bin/bash -eu

# If using normal root, avoid changing anything.
echo $RPM_BUILD_ROOT
if [ -z "$RPM_BUILD_ROOT" -o "$RPM_BUILD_ROOT" = "/" ]; then
  exit 0
fi


The above doesn't test whether the directory actually exists.
For a spec file which I am able to build on RHEL-7 successfully, I am getting following failure on RHEL-8:

/usr/lib/rpm/redhat/brp-mangle-shebangs: line 72: cd: /tmp/bz-ilrKNb/BUILDROOT/special-1.0-1.x86_64: No such file or directory
error: Bad exit status from /var/tmp/rpm-tmp.5l4W0o (%install)


RPM build errors:
    Bad exit status from /var/tmp/rpm-tmp.5l4W0o (%install)


Changing the condition to the following fixed it for me.

if [ -z "$RPM_BUILD_ROOT" -o "$RPM_BUILD_ROOT" = "/" -o ! -d "$RPM_BUILD_ROOT" ]; then
  exit 0
fi

Version-Release number of selected component (if applicable):
redhat-rpm-config-116-1.el8.noarch

Comment 2 Panu Matilainen 2019-03-07 12:20:15 UTC
Actually none of the brp-scripts specifically test for buildroot existence, and eg brp-compress does similar unchecked cd into buildroot:

+ /usr/lib/rpm/check-buildroot
find: '/home/pmatilai/rpmbuild/BUILDROOT/special-1.0-1.x86_64': No such file or directory
+ /usr/lib/rpm/redhat/brp-ldconfig
/sbin/ldconfig: Warning: ignoring configuration file that cannot be opened: /home/pmatilai/rpmbuild/BUILDROOT/special-1.0-1.x86_64/: No such file or directory
+ /usr/lib/rpm/brp-compress
/usr/lib/rpm/brp-compress: line 10: cd: /home/pmatilai/rpmbuild/BUILDROOT/special-1.0-1.x86_64: No such file or directory
+ /usr/lib/rpm/brp-strip /usr/bin/strip
find: '/home/pmatilai/rpmbuild/BUILDROOT/special-1.0-1.x86_64': No such file or directory
+ /usr/lib/rpm/brp-strip-comment-note /usr/bin/strip /usr/bin/objdump
find: '/home/pmatilai/rpmbuild/BUILDROOT/special-1.0-1.x86_64': No such file or directory
+ /usr/lib/rpm/brp-strip-static-archive /usr/bin/strip
find: '/home/pmatilai/rpmbuild/BUILDROOT/special-1.0-1.x86_64': No such file or directory
+ /usr/lib/rpm/brp-python-bytecompile '%{__python}' 1 1
find: '/home/pmatilai/rpmbuild/BUILDROOT/special-1.0-1.x86_64': No such file or directory
find: '/home/pmatilai/rpmbuild/BUILDROOT/special-1.0-1.x86_64': No such file or directory
+ /usr/lib/rpm/brp-python-hardlink
find: '/home/pmatilai/rpmbuild/BUILDROOT/special-1.0-1.x86_64': No such file or directory
+ /usr/lib/rpm/redhat/brp-mangle-shebangs
/usr/lib/rpm/redhat/brp-mangle-shebangs: line 71: cd: /home/pmatilai/rpmbuild/BUILDROOT/special-1.0-1.x86_64: No such file or directory

The catch is that brp-mangle-shebangs runs with -e:
#!/usr/bin/bash -eu

Whatever the fix ends up being, I agree these things should behave consistently.

Comment 3 Karel Srot 2019-03-07 12:43:26 UTC
That is correct. These errors are reported even on RHEL-7, however none of them prevents the package from being built.


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