~tvansteenburgh/charm-helpers/config-implicit-save

« back to all changes in this revision

Viewing changes to charmhelpers/fetch/__init__.py

  • Committer: Tim Van Steenburgh
  • Date: 2014-08-26 15:13:37 UTC
  • mfrom: (173.1.26 charm-helpers-231384)
  • Revision ID: tim.van.steenburgh@canonical.com-20140826151337-8nmtjlfi5jlpjabf
MergeĀ fromĀ lp:charm-helpers

Show diffs side-by-side

added added

removed removed

Lines of Context:
117
117
 
118
118
def filter_installed_packages(packages):
119
119
    """Returns a list of packages that require installation"""
120
 
    import apt_pkg
121
 
    apt_pkg.init()
122
 
 
123
 
    # Tell apt to build an in-memory cache to prevent race conditions (if
124
 
    # another process is already building the cache).
125
 
    apt_pkg.config.set("Dir::Cache::pkgcache", "")
126
 
    apt_pkg.config.set("Dir::Cache::srcpkgcache", "")
127
 
 
128
 
    cache = apt_pkg.Cache()
 
120
    cache = apt_cache()
129
121
    _pkgs = []
130
122
    for package in packages:
131
123
        try:
138
130
    return _pkgs
139
131
 
140
132
 
 
133
def apt_cache(in_memory=True):
 
134
    """Build and return an apt cache"""
 
135
    import apt_pkg
 
136
    apt_pkg.init()
 
137
    if in_memory:
 
138
        apt_pkg.config.set("Dir::Cache::pkgcache", "")
 
139
        apt_pkg.config.set("Dir::Cache::srcpkgcache", "")
 
140
    return apt_pkg.Cache()
 
141
 
 
142
 
141
143
def apt_install(packages, options=None, fatal=False):
142
144
    """Install one or more packages"""
143
145
    if options is None: