From c627059c286534e4fe9e2bb1e89d26ff6383ea8a Mon Sep 17 00:00:00 2001 From: Darragh Bailey Date: Thu, 8 Sep 2022 11:19:38 +0100 Subject: [PATCH] Handle REXML requires for Ubuntu focal The distribution provided vagrant package on Ubuntu 20.04 is version 2.2.6 running on ruby 2.7.2. It appears that the rexml layout is slightly different and imports different paths than the current code expects. Add this combination to the unit tests and switch the requires to load the specific library requirements instead of relying on rexml loading everything underneath. Additionally it appears the hook behaviour change appeared earlier that the understood vagrant release of 2.2.11, and 2.2.6 also requires the newer hook behaviour. --- .github/workflows/unit-tests.yml | 4 ++++ lib/vagrant-libvirt/action/destroy_domain.rb | 7 ++----- lib/vagrant-libvirt/action/resolve_disk_settings.rb | 7 ++----- lib/vagrant-libvirt/action/start_domain.rb | 2 ++ lib/vagrant-libvirt/util/compat.rb | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 59273559f..daf092790 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -41,6 +41,10 @@ jobs: - ruby: 2.6.6 vagrant: v2.2.14 allow_fail: false + - ruby: 2.7.2 + vagrant: v2.2.6 + allow_fail: false + # above block is to ensure compatible with Ubuntu 20.04 vagrant package - ruby: 3.0.0 vagrant: allow_fail: false diff --git a/lib/vagrant-libvirt/action/destroy_domain.rb b/lib/vagrant-libvirt/action/destroy_domain.rb index 95b32f901..3b64b2c74 100644 --- a/lib/vagrant-libvirt/action/destroy_domain.rb +++ b/lib/vagrant-libvirt/action/destroy_domain.rb @@ -2,11 +2,8 @@ require 'log4r' -begin - require 'rexml' -rescue LoadError - require 'rexml/rexml' -end +require 'rexml/document' +require 'rexml/xpath' require 'vagrant-libvirt/util/domain_flags' diff --git a/lib/vagrant-libvirt/action/resolve_disk_settings.rb b/lib/vagrant-libvirt/action/resolve_disk_settings.rb index 1213f198b..272699558 100644 --- a/lib/vagrant-libvirt/action/resolve_disk_settings.rb +++ b/lib/vagrant-libvirt/action/resolve_disk_settings.rb @@ -2,11 +2,8 @@ require 'log4r' -begin - require 'rexml' -rescue LoadError - require 'rexml/rexml' -end +require 'rexml/document' +require 'rexml/xpath' require 'vagrant-libvirt/util/resolvers' diff --git a/lib/vagrant-libvirt/action/start_domain.rb b/lib/vagrant-libvirt/action/start_domain.rb index 577e72439..524c2298d 100644 --- a/lib/vagrant-libvirt/action/start_domain.rb +++ b/lib/vagrant-libvirt/action/start_domain.rb @@ -3,6 +3,8 @@ require 'log4r' require 'rexml/document' +require 'rexml/formatters/pretty' +require 'rexml/xpath' require 'vagrant-libvirt/util/xml' diff --git a/lib/vagrant-libvirt/util/compat.rb b/lib/vagrant-libvirt/util/compat.rb index 3c15d55d5..8f89001de 100644 --- a/lib/vagrant-libvirt/util/compat.rb +++ b/lib/vagrant-libvirt/util/compat.rb @@ -11,7 +11,7 @@ module Util module Compat def self.action_hook_args(name, action) # handle different number of arguments for action_hook depending on vagrant version - if Gem::Version.new(Vagrant::VERSION) >= Gem::Version.new('2.2.11') + if Gem::Version.new(Vagrant::VERSION) >= Gem::Version.new('2.2.6') return name, action end