Wednesday, April 13, 2022

[SOLVED] build rpm without compiling the source file

Issue

I am trying a sample rpm package with single file.

In my source folder I have python_test_rpm.tar.gz which contains only one python script file. But, the file is not a valid python script.

All I want to do is package this and deploy it in a specific folder. While executing the rpm build command it is showing the compilation/syntax error in the python script. How to skip this validation and make the build.

rpmbuild command rpmbuild -v -bb

Spec File:

Name: python_test_rpm

Version: 1

Release: 1

Summary: Sample RPM for Linux Installer

Group: Development/Tools

License: GPL

URL: None

Source: python_test_rpm.tar.gz

BuildRoot: /home/rpmdev/rpmbuild

%description

POC package for Linux RPM installer

%prep

%setup -n "python_test_rpm"

%install

rm -rf "$RPM_BUILD_ROOT"

mkdir -p "$RPM_BUILD_ROOT/python_test_rpm"

cp -R _mock_backport.py "$RPM_BUILD_ROOT/python_test_rpm"

%files

/python_test_rpm/_mock_backport.py

Error Message: Compiling /home/rpmdev/rpmbuild/BUILDROOT/python_test_rpm-1-1.x86_64/python_test_rpm/_mock_backport.py ... SyntaxError: unqualified exec is not allowed in function '_set_signature' it contains a nested function with free variables (_mock_backport.py, line 191)

error: Bad exit status from /var/tmp/rpm-tmp.4gSvIa (%install)

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


Solution

The easy fix: Adding "exit 0' at the end of %install will disable build root policy scripts that are trying to generate %.pyo/%.pyc files.

Better fixes include overriding the specific build root policy script that is compiling python files, or simply fixing/commenting the code that does not compile.



Answered By - Jeff Johnson
Answer Checked By - Terry (WPSolving Volunteer)