LibPkg
Classes | Public Types | Public Member Functions | Static Public Attributes | Protected Member Functions | List of all members
pkg::unpack Class Reference

A class for unpacking and removing sets of packages. More...

#include <unpack.h>

Inheritance diagram for pkg::unpack:
pkg::thread

Classes

class  cannot_process
 An exception class for reporting that one or more packages cannot be processed. More...
 
class  file_conflict
 An exception class for reporting that one or more files conflict with those already on the system. More...
 
class  file_info_not_found
 An exception class for reporting that a file information record could not be found. More...
 

Public Types

enum  state_type {
  state_pre_unpack, state_pre_remove, state_copy_post_remove, state_run_pre_remove_triggers,
  state_remove_files_replaced_by_dirs, state_unpack, state_run_pre_install_triggers, state_replace,
  state_remove, state_post_remove, state_create_empty_dirs, state_post_unpack,
  state_done, state_unwind_create_empty_dirs, state_unwind_remove, state_unwind_replace,
  state_unwind_pre_install_triggers, state_unwind_unpack, state_unwind_remove_files_replaced_by_dirs, state_unwind_pre_remove_triggers,
  state_unwind_copy_post_remove, state_unwind_pre_remove, state_unwind_pre_unpack, state_fail
}
 An enumeration for describing the state of the unpack operation. More...
 
typedef unsigned long long size_type
 A type for representing byte counts. More...
 

Public Member Functions

 unpack (pkgbase &pb, const std::set< string > &packages)
 Construct unpack object. More...
 
virtual ~unpack ()
 Destroy unpack object. More...
 
state_type state () const
 Get current state of the unpack operation. More...
 
size_type files_done () const
 Get number of files processed. More...
 
size_type files_total () const
 Get total number of files to process. More...
 
size_type bytes_done () const
 Get number of bytes processed. More...
 
size_type bytes_total () const
 Get total number of bytes to process. More...
 
string message () const
 Get error message. More...
 
bool clear_state_text_changed ()
 Check is state text has changed and clear the changed flag. More...
 
const std::string & state_text () const
 Return the current state text. More...
 
const std::set< string > & packages_cannot_process () const
 Get the set of packages that cannot be processed. More...
 
const std::set< string, case_insensitive_cmp > & files_that_conflict () const
 Get the set of destination pathnames that conflict with files already on the system. More...
 
void use_trigger_run (trigger_run *tr)
 Set the class to run triggers. More...
 
void log_to (pkg::log *use_log)
 Set the log to add the unpack messages to. More...
 
void warning_func (std::tr1::function< void(LogCode code, const std::string &item, const std::string &what)> &f)
 Set the function to log and capture warnings. More...
 
triggersdetach_triggers ()
 Detach triggers for use later in the commit stage. More...
 
- Public Member Functions inherited from pkg::thread
 thread ()
 Construct thread. More...
 
virtual ~thread ()
 Destroy thread. More...
 

Static Public Attributes

static const size_type npos =static_cast<size_type>(-1)
 A null value for use in place of a byte count. More...
 

Protected Member Functions

void poll ()
 Poll this thread. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from pkg::thread
static void poll_all ()
 Poll all threads. More...
 

Detailed Description

A class for unpacking and removing sets of packages.

Member Typedef Documentation

◆ size_type

typedef unsigned long long pkg::unpack::size_type

A type for representing byte counts.

Member Enumeration Documentation

◆ state_type

An enumeration for describing the state of the unpack operation.

Enumerator
state_pre_unpack 

The state in which the states of packages to be unpacked are changed to status::state_half_unpacked.

state_pre_remove 

The state in which the states of packages to be removed are changed to status::state_half_unpacked.

state_copy_post_remove 

The state in which post remove triggers are copied so they are preserved to be run after the packages have been removed.

state_run_pre_remove_triggers 

The state in which the pre remove triggers are run.

state_remove_files_replaced_by_dirs 

The state in which files are moved that will overwritten by auto create directories.

state_unpack 

The state in which files are unpacked from their zip archives and moved to temporary locations.

state_run_pre_install_triggers 

The state in which pre install triggers are run.

state_replace 

The state in which old versions of files are backed up and replaced with new versions.

state_remove 

The state in which old versions of files that do not have replacements are backed up then removed.

state_post_remove 

The state in which backups are deleted, and the states of packages to be removed are changed to status::state_removed.

state_create_empty_dirs 

The state in which any empty directories that need creating are created.

state_post_unpack 

The state in which the states of packages to be unpacked are changed to status::state_unpacked.

state_done 

The state in which all operations have been successfully completed.

state_unwind_create_empty_dirs 

The state in which empty diwas created are removed.

state_unwind_remove 

The state in which state_remove is being backed out.

state_unwind_replace 

The state in which state_replace is being backed out.

state_unwind_pre_install_triggers 

The state in which post remove triggers are run to unwind the actions of the pre install triggers.

state_unwind_unpack 

The state in which state_unpack is being backed out.

