~ahasenack/landscape-client/landscape-client-1.5.5-0ubuntu0.9.04.0

« back to all changes in this revision

Viewing changes to landscape/package/facade.py

  • Committer: Bazaar Package Importer
  • Author(s): Free Ekanayaka
  • Date: 2009-12-16 10:50:05 UTC
  • mfrom: (1.2.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20091216105005-9p9absehm0l6sd2t
Tags: 1.4.0-0ubuntu0.9.04.0
* New upstream release (LP: #497351)

* Bug fixes:
  - Fix landscape daemons fail to start when too many groups are
    available (LP: #456124)
  - Fix landscape programs wake up far too much. (LP: #340843)
  - Fix Package manager fails with 'no such table: task' (LP #465846)
  - Fix test suite leaving temporary files around (LP #476418)
  - Fix the 1hr long wait for user data to be uploaded following a
    resynchronisation (LP #369000)

* Add support for Ubuntu release upgrades:
  - Add helper function to fetch many files at once (LP: #450629)
  - Handle release-upgrade messages in the packagemanager
    plugin (LP: #455217)
  - Add a release-upgrader task handler (LP: #462543)
  - Support upgrade-tool environment variables (LP: #463321)

* Add initial support for Smart package locking:
  - Detect and report changes about Smart package locks (#488108)

* Packaging fixes:
  - Turn unnecessary Pre-Depends on python-gobject into a regular Depends
  - If it's empty, remove /etc/landscape upon purge

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
class TransactionError(Exception):
10
10
    """Raised when the transaction fails to run."""
11
11
 
 
12
 
12
13
class DependencyError(Exception):
13
14
    """Raised when a needed dependency wasn't explicitly marked."""
14
15
 
19
20
        return ("Missing dependencies: %s" %
20
21
                ", ".join([str(package) for package in self.packages]))
21
22
 
 
23
 
22
24
class SmartError(Exception):
23
25
    """Raised when Smart fails in an undefined way."""
24
26
 
146
148
        return [pkg for pkg in self._get_ctrl().getCache().getPackages()
147
149
                if isinstance(pkg, self._deb_package_type)]
148
150
 
 
151
    def get_locked_packages(self):
 
152
        """Get all packages in the channels matching the set locks."""
 
153
        return smart.pkgconf.filterByFlag("lock", self.get_packages())
 
154
 
149
155
    def get_packages_by_name(self, name):
150
156
        """
151
157
        Get all available packages matching the provided name.
279
285
        channels.update({alias: channel})
280
286
        smart.sysconf.set("channels", channels, soft=True)
281
287
 
 
288
    def add_channel_apt_deb(self, url, codename, components):
 
289
        """Add a Smart channel of type C{"apt-deb"}.
 
290
 
 
291
        @see: L{add_channel}
 
292
        """
 
293
        alias = codename
 
294
        channel = {"baseurl": url, "distribution": codename,
 
295
                   "components": components, "type": "apt-deb"}
 
296
        self.add_channel(alias, channel)
 
297
 
 
298
    def add_channel_deb_dir(self, path):
 
299
        """Add a Smart channel of type C{"deb-dir"}.
 
300
 
 
301
        @see: L{add_channel}
 
302
        """
 
303
        alias = path
 
304
        channel = {"path": path, "type": "deb-dir"}
 
305
        self.add_channel(alias, channel)
 
306
 
282
307
    def get_channels(self):
283
308
        """
284
309
        @return: A C{dict} of all configured channels.
286
311
        self._get_ctrl()
287
312
        return smart.sysconf.get("channels")
288
313
 
289
 
 
290
 
def make_apt_deb_channel(baseurl, distribution, components):
291
 
    """Convenience to create Smart channels of type C{"apt-deb"}."""
292
 
    return {"baseurl": baseurl,
293
 
            "distribution": distribution,
294
 
            "components": components,
295
 
            "type": "apt-deb"}
296
 
 
297
 
def make_deb_dir_channel(path):
298
 
    """Convenience to create Smart channels of type C{"deb-dir"}."""
299
 
    return {"path": path,
300
 
            "type": "deb-dir"}
 
314
    def get_package_locks(self):
 
315
        """Return all set package locks.
 
316
 
 
317
        @return: A C{list} of ternary tuples, contaning the name, relation
 
318
            and version details for each lock currently set on the system.
 
319
        """
 
320
        self._get_ctrl()
 
321
        locks = []
 
322
        locks_by_name = smart.pkgconf.getFlagTargets("lock")
 
323
        for name in locks_by_name:
 
324
            for condition in locks_by_name[name]:
 
325
                relation = condition[0] or ""
 
326
                version = condition[1] or ""
 
327
                locks.append((name, relation, version))
 
328
        return locks
 
329
 
 
330
    def _validate_lock_condition(self, relation, version):
 
331
        if relation and not version:
 
332
            raise RuntimeError("Package lock version not provided")
 
333
        if version and not relation:
 
334
            raise RuntimeError("Package lock relation not provided")
 
335
 
 
336
    def set_package_lock(self, name, relation=None, version=None):
 
337
        """Set a new package lock.
 
338
 
 
339
        Any package matching the given name and possibly the given version
 
340
        condition will be locked.
 
341
 
 
342
        @param name: The name a package must match in order to be locked.
 
343
        @param relation: Optionally, the relation of the version condition the
 
344
            package must satisfy in order to be considered as locked.
 
345
        @param version: Optionally, the version associated with C{relation}.
 
346
 
 
347
        @note: If used at all, the C{relation} and C{version} parameter must be
 
348
           both provided.
 
349
        """
 
350
        self._validate_lock_condition(relation, version)
 
351
        self._get_ctrl()
 
352
        smart.pkgconf.setFlag("lock", name, relation, version)
 
353
 
 
354
    def remove_package_lock(self, name, relation=(), version=()):
 
355
        """Remove a package lock."""
 
356
        self._validate_lock_condition(relation, version)
 
357
        self._get_ctrl()
 
358
        smart.pkgconf.clearFlag("lock", name=name, relation=relation,
 
359
                                version=version)