summaryrefslogtreecommitdiff
path: root/hooks
diff options
authordann frazier <dannf@ubuntu.com>2014-11-20 09:42:07 -0600
committerdann frazier <dannf@ubuntu.com>2014-11-20 09:42:07 -0600
commit3bc4c03f57339725afef516fcee0408d8b11dfba (patch)
tree3a4ba4ad42d99d7565868c404c49b87a88a3ac57 /hooks
parente489a2b1a3948ba758403f3e88fa53aa838a0e72 (diff)
Use ppa:mongodb-arm64/ppa by default when running on arm64/trusty
We know that the version of mongodb that shipped in trusty is insufficient for arm64, so there's no point in having the charm try to use it. Instead, default to pulling from a Canonical-maintained PPA - but still respect a user's "source" config setting if specified.
Diffstat (limited to 'hooks')
-rwxr-xr-xhooks/hooks.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/hooks/hooks.py b/hooks/hooks.py
index d6a590a..a7aa4cd 100755
--- a/hooks/hooks.py
+++ b/hooks/hooks.py
@@ -45,6 +45,7 @@ from charmhelpers.core.hookenv import log as juju_log
from charmhelpers.core.host import (
service,
+ lsb_release,
)
hooks = Hooks()
@@ -718,6 +719,17 @@ PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
""" % (cron_runtime, script_filename))
+# We can remove this quirk when charm no longer supports trusty
+def arm64_trusty_quirk():
+ arch = subprocess.check_output(['dpkg', '--print-architecture']).strip()
+ if arch != 'arm64':
+ return
+ if lsb_release()['DISTRIB_CODENAME'] != 'trusty':
+ return
+ ppa = 'ppa:mongodb-arm64/ppa'
+ juju_log("*** Detected trusty/arm64. Archive version contains incomplete "
+ "mongodb port, enabling installs from %s ***" % (ppa))
+ add_source(ppa)
###############################################################################
# Hook functions
@@ -726,6 +738,11 @@ PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
def install_hook():
juju_log("Installing mongodb")
add_source(config('source'), config('key'))
+
+ # Allow users to bypass arm64/trusty workaround by adding their own source
+ if config('source') == 'None':
+ arm64_trusty_quirk()
+
apt_update(fatal=True)
apt_install(packages=['mongodb-server', 'mongodb-clients', 'python-yaml'],
fatal=True)