def info_name(package_name, useinstalldb=False): """Fetch package information for the given package.""" installdb = pisi.db.installdb.InstallDB() packagedb = pisi.db.packagedb.PackageDB() if useinstalldb: package = installdb.get_package(package_name) repo = None else: package, repo = packagedb.get_package_repo(package_name) metadata = pisi.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 pisi.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 = pisi.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 = pisi.db.componentdb.ComponentDB() # Bug 4211 if componentdb.has_component('system.base'): order = reorder_base_packages(order) return order
def configure_pending(packages=None): # Import COMAR import pisi.comariface # start with pending packages # configure them in reverse topological order of dependency installdb = pisi.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 = pisi.metadata.MetaData() metadata_path = pisi.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(pisi.ui.configuring, package=pkginfo, files=None) pisi.comariface.post_install( pkginfo.name, m.package.providesComar, pisi.util.join_path(pkg_path, ctx.const.comar_dir), pisi.util.join_path(pkg_path, ctx.const.metadata_xml), pisi.util.join_path(pkg_path, ctx.const.files_xml), None, None, m.package.version, m.package.release) ctx.ui.notify(pisi.ui.configured, package=pkginfo, files=None) installdb.clear_pending(x) except ImportError: raise pisi.Error(_("comar package is not fully installed"))
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 pisi history mechanism as it works automatically on install, remove and upgrade operations. """ installdb = pisi.db.installdb.InstallDB() historydb = pisi.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 pisi.util.config_changed(f): fpath = pisi.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 snapshot(): """ Takes snapshot of the system packages. The snapshot is only a record of which packages are currently installed. The record is kept by pisi history mechanism as it works automatically on install, remove and upgrade operations. """ installdb = pisi.db.installdb.InstallDB() historydb = pisi.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 pisi.util.config_changed(f): fpath = pisi.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): # start with pending packages # configure them in reverse topological order of dependency installdb = pisi.db.installdb.InstallDB() if not packages: packages = installdb.list_pending() else: packages = set(packages).intersection(installdb.list_pending()) try: ctx.exec_usysconf() except Exception as e: raise e return # Clear legacy "needs configuration" flag order = generate_pending_order(packages) for x in order: if installdb.has_package(x): pkginfo = installdb.get_package(x) pkg_path = installdb.package_path(x) m = pisi.metadata.MetaData() metadata_path = pisi.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(pisi.ui.configuring, package = pkginfo, files = None) ctx.ui.notify(pisi.ui.configured, package = pkginfo, files = None) installdb.clear_pending(x)
def configure_pending(packages=None): # Import COMAR import pisi.comariface # start with pending packages # configure them in reverse topological order of dependency installdb = pisi.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) pkgname = pisi.util.package_name(x, pkginfo.version, pkginfo.release, False, False) pkg_path = pisi.util.join_path(ctx.config.packages_dir(), pkgname) m = pisi.metadata.MetaData() metadata_path = pisi.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(pisi.ui.configuring, package = pkginfo, files = None) pisi.comariface.post_install( pkginfo.name, m.package.providesComar, pisi.util.join_path(pkg_path, ctx.const.comar_dir), pisi.util.join_path(pkg_path, ctx.const.metadata_xml), pisi.util.join_path(pkg_path, ctx.const.files_xml), None, None, m.package.version, m.package.release ) ctx.ui.notify(pisi.ui.configured, package = pkginfo, files = None) installdb.clear_pending(x) except ImportError: raise pisi.Error(_("comar package is not fully installed"))
def info_name(package_name, useinstalldb=False): """Fetch package information for the given package.""" installdb = pisi.db.installdb.InstallDB() packagedb = pisi.db.packagedb.PackageDB() if useinstalldb: package = installdb.get_package(package_name) repo = None else: package, repo = packagedb.get_package_repo(package_name) metadata = pisi.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 pisi.Error, e: ctx.ui.warning(e) files = None