distutils setup.py和%post%postun [英] distutils setup.py and %post %postun

查看:84
本文介绍了distutils setup.py和%post%postun的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新手。
我正在为自己的应用程序构建rpm软件包,并决定使用distutils来实现它。通过使用本网站的建议,我设法创建了%post的替代品,对此我表示非常感谢,但是%postun遇到了问题。
让我描述一下我做了什么。在setup.py中,我运行创建创建应用程序所需的符号链接的命令。它工作正常,但问题是当我想删除rpm时,链接停留在那儿。所以我想我应该在规格文件中使用%postun。我的问题是:在setup.py中有没有办法做到这一点,还是我必须手动编辑spec文件?
请提供建议或为我指出一些手册或其他内容。
谢谢

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

推荐答案

是的,您可以指定安装后脚本,只需在bdist_rpm中声明在选项arg中要使用的文件:

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'}},
...)

在post_uninstall文件中,输入需要删除链接的代码,像这样:

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

rm -f /var/lib/mylink

这篇关于distutils setup.py和%post%postun的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