在不编译源文件的情况下构建 rpm

build rpm without compiling the source file

我正在尝试使用单个文件的示例 rpm 包。

在我的源文件夹中,我有 python_test_rpm.tar.gz,其中仅包含一个 python 脚本文件。但是,该文件不是有效的 python 脚本。

我只想将其打包并部署到特定文件夹中。在执行 rpm build 命令时,它在 python 脚本中显示 compilation/syntax 错误。如何跳过此验证并进行构建。

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)

简单的解决方法:在 %install 末尾添加“exit 0”将禁用试图生成 %.pyo/%.pyc 文件的构建根策略脚本。

更好的修复包括覆盖正在编译 python 文件的特定构建根策略脚本,或者只是 fixing/commenting 不编译的代码。