From: Michal Nowikowski Date: Mon, 4 Mar 2019 10:36:57 +0000 (+0100) Subject: hammer: added checking vagrant version, removed hammer from EXTRA_DIST X-Git-Tag: 430-configure-location-of-datadir_base~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ea0006f6eb948d7d4a034b413c5086cbe483eb75;p=thirdparty%2Fkea.git hammer: added checking vagrant version, removed hammer from EXTRA_DIST --- diff --git a/Makefile.am b/Makefile.am index 4f364e7672..3adb68f82e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -157,9 +157,6 @@ EXTRA_DIST += tools/mk_cfgrpt.sh #### include external sources in the distributed tarball: EXTRA_DIST += ext/coroutine/coroutine.hpp -# Add Hammer -EXTRA_DIST += hammer.py - pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = dns++.pc diff --git a/hammer.py b/hammer.py index 41f4175080..1604e10d46 100755 --- a/hammer.py +++ b/hammer.py @@ -9,6 +9,7 @@ from __future__ import print_function import os +import re import sys import glob import time @@ -1204,27 +1205,46 @@ def ssh(provider, system, revision): ve.ssh() -def ensure_hammer_deps(): - """Install Hammer dependencies onto current, host system.""" +def _install_vagrant(ver='2.2.4', upgrade=False): system, _ = get_system_revision() + if system in ['fedora', 'centos', 'rhel']: + if upgrade: + execute('sudo rpm -e vagrant') + rpm = 'vagrant_%s_x86_64.rpm' % ver + cmd = 'wget --no-verbose -O /tmp/%s ' % rpm + cmd += 'https://releases.hashicorp.com/vagrant/%s/%s' % (ver, rpm) + execute(cmd) + execute('sudo rpm -i /tmp/%s' % rpm) + os.unlink('/tmp/%s' % rpm) + elif system in ['debian', 'ubuntu']: + if upgrade: + execute('sudo dpkg --purge vagrant') + deb = 'vagrant_%s_x86_64.deb' % ver + cmd = 'wget --no-verbose -O /tmp/%s ' % deb + cmd += 'https://releases.hashicorp.com/vagrant/%s/%s' % (ver, deb) + execute(cmd) + execute('sudo dpkg -i /tmp/%s' % deb) + os.unlink('/tmp/%s' % deb) + else: + # TODO: check for packages here: https://www.vagrantup.com/downloads.html + raise NotImplementedError + - exitcode = execute('vagrant version', raise_error=False) +def ensure_hammer_deps(): + """Install Hammer dependencies onto current, host system.""" + exitcode, out = execute('vagrant version', raise_error=False, capture=True) if exitcode != 0: - if system in ['fedora', 'centos', 'rhel']: - cmd = 'wget --no-verbose -O /tmp/vagrant_2.2.2_x86_64.rpm ' - cmd += 'https://releases.hashicorp.com/vagrant/2.2.2/vagrant_2.2.2_x86_64.rpm' - execute(cmd) - execute('sudo rpm -i /tmp/vagrant_2.2.2_x86_64.rpm') - os.unlink('/tmp/vagrant_2.2.2_x86_64.rpm') - elif system in ['debian', 'ubuntu']: - cmd = 'wget --no-verbose -O /tmp/vagrant_2.2.2_x86_64.deb ' - cmd += 'https://releases.hashicorp.com/vagrant/2.2.2/vagrant_2.2.2_x86_64.deb' - execute(cmd) - execute('sudo dpkg -i /tmp/vagrant_2.2.2_x86_64.deb') - os.unlink('/tmp/vagrant_2.2.2_x86_64.deb') - else: - # TODO: check for packages here: https://www.vagrantup.com/downloads.html - raise NotImplementedError + _install_vagrant() + else: + m = re.search('Installed Version: ([\d\.]+)', out, re.I) + ver = m.group(1) + major, minor, patch = [int(v) for v in ver.split('.')] + # if ver < 2.2.3 + if major < 2 or (major == 2 and (minor < 2 or (minor == 2 and patch < 3))): + m = re.search('Latest Version: ([\d\.]+)', out, re.I) + ver = m.group(1) + _install_vagrant(ver, upgrade=True) + exitcode = execute('vagrant plugin list | grep vagrant-lxc', raise_error=False) if exitcode != 0: