【问题标题】:Having trouble building python deb package , complain about modified binary构建 python deb 包时遇到问题,抱怨修改后的二进制文件
【发布时间】:2012-03-13 03:25:33
【问题描述】:

我在使用 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。其次,它们不会被删除。

自从我推出 tarball 以来,没有任何文件发生变化,所以我不明白为什么二进制文件会出现这个错误。

为什么它在 share/ 下而不是 usr/ 下?

在运行 dh 的 dh_install 部分之前,它似乎已经死了。

非常感谢您的帮助。

【问题讨论】:

    标签: python package deb dpkg debhelper


    【解决方案1】:

    经过大量阅读和反复试验,我发现出了什么问题。我跑了一个

    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,就像我在上面的问题中提到的那样。这让我开始思考我是如何搞砸了构建焦油的。果然,我用 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:您的应用程序创建启动器是否对您需要声明的 Python 有任何依赖关系?这会创建一个 .deb 包,在安装时有一个 .desktop 文件,这样您的图标就会出现在例如 Ubuntu 软件中心的 Installed Apps 下?您的应用程序有助于创建 .desktop 文件,请参阅sourceforge.net/projects/createlauncher/?source=navbar
    • 谢谢!添加 '--source-option=--include-binaries' 在构建 gnu make 的未签名反向移植时救了我,接下来是 wiki.debian.org/SimpleBackportCreation
    【解决方案2】:

    您不应在源代码包中包含所有 *.pyc 文件。当您构建二进制包时,Debian 有机器自动为您编译这些。在安装步骤中,确保将所有文件都放在适当的位置,或者编写一个 debian/install 文件来执行此操作。

    dh 有一个 python 插件,如果您使用标准工具链,它可以自动处理 Python 项目。您可以告诉dh_make 使用它(基本上,它只是debian/rules 文件中dh 的一个选项)。

    【讨论】:

      猜你喜欢
      • 2010-12-07
      • 2020-06-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-03
      • 2012-10-11
      • 2017-09-01
      相关资源
      最近更新 更多