Distutils, older rpm, and customized spec file
I finally got my program packaged in a RPM on Fedora 14 yesterday, and I thought that it would be easy to build it the same way on a CentOS 4.8 box. It turns out that the older version of rpm and distutils are severally limited, and I'm not having any luck working around it.
The basic problem is that distutils with Python 2.7 supports an option called "--post-install" where I can specify a script. The script is included and is run when I install with yum or rpm. Everything is great. However, with Python 2.3, there is no --post-install option (it's actually not available in RPM). Whatever, I can just add it to the "%install" section in my .spec file. So I start the RPM building process with
python setup.py bdist_rpm --spec-only
which creates my .spec. I edit it and paste my script into the .spec. Then, I go to build the source with
python setup.py bdist_rpm --source-only
This is where problems seem to start occurring. distutils creates the following sub-directories ./build/bdist.linux-i686/rpm/. Inside that there is 开发者_开发问答a folder called SPECS/netinfo.spec (my program is called netinfo). However, that doesn't use the custom .spec that I just created. That's weird since it should use the generated .spec. If I try to build with the default .spec, then predictably my script isn't included in the RPM. If I overwrite that with my custom .spec, it still doesn't work. It's like it recreates the .spec for every command.
There are various commands that bdist_rpm has, and they can be listed with
python setup.py bdist_rpm --help
I expected to find an otpion where you can specify the .spec file to use. Yet, on Python 2.3 and 2.7, no option exists.
There has to be some simple way to get distutils to use my custom .spec file. Does anyone know how to specify this?
Thanks,
There isn't. Build the SRPM with rpmbuild -bs
and then use Mock to build a package for EL4.
精彩评论