distutils setup.py and %post %postun

你。 提交于 2019-12-22 09:07:10

问题


I am newbie. I am buidling rpm package for my own app and decided to use distutils to do achieve it. I managed to create some substitue of %post by using advice from this website, which i really am thankfull for, but i am having problems with %postun. Let me describe what i have done. In setup.py i run command that creates symbolic link which is needed to run application. It works good but problem is when i want to remove rpm, link stays there. So i figured that i should use %postun in spec file. My question is: is there a way to do this in setup.py or do i have to manually edit spec file? Please advise or point me some manuals or anything. Thank you


回答1:


Yes, you can specify a post install script, all you need is to declare in the bdist_rpm in the options arg the file you want to use:

setup(
...
options = {'bdist_rpm':{'post_install' : 'post_install',
                        'post_uninstall' : 'post_uninstall'}},
...)

In the post_uninstall file, put he code you need to remove the link, somethink like:

rm -f /var/lib/mylink



回答2:


Neither distutils nor setuptools have uninstall functionality.

At some point, the python community agreed that uninstall should be handled by the packaging system. In this case you want to use rpm, so there is probably a way inside of rpm system to remove packages, but you will not find that in distutils or setuptools.

@ pycon2009, there was a presentation on distutils and setuptools. You can find all of the videos here

Eggs and Buildout Deployment in Python - Part 1

Eggs and Buildout Deployment in Python - Part 2

Eggs and Buildout Deployment in Python - Part 3

There is a video called How to Build Applications Linux Distributions will Package. I have not seen it, but it seems to be appropriate.



来源:https://stackoverflow.com/questions/1407021/distutils-setup-py-and-post-postun

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!