当使用“--disable-dbus”选项时,Debian 软件包构建失败了

Debian package build fails for evince, when using the "--disable-dbus" option

我正在尝试在 Debian Buster 上使用 Debian 构建过程构建 Debian 软件包 evince

apt-get source evince

然后

cd evince-3.30.2/
dpkg-buildpackage --build=binary --no-sign

当我使用 dbus(默认设置)构建包时构建过程成功。

当我更改配置并添加 --disable-dbus 时,构建过程失败并出现以下错误:

ev-application.c: In function ‘ev_application_new’:
ev-application.c:106:42: error: ‘APPLICATION_NAME’ undeclared (first use in this function); did you mean ‘G_APPLICATION_CLASS’?
                    "application-id", APPLICATION_NAME,
                                      ^~~~~~~~~~~~~~~~
                                      G_APPLICATION_CLASS
ev-application.c:106:42: note: each undeclared identifier is reported only once for each function it appears in
ev-application.c:109:1: error: control reaches end of non-void function [-Werror=return-type]
 }
^

波纹管是来自 debian/rules 文件的片段:

override_dh_auto_configure:
  dh_auto_configure -- \
    --libexecdir=/usr/lib/evince \
    --enable-djvu \
    --enable-dvi \
    --enable-ps \
    --enable-introspection \
    --enable-gtk-doc \
    --disable-libgnome-desktop \
    --disable-multimedia \
    --disable-nautilus \
    --disable-browser-plugin \
    --without-keyring

这是没有的(唯一的变化是添加 --disable-dbus):

override_dh_auto_configure:
  dh_auto_configure -- \
    --libexecdir=/usr/lib/evince \
    --enable-djvu \
    --enable-dvi \
    --enable-ps \
    --enable-introspection \
    --enable-gtk-doc \
    --disable-dbus \
    --disable-libgnome-desktop \
    --disable-multimedia \
    --disable-nautilus \
    --disable-browser-plugin \
    --without-keyring

错误是什么意思,我该如何解决?

更新 2021-09-01

我已经按照@cody 的建议修复了 APPLICATION_NAME

我还在 debian/evince.install

中删除了对 dbus 的一行引用

但是使用 --disable-dbus 构建现在以另一个错误结束:

/usr/bin/ld: .libs/evince-scan.o: in function `get_object_types':
./help/reference/shell/evince-scan.c:43: undefined reference to `ev_media_player_keys_get_type'
collect2: error: ld returned 1 exit status
make[5]: *** [Makefile:867: scan-build.stamp] Error 1
make[4]: *** [Makefile:506: all-recursive] Error 1
make[3]: *** [Makefile:591: all-recursive] Error 1
make[3]: *** Waiting for unfinished jobs....
make[2]: *** [Makefile:730: all-recursive] Error 1
make[1]: *** [Makefile:595: all] Error 2
dh_auto_build: make -j4 returned exit code 2
make: *** [debian/rules:11: build] Error 2
dpkg-buildpackage: error: debian/rules build subprocess returned exit status 2

看起来这是那个版本的 evince 源代码中的错误。如果您查看 most recent version of ev-application.c,您会注意到 APPLICATION_NAME 是在相邻的 #ifdef ENABLE_DBUS:

之外定义的
#define APPLICATION_NAME             "org.gnome.Evince"
#ifdef ENABLE_DBUS
#define APPLICATION_DBUS_OBJECT_PATH "/org/gnome/evince/Evince"
#define APPLICATION_DBUS_INTERFACE   "org.gnome.evince.Application"
...
#endif

但是如果您随后查看 the version in Debian Buster,您会注意到它是在 #ifdef:

内部定义的
#ifdef ENABLE_DBUS
#define APPLICATION_NAME             "org.gnome.Evince"
#define APPLICATION_DBUS_OBJECT_PATH "/org/gnome/evince/Evince"
#define APPLICATION_DBUS_INTERFACE   "org.gnome.evince.Application"
...
#endif

所以在Debian版本中,如果dbus被禁用,APPLICATION_NAME将不会被定义。我相信您需要做的就是改变 ev-application.c 将 APPLICATION_NAME 的定义移到 #ifdef ENABLE_DBUS 之外,它应该可以编译。

这似乎也在 Debian 存储库中fixed

除了 之外,还需要进行一些更改才能使用 --disable-dbus 构建程序包:

  • help/reference/shell/evince.types中,需要删除ev_media_player_keys_get_type行;
  • debian/evince.install中,需要删除禁用D-Bus支持时未构建的组件:
    • usr/lib/evince/evinced
    • usr/lib/systemd/user/
    • usr/share/dbus-1

我已经在 evince-3.30.2-3+deb10u1+400cat1-nmu.diff 中封装了完整的更改集;构建包:

apt source evince/buster
cd evince-3.30.2
patch -p1 < /path/to/evince-3.30.2-3+deb10u1+400cat1-nmu.diff
dpkg-buildpackage -us -uc

(根据需要安装所需的构建依赖项)。最后一步可以替换为 pdebuild 或您设置的任何其他构建工具。