def info_name(package_name, useinstalldb=False): """Fetch package information for the given package.""" installdb = pisilinux.db.installdb.InstallDB() packagedb = pisilinux.db.packagedb.PackageDB() if useinstalldb: package = installdb.get_package(package_name) repo = None else: package, repo = packagedb.get_package_repo(package_name) metadata = pisilinux.metadata.MetaData() metadata.package = package #FIXME: get it from sourcedb if available metadata.source = None #TODO: fetch the files from server if possible (wow, you maniac -- future exa) if useinstalldb and installdb.has_package(package.name): try: files = installdb.get_files(package.name) except pisilinux.Error as e: ctx.ui.warning(e) files = None else: files = None return metadata, files, repo
def generate_pending_order(A): # returns pending package list in reverse topological order of dependency installdb = pisilinux.db.installdb.InstallDB() G_f = pgraph.PGraph(installdb) # construct G_f for x in A: G_f.add_package(x) B = A while len(B) > 0: Bp = set() for x in B: pkg = installdb.get_package(x) for dep in pkg.runtimeDependencies(): if dep.package in G_f.vertices(): G_f.add_dep(x, dep) B = Bp if ctx.get_option('debug'): import sys G_f.write_graphviz(sys.stdout) order = G_f.topological_sort() order.reverse() componentdb = pisilinux.db.componentdb.ComponentDB() # Bug 4211 if componentdb.has_component('system.base'): order = reorder_base_packages(order) return order
def snapshot(): """ Takes snapshot of the system packages. The snapshot is only a record of which packages are currently installed. The record is kept by pisilinux history mechanism as it works automatically on install, remove and upgrade operations. """ installdb = pisilinux.db.installdb.InstallDB() historydb = pisilinux.db.historydb.HistoryDB() historydb.create_history("snapshot") li = installdb.list_installed() progress = ctx.ui.Progress(len(li)) processed = 0 for name in installdb.list_installed(): package = installdb.get_package(name) historydb.add_package(pkgBefore=package, operation="snapshot") # Save changed config files of the package in snapshot for f in installdb.get_files(name).list: if f.type == "config" and pisilinux.util.config_changed(f): fpath = pisilinux.util.join_path(ctx.config.dest_dir(), f.path) historydb.save_config(name, fpath) processed += 1 ctx.ui.display_progress(operation = "snapshot", percent = progress.update(processed), info = _("Taking snapshot of the system")) historydb.update_history()
def configure_pending(packages=None): # Import COMAR import pisilinux.comariface # start with pending packages # configure them in reverse topological order of dependency installdb = pisilinux.db.installdb.InstallDB() if not packages: packages = installdb.list_pending() else: packages = set(packages).intersection(installdb.list_pending()) order = generate_pending_order(packages) try: for x in order: if installdb.has_package(x): pkginfo = installdb.get_package(x) pkg_path = installdb.package_path(x) m = pisilinux.metadata.MetaData() metadata_path = pisilinux.util.join_path(pkg_path, ctx.const.metadata_xml) m.read(metadata_path) # FIXME: we need a full package info here! pkginfo.name = x ctx.ui.notify(pisilinux.ui.configuring, package = pkginfo, files = None) pisilinux.comariface.post_install( pkginfo.name, m.package.providesComar, pisilinux.util.join_path(pkg_path, ctx.const.comar_dir), pisilinux.util.join_path(pkg_path, ctx.const.metadata_xml), pisilinux.util.join_path(pkg_path, ctx.const.files_xml), None, None, m.package.version, m.package.release ) ctx.ui.notify(pisilinux.ui.configured, package = pkginfo, files = None) installdb.clear_pending(x) except ImportError: raise pisilinux.Error(_("comar package is not fully installed"))