10

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
fossfreedom
  • 172,746

3 Answers3

8

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 <somewhere@xmail.com>/Maintainer: Andrew King (No comment) <newplace@ymail.com>/g' debian/control
sed -i 's/fossfreedom <somewhere@xmail.com>/Andrew King (No comment) <newplace@ymail.com>/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

RobotHumans
  • 29,530
5

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

ish
  • 139,926
3

This is a little bit harder than just adding a file.

First, you would need to rebuild the .orig.tar.gz with the included binaries in the new source package, and likely would need to increment the software version (package_1.0.0.orig.tar.gz -> package_1.0.1.orig.tar.gz or something) both in the tar, and in the debian/changelog.

After modifying the orig.tar.gz with the new files (do NOT include debian/ files in the orig.tar.gz), you would then add a debian/changelog entry, changing the version to increment it as you did to the orig.tar.gz.

Then rebuild the source package (debuild -S), and upload the new source package to the PPA. That new source package will overwrite the "older" one in the PPA.


From Chat:

@LordofTime ... wouldnt launchpad complain that its just received a different original source file


@fossfreedom not if you increment the version
new version, new source
@fossfreedom if you don't increment the version it'll explode
so you must increment the version
also, make individual debian packages for each release of ubuntu
and it'll not yell as much (it'll still enforce original version)
i.e.
"I am updating the NGINX PPA from 1.2.2 to 1.2.3. I need to get the 1.2.3 source, and work from that."
"I change the package, and the .orig.tar.gz, and upload the new package to Launchpad."
"If there are no build errors, then i'm done. If there is a build error, then I damned well better fix that error."
(then reupload with 1.2.3-2 or something)
but generally i do build testing in a staging repo
Thomas Ward
  • 74,764
  • Maybe this answer would benefit by being edited to just "if you don't increment the version it'll explode"? – Jonas G. Drange Jun 25 '14 at 16:31
  • You can always propose an edit to the answer Jonas, and comment why you think the edit is useful and I and others might look at it and consider it. – Thomas Ward Jun 25 '14 at 16:33
  • Sadly I am unfamiliar with the Debian packaging system, so exactly why it blows up is beyond me. An edit made by myself would be painfully inadequate. – Jonas G. Drange Jun 25 '14 at 20:36