state_unwind_remove_files_replaced_by_dirs 

The state in which files replaced by directories are restored.

state_unwind_pre_remove_triggers 

The state in which post install triggers are run to unwind the actions of the pre remove and/or pre install triggers.

state_unwind_copy_post_remove 

The state in which post remove trigger copies are removed.

state_unwind_pre_remove 

The state in which state_pre_remove is being backed out.

state_unwind_pre_unpack 

The state in which state_pre_unpack is being backed out.

state_fail 

The state in which an error has occurred and an attempt has been made to back out changes.

Constructor & Destructor Documentation

◆ unpack()

pkg::unpack::unpack ( pkgbase pb,
const std::set< string > &  packages 
)

Construct unpack object.

Parameters
pbthe package database
packagesthe set of packages to process

References pkg::pkgbase::curstat(), pkg::remove_req(), pkg::pkgbase::selstat(), and pkg::unpack_req().

◆ ~unpack()

pkg::unpack::~unpack ( )
virtual

Destroy unpack object.

Member Function Documentation

◆ state()

state_type pkg::unpack::state ( ) const
inline

Get current state of the unpack operation.

Returns
the current state

Referenced by pkg::commit::poll(), and poll().

◆ files_done()

size_type pkg::unpack::files_done ( ) const
inline

Get number of files processed.

Returns
the number of files processed (in current stage)

Referenced by pkg::commit::poll().

◆ files_total()

size_type pkg::unpack::files_total ( ) const
inline

Get total number of files to process.

Returns
the total number of files to process (in current stage)

Referenced by pkg::commit::poll().

◆ bytes_done()

size_type pkg::unpack::bytes_done ( ) const
inline

Get number of bytes processed.

Returns
the number of bytes processed (in current stage)

Referenced by pkg::commit::poll().

◆ bytes_total()

size_type pkg::unpack::bytes_total ( ) const
inline

Get total number of bytes to process.

Returns
the total number of bytes to process (in current stage)

Referenced by pkg::commit::poll().

◆ message()

string pkg::unpack::message ( ) const
inline

Get error message.

When state()==state_fail, this function returns a human-readable description of what went wrong.

Returns
the error message

Referenced by pkg::commit::poll().

◆ clear_state_text_changed()

bool pkg::unpack::clear_state_text_changed ( )
inline

Check is state text has changed and clear the changed flag.

◆ state_text()

const std::string& pkg::unpack::state_text ( ) const
inline

Return the current state text.

Referenced by poll().

◆ packages_cannot_process()

const std::set<string>& pkg::unpack::packages_cannot_process ( ) const
inline

Get the set of packages that cannot be processed.

When state()==state_fail, this function returns a list of packages that cannot be processed until the package manager has been upgraded.

Returns
the set of packages that cannot be processed

◆ files_that_conflict()

const std::set<string, case_insensitive_cmp>& pkg::unpack::files_that_conflict ( ) const
inline

Get the set of destination pathnames that conflict with files already on the system.

When state()==state_fail, this function returns a list of files that must be deleted before the given set of packages can be processed.

Referenced by pkg::commit::poll().

◆ use_trigger_run()

void pkg::unpack::use_trigger_run ( trigger_run tr)

Set the class to run triggers.

Referenced by pkg::commit::poll().

◆ log_to()

void pkg::unpack::log_to ( pkg::log use_log)

Set the log to add the unpack messages to.

Referenced by pkg::commit::poll().

◆ warning_func()

void pkg::unpack::warning_func ( std::tr1::function< void(LogCode code, const std::string &item, const std::string &what)> &  f)
inline

Set the function to log and capture warnings.

References dst_pathname, and src_pathname.

◆ detach_triggers()

triggers * pkg::unpack::detach_triggers ( )

Detach triggers for use later in the commit stage.

This should done if the unpack was successful. The object that called this memory will now own the triggers and must delete them when they are no longer required.

Referenced by pkg::commit::poll().

◆ poll()

void pkg::unpack::poll ( )
protectedvirtual

Poll this thread.

This function will be called repeatedly until the thread ceases to exist. The amount of work done per invokation should be kept small, in order that multithreading (within the application) and multitasking (across RISC OS as a whole) operate smoothly.

Reimplemented from pkg::thread.

