[libvirt] [PATCH libvirt-glib 0/5] Portability fixes

Currently, trying to build libvirt-glib on FreeBSD results in all sorts of interesting failures. After applying this series, it's possible to build libvirt-glib and run the test suite successfully. There's even a couple of clean-ups thrown in for good measure :) Andrea Bolognani (5): maint: Drop autobuild.sh configure: Bump required libvirt version to 1.2.5 configure: Look for Perl interpreter path tests: Don't rely on non-portable paths scripts: Fix sha-bang lines autobuild.sh | 91 ------------------------------------------- build-aux/check-symfile.pl | 2 +- build-aux/check-symsorting.pl | 2 +- configure.ac | 4 +- examples/config-demo.py | 2 +- examples/conn-test.js | 2 +- examples/conn-test.py | 2 +- examples/event-test.py | 1 + tap-driver.sh | 2 +- tap-test | 2 +- tests/test-events.c | 2 +- 11 files changed, 12 insertions(+), 100 deletions(-) delete mode 100755 autobuild.sh -- 2.13.5

The Test-AutoBuild project, that this script is supposed to be used with, hasn't seen any activity in ~6 years; libvirt's own CI, which also performs periodic builds of libvirt-glib, is running on Jenkins with a completely independent setup that doesn't use the script at all. Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- autobuild.sh | 91 ------------------------------------------------------------ 1 file changed, 91 deletions(-) delete mode 100755 autobuild.sh diff --git a/autobuild.sh b/autobuild.sh deleted file mode 100755 index 9935de1..0000000 --- a/autobuild.sh +++ /dev/null @@ -1,91 +0,0 @@ -#!/bin/sh - -set -e -set -v - -test -n "$1" && RESULTS=$1 || RESULTS=results.log -: ${AUTOBUILD_INSTALL_ROOT=$HOME/builder} - -# Make things clean. -test -f Makefile && make -k distclean || : - -rm -rf build -mkdir build -cd build - -../autogen.sh --prefix=$AUTOBUILD_INSTALL_ROOT \ - --enable-gtk-doc - -make -make install - -# set -o pipefail is a bashism; this use of exec is the POSIX alternative -exec 3>&1 -st=$( - exec 4>&1 >&3 - { make check syntax-check 2>&1 3>&- 4>&-; echo $? >&4; } | tee "$RESULTS" -) -exec 3>&- -test "$st" = 0 - -rm -f *.tar.gz -make dist - -if [ -n "$AUTOBUILD_COUNTER" ]; then - EXTRA_RELEASE=".auto$AUTOBUILD_COUNTER" -else - NOW=`date +"%s"` - EXTRA_RELEASE=".$USER$NOW" -fi - -if [ -f /usr/bin/rpmbuild ]; then - rpmbuild --nodeps \ - --define "extra_release $EXTRA_RELEASE" \ - --define "_sourcedir `pwd`" \ - -ba --clean libvirt-glib.spec -fi - -# Test mingw32 cross-compile -if test -x /usr/bin/i686-w64-mingw32-gcc ; then - make distclean - - PKG_CONFIG_PATH="$AUTOBUILD_INSTALL_ROOT/i686-w64-mingw32/sys-root/mingw/lib/pkgconfig" \ - CC="i686-w64-mingw32-gcc" \ - ../configure \ - --build=$(uname -m)-pc-linux \ - --host=i686-w64-mingw32 \ - --prefix="$AUTOBUILD_INSTALL_ROOT/i686-w64-mingw32/sys-root/mingw" \ - --enable-werror \ - --enable-introspection=no - - make - make install - -fi - -# Test mingw64 cross-compile -if test -x /usr/bin/x86_64-w64-mingw32-gcc ; then - make distclean - - PKG_CONFIG_PATH="$AUTOBUILD_INSTALL_ROOT/x86_64-w64-mingw32/sys-root/mingw/lib/pkgconfig" \ - CC="x86_64-w64-mingw32-gcc" \ - ../configure \ - --build=$(uname -m)-pc-linux \ - --host=x86_64-w64-mingw32 \ - --prefix="$AUTOBUILD_INSTALL_ROOT/i686-w64-mingw32/sys-root/mingw" \ - --enable-werror \ - --enable-introspection=no - - make - make install - -fi - -if test -x /usr/bin/i686-w64-mingw32-gcc && test -x /usr/bin/x86_64-w64-mingw32-gcc ; then - if test -f /usr/bin/rpmbuild ; then - rpmbuild --nodeps \ - --define "extra_release $EXTRA_RELEASE" \ - --define "_sourcedir `pwd`" \ - -ba --clean mingw-libvirt-glib.spec - fi -fi -- 2.13.5

That's the version that introduced VIR_DOMAIN_TIME_SYNC, which we use in the library. Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 7981d23..43b0ffb 100644 --- a/configure.ac +++ b/configure.ac @@ -9,7 +9,7 @@ AC_CANONICAL_HOST AM_SILENT_RULES([yes]) -LIBVIRT_REQUIRED=1.1.1 +LIBVIRT_REQUIRED=1.2.5 AC_SUBST([LIBVIRT_REQUIRED]) dnl used in the .spec file GLIB2_REQUIRED=2.36.0 AC_SUBST([GLIB2_REQUIRED]) dnl used in the .spec file -- 2.13.5

The $(PERL) variable is used in several places, but configure is not actually looking for the Perl interpreter path, so it will always end up being empty. Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- configure.ac | 2 ++ 1 file changed, 2 insertions(+) diff --git a/configure.ac b/configure.ac index 43b0ffb..05b9628 100644 --- a/configure.ac +++ b/configure.ac @@ -71,6 +71,8 @@ AC_SUBST([LIBVIRT_GLIB_VERSION_NUMBER]) AC_PROG_CC AM_PROG_CC_C_O +AC_PATH_PROG([PERL], [perl]) + LT_INIT([shared disable-static win32-dll]) dnl AC_CONFIG_LIBOBJ_DIR([src]) -- 2.13.5

The test-events program sets up a watch on /bin/true; however, that path is not portable: FreeBSD uses /usr/bin/true for example. Remove the portability issue by using /dev/null instead. Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- tests/test-events.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test-events.c b/tests/test-events.c index 0c0e929..6845243 100644 --- a/tests/test-events.c +++ b/tests/test-events.c @@ -98,7 +98,7 @@ static gboolean test_watch(gpointer user_data G_GNUC_UNUSED) static void test_remove_disabled_watch(void) { main_loop = g_main_loop_new(NULL, FALSE); - watch_fd = open("/bin/true", O_RDONLY); + watch_fd = open("/dev/null", O_RDONLY); g_idle_add(test_watch, NULL); g_main_loop_run(main_loop); g_main_loop_unref(main_loop); -- 2.13.5

This is particularly useful on operating systems that don't ship Perl or Python as part of the base system (eg. FreeBSD) while still working just as well as it did before on Linux. While at it, make it explicit that our scripts are only going to work with Python 2, add a couple of missing sha-bang lines and tweak a couple more that just didn't look very nice. Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- build-aux/check-symfile.pl | 2 +- build-aux/check-symsorting.pl | 2 +- examples/config-demo.py | 2 +- examples/conn-test.js | 2 +- examples/conn-test.py | 2 +- examples/event-test.py | 1 + tap-driver.sh | 2 +- tap-test | 2 +- 8 files changed, 8 insertions(+), 7 deletions(-) diff --git a/build-aux/check-symfile.pl b/build-aux/check-symfile.pl index d59a213..4f88300 100755 --- a/build-aux/check-symfile.pl +++ b/build-aux/check-symfile.pl @@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl # Copyright (C) 2012-2013 Red Hat, Inc. # diff --git a/build-aux/check-symsorting.pl b/build-aux/check-symsorting.pl index 31b6059..942097a 100755 --- a/build-aux/check-symsorting.pl +++ b/build-aux/check-symsorting.pl @@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl # Copyright (C) 2012-2013 Red Hat, Inc. # diff --git a/examples/config-demo.py b/examples/config-demo.py index e92aa43..ab3bc77 100644 --- a/examples/config-demo.py +++ b/examples/config-demo.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python2 from gi.repository import LibvirtGConfig; diff --git a/examples/conn-test.js b/examples/conn-test.js index 7f9784b..17affba 100755 --- a/examples/conn-test.js +++ b/examples/conn-test.js @@ -1,4 +1,4 @@ -#!/usr/bin/gjs +#!/usr/bin/env gjs const lv = imports.gi.LibvirtGObject; const gio = imports.gi.Gio; diff --git a/examples/conn-test.py b/examples/conn-test.py index deeaa26..e3b1b99 100644 --- a/examples/conn-test.py +++ b/examples/conn-test.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python2 from gi.repository import LibvirtGObject; from gi.repository import Gio; diff --git a/examples/event-test.py b/examples/event-test.py index 6ccc8f4..2b25e0a 100644 --- a/examples/event-test.py +++ b/examples/event-test.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python2 from gi.repository import Gtk import libvirt diff --git a/tap-driver.sh b/tap-driver.sh index 6fef8f4..dc40648 100755 --- a/tap-driver.sh +++ b/tap-driver.sh @@ -1,4 +1,4 @@ -#! /bin/sh +#!/bin/sh # Copyright (C) 2011-2013 Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or modify diff --git a/tap-test b/tap-test index 481e333..4d5892c 100755 --- a/tap-test +++ b/tap-test @@ -1,4 +1,4 @@ -#! /bin/sh +#!/bin/sh # run a GTest in tap mode. The test binary is passed as $1 -- 2.13.5

On Wed, Sep 20, 2017 at 07:54:45PM +0200, Andrea Bolognani wrote:
Currently, trying to build libvirt-glib on FreeBSD results in all sorts of interesting failures.
After applying this series, it's possible to build libvirt-glib and run the test suite successfully.
There's even a couple of clean-ups thrown in for good measure :)
Andrea Bolognani (5): maint: Drop autobuild.sh configure: Bump required libvirt version to 1.2.5 configure: Look for Perl interpreter path tests: Don't rely on non-portable paths scripts: Fix sha-bang lines
For all 5 patches: Reviewed-by: Daniel P. Berrange <berrange@redhat.com> Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
participants (2)
-
Andrea Bolognani
-
Daniel P. Berrange