LibPkg
Classes | Public Member Functions | List of all members
pkg::triggers Class Reference

A class to manage the package triggers executed during the commiting of the packages. More...

#include <triggers.h>

Public Member Functions

 triggers (pkgbase &pb, trigger_run *tr, log *lg)
 Construct the class to maintain lists and create triggers. More...
 
 ~triggers ()
 
void add_pre_install (const std::string &pkgname, const std::string &old_version, const std::string &new_version, bool has_unwind)
 Add pre install trigger to list of triggers. More...
 
void add_post_install (const std::string &pkgname, const std::string &old_version, const std::string &new_version)
 Add post install trigger to list of triggers. More...
 
void add_pre_remove (const std::string &pkgname, const std::string &old_version, const std::string &new_version)
 Add pre remove trigger to list of triggers. More...
 
void add_post_remove (const std::string &pkgname, const std::string &old_version, const std::string &new_version)
 Add post remove trigger to list of triggers. More...
 
void add_post_install_abort (const string &pkgname, const std::string &old_version, const std::string &new_version)
 Set package being removed has a post install trigger. More...
 
void add_post_remove_file (const std::string &filename)
 Add file to list of files that need to be copied so they are available to run after the package has been removed. More...
 
bool post_remove_files_to_copy () const
 Check if there are any post remove triggers left to copy. More...
 
bool copy_post_remove_file ()
 Copy one post remove trigger file for use later. More...
 
bool pre_remove_triggers_to_run () const
 Check if there are any pre remove triggers to run. More...
 
triggernext_pre_remove_trigger ()
 Remove and return the next pre remove trigger to run. More...
 
bool pre_install_triggers_to_run () const
 Check if there are any pre install triggers to run. More...
 
triggernext_pre_install_trigger ()
 Remove and return the next pre install trigger to run. More...
 
bool pre_install_to_unwind () const
 Check if there are any pre install triggers to unwind. More...
 
triggernext_pre_install_unwind ()
 Return a post remove trigger to be called to unwind the action of a pre install trigger. More...
 
bool pre_remove_to_unwind () const
 Check if there are any pre remove triggers to remove. More...
 
triggernext_pre_remove_unwind ()
 Return a post install trigger to be called to unwind the action of a pre remove trigger. More...
 
bool post_remove_files_to_remove () const
 Check if there are any post remove trigger copies to remove. More...
 
void remove_post_remove_file ()
 Remove a post remove copied field. More...
 
bool post_remove_triggers_to_run () const
 Check if there are any post remove triggers to run. More...
 
triggernext_post_remove_trigger ()
 Remove and return the next post remove trigger to run. More...
 
bool post_install_triggers_to_run () const
 Check if there are any post install triggers to run. More...
 
triggernext_post_install_trigger ()
 Remove and return the next postinstall trigger to run. More...
 
void delete_shared_vars ()
 Delete the shared environmental variables created by the triggers. More...
 

Detailed Description

A class to manage the package triggers executed during the commiting of the packages.

Constructor & Destructor Documentation

◆ triggers()

pkg::triggers::triggers ( pkgbase pb,
trigger_run tr,
log lg 
)

Construct the class to maintain lists and create triggers.

Parameters
trthe trigger_run object that will run the triggers
lgthe log to log trigger output to. Can be 0 for no logging.

◆ ~triggers()

pkg::triggers::~triggers ( )

References delete_shared_vars().

Member Function Documentation

◆ add_pre_install()

void pkg::triggers::add_pre_install ( const std::string &  pkgname,
const std::string &  old_version,
const std::string &  new_version,
bool  has_unwind 
)

Add pre install trigger to list of triggers.

Parameters
pkgnamename of package containing the trigger
old_versionversion of package the package to remove or "" if install only
new_versionversion of the package to install or "" if remove only
has_unwindpost remove script exists for unwind

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

◆ add_post_install()

void pkg::triggers::add_post_install ( const std::string &  pkgname,
const std::string &  old_version,
const std::string &  new_version 
)

Add post install trigger to list of triggers.

Parameters
pkgnamename of package containing the trigger
old_versionversion of package the package to remove or "" if install only
new_versionversion of the package to install or "" if remove only

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

◆ add_pre_remove()

void pkg::triggers::add_pre_remove ( const std::string &  pkgname,
const std::string &  old_version,
const std::string &  new_version 
)

Add pre remove trigger to list of triggers.

Parameters
pkgnamename of package containing the trigger
old_versionversion of package the package to remove or "" if install only
new_versionversion of the package to install or "" if remove only

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

◆ add_post_remove()

void pkg::triggers::add_post_remove ( const std::string &  pkgname,
const std::string &  old_version,
const std::string &  new_version 
)

Add post remove trigger to list of triggers.

Parameters
pkgnamename of package containing the trigger
old_versionversion of package the package to remove or "" if install only
new_versionversion of the package to install or "" if remove only

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

◆ add_post_install_abort()

void pkg::triggers::add_post_install_abort ( const string &  pkgname,
const std::string &  old_version,
const std::string &  new_version 
)

Set package being removed has a post install trigger.

Parameters
pkgnamename of package containing the trigger
old_versionversion of package the package to remove or "" if install only
new_versionversion of the package to install or "" if remove only

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

◆ add_post_remove_file()

void pkg::triggers::add_post_remove_file ( const std::string &  filename)

Add file to list of files that need to be copied so they are available to run after the package has been removed.

Parameters
filenamethe path to the file that will be copied

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

◆ post_remove_files_to_copy()

bool pkg::triggers::post_remove_files_to_copy ( ) const

Check if there are any post remove triggers left to copy.

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

◆ copy_post_remove_file()

bool pkg::triggers::copy_post_remove_file ( )

Copy one post remove trigger file for use later.

References pkg::copy_object(), pkg::dst_to_post_remove(), pkg::force_delete(), pkg::LOG_ERROR_POST_REMOVE_COPY, and pkg::log::message().

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

◆ pre_remove_triggers_to_run()

bool pkg::triggers::pre_remove_triggers_to_run ( ) const

Check if there are any pre remove triggers to run.

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

◆ next_pre_remove_trigger()

trigger * pkg::triggers::next_pre_remove_trigger ( )

Remove and return the next pre remove trigger to run.

References pkg::trigger::pre_remove.

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

◆ pre_install_triggers_to_run()

bool pkg::triggers::pre_install_triggers_to_run ( ) const

Check if there are any pre install triggers to run.

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

◆ next_pre_install_trigger()

trigger * pkg::triggers::next_pre_install_trigger ( )

Remove and return the next pre install trigger to run.

References pkg::trigger::pre_install.

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

◆ pre_install_to_unwind()

bool pkg::triggers::pre_install_to_unwind ( ) const

Check if there are any pre install triggers to unwind.

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

◆ next_pre_install_unwind()

trigger * pkg::triggers::next_pre_install_unwind ( )

Return a post remove trigger to be called to unwind the action of a pre install trigger.

References pkg::trigger::abort_pre_install.

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

◆ pre_remove_to_unwind()

bool pkg::triggers::pre_remove_to_unwind ( ) const

Check if there are any pre remove triggers to remove.

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

◆ next_pre_remove_unwind()

trigger * pkg::triggers::next_pre_remove_unwind ( )

Return a post install trigger to be called to unwind the action of a pre remove trigger.

References pkg::trigger::abort_pre_remove.

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

◆ post_remove_files_to_remove()

bool pkg::triggers::post_remove_files_to_remove ( ) const

Check if there are any post remove trigger copies to remove.

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

◆ remove_post_remove_file()

void pkg::triggers::remove_post_remove_file ( )

Remove a post remove copied field.

References pkg::dst_to_post_remove(), and pkg::force_delete().

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

◆ post_remove_triggers_to_run()

bool pkg::triggers::post_remove_triggers_to_run ( ) const

Check if there are any post remove triggers to run.

◆ next_post_remove_trigger()

trigger * pkg::triggers::next_post_remove_trigger ( )

Remove and return the next post remove trigger to run.

References pkg::trigger::post_remove.

◆ post_install_triggers_to_run()

bool pkg::triggers::post_install_triggers_to_run ( ) const

Check if there are any post install triggers to run.

◆ next_post_install_trigger()

trigger * pkg::triggers::next_post_install_trigger ( )

Remove and return the next postinstall trigger to run.

References pkg::trigger::post_install.

◆ delete_shared_vars()

void pkg::triggers::delete_shared_vars ( )

Delete the shared environmental variables created by the triggers.

i.e. All variables starting PkgTrigger$S_

References pkg::LOG_INFO_DELETE_SHARED_VAR, pkg::log::message(), and pkg::swi::OS_ReadVarVal.

Referenced by pkg::unpack::poll(), and ~triggers().


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

Reference Manual LibPkg Version 0.9.0 (4 Sep 2020)