~fginther/landscape-charm/use-host-series

« back to all changes in this revision

Viewing changes to lib/apt.py

  • Committer: Francis Ginther
  • Date: 2016-07-01 18:28:54 UTC
  • Revision ID: francis.ginther@canonical.com-20160701182854-8bpy56w4dm8rt1rw
Match the source repository series to the host.

Show diffs side-by-side

added added

removed removed

Lines of Context:
156
156
            raise AptSourceAndKeyDontMatchError()
157
157
 
158
158
        for repository, key in zip(repositories, keys):
 
159
            if repository.startswith("deb"):
 
160
                # Make sure the repository series matches the host
 
161
                host_series = subprocess.check_output(
 
162
                    ["lsb_release", "-sc"]).decode("utf-8").strip()
 
163
                repository = repository.strip()
 
164
                fields = repository.split()
 
165
                fields[2] = host_series
 
166
                repository = " ".join(fields)
159
167
            self._hookenv.log("Adding repository: " + repository)
160
168
            self._fetch.add_source(repository, key)
161
169