How do I add a binary file to my existing PPA package

Adding modified or new text files to my PPA package is simple enough:

Step 1:

apt-get source [foo-package]
cd [foo-package]

Step 2: add or modify new text files containing the changes

Step 3 - update the changelog:

dch -i

Step 4 - create a patch

dpkg-source --commit

Step 5 - create a source package

debuild -S 

Step 6 - upload to launchpad

cd ..
dput [myppa]/[foo_source.changes]

However, I now need to add a new icon file (a .png file) to the existing package.

So at step 2 - just copied into the [foo-package]

At step 4 - I get the following errors:

dpkg-source: error: cannot represent change to foo-package/foo-icon.png: binary file contents changed
dpkg-source: error: unrepresentable changes to source

If I attempt to move to step 5 I get the following additional errors to the above:

dpkg-source: error: add foo-package/foo-icon.png in debian/source/include-binaries if you want to store the modified binary in the Debian tar-ball
...
dpkg-buildpackage -rfakeroot -d -us -uc -S failed

Any ideas how do I add a binary icon file to my existing PPA package?


More information

By running:

debuild -S --source-option=--include-binaries

This then allows for the source package to be built and step 6 is possible.

However this isnt really the answer - because I subsequently cannot then make further code changes (step 2) because I'm still getting the same errors.

It doesnt look like I can do dpkg-source --commit --source-option=--include-binaries because this just gives errors:

dpkg-source --commit --source-option=--include-binaries
dpkg-source: warning: --source-option=--include-binaries is not a valid option for Dpkg::Source::Package::V3::quilt
dpkg-source: error: cannot represent change to foo-package/foo-icon.png: binary file contents changed
dpkg-source: error: unrepresentable changes to source

Solution 1:

What I did:

apt-get source rhythmbox-plugin-llyrics
cd rhythmbox-plugin-llyrics-0.1/
echo '#Junk commit' >> llyrics/ChartlyricsParser.py
sed -i 's/Maintainer: fossfreedom <[email protected]>/Maintainer: Andrew King (No comment) <[email protected]>/g' debian/control
sed -i 's/fossfreedom <[email protected]>/Andrew King (No comment) <[email protected]>/g' debian/changelog
dpkg-source --commit

debuild -S -sa
mkdir debian/icons
cp ~/Pictures/awesome-cat.jpg ./debian/icons/
echo 'debian/icons/awesome-cat.jpg' > debian/source/include-binaries
cd ..
dpkg-source --include-binaries -b rhythmbox-plugin-llyrics-0.1
cd -
debuild -S

echo '#Junk commit' >> llyrics/ChartlyricsParser.py
dpkg-source --commit

#so now it's still allowing commits and in the deb-src...add it to install
echo 'debian/icons/* /usr/share/icons/hicolor/' >> debian/install
echo '' >> debian/install
debuild -S

#note that you should have the proper subfolders here e.g. 32x32/myicon.png or whatever
#also note that per packaging guidelines it should be one entry per file, not a wildcard

Confirmed that it correctly pushes and builds on Launchpad fossfreedom

Solution 2:

Just get dpkg-source --commit to ignore binary files with the extend-diff-ignore switch

Here's another simpler way to do it: you basically tell dpkg-source to ignore what it can't comprehend (i.e., binary files), and to mind its own business ;)

After adding a binary file(s) the first time, the key is to use dpkg-source --commit with the --extend-diff-ignore switch, along with the appropriate paths/filenames to ignore (Perl regex format).

For example, suppose you stick a bunch of PNGs in the llyrics directory, and then you modify some text files. The correct commit call is:

dpkg-source --commit --extend-diff-ignore="(^|/)(llyrics/.*\.png)$"

Follow that with:

debuild -S --source-option=--include-binaries

to get your PPA upload.


Let's test this with the rhythmbox-plugin-llyrics package from fossfreedom's "playground" PPA:

  1. Get source: apt-get source rhythmbox-plugin-llyrics

  2. Modify a text file and add a PNG:

    $ cd rhythmbox-plugin-llyrics-0.1
    $ echo FORCE-A-DIFF >> llyrics/README 
    $ wget -Ollyrics/dancemonkeyboy.png \
       http://www.samrethsingh.com/wp-content/uploads/2009/02/untitled-image.png
    ... `llyrics/dancemonkeyboy.png' saved [243304/243304]
    
  3. Add to changelog and increment version with dch -v 0.1-3ubuntu6~izx1

  4. Commit text changes while ignoring the PNG with:

    $ dpkg-source --commit --extend-diff-ignore="(^|/)(llyrics/.*\.png)$"
    dpkg-source: info: local changes detected, the modified files are:
    rhythmbox-plugin-llyrics-0.1/llyrics/README
    Enter the desired patch name: PPABinaryTest
    dpkg-source: info: local changes have been recorded in a new patch: rhythmbox-plugin-llyrics-0.1/debian/patches/PPABinaryTest
    
  5. Build source/changes:

    $ debuild -S --source-option=--include-binaries
    ...
    dpkg-source: info: building rhythmbox-plugin-llyrics using existing ./rhythmbox-plugin-llyrics_0.1.orig.tar.gz
    dpkg-source: info: adding llyrics/dancemonkeyboy.png to debian/source/include-binaries
    ...
    

And...voila! (Launchpad-built deb--note the ~200k size difference...)