构建Python的deb包遇到困难,抱怨修改了二进制文件。

7

我之前使用debhelper构建过我的软件包,但是我现在遇到了一个非常令人沮丧的问题。

这是我的文档树结构:

usr/
`-- share
    |-- applications
    |   `-- create-launcher.desktop
    `-- create-launcher
        |-- bin
        |   |-- callbacks.py
        |   |-- callbacks.pyc
        |   |-- create_launcher.py
        |   |-- create_launcher.pyc
        |   |-- file_handler.py
        |   |-- file_handler.pyc
        |   |-- make_launcher.py
        |   |-- make_launcher.pyc
        |   |-- message_dialog.py
        |   |-- message_dialog.pyc
        |   `-- session
        |-- data
        |   `-- gui.glade
        |-- images
        |   `-- icon_48x48.png
        `-- README

如您所见,我有一些Python的pyc二进制文件和图像二进制文件。我不知道这是否是我的问题,但我已经运行了。

dh_make

我已经生成了Debian目录并修改了所有必要的文件。

如果我运行:

dh_install

所有东西都会放到正确的debian/create-launcher/usr...位置。

但是,如果我运行:

debuild -uc -us

我看到以下输出:
 dpkg-buildpackage -rfakeroot -D -us -uc
dpkg-buildpackage: source package create-launcher
dpkg-buildpackage: source version 0.1.2+alpha-1
dpkg-buildpackage: source changed by Narnie Harshoe <signupnarnie@gmail.com>
 dpkg-source --before-build create-launcher-0.1.2+alpha
dpkg-buildpackage: host architecture amd64
 fakeroot debian/rules clean
dh clean 
   dh_testdir
   dh_auto_clean
   dh_clean
 dpkg-source -b create-launcher-0.1.2+alpha
dpkg-source: info: using source format `3.0 (quilt)'
dpkg-source: info: building create-launcher using existing ./create-launcher_0.1.2+alpha.orig.tar.gz
dpkg-source: warning: ignoring deletion of directory share
dpkg-source: warning: ignoring deletion of directory share/applications
dpkg-source: warning: ignoring deletion of file share/applications/create-launcher.desktop
dpkg-source: warning: ignoring deletion of directory share/create-launcher
dpkg-source: warning: ignoring deletion of file share/create-launcher/README
dpkg-source: warning: ignoring deletion of directory share/create-launcher/data
dpkg-source: warning: ignoring deletion of file share/create-launcher/data/gui.glade
dpkg-source: warning: ignoring deletion of directory share/create-launcher/images
dpkg-source: warning: ignoring deletion of file share/create-launcher/images/icon_48x48.png
dpkg-source: warning: ignoring deletion of directory share/create-launcher/bin
dpkg-source: warning: ignoring deletion of file share/create-launcher/bin/message_dialog.py
dpkg-source: warning: ignoring deletion of file share/create-launcher/bin/create_launcher.py
dpkg-source: warning: ignoring deletion of file share/create-launcher/bin/callbacks.py
dpkg-source: warning: ignoring deletion of file share/create-launcher/bin/make_launcher.py
dpkg-source: warning: ignoring deletion of file share/create-launcher/bin/file_handler.py
dpkg-source: warning: newly created empty file 'usr/share/applications/create-launcher.desktop' will not be represented in diff
dpkg-source: error: cannot represent change to create-launcher-0.1.2+alpha/usr/share/create-launcher/images/icon_48x48.png: binary file contents changed
dpkg-source: error: add usr/share/create-launcher/images/icon_48x48.png in debian/source/include-binaries if you want to store the modified binary in the debian tarball
dpkg-source: error: cannot represent change to create-launcher-0.1.2+alpha/usr/share/create-launcher/bin/file_handler.pyc: binary file contents changed
dpkg-source: error: add usr/share/create-launcher/bin/file_handler.pyc in debian/source/include-binaries if you want to store the modified binary in the debian tarball
dpkg-source: warning: executable mode 0755 of 'usr/share/create-launcher/bin/create_launcher.py' will not be represented in diff
dpkg-source: error: cannot represent change to create-launcher-0.1.2+alpha/usr/share/create-launcher/bin/message_dialog.pyc: binary file contents changed
dpkg-source: error: add usr/share/create-launcher/bin/message_dialog.pyc in debian/source/include-binaries if you want to store the modified binary in the debian tarball
dpkg-source: error: cannot represent change to create-launcher-0.1.2+alpha/usr/share/create-launcher/bin/make_launcher.pyc: binary file contents changed
dpkg-source: error: add usr/share/create-launcher/bin/make_launcher.pyc in debian/source/include-binaries if you want to store the modified binary in the debian tarball
dpkg-source: error: cannot represent change to create-launcher-0.1.2+alpha/usr/share/create-launcher/bin/create_launcher.pyc: binary file contents changed
dpkg-source: error: add usr/share/create-launcher/bin/create_launcher.pyc in debian/source/include-binaries if you want to store the modified binary in the debian tarball
dpkg-source: error: cannot represent change to create-launcher-0.1.2+alpha/usr/share/create-launcher/bin/callbacks.pyc: binary file contents changed
dpkg-source: error: add usr/share/create-launcher/bin/callbacks.pyc in debian/source/include-binaries if you want to store the modified binary in the debian tarball
dpkg-source: error: unrepresentable changes to source
dpkg-buildpackage: error: dpkg-source -b create-launcher-0.1.2+alpha gave error exit status 2

