尝试使用debuild构建修改后的软件包时出现了"dpkg-source: unrepresentable changes to source"的错误提示。

我使用以下方式下载了一个软件包的源代码:

$ apt-get source gkrellweather

我还确保我拥有编译依赖项:

$ sudo apt-get build-dep gkrellweather

我测试了一下,发现它可以很好地构建。
$ cd gkrellweather-2.0.8
$ debuild

它在上面的文件夹中构建了一个.deb软件包,我可以使用以下命令进行安装:
$ sudo dpkg -i ../gkrellweather*.deb

好的,一切都准备就绪。让我们开始吧!
我在Vim中打开了源代码,并进行了一些我想要的更改。然后我尝试重新构建:
$ debuild

但是我遇到了以下错误:
...
dh_clean: Compatibility levels before 5 are deprecated (level 4 in use)
 dpkg-source -b gkrellweather-2.0.8
dpkg-source: warning: no source format specified in debian/source/format, see dpkg-source(1)
dpkg-source: info: using source format `1.0'
dpkg-source: info: building gkrellweather using existing gkrellweather_2.0.8.orig.tar.gz
dpkg-source: info: building gkrellweather in gkrellweather_2.0.8-2.diff.gz
dpkg-source: error: cannot represent change to gkrellweather-2.0.8/.gkrellweather.c.swp: binary file contents changed
dpkg-source: warning: the diff modifies the following upstream files: 
 GrabWeather
 Makefile
 gkrellweather.c
dpkg-source: info: use the '3.0 (quilt)' format to have separate and documented changes to upstream files, see dpkg-source(1)
dpkg-source: unrepresentable changes to source
dpkg-buildpackage: error: dpkg-source -b gkrellweather-2.0.8 gave error exit status 1
debuild: fatal error at line 1357:
dpkg-buildpackage -rfakeroot -D -us -uc failed

为什么?
2个回答

感谢joeytwiddle的回答,它给了我解决这个问题的一个很好的起点。
在我尝试为我的Python项目创建一个Debian软件包时,我使用了以下工具:
- 使用pybuild在运行debuild之前准备Debian软件包 - 使用git进行版本控制 - 使用PyCharm IDE进行Python开发
git会创建一个.git目录,pybuild会创建一个.pybuild目录,而PyCharm会在我的项目根目录下创建一个.idea目录。
因为joeytwiddle提到debuild不喜欢某个文件(在他的情况下是一个swp文件),所以我觉得它可能对隐藏目录也有意见。我发现对于git,可以使用命令`debuild -i`来忽略版本控制目录,但至于pybuild和idea目录,我还没有找到其他选项。因此,为了解决这个问题,我将项目复制到一个空目录中,然后删除.git、.idea和.pybuild目录,最终成功!

3-i会通过debuild传递给dpkg-buildpackage,然后传递给dpkg-source,其手册中提到可以提供一个正则表达式。没有经过测试,我猜-i'(^|/)\.(git|idea|pybuild)($|/)'可能适合你。 - joeytwiddle

这个问题曾经让我多次困扰。有时候在修改源代码后出现debuild错误,我以为问题是源代码修改后,打包维护者的签名(签名确认)对于该源码不再有效。
但实际上,在这种情况下答案很简单:
dpkg-source: error: cannot represent change to gkrellweather-2.0.8/.gkrellweather.c.swp: binary file contents changed

问题是Vim创建了一个swafile,而debuild不喜欢这个!
解决方案很简单:删除swapfile,然后构建就可以正常工作了。
$ rm ./.gkrellweather.c.swp
$ debuild