Alex Kavanagh 787a9c5ae9 Ensure py3 pkgs installed on series-upgrade
On series-upgrade the g-s-s stopped syncing due python packages required
by the sync file (that is run in the context of the unit, rather than
the charm) not being present.  I believe they may have been removed
during the series-upgrade when unused packages were removed.

This patch ensures that on both upgrade and series upgrade, all the
packages that are needed are installed.

Change-Id: I8dfa9b0111fa3f204364e2c0833595bf8b219a7c
Closes-Bug: #1934306
2021-07-01 15:44:40 +01:00

22 lines
492 B
Bash
Executable File

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