Ensure python2 is installed before hook execution

Change-Id: I724eaea5f09191b548e5497f9bb2c777f882d290
Closes-Bug: 1606906
This commit is contained in:
Corey Bryant 2017-03-30 15:24:11 -04:00 committed by Ryan Beisner
parent e95488afa0
commit 41b60eb037
3 changed files with 22 additions and 2 deletions

View File

@ -103,7 +103,7 @@ SUPPORTED_TRANSPORTS = ['udp', 'udpu', 'multicast', 'unicast']
DEPRECATED_TRANSPORT_VALUES = {"multicast": "udp", "unicast": "udpu"}
@hooks.hook()
@hooks.hook('install.real')
def install():
ubuntu_release = lsb_release()['DISTRIB_CODENAME'].lower()
if CompareHostReleases(ubuntu_release) >= 'zesty':

View File

@ -1 +0,0 @@
hooks.py

20
hooks/install Executable file
View File

@ -0,0 +1,20 @@
#!/bin/bash
# Wrapper to deal with newer Ubuntu versions that don't have py2 installed
# by default.
declare -a DEPS=('apt' 'netaddr' 'netifaces' 'pip' 'yaml' 'dnspython')
check_and_install() {
pkg="${1}-${2}"
if ! dpkg -s ${pkg} 2>&1 > /dev/null; then
apt-get -y install ${pkg}
fi
}
PYTHON="python"
for dep in ${DEPS[@]}; do
check_and_install ${PYTHON} ${dep}
done
exec ./hooks/install.real

1
hooks/install.real Symbolic link
View File

@ -0,0 +1 @@
hooks.py