如何将二进制文件添加到我现有的PPA软件包中?

将修改或新增的文本文件添加到我的PPA软件包中非常简单:
步骤1:
apt-get source [foo-package]
cd [foo-package]

第二步: 添加或修改包含更改的新文本文件
第三步 - 更新变更日志:
dch -i

第四步 - 创建一个补丁

dpkg-source --commit

步骤5 - 创建源代码包

debuild -S 

第六步 - 上传至Launchpad
cd ..
dput [myppa]/[foo_source.changes]

然而,我现在需要将一个新的图标文件(一个.png文件)添加到现有的包中。
所以在第2步 - 只需复制到[foo-package]中
在第4步 - 我遇到了以下错误:
dpkg-source: error: cannot represent change to foo-package/foo-icon.png: binary file contents changed
dpkg-source: error: unrepresentable changes to source

如果我尝试跳到第5步,我会得到以下额外的错误信息:
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

有没有办法将二进制图标文件添加到我现有的PPA软件包中?


更多信息

通过运行:

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

这样就可以构建源代码包,从而使得“步骤6”成为可能。
然而,这并不是真正的答案,因为我随后无法进行进一步的代码更改(“步骤2”),因为我仍然遇到相同的错误。
看起来我不能使用“dpkg-source --commit --source-option=--include-binaries”,因为这只会导致错误。
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
3个回答

我做了什么:
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

确认它在Launchpad上正确推送和构建。 fossfreedom

1嘿,兄弟!<击拳> 是时候让那些编码器变得正常了吧?;) - ish

只需要使用dpkg-source --commit命令并带上extend-diff-ignore选项,就可以让它忽略二进制文件了

这里还有一个更简单的方法:你只需要告诉dpkg-source忽略它无法理解的东西(即二进制文件),然后让它专心做自己的事情 ;)

在第一次添加二进制文件之后,关键是要使用dpkg-source --commit命令,并带上--extend-diff-ignore选项,同时指定要忽略的路径/文件名(使用Perl正则表达式格式)。

例如,假设你把一堆PNG文件放在llyrics目录中,然后修改了一些文本文件。正确的提交命令是:

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

跟着这样做:
debuild -S --source-option=--include-binaries

获取您的PPA上传。
我们来用 fossfreedom 的“playground” PPA 中的 rhythmbox-plugin-llyrics 软件包进行测试吧。
  1. 获取源代码:apt-get source rhythmbox-plugin-llyrics

  2. 修改一个文本文件并添加一个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. 在changelog中添加并增加版本号:dch -v 0.1-3ubuntu6~izx1

  4. 提交文本更改,同时忽略PNG图片:

    $ dpkg-source --commit --extend-diff-ignore="(^|/)(llyrics/.*\.png)$"
    dpkg-source: info: 检测到本地更改,已修改的文件为:
    rhythmbox-plugin-llyrics-0.1/llyrics/README
    输入所需的补丁名称:PPABinaryTest
    dpkg-source: info: 本地更改已记录在新的补丁中:rhythmbox-plugin-llyrics-0.1/debian/patches/PPABinaryTest
    
  5. 构建源代码/更改:

    $ debuild -S --source-option=--include-binaries
    ...
    dpkg-source: info: 使用现有的 ./rhythmbox-plugin-llyrics_0.1.orig.tar.gz 构建 rhythmbox-plugin-llyrics
    dpkg-source: info: 将 llyrics/dancemonkeyboy.png 添加到 debian/source/include-binaries
    ...
    

而且...瞧!(使用 Launchpad 构建的 deb--请注意约 200K 的大小差异...


这比仅仅添加一个文件要困难一些。
首先,您需要使用新的源代码包中包含的二进制文件重新构建.orig.tar.gz,并且很可能需要增加软件版本(例如,package_1.0.0.orig.tar.gz -> package_1.0.1.orig.tar.gz),在tar文件和debian/changelog文件中都需要进行修改。
在用新文件修改orig.tar.gz之后(不要将debian/文件包含在orig.tar.gz中),您需要添加一个debian/changelog条目,并将版本号递增,就像您对orig.tar.gz所做的那样。
然后重新构建源代码包(debuild -S),并将新的源代码包上传到PPA。这个新的源代码包将覆盖PPA中的“旧”版本。

从聊天记录中:

@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

也许这个答案被编辑为"如果你不增加版本,它将会爆炸"会更好。 - Jonas G. Drange
你可以随时对Jonas的回答提出修改建议,并解释为什么你认为这个修改是有用的,我和其他人会查看并考虑它。 - Thomas Ward
遗憾的是,我对Debian打包系统不熟悉,所以它为什么会出问题超出了我的理解。我自己做的修改将是非常不足的。 - Jonas G. Drange