Exemple #1
0
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()
Exemple #2
0
def takeback(operation):
    """
    Takes back the system to a previous state. Uses pisilinux history to find out which packages were
    installed at the time _after_ the given operation that the system is requested to be taken back.
    @param operation: number of the operation that the system will be taken back -> integer
    """

    historydb = pisilinux.db.historydb.HistoryDB()
    historydb.create_history("takeback")

    pisilinux.operations.history.takeback(operation)