rpmbuild告警mangling shebang in xxx from #!/bin/python to #!/usr/bin/python/python2. This will become an ERROR, fix it.
Linux环境,使用rpmbuild打包包含python的rpm包,打包完成后,解压后查看,包里面的python脚本第一行解释器#!/bin/python 被修改成了#!/usr/bin/python/python2.
sh -x rpm_build_pkg.sh
调试打包脚本,中间有输出:
......
+ /usr/bin/rpm/redhat/brp-mange-shebangs
*** WARNING:mangling shebang in xxx from #!/bin/python to #!/usr/bin/python/python2. This will become an ERROR, fix it.
......
原因:rpmbuild过程中,会调用/usr/bin/rpm/redhat/brp-mange-shebangs脚本,查看这个脚本的源码,脚本会查询要打包的所有文件,找到python可执行文件,会去检查他的第一行解释器,并修改成建议值(和环境上面的python版本有关)。
shebang不建议python是模糊指定的。
修改方法:
在打包前不要给python脚本加上可执行权限,chmod -x xxx.py去掉所有脚本的可执行权限
rpmbuild配置文件xxx.spec, 该文件中%install中也不要加上可执行权限。
可以再 %post中 chmod +x xxx.py给文件加上可执行权限。