~simpoir/landscape-charm/bootstrap_with_key

« back to all changes in this revision

Viewing changes to charmhelpers/core/host_factory/ubuntu.py

  • Committer: 🤖 Landscape Builder
  • Author(s): Simon Poirier
  • Date: 2019-05-24 14:06:39 UTC
  • mfrom: (396.1.1 charmhelpers-and-keys)
  • Revision ID: _landscape_builder-20190524140639-q3t8aavbxute9714
This branch updates charm helpers, and add the fix proposed as
https://github.com/juju/charm-helpers/pull/326

This should fix apt failures when specifying a deb source and key.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
import subprocess
2
2
 
 
3
from charmhelpers.core.hookenv import cached
3
4
from charmhelpers.core.strutils import BasicStringComparator
4
5
 
5
6
 
19
20
    'xenial',
20
21
    'yakkety',
21
22
    'zesty',
 
23
    'artful',
 
24
    'bionic',
 
25
    'cosmic',
 
26
    'disco',
22
27
)
23
28
 
24
29
 
69
74
    return d
70
75
 
71
76
 
 
77
def get_distrib_codename():
 
78
    """Return the codename of the distribution
 
79
    :returns: The codename
 
80
    :rtype: str
 
81
    """
 
82
    return lsb_release()['DISTRIB_CODENAME'].lower()
 
83
 
 
84
 
72
85
def cmp_pkgrevno(package, revno, pkgcache=None):
73
86
    """Compare supplied revno with the revno of the installed package.
74
87
 
86
99
        pkgcache = apt_cache()
87
100
    pkg = pkgcache[package]
88
101
    return apt_pkg.version_compare(pkg.current_ver.ver_str, revno)
 
102
 
 
103
 
 
104
@cached
 
105
def arch():
 
106
    """Return the package architecture as a string.
 
107
 
 
108
    :returns: the architecture
 
109
    :rtype: str
 
110
    :raises: subprocess.CalledProcessError if dpkg command fails
 
111
    """
 
112
    return subprocess.check_output(
 
113
        ['dpkg', '--print-architecture']
 
114
    ).rstrip().decode('UTF-8')