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

Viewed 102

I am trying to build Debian package evince, on Debian Buster, using the Debian build process:

apt-get source evince

and then

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

The build process is successful when I build the package with dbus (default setting).

When I change the configuration and add --disable-dbus, the build process fails with following error:

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]
 }
^

Bellow is snippet from the debian/rules file that works:

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

and here is the the one that does not (the only change is added --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

What does the error mean, and how can I fix it ?

UPDATE 2021-09-01

I have fixed the APPLICATION_NAME as suggested by @cody.

I have also removed one-line reference to dbus in debian/evince.install

But building with --disable-dbus now ends with another error:

/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
2 Answers

It looks like this is a bug in that version of the evince source code. If you look at the most recent version of ev-application.c, you will note that APPLICATION_NAME is defined outside of the adjacent #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

But if you then look at the version in Debian Buster, you will note that it is defined INSIDE that #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

So in the Debian version, if dbus is disabled, APPLICATION_NAME will not be defined. I believe all you would need to do is alter ev-application.c to move that definition of APPLICATION_NAME outside of the #ifdef ENABLE_DBUS, and it should compile.

This appears to have been fixed in the Debian repo as well.

In addition to moving the APPLICATION_NAME definition, a few more changes are required to build the package with --disable-dbus:

  • in help/reference/shell/evince.types, the ev_media_player_keys_get_type line needs to be removed;
  • in debian/evince.install, the components which aren’t built when D-Bus support is disabled need to be removed:
    • usr/lib/evince/evinced
    • usr/lib/systemd/user/
    • usr/share/dbus-1

I’ve encapsulated the complete set of changes in evince-3.30.2-3+deb10u1+400cat1-nmu.diff; to build the package:

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

(installing the required build-dependencies as necessary). The last step can be replaced with pdebuild or any other build tool you have set up.

Related