Reputation: 309
I am trying to build a RPM from a python application on RHEL8.2 machine.
the shebangs on the scripts are set correctly to #!/usr/bin/python3
however for some reason the shebang gets changed to #!/usr/libexec/platform-python -s
when the RPM is built.
I have tried almost everything.
I have undefined the mangling according to doc: https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/packaging_and_distributing_software/advanced-topics
%undefine __brp_mangle_shebangs
but the shebangs gets still changed.
this is the relevant parts of the specs file:
%undefine __brp_mangle_shebangs
Name: myapp
Version: 2.0.0
Release: 1%{?dist}
summary: rpm for my APP
BuildArch: noarch
### Build Dependencies ###
BuildRequires: python3-setuptools
BuildRequires: python3-devel
%?python_enable_dependency_generator
%build
%py3_build
%install
%py3_install
%files
....
I can include python*-rpm-macros
to the specs and that would set the shebang to something like /usr/bin/python3.6
but it is too restrictive. Our code works in anything > python3.6 so if we deploy the rpm in a system with python3.8 it should work.
how can I set /usr/bin/python3 or leave the shebang unchanged on the python scripts? when the rpm is packaged?
Upvotes: 2
Views: 3679
Reputation: 720
I ran into this. Adding %undefine __brp_mangle_shebangs
into the specfile had no effect, the shebang was still getting mangled from #!/usr/bin/python3
to #!/usr/libexec/platform-python
. However, when sending it as a command line argument i.e. $ rpmbuild --undefine __brp_mangle_shebangs -bb <specfile>
took care of it.
Upvotes: 0
Reputation: 473
%undefine __brp_mangle_shebangs
works for me.
$ rpmbuild --version
RPM version 4.14.3
Perhaps you need to put it later in your preamble? eg:
Name: myapp
Version: 2.0.0
Release: 1%{?dist}
summary: rpm for my APP
BuildArch: noarch
### Build Dependencies ###
BuildRequires: python3-setuptools
BuildRequires: python3-devel
## Fixes
# disable shebang mangling of python scripts
%undefine __brp_mangle_shebangs
...
Note also there seem to be some additional variables that give finer grained control, however I have not tried these:
Excluding based on shebang:
%global __mangle_shebangs_exclude ruby
Excluding based on path:
%global __mangle_shebangs_exclude_from /test/
Reference: https://src.fedoraproject.org/rpms/redhat-rpm-config/pull-request/19
I would also note that the document cited above is incorrect: https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/packaging_and_distributing_software/advanced-topics section 4.6.2
To prevent the BRP script from checking and modifying interpreter directives, use the following RPM directive:
%undefine %brp_mangle_shebangs
as it is %undefine __brp_mangle_shebangs
Upvotes: 1