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

A class for representing the collection of package database tables. More...

#include <pkgbase.h>

Classes

class  cache_error
 An exception class for reporting cache errors. More...
 

Public Member Functions

 pkgbase (const string &pathname, const string &dpathname, const string &cpathname)
 Create pkgbase object. More...
 
 ~pkgbase ()
 Destroy pkgbase object. More...
 
status_tablecurstat ()
 Get current status table. More...
 
status_tableselstat ()
 Get selected status table. More...
 
status_tableprevstat ()
 Get previous status table. More...
 
binary_control_tablecontrol ()
 Get binary control table. More...
 
source_tablesources ()
 Get source table. More...
 
env_packages_tableenv_packages ()
 Get environment packages table which contains the package names of packages suitable for the current environment and the "best" version to install. More...
 
path_tablepaths ()
 Get path table. More...
 
string list_pathname (const string &url)
 Get pathname for index file from given source. More...
 
string available_pathname ()
 Get pathname for available list file. More...
 
string cache_pathname (const string &pkgname, const string &pkgvrsn, const string &pkgenvid)
 Get pathname for package in cache. More...
 
string info_pathname (const string &pkgname)
 Get pathname for info directory of package. More...
 
string sysvars_pathname ()
 Get pathname for sysvars directory. More...
 
string sprites_pathname ()
 Get pathname for sprites directory. More...
 
string setvars_pathname ()
 Get pathname for setvars file. More...
 
string bootsprites_pathname ()
 Get pathname for sprites file. More...
 
string component_update_pathname ()
 Get pathname for component update file. More...
 
void verify_cached_file (const binary_control &ctrl)
 Verify file in cache. More...
 
bool fix_dependencies (const std::set< string > &seed)
 Fix dependencies. More...
 
void remove_auto ()
 Remove redundant auto-installed packages. More...
 

Detailed Description

A class for representing the collection of package database tables.

Constructor & Destructor Documentation

◆ pkgbase()

pkg::pkgbase::pkgbase ( const string &  pathname,
const string &  dpathname,
const string &  cpathname 
)

Create pkgbase object.

Parameters
pathnamethe pathname of the !Packages directory.
dpathnamethe pathname of the default choices directory
cpathnamethe pathname of the choices directory

References pkg::create_directory().

◆ ~pkgbase()

pkg::pkgbase::~pkgbase ( )

Destroy pkgbase object.

Member Function Documentation

◆ curstat()

status_table& pkg::pkgbase::curstat ( )
inline

Get current status table.

Returns
the current status table

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

◆ selstat()

status_table& pkg::pkgbase::selstat ( )
inline

Get selected status table.

Returns
the selected status table

Referenced by pkg::commit::commit(), fix_dependencies(), pkg::commit::poll(), pkg::unpack::poll(), remove_auto(), and pkg::unpack::unpack().

◆ prevstat()

status_table& pkg::pkgbase::prevstat ( )
inline

Get previous status table.

This is the state to which packages are restored when changes are unwound after an error.

Returns
the previous status table

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

◆ control()

binary_control_table& pkg::pkgbase::control ( )
inline

Get binary control table.

Returns
the binary control table

Referenced by pkg::update::poll(), pkg::commit::poll(), pkg::unpack::poll(), and pkg::trigger::trigger().

◆ sources()

source_table& pkg::pkgbase::sources ( )
inline

Get source table.

Returns
the source table

References env_packages().

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

◆ env_packages()

env_packages_table & pkg::pkgbase::env_packages ( )

Get environment packages table which contains the package names of packages suitable for the current environment and the "best" version to install.

Returns
environment packages table

Referenced by fix_dependencies(), remove_auto(), and sources().

◆ paths()

path_table& pkg::pkgbase::paths ( )
inline

◆ list_pathname()

string pkg::pkgbase::list_pathname ( const string &  url)

Get pathname for index file from given source.

Parameters
urlthe URL of the source
Returns
the pathname

Referenced by paths(), and pkg::update::poll().

◆ available_pathname()

string pkg::pkgbase::available_pathname ( )

Get pathname for available list file.

Returns
the pathname

Referenced by paths(), and pkg::update::poll().

◆ cache_pathname()

string pkg::pkgbase::cache_pathname ( const string &  pkgname,
const string &  pkgvrsn,
const string &  pkgenvid 
)

Get pathname for package in cache.

Parameters
pkgnamethe package name
pkgvrsnthe package version
pkgenvidthe package environment id
Returns
the pathname

Referenced by paths(), pkg::commit::poll(), pkg::unpack::poll(), and verify_cached_file().

◆ info_pathname()

string pkg::pkgbase::info_pathname ( const string &  pkgname)

Get pathname for info directory of package.

Parameters
pkgnamethe package name
Returns
the pathname

Referenced by paths(), pkg::update::poll(), and pkg::unpack::poll().

◆ sysvars_pathname()

string pkg::pkgbase::sysvars_pathname ( )

Get pathname for sysvars directory.

Returns
the pathname

Referenced by paths(), and pkg::update_sysvars().

◆ sprites_pathname()

string pkg::pkgbase::sprites_pathname ( )

Get pathname for sprites directory.

Returns
the pathname

Referenced by paths().

◆ setvars_pathname()

string pkg::pkgbase::setvars_pathname ( )

Get pathname for setvars file.

Returns
the pathname

Referenced by paths(), and pkg::update_sysvars().

◆ bootsprites_pathname()

string pkg::pkgbase::bootsprites_pathname ( )

Get pathname for sprites file.

Returns
the pathname

Referenced by paths().

◆ component_update_pathname()

string pkg::pkgbase::component_update_pathname ( )

Get pathname for component update file.

Returns
the pathname

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

◆ verify_cached_file()

void pkg::pkgbase::verify_cached_file ( const binary_control ctrl)

Verify file in cache.

This function checks first whether a suitably named file exists, then whether it has the correct length, then whether it has the correct MD5Sum. If any of these tests fail then a cache error is thrown.

Parameters
ctrla control record for the requested package

References cache_pathname(), pkg::control::end(), pkg::binary_control::environment_id(), pkg::control::find(), pkg::object_length(), pkg::object_type(), pkg::control::pkgname(), and pkg::control::version().

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

◆ fix_dependencies()

bool pkg::pkgbase::fix_dependencies ( const std::set< string > &  seed)

Fix dependencies.

If a package is in the seed set then its selection state cannot change from installed to removed or vice-versa. If it is not in the seed set then it can be installed or removed as necessary to meet all dependencies.

Parameters
seedthe seed set
Returns
true if all dependencies were fixed, otherwise false

References pkg::status_table::begin(), pkg::status_table::end(), env_packages(), pkg::status::environment_id(), pkg::env_packages_table::find(), pkg::status::flag(), pkg::status::flag_auto, pkg::status::flag_must_install, pkg::status::flag_must_remove, pkg::status::flag_must_upgrade, pkg::status_table::insert(), selstat(), pkg::status::state(), pkg::status::state_installed, pkg::status::state_removed, pkg::status::version(), and pkg::control::version().

Referenced by paths(), and remove_auto().

◆ remove_auto()

void pkg::pkgbase::remove_auto ( )

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

Reference Manual LibPkg Version 0.6.1 (28 Jan 2015)