“dpkg-source: unrepresentable changes to source” 试图解构修改后的包时

joe*_*dle 9 debuild

我使用以下命令将源下载到一个包中:

$ apt-get source gkrellweather
Run Code Online (Sandbox Code Playgroud)

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

$ sudo apt-get build-dep gkrellweather
Run Code Online (Sandbox Code Playgroud)

我测试它可以很好地构建:

$ cd gkrellweather-2.0.8
$ debuild
Run Code Online (Sandbox Code Playgroud)

.deb在上面的文件夹中构建了一个包,我可以使用以下方法进行安装:

$ sudo dpkg -i ../gkrellweather*.deb
Run Code Online (Sandbox Code Playgroud)

好的,所以一切都到位了。让我们开始吧!

我在 Vim 中打开了源代码并进行了一些我想要的更改。然后我尝试重建:

$ debuild
Run Code Online (Sandbox Code Playgroud)

但我收到以下错误:

...
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
Run Code Online (Sandbox Code Playgroud)

为什么?

小智 6

感谢 joeytwiddle 的回答,因为它为我解决这个问题提供了一个很好的起点。

在我尝试为其创建 debian 包的 Python 项目中,我正在使用:

  • pybuild 在运行 debuild 之前准备 debian 包
  • 用于版本控制的 git
  • 用于 Python 开发的 PyCharm IDE

git 创建一个.git目录,pybuild 创建一个.pybuild目录,PyCharm.idea在我的项目的根目录中创建一个目录。

因为 joeytwiddle 提到 debuild 不喜欢某个文件(在他的例子中是一个 swp 文件),所以我觉得它可能适合隐藏目录。我发现对于 git,你可以这样做:debuild -i它忽略了 pybuild 和 idea 目录的版本控制目录,我还没有找到另一个选项。所以对于我的解决方案,我复制我的项目到空白目录,删除.git.idea.pybuild目录,成功!

  • `-i` 通过 `debuild` 传递给 `dpkg-buildpackage`,然后传递给 `dpkg-source`,其手册页说可以提供正则表达式。如果没有测试,我猜 `-i'(^|/)\.(git|idea|pybuild)($|/)'` 可能对你有用。 (3认同)

joe*_*dle 3

这已经不止一次地让我绊倒了。有时我认为更改源后出现debuild错误的原因是源更改后,包维护者签名(signoff)对该源不再有效。

但实际上,在这种情况下,答案很简单:

dpkg-source: error: cannot represent change to gkrellweather-2.0.8/.gkrellweather.c.swp: binary file contents changed
Run Code Online (Sandbox Code Playgroud)

问题是Vim 创建了一个 swafile,但debuild不喜欢这样!

解决方案很简单:删除交换文件,然后构建就可以工作:

$ rm ./.gkrellweather.c.swp
$ debuild
Run Code Online (Sandbox Code Playgroud)