问题描述
我创建了一个 deb
包,例如 abc.deb
。现在很少有依赖项,例如 python-dev,python-mysql
等,这些依赖项需要作为deb安装本身的一部分进行安装。
I have created a deb
package say abc.deb
. Now there are few dependencies like python-dev, python-mysql
etc., which are needed to be installed as a part of deb installation itself.
(即,当用户运行 dpkg -i abc.deb
时,依赖项也应自动安装)。
(i.e. when user runs dpkg -i abc.deb
, the dependencies should also get installed automatically).
我正在使用控件
文件,其中包含一些参数,例如 preinst,postinst
等。试图将 Depends
添加到控制文件中,但是我想,如果没有提到的依赖项, Depends
只会停止软件包安装。如何将依赖项作为deb软件包安装本身的一部分进行安装?我正在寻找一种适用于 Ubuntu 12.04
的解决方案。
I am using a control
file which contains few parameters like preinst, postinst
etc. I tried to add Depends
to the control file, but I guess, Depends
only stops package installation if dependencies mentioned are not present. How could I install the dependencies as a part of deb package installation itself? I am looking for a solution that will work on Ubuntu 12.04
.
P.S。当我尝试在 postinst
脚本中以
P.S. When I try to install dependencies in my postinst
script as
sudo apt-get install python-dev -y
我给我一个错误:
E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable)
E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?`
推荐答案
dpkg
只能安装单个软件包。
dpkg
can only install single packages.
您应声明所有软件包的依赖项在控制文件的 Depends
字段中。
You should declare all your package's dependencies in the Depends
field of the control file.
如果您的用户使用 dpkg -i package.deb ,他们将收到一条消息,指出缺少依赖项。然后,用户可以调用 apt-get -f install
来修复软件包存储库中缺少的依赖项(这假设您的依赖项在官方中实际上是
If your user then installs the package with dpkg -i package.deb
, they will get a message that dependencies are missing. The user can then invoke apt-get -f install
to fix missing dependencies from the package repository (this assumes that your dependencies actually are in the official repositories).
一种替代方法是使用诸如 gdebi
之类的工具来安装软件包; gdebi
知道如何获取缺少的依赖项,从而无需执行 apt-get -f install
步骤。
An alternative is to use a tool such as gdebi
to install your package; gdebi
knows how to fetch missing dependencies, making the apt-get -f install
step unnecessary.
我的建议是将您的 package.deb
文件(带有正确的依赖项声明)发送给用户,并建议他们使用 gdebi
。
My advice is to ship your package.deb
file (with proper dependency declaration) to your users, and advise them to install it with gdebi
.
这篇关于创建.deb安装程序时如何安装依赖项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!