146
148
return [pkg for pkg in self._get_ctrl().getCache().getPackages()
147
149
if isinstance(pkg, self._deb_package_type)]
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())
149
155
def get_packages_by_name(self, name):
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)
288
def add_channel_apt_deb(self, url, codename, components):
289
"""Add a Smart channel of type C{"apt-deb"}.
294
channel = {"baseurl": url, "distribution": codename,
295
"components": components, "type": "apt-deb"}
296
self.add_channel(alias, channel)
298
def add_channel_deb_dir(self, path):
299
"""Add a Smart channel of type C{"deb-dir"}.
304
channel = {"path": path, "type": "deb-dir"}
305
self.add_channel(alias, channel)
282
307
def get_channels(self):
284
309
@return: A C{dict} of all configured channels.
287
312
return smart.sysconf.get("channels")
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,
297
def make_deb_dir_channel(path):
298
"""Convenience to create Smart channels of type C{"deb-dir"}."""
299
return {"path": path,
314
def get_package_locks(self):
315
"""Return all set package locks.
317
@return: A C{list} of ternary tuples, contaning the name, relation
318
and version details for each lock currently set on the system.
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))
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")
336
def set_package_lock(self, name, relation=None, version=None):
337
"""Set a new package lock.
339
Any package matching the given name and possibly the given version
340
condition will be locked.
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}.
347
@note: If used at all, the C{relation} and C{version} parameter must be
350
self._validate_lock_condition(relation, version)
352
smart.pkgconf.setFlag("lock", name, relation, version)
354
def remove_package_lock(self, name, relation=(), version=()):
355
"""Remove a package lock."""
356
self._validate_lock_condition(relation, version)
358
smart.pkgconf.clearFlag("lock", name=name, relation=relation,