autotools plugin does not allow specifying a build directory different from source directory

Bug #1882255 reported by Dmitrii Shcherbakov on 2020-06-05
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Snapcraft
Undecided
Unassigned

Bug Description

I am trying to build a newer version of libvirt from source but recently there was a change made to force the build directory to be different from the source directory:
https://github.com/libvirt/libvirt/commit/f96395e78eaccffbf128336382c74b1250f04032

Which results in "configure: error: Build directory must be different from source directory" when I try to build it.

https://github.com/snapcore/snapcraft/blob/3.11/snapcraft/plugins/autotools.py#L90-L129

The relevant snapcraft.yaml part.

  libvirt:
    source: .
    source-subdir: libvirt-6.0.0
# ...
    override-build: |
      rm -Rf libvirt-6.0.0
      apt source libvirt
      dpkg-source --before-build libvirt-6.0.0
      snapcraftctl build

Without snapcraft it would look like this:

➜ libvirt git:(master) ./autogen.sh
autoreconf: Entering directory `.'
autoreconf: configure.ac: not using Gettext
autoreconf: running: aclocal --force -I m4
autoreconf: configure.ac: tracing
autoreconf: running: libtoolize --copy --force
libtoolize: putting auxiliary files in AC_CONFIG_AUX_DIR, 'build-aux'.
libtoolize: copying file 'build-aux/ltmain.sh'
libtoolize: putting macros in AC_CONFIG_MACRO_DIRS, 'm4'.
libtoolize: copying file 'm4/libtool.m4'
libtoolize: copying file 'm4/ltoptions.m4'
libtoolize: copying file 'm4/ltsugar.m4'
libtoolize: copying file 'm4/ltversion.m4'
libtoolize: copying file 'm4/lt~obsolete.m4'
autoreconf: running: /usr/bin/autoconf --force
autoreconf: running: /usr/bin/autoheader --force
autoreconf: running: automake --add-missing --copy --force-missing
configure.ac:53: installing 'build-aux/compile'
configure.ac:51: installing 'build-aux/config.guess'
configure.ac:51: installing 'build-aux/config.sub'
configure.ac:32: installing 'build-aux/install-sh'
configure.ac:32: installing 'build-aux/missing'
examples/Makefile.am: installing 'build-aux/depcomp'
parallel-tests: installing 'build-aux/test-driver'
autoreconf: Leaving directory `.'
configure: error: Build directory must be different from source directory

In a different directory:

➜ libvirt git:(master) mkdir build
➜ libvirt git:(master) cd build
➜ build git:(master) ../autogen.sh
autoreconf: Entering directory `.'
autoreconf: configure.ac: not using Gettext
autoreconf: running: aclocal --force -I m4
autoreconf: configure.ac: tracing
autoreconf: running: libtoolize --copy --force
libtoolize: putting auxiliary files in AC_CONFIG_AUX_DIR, 'build-aux'.
libtoolize: copying file 'build-aux/ltmain.sh'
libtoolize: putting macros in AC_CONFIG_MACRO_DIRS, 'm4'.
libtoolize: copying file 'm4/libtool.m4'
libtoolize: copying file 'm4/ltoptions.m4'
libtoolize: copying file 'm4/ltsugar.m4'
libtoolize: copying file 'm4/ltversion.m4'
libtoolize: copying file 'm4/lt~obsolete.m4'
autoreconf: running: /usr/bin/autoconf --force
autoreconf: running: /usr/bin/autoheader --force
autoreconf: running: automake --add-missing --copy --force-missing
configure.ac:53: installing 'build-aux/compile'
configure.ac:32: installing 'build-aux/missing'
examples/Makefile.am: installing 'build-aux/depcomp'
autoreconf: Leaving directory `.'
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
# ...
Now type 'make' to compile libvirt

Dmitrii Shcherbakov (dmitriis) wrote :

I came up with a pretty terrible workaround:

  libvirt:
    source: .
    source-subdir: libvirt-6.0.0/build-subdir
    # ...
    override-build: |
      # ...
      mkdir libvirt-6.0.0/build-subdir
      cd libvirt-6.0.0/build-subdir
      ../autogen.sh

      echo "#!/bin/sh
      exit 0
      " >> autogen.sh
      chmod +x autogen.sh
      ln -s ../configure configure
      cd ../..
      # Build
      snapcraftctl build

But it would be nice to have something more sane.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers