为什么我手工创建的 deb 包在安装时失败并显示“无法创建”?在文件上?
我制作了一个 perl 脚本,从头开始创建 deb 二进制包。 我创建了数据、控件等。 但是当我在 deb 包上运行 dpkg -i 时,它抱怨无法从数据中提取文件。 例子: 无法创建“.dpkg-new”(处理“时”):没有这样的文件或目录。
我已经下载了一些 .deb 软件包来查看,它们不使用 preinst 脚本来创建目录结构。
我认为我做错了什么,我考虑必须在 preinst 中创建自己的目录,但这似乎不对......也许我错过了一些东西?
我是否必须创建目录,将数据中的文件复制到 preinst sh 中,或者应该 dpkg 执行此操作而我做错了什么?
I made a perl script that creates a deb binary package from scratch.
I created the data, control, etc.
But when I run dpkg -i on my deb package it complains that it is unable to files from data.
Example:
unable to create '.dpkg-new'(while processing ''): No such file or directory.
I have downloaded some .deb packages to look at and they do not use the preinst script to create the directory structure.
I am thinking I am doing something wrong, I consider having to create my own directories in preinst but it does not seem right... perhaps I am missing something?
Do I have to create directories where my files from data will be copied in the preinst sh, or should dpkg do it and I am doing something wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我在编写的 Ruby 脚本中遇到了同样的问题。
在构建 data.tar.gz 存档时,我正在生成要传递给 tar 的文件列表。当我手动解压缩并解压存档时,它会很好地缩小,但 dpkg 会失败。
事实证明,文件列表还必须包含要创建的每个目录。
请注意,当我创建 data.tar.gz 时,我使用与 dpkg-deb/build 几乎相同的选项来构建它。 c 在 dpkg-1.15.8.11 源中执行此操作。
execlp(TAR, "tar", "-cf", "-", "--format=gnu", "--null", "-T", "-", "--no-recursion" , NULL);
相反,我使用了
IO.popen("gnutar -czf - --format=gnu -T - --no-recursion", "r+")
I had the same problem in a Ruby script I wrote.
I was generating a list of files to pass to tar when building the data.tar.gz archive. When I ungzip and untared the archive manually it would deflate fine, but dpkg would fail.
It turns out that the list of files must also include each directory to create as well.
Note that when I created data.tar.gz I built it with nearly the same options as dpkg-deb/build.c does in the dpkg-1.15.8.11 source.
execlp(TAR, "tar", "-cf", "-", "--format=gnu", "--null", "-T", "-", "--no-recursion", NULL);
Instead I used
IO.popen("gnutar -czf - --format=gnu -T - --no-recursion", "r+")
除了 @Arrowmaster 所说的之外,请检查 http://www.debian.org/doc/ debian-policy/ 了解这些文件的一些详细说明。构建包本身后,您可以使用
lintian
工具检查它,看看是否有任何您可能错过的明显内容。In addition to what @Arrowmaster said, check the http://www.debian.org/doc/debian-policy/ for some detailed explanation of the files. After you build the package itself, you can check it with
lintian
tool to see if there is anything obvious you might have missed.如果有人正在寻找问题的解决方案:
“从 rpm 规范文件构建 deb 包。”
看这里 http://www.deepnet.cx/debbuild/
我已经制作了自己的 perl 构建脚本比上面提到的简单得多,所以我可以轻松维护它。
在此过程中获得的一些有用的知识:
0. deb是一个ar存档,包含3个文件,文件的顺序很重要。
1. control.tar.gz 中的脚本必须可执行。
2. 如果目录不存在,最好有一个预安装脚本来创建目录。
3. 有时 dpkg 决定解压缩您的 zip(如果 zip 是 data.tar.gz 中的唯一文件,则会发生这种情况),因此请在安装后脚本中检查这一点。
4. 当您 tar.gz 某些文件时,请务必 chmod 到包含 tar 目录结构的目录。
If any one looks for a solution to the problem:
"Build a deb package from an rpm spec file."
Look here http://www.deepnet.cx/debbuild/
I have made my own perl build script much simple then the mentioned one so I can easily maintain it.
Some useful knowledge gained in the process:
0. the deb is an ar archive that contains 3 files, the order of the files is important.
1. the scripts from control.tar.gz must be made executable.
2. it is good to have a preinstall script to make directories if dirs do not exist.
3. sometimes dpkg decides to unzip your zips (this happened if the zip was the only file in the data.tar.gz) so check for that in an postinstall script.
4. when you tar.gz some files be sure to chmod to the dir that contains the directory structure for your tar.
您不应尝试手动创建 .deb 二进制包。 Debian 新维护者指南 介绍了如何开始使用正确的方法创建 Debian 软件包工具。
您手工创建的软件包对您来说可能看起来是正确的,但因为它没有安装,所以它明显有缺陷,要么是您没有注意到的小问题,要么是您不可见的更严重的问题(例如大多数人没有意识到) .deb 实际上是一个 ar 存档)。
You should not attempt to manually create a .deb binary package by hand. The Debian New Maintainers' Guide covers how to get started creating a Debian package using the correct tools.
Your hand created package may look correct to you but because it is not installing it is obviously flawed in either a minor way that you have not noticed or in a more serious way that is not visible to you (for example most people don't realize a .deb is actually an ar archive).
这有很多原因。您确实需要运行:
并发布结果以希望有人能够解决问题。
There are lots of reasons for this. You really need to run:
And post the result to have any hope of someone being able to solve the problem.