~bjornt/landscape-client/update-internal-repos-only

« back to all changes in this revision

Viewing changes to landscape/package/facade.py

  • Committer: Bjorn Tillenius
  • Date: 2012-03-17 08:50:40 UTC
  • mfrom: (517.1.6 remove-binary-repo)
  • Revision ID: bjorn@canonical.com-20120317085040-0zk7pwtd1w0ny1uf
Merged remove-binary-repo [r=chad.smith,jseutter] [f=956590].

Remove the binaries and the facade's internal sources.list after
handling a change-packages message. Before we removed only the binaries
at the start of the message handler, but left the sources.list file, so
apt-get update failed.

I've still left the cleanup in the beginning of the handler, in case the
handler crashed for some reason the last time it was run, leaving the
binaries in place.

Note that I didn't bother doing anything for Smart, since it works as it
is, and we will remove it soon anyway.

Show diffs side-by-side

added added

removed removed

Lines of Context:
255
255
            return
256
256
        self.reload_channels()
257
257
 
 
258
    def _get_internal_sources_list(self):
 
259
        """Return the path to the source.list file for the facade channels."""
 
260
        sources_dir = apt_pkg.config.find_dir("Dir::Etc::sourceparts")
 
261
        return os.path.join(sources_dir, "_landscape-internal-facade.list")
 
262
 
258
263
    def add_channel_apt_deb(self, url, codename, components=None):
259
264
        """Add a deb URL which points to a repository.
260
265
 
262
267
        @param codename: The dist in the repository.
263
268
        @param components: The components to be included.
264
269
        """
265
 
        sources_dir = apt_pkg.config.find_dir("Dir::Etc::sourceparts")
266
 
        sources_file_path = os.path.join(
267
 
            sources_dir, "_landscape-internal-facade.list")
 
270
        sources_file_path = self._get_internal_sources_list()
268
271
        sources_line = "deb %s %s" % (url, codename)
269
272
        if components:
270
273
            sources_line += " %s" % " ".join(components)
286
289
        self._create_packages_file(path)
287
290
        self.add_channel_apt_deb("file://%s" % path, "./", None)
288
291
 
 
292
    def clear_channels(self):
 
293
        """Clear the channels that have been added through the facade.
 
294
 
 
295
        Channels that weren't added through the facade (i.e.
 
296
        /etc/apt/sources.list and /etc/apt/sources.list.d) won't be
 
297
        removed.
 
298
        """
 
299
        sources_file_path = self._get_internal_sources_list()
 
300
        if os.path.exists(sources_file_path):
 
301
            os.remove(sources_file_path)
 
302
 
289
303
    def _create_packages_file(self, deb_dir):
290
304
        """Create a Packages file in a directory with debs."""
291
305
        packages_contents = "\n".join(
960
974
        channel = {"path": path, "type": "deb-dir"}
961
975
        self.add_channel(alias, channel)
962
976
 
 
977
    def clear_channels(self):
 
978
        """Clear channels.
 
979
 
 
980
        This method exists to be compatible with AptFacade. Smart
 
981
        doesn't need to clear its channels.
 
982
        """
 
983
 
963
984
    def get_channels(self):
964
985
        """
965
986
        @return: A C{dict} of all configured channels.