简体   繁体   English

在构建python deb包时遇到问题,抱怨修改后的二进制文件

[英]Having trouble building python deb package , complain about modified binary

I have built my packages before using debhelper, but I'm running into a very frustrating problem. 我在使用debhelper之前构建了我的包,但是我遇到了一个非常令人沮丧的问题。

This is my file tree: 这是我的文件树:

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

A you can see, I have some python pyc files that are binaries and the image binary. 你可以看到,我有一些python pyc文件是二进制文件和图像二进制文件。 I don't know if this is my problem, but I have run 我不知道这是不是我的问题,但我已经跑了

dh_make

generating the debian directory and I have modified all the necessary files. 生成debian目录,我修改了所有必要的文件。

If I run: 如果我跑:

dh_install

Everything goes into the correct debian/create-launcher/usr ... locations. 一切都进入正确的debian / create-launcher / usr ...位置。

Still, if I run: 如果我跑:

debuild -uc -us

I get the following output: 我得到以下输出:

 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

I have no idea why it is talking about "ignoring deletion of directory share" and so on. 我不知道为什么它在谈论“忽略删除目录共享”等等。 First, it should start with folder usr, not share. 首先,它应该从文件夹usr开始,而不是共享。 Secondly, they are not deleted. 其次,它们不会被删除。

No file has changed since I rolled my tarball, so I don't understand why the binaries make that error. 自从我滚动tarball以来没有文件发生变化,所以我不明白为什么二进制文件会出错。

Why is it looking under share/ and not usr/? 为什么它看起来在share /而不是usr /?

It seems to be dying before even running the dh_install portion of dh. 在运行dh的dh_install部分之前,它似乎正在消亡。

Help much appreciated. 非常感谢。

After a lot of reading and trial and error, I figured out what was wrong. 经过大量的阅读和反复试验,我发现了什么是错的。 I had run a 我跑了一个

dpkg-source -b create-launcher_0.1.2+alpha

And for some reason, it failed to delete the unpacked create-launcher_0.1.2+alpha.orig.tar.gz file directory that looks something like create-launcher-0.1.2+alpha.orig.6h0gQo. 由于某种原因,它无法删除看起来像create-launcher-0.1.2 + alpha.orig.6h0gQo的解压缩的create-launcher_0.1.2 + alpha.orig.tar.gz文件目录。 I looked in it, and it started with the folder: share, not usr like it should just as I mentioned in the above question. 我看着它,它开始于文件夹:分享,而不是像我在上面的问题中提到的那样。 That made me start thinking about how I might have messed up with building the tar. 这让我开始思考如何搞砸建造焦油。 Sure enough, I built it with usr as the top folder, and it "chops" that off to do the comparison. 果然,我用usr作为顶级文件夹构建它,然后它“切断”它来进行比较。 I needed to build the tar using create-launcher_0.1.2+alpha/ as the top dir. 我需要使用create-launcher_0.1.2 + alpha /作为顶级目录来构建tar。 Thus it is cut off allowing the diff of the "usr" dir on down of each tree. 因此它被切断,允许“usr”目录的差异在每棵树的下方。

It still didn't build right. 它仍然没有正确建立。 I needed this command: 我需要这个命令:

dpkg-source --include-binaries -b create-launcher_0.1.2+alpha

I found it you do that with the "--source-option" parameter like: 我发现你使用“--source-option”参数执行此操作,如:

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

This still failed because my vim session file in the /bin directory showed a change (I don't know why, but I needed to ignore it. dpkg-source has some ignore options. This final command did the trick: 这仍然失败,因为我在/ bin目录中的vim会话文件显示了一个更改(我不知道为什么,但我需要忽略它.dpkg-source有一些忽略选项。这个最后的命令做了诀窍:

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

I was able to roll the deb successfully. 我成功地推动了deb。

Hope this helps someone out there. 希望这有助于那里的人。 Stupid mistake on my part. 我这个愚蠢的错误。 I should learn to use my old scripts (to build the tar) instead of making it up each time. 我应该学习使用我的旧脚本(构建tar),而不是每次都使用它。 Lesson learned. 学过的知识。

You should not include all the *.pyc files in your source package. 您不应该在源包中包含所有*.pyc文件。 Debian has machinery to compile these for you automatically when you build the binary package. 在构建二进制包时,Debian可以自动为您编译这些内容。 In the installation step, make sure that you put all the files in place, or write a debian/install file which does that. 在安装步骤中,确保将所有文件放在适当位置,或者编写一个debian/install文件来执行此操作。

There is a python addon for dh , which can handle Python projects automatically if you use the standard toolchain. dh有一个python插件,如果使用标准工具链,它可以自动处理Python项目。 You can tell dh_make to use it (it's just an option to dh in the debian/rules file, basically). 你可以告诉dh_make使用它(它只是dhdebian/rules文件中的一个选项,基本上)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM