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

A class for installing, removing and purging packages. More...

#include <commit.h>

Inheritance diagram for pkg::commit:
pkg::thread

Classes

struct  progress
 A structure for monitoring the download progress of one source. More...
 

Public Types

enum  state_type {
  state_paths, state_pre_download, state_download, state_unpack,
  state_configure, state_purge, state_update_sysvars, state_update_sprites,
  state_update_boot_options, state_boot_files, state_run_files, state_add_files_to_apps,
  state_post_remove_triggers, state_post_install_triggers, state_cleanup_triggers, state_done,
  state_fail
}
 
typedef unsigned long long size_type
 A type for representing byte counts. More...
 

Public Member Functions

 commit (pkgbase &pb, const std::set< string > &packages)
 Construct commit operation. More...
 
virtual ~commit ()
 Destroy commit operation. More...
 
state_type state () const
 Get current state of the commit 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 has_substate_text () const
 
bool clear_substate_text_changed ()
 
std::string substate_text () const
 
const std::set< string > & 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 (log *use_log)
 Set the log to add to. More...
 
logwarnings () const
 Return warnings log. More...
 
logdetach_warnings ()
 Detach warnings log. 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

virtual 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 installing, removing and purging packages.

Member Typedef Documentation

◆ size_type

typedef unsigned long long pkg::commit::size_type

A type for representing byte counts.

Member Enumeration Documentation

◆ state_type

Enumerator
state_paths 

The state in which paths for components are set.

state_pre_download 

The state in which packages are being considered for download.

state_download 

The state in which packages are being downloaded.

state_unpack 

The state in which packages are being unpacked or removed.

state_configure 

The state in which packages are being configured.

state_purge 

The state in which packages are being purged.

state_update_sysvars 

The state in which the list of system variables is updated.

state_update_sprites 

The state in which the sprite pool is updated.

state_update_boot_options 

The state in which the RISC OS boot option files are updated.

state_boot_files 

The state in which files added to the boot look at and boot run files are booted.

state_run_files 

The state in which files added to the boot run files are run.

state_add_files_to_apps 

The state in which files are added to the current apps virtual directory.

state_post_remove_triggers 

The state in which post remove triggers are run.

state_post_install_triggers 

The state in which post install triggers are run.

state_cleanup_triggers 

The state in which work files and variables for triggers are cleaned up.

state_done 

The state in which all operations have been successfully completed.

state_fail 

The state in which an error has occurred.

Constructor & Destructor Documentation

◆ commit()

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

Construct commit operation.

Parameters
pbthe package database
packagesthe set of packages to process

References pkg::status_table::clear(), pkg::status_table::commit(), pkg::pkgbase::curstat(), pkg::status_table::insert(), pkg::pkgbase::prevstat(), and pkg::pkgbase::selstat().

◆ ~commit()

pkg::commit::~commit ( )
virtual

Destroy commit operation.

Member Function Documentation

◆ state()

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

Get current state of the commit operation.

Returns
the current state

◆ files_done()

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

Get number of files processed.

Returns
the number of files processed (in current stage)

◆ files_total()

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

Get total number of files to process.

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

◆ bytes_done()

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

Get number of bytes processed.

Returns
the number of bytes processed (in current stage)

◆ bytes_total()

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

Get total number of bytes to process.

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

◆ message()

string pkg::commit::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

References clear_substate_text_changed(), has_substate_text(), and substate_text().

◆ has_substate_text()

bool pkg::commit::has_substate_text ( ) const

Referenced by message().

◆ clear_substate_text_changed()

bool pkg::commit::clear_substate_text_changed ( )

Referenced by message().

◆ substate_text()

std::string pkg::commit::substate_text ( ) const

Referenced by message().

◆ files_that_conflict()

const std::set<string>& pkg::commit::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.

References log_to(), and use_trigger_run().

◆ use_trigger_run()

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

Set the class to run triggers.

Referenced by files_that_conflict().

◆ log_to()

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

Set the log to add to.

Parameters
use_loglog to use or 0 to stop logging

References pkg::LOG_INFO_START_COMMIT, pkg::LOG_INFO_WARNING_INTRO1, pkg::LOG_INFO_WARNING_INTRO2, and pkg::log::message().

Referenced by files_that_conflict().

◆ warnings()

log* pkg::commit::warnings ( ) const
inline

Return warnings log.

Returns
warnings log or 0 if there were no warnings

◆ detach_warnings()

log* pkg::commit::detach_warnings ( )
inline

Detach warnings log.

Detach the warnings log so it doesn't get destroyed with the commit object. It is then the responsibility of the object that detached the log to delete it.

Returns
warnings log or 0 if there were no warnings

References poll().

◆ poll()

void pkg::commit::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::boot_options_file::add(), pkg::component::add_to_apps, pkg::path_table::alter(), pkg::boot_drive_relative(), pkg::commit::progress::bytes_done, pkg::unpack::bytes_done(), pkg::commit::progress::bytes_total, pkg::unpack::bytes_total(), pkg::pkgbase::cache_pathname(), pkg::boot_options_file::commit(), pkg::path_table::commit(), pkg::pkgbase::component_update_pathname(), pkg::config_req(), pkg::pkgbase::control(), pkg::pkgbase::curstat(), pkg::unpack::detach_triggers(), pkg::control::end(), pkg::pkg_env::env_names(), pkg::status::environment_id(), pkg::unpack::files_done(), pkg::unpack::files_that_conflict(), pkg::unpack::files_total(), pkg::control::find(), pkg::component::flag(), pkg::LOG_ERROR_CACHE_INSERT, pkg::LOG_ERROR_PACKAGE_DOWNLOAD_FAILED, pkg::LOG_ERROR_PATHS_COMMIT, pkg::LOG_ERROR_PATHS_ROLLBACK, pkg::LOG_ERROR_UNPACK_FAILED, pkg::LOG_INFO_ADDING, pkg::LOG_INFO_ADDING_TO_APPS, pkg::LOG_INFO_BOOT_OPTIONS_UPDATED, pkg::LOG_INFO_BOOTING, pkg::LOG_INFO_BOOTING_FILES, pkg::LOG_INFO_CACHE_USED, pkg::LOG_INFO_COMMIT_DONE, pkg::LOG_INFO_DOWNLOADED_PACKAGE, pkg::LOG_INFO_DOWNLOADING_PACKAGE, pkg::LOG_INFO_END_PATHS, pkg::LOG_INFO_INSTALLED, pkg::LOG_INFO_NOT_USING_CACHE, pkg::LOG_INFO_PACKAGE_ENV, pkg::LOG_INFO_PATH_CHANGE, pkg::LOG_INFO_POST_INSTALL_TRIGGERS, pkg::LOG_INFO_POST_REMOVE_TRIGGERS, pkg::LOG_INFO_PREPROCESS_PACKAGE, pkg::LOG_INFO_PURGED, pkg::LOG_INFO_REMOVE_PATH_OPTS, pkg::LOG_INFO_REMOVE_POST_REMOVE_TRIGGERS, pkg::LOG_INFO_RUNNING, pkg::LOG_INFO_RUNNING_FILES, pkg::LOG_INFO_SPRITES_UPDATED, pkg::LOG_INFO_START_PATHS, pkg::LOG_INFO_STATE_UPDATE, pkg::LOG_INFO_SYSVARS_UPDATED, pkg::LOG_INFO_UNPACKED, pkg::LOG_INFO_UNPACKING, pkg::LOG_INFO_UPDATING_BOOT_OPTIONS, pkg::LOG_INFO_UPDATING_SPRITES, pkg::LOG_INFO_UPDATING_SYSVARS, pkg::unpack::log_to(), pkg::LOG_WARNING_ADDING_TO_APPS_FAILED, pkg::LOG_WARNING_BOOT_OPTIONS_FAILED, pkg::LOG_WARNING_BOOTING_FAILED, pkg::LOG_WARNING_COMPONENT_NOT_INSTALLED, pkg::LOG_WARNING_COMPONENT_UPDATE_DONE_FAILED, pkg::LOG_WARNING_POST_INSTALL_TRIGGER_FAILED, pkg::LOG_WARNING_POST_REMOVE_TRIGGER_FAILED, pkg::LOG_WARNING_REMOVE_COMPONENT, pkg::LOG_WARNING_RUNNING_FAILED, pkg::component::look_at, pkg::download::message(), pkg::log::message(), pkg::unpack::message(), pkg::pkg_env::module_names(), pkg::component::movable, pkg::component::name(), npos, pkg::object_type(), pkg::os::OS_CLI(), pkg::binary_control::package_env(), pkg::parse_component_list(), pkg::component::path(), pkg::pkgbase::paths(), pkg::purge_req(), pkg::boot_options_file::remove(), pkg::remove_req(), pkg::path_table::rollback(), pkg::component::run, pkg::pkgbase::selstat(), pkg::download::state(), pkg::status::state(), pkg::unpack::state(), state_add_files_to_apps, state_boot_files, state_cleanup_triggers, state_configure, pkg::download::state_done, state_done, pkg::unpack::state_done, pkg::download::state_download, state_download, pkg::trigger::state_error, pkg::download::state_fail, state_fail, pkg::unpack::state_fail, pkg::status::state_installed, pkg::status::state_not_present, state_paths, state_post_install_triggers, state_post_remove_triggers, state_pre_download, state_purge, pkg::status::state_removed, state_run_files, pkg::trigger::state_success, state_unpack, state_update_boot_options, state_update_sprites, state_update_sysvars, pkg::unpack_req(), pkg::update_sprite_pool(), pkg::update_sysvars(), pkg::unpack::use_trigger_run(), pkg::pkgbase::verify_cached_file(), and pkg::status::version().

Referenced by detach_warnings().

Member Data Documentation

◆ npos

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

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

Referenced by poll().


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

Reference Manual LibPkg Version 0.6.1 (28 Jan 2015)