我不明白为什么会提到“忽略目录共享的删除”之类的内容。首先,它应该从usr文件夹开始而不是share。其次,它们并没有被删除。
自从我打包时,没有任何文件发生了更改,所以我不明白为什么二进制文件会出现这个错误。
为什么它要在share/下寻找,而不是usr/?
在运行dh_install部分之前,它似乎已经崩溃了。
非常感谢您的帮助。
2个回答

11

经过大量的阅读和试错,我找出了问题所在。 我运行了一个

dpkg-source -b create-launcher_0.1.2+alpha
由于某种原因,它未能删除解压后的create-launcher_0.1.2+alpha.orig.tar.gz文件目录,看起来像create-launcher-0.1.2+alpha.orig.6h0gQo。我查看了它,并且它以文件夹share开头,而不是像我在上面的问题中提到的usr。这让我开始思考我可能在构建tar时出了什么问题。果然,我将其构建为usr作为顶层文件夹,并且它会“砍掉”它以进行比较。我需要使用create-launcher_0.1.2+alpha/作为顶级目录来构建tar。因此,它被切断,从而允许每个树的“usr”目录向下的差异。
它仍然没有正确构建。我需要这个命令:
dpkg-source --include-binaries -b create-launcher_0.1.2+alpha

我发现你可以使用“--source-option”参数来实现这个操作,例如:

debuild -uc -us --source-option=--include-binaries

由于/bin目录中我的vim会话文件显示有更改(我不知道为什么,但我需要忽略它),因此这仍然失败了。dpkg-source有一些忽略选项。最后这个命令解决了问题:

debuild -uc -us --source-option=--include-binaries --source-option=-isession

我成功地完成了deb的打包。

希望能帮助到某些人。这是我自己犯傻瓜错误。我应该学会使用我的旧脚本(来构建tar包)而不是每次都重新发明。吸取了教训。


谢谢,这是一个有用的例子。我正在尝试理解dpkg:您的应用程序create-launcher是否有任何依赖于Python需要声明的内容?这将创建一个.deb包,安装后会有一个.desktop文件,以便您的图标出现在例如Ubuntu软件中心下的已安装应用程序中?而您的应用程序可以帮助创建.desktop文件,请参见http://sourceforge.net/projects/createlauncher/?source=navbar - bootchk
谢谢!添加'--source-option=--include-binaries'选项在我构建未签名的gnu make回溯时帮了我大忙,参考https://wiki.debian.org/SimpleBackportCreation。 - Epu

1
你不应该在源代码包中包含所有的*.pyc文件。Debian有机制可以在构建二进制包时自动编译这些文件。在安装步骤中,请确保将所有文件放置在正确的位置,或者编写一个debian/install文件来完成这个任务。
如果使用标准工具链,python插件可以自动处理Python项目。你可以告诉dh_make使用它(基本上是在debian/rules文件中给dh添加一个选项)。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接