[英]Create a debian package to install python scripts to /usr/local/bin in Ubuntu
I try to create a debian package of a python application as follows: 我尝试创建一个python应用程序的debian包,如下所示:
The setup.py is like setup.py就像
#!/usr/bin/env python
from distutils.core import setup
setup(name='foo',
version='1.0.0',
description='Foo example',
author='Kuan-Kai Chiu',
author_email='ntu.kchiu@gmail.com',
scripts=['src/foo.py']
)
How do I install the foo.py to /usr/local/bin instead of being installed to /usr/bin ? 如何将foo.py安装到/ usr / local / bin而不是安装到/ usr / bin ? I know there's an option --install-scripts=/usr/local/bin while running python setup.py install , but I have to debianize my python application and it seems no way to specify the install-scripts prefix.
我知道在运行python setup.py install时有一个选项--install-scripts = / usr / local / bin ,但是我必须对我的python应用程序进行debianize,似乎无法指定install-scripts前缀。
Thanks in advance! 提前致谢!
If you just want to install a file in /usr/local/bin/
, then drop the setup.py
as it's not really needed. 如果您只想在
/usr/local/bin/
安装文件,请删除setup.py
因为它并不是真正需要的。 If you are using dh
in your package (you can see if you are by checking it's being invoked in your debian/rules
file. If you aren't using it, you should :-), then you'll only have to feed dh_install
(see its manpage ) with an install
file. 如果你在你的软件包中使用
dh
(你可以看看你是否在你的debian/rules
文件中检查它。如果你没有使用它,你应该:-),那么你只需要提供dh_install
(请参阅其联机帮助页 ),其中包含install
文件。 The syntax of this file is really simple, you have to specify what do you want to install, and where . 这个文件的语法非常简单,你必须指定你想要安装什么 ,以及在哪里 。 You can do this by issuing the following command in the root directory of your package:
您可以通过在程序包的根目录中发出以下命令来执行此操作:
$ echo "src/foo.py usr/local/bin" > debian/install
Now, as you want to install a script under /usr/local/
, and this is against the Debian policy, one of the dh_*
tools will fail. 现在,由于您要在
/usr/local/
下安装脚本,这违反了Debian策略,其中一个dh_*
工具将失败。 This tool is dh_usrlocal
. 这个工具是
dh_usrlocal
。 The fix is quite simple. 修复非常简单。 We just have to tell
debian/rules
that we don't want to run it, and we can do this by overriding its behavior. 我们只需告诉
debian/rules
我们不想运行它,我们可以通过覆盖它的行为来实现。 This is how your final debian/rules
should look: 这就是你的最终
debian/rules
应该如何:
#!/usr/bin/make -f
# -*- makefile -*-
%:
dh $@
override_dh_usrlocal:
That's it. 而已。 Run
dpkg-buildpackage
and you should have your fresh new packages in ../
. 运行
dpkg-buildpackage
,你应该在../
全新的软件包。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.