views:

269

answers:

2

Hi,

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

A: 

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.

tarasm
Thanks, i will definitely watch those videos.
MichalKlich
+1  A: 

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
Antonio Beamud
Thank you much, that took care of what i intended to do.
MichalKlich