Install python-apt before hooks run

Previously this charm had relied on python-apt being installed by
the principle. As charms migrate to py3 this is no longer a safe
assumption and actually never was. This change ensures that
python-apt is installed before immediatly. This follows the same
pattern

Change-Id: I21ca95a9f2e410a52a7b64c99fad85749d52473a
This commit is contained in:
Liam Young 2017-11-27 08:59:56 +00:00
parent c6ae48be4a
commit efd2dbcdd0
3 changed files with 22 additions and 2 deletions

View File

@ -1 +0,0 @@
lxd_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')
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 @@
lxd_hooks.py

View File

@ -59,7 +59,7 @@ from charmhelpers.fetch import (
hooks = Hooks()
@hooks.hook()
@hooks.hook('install.real')
def install():
status_set('maintenance', 'Installing LXD packages')
if config('source'):