References pkg::triggers::add_post_install(), pkg::triggers::add_post_install_abort(), pkg::triggers::add_post_remove(), pkg::triggers::add_post_remove_file(), pkg::triggers::add_pre_install(), pkg::triggers::add_pre_remove(), pkg::control::begin(), pkg::pkgbase::cache_pathname(), pkg::can_process(), pkg::status_table::commit(), pkg::binary_control_table::commit(), pkg::pkgbase::control(), pkg::triggers::copy_post_remove_file(), pkg::create_directory(), pkg::pkgbase::curstat(), pkg::triggers::delete_shared_vars(), pkg::control::description(), dst_pathname, pkg::control::end(), pkg::status::environment_id(), pkg::zipfile::extract(), pkg::zipfile::find(), pkg::zipfile::file_info::find_extra(), pkg::trigger::finished(), pkg::status::flag(), pkg::status::flag_auto, pkg::force_delete(), pkg::force_move(), pkg::module_info::help_string(), pkg::pkgbase::info_pathname(), pkg::status_table::insert(), pkg::binary_control_table::insert(), pkg::LOG_ERROR_UNINITIALISED, pkg::LOG_ERROR_UNPACK_EXCEPTION, pkg::LOG_INFO_COPY_POST_REMOVE, pkg::LOG_INFO_CREATE_EMPTY_DIRS, pkg::LOG_INFO_MODULE_CHECK, pkg::LOG_INFO_MODULE_REPLACE, pkg::LOG_INFO_MODULE_UNWIND, pkg::LOG_INFO_MODULE_UPDATE, pkg::LOG_INFO_MODULE_USE, pkg::LOG_INFO_PRE_INSTALL_TRIGGERS, pkg::LOG_INFO_PRE_REMOVE_TRIGGERS, pkg::LOG_INFO_PREREMOVE, pkg::LOG_INFO_PREUNPACK, pkg::LOG_INFO_REMOVE_FILES_REPLACED_BY_DIRS, pkg::LOG_INFO_REMOVE_POST_REMOVE_TRIGGERS, pkg::LOG_INFO_RESTORE_CONTROL, pkg::LOG_INFO_UNPACK_DONE, pkg::LOG_INFO_UNPACK_FILES, pkg::LOG_INFO_UNPACK_REMOVE, pkg::LOG_INFO_UNPACK_REMOVED, pkg::LOG_INFO_UNPACK_REPLACE, pkg::LOG_INFO_UNPACKED_PACKAGE, pkg::LOG_INFO_UNPACKING_PACKAGE, pkg::LOG_INFO_UNWIND_DONE, pkg::LOG_INFO_UNWIND_EMPTY_DIRS, pkg::LOG_INFO_UNWIND_PRE_INSTALL_TRIGGERS, pkg::LOG_INFO_UNWIND_PRE_REMOVE_TRIGGERS, pkg::LOG_INFO_UNWIND_REMOVE_FILES_REPLACED_BY_DIRS, pkg::LOG_INFO_UNWIND_REMOVED, pkg::LOG_INFO_UNWIND_REPLACED_FILES, pkg::LOG_INFO_UNWIND_STATE, pkg::LOG_INFO_UNWIND_STATE_REMOVED, pkg::LOG_INFO_UNWIND_UNPACK_FILES, pkg::trigger::log_to(), pkg::LOG_WARNING_MODULE_PACKAGE_UPDATE_FAILED, pkg::LOG_WARNING_NO_TRIGGER_RUN, pkg::trigger::message(), pkg::log::message(), pkg::triggers::next_pre_install_trigger(), pkg::triggers::next_pre_install_unwind(), pkg::triggers::next_pre_remove_trigger(), pkg::triggers::next_pre_remove_unwind(), pkg::object_length(), pkg::object_type(), pkg::pkgbase::paths(), pkg::triggers::post_remove_files_to_copy(), pkg::triggers::post_remove_files_to_remove(), pkg::triggers::pre_install_to_unwind(), pkg::triggers::pre_install_triggers_to_run(), pkg::triggers::pre_remove_to_unwind(), pkg::triggers::pre_remove_triggers_to_run(), pkg::pkgbase::prevstat(), pkg::module_info::read_ok(), pkg::triggers::remove_post_remove_file(), pkg::status_table::rollback(), pkg::trigger::run(), pkg::pkgbase::selstat(), pkg::zipfile::size(), pkg::soft_delete(), src_pathname, pkg::trigger::state(), pkg::status::state(), state(), state_copy_post_remove, state_create_empty_dirs, state_done, pkg::trigger::state_error, state_fail, pkg::status::state_half_unpacked, pkg::status::state_installed, state_post_remove, state_post_unpack, state_pre_remove, state_pre_unpack, state_remove, state_remove_files_replaced_by_dirs, pkg::status::state_removed, state_replace, state_run_pre_install_triggers, state_run_pre_remove_triggers, pkg::trigger::state_success, state_text(), state_unpack, pkg::status::state_unpacked, state_unwind_copy_post_remove, state_unwind_create_empty_dirs, state_unwind_pre_install_triggers, state_unwind_pre_remove, state_unwind_pre_remove_triggers, state_unwind_pre_unpack, state_unwind_remove, state_unwind_remove_files_replaced_by_dirs, state_unwind_replace, state_unwind_unpack, pkg::module_info::title(), pkg::zipfile::file_info::usize(), pkg::module_info::version(), pkg::status::version(), pkg::control::version(), and pkg::write_file_info().

Member Data Documentation

◆ npos

const size_type pkg::unpack::npos =static_cast<size_type>(-1)
static

A null value for use in place of a byte count.


The documentation for this class was generated from the following files:

Reference Manual LibPkg Version 0.6.1 (28 Jan 2015)