Having trouble building python deb package , complain about modified binary
Asked Answered
V

2

7

I have built my packages before using debhelper, but I'm running into a very frustrating problem.

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. 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.

If I run:

dh_install

Everything goes into the correct debian/create-launcher/usr ... locations.

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 <[email protected]>
 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. 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.

Why is it looking under share/ and not usr/?

It seems to be dying before even running the dh_install portion of dh.

Help much appreciated.

Virgilio answered 13/3, 2012 at 3:25 Comment(0)
V
11

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. 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. I needed to build the tar using create-launcher_0.1.2+alpha/ as the top dir. Thus it is cut off allowing the diff of the "usr" dir on down of each tree.

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:

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:

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

I was able to roll the deb successfully.

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. Lesson learned.

Virgilio answered 13/3, 2012 at 7:0 Comment(2)
Thanks, a useful example. I'm trying to understand dpkg: does your app create-launcher have any dependencies on Python that you needed to declare? This creates a .deb package that when installed has a .desktop file so that your icon appears for example in the Ubuntu Software Center under Installed Apps? And your app helps create the .desktop file see sourceforge.net/projects/createlauncher/?source=navbarErine
Thanks! The addition of '--source-option=--include-binaries' saved me while building an unsigned backport of gnu make, following along at wiki.debian.org/SimpleBackportCreationIndophenol
K
1

You should not include all the *.pyc files in your source package. Debian has machinery to compile these for you automatically when you build the binary package. In the installation step, make sure that you put all the files in place, or write a debian/install file which does that.

There is a python addon for dh, which can handle Python projects automatically if you use the standard toolchain. You can tell dh_make to use it (it's just an option to dh in the debian/rules file, basically).

Kiker answered 27/4, 2014 at 3:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.