dpkg 1.21.11
Data Structures | Enumerations | Functions | Variables
In-core package database management
Collaboration diagram for In-core package database management:

Data Structures

struct  dependency
 
struct  deppossi
 
struct  arbitraryfield
 
struct  conffile
 
struct  archivedetails
 
struct  pkgbin
 Node describing a binary package file. More...
 
struct  trigpend
 Node indicates that parent's Triggers-Pending mentions name. More...
 
struct  trigaw
 Node indicates that aw's Triggers-Awaited mentions pend. More...
 
struct  pkginfo
 Node describing an architecture package instance. More...
 
struct  pkgset
 Node describing a package set sharing the same package name. More...
 

Enumerations

enum  deptype {
  dep_suggests , dep_recommends , dep_depends , dep_predepends ,
  dep_breaks , dep_conflicts , dep_provides , dep_replaces ,
  dep_enhances
}
 
enum  pkgmultiarch { PKG_MULTIARCH_NO , PKG_MULTIARCH_SAME , PKG_MULTIARCH_ALLOWED , PKG_MULTIARCH_FOREIGN }
 
enum  pkgwant {
  PKG_WANT_UNKNOWN , PKG_WANT_INSTALL , PKG_WANT_HOLD , PKG_WANT_DEINSTALL ,
  PKG_WANT_PURGE , PKG_WANT_SENTINEL
}
 
enum  pkgeflag { PKG_EFLAG_OK = 0 , PKG_EFLAG_REINSTREQ = 1 }
 
enum  pkgstatus {
  PKG_STAT_NOTINSTALLED , PKG_STAT_CONFIGFILES , PKG_STAT_HALFINSTALLED , PKG_STAT_UNPACKED ,
  PKG_STAT_HALFCONFIGURED , PKG_STAT_TRIGGERSAWAITED , PKG_STAT_TRIGGERSPENDING , PKG_STAT_INSTALLED
}
 
enum  pkgpriority {
  PKG_PRIO_REQUIRED , PKG_PRIO_IMPORTANT , PKG_PRIO_STANDARD , PKG_PRIO_OPTIONAL ,
  PKG_PRIO_EXTRA , PKG_PRIO_OTHER , PKG_PRIO_UNKNOWN , PKG_PRIO_UNSET = -1
}
 
enum  modstatdb_rw {
  msdbrw_readonly , msdbrw_needsuperuserlockonly , msdbrw_writeifposs , msdbrw_write ,
  msdbrw_needsuperuser , msdbrw_available_readonly = DPKG_BIT(8) , msdbrw_available_write = DPKG_BIT(9) , msdbrw_available_mask = 0xff00
}
 
enum  parsedbflags {
  pdb_single_stanza = DPKG_BIT(0) , pdb_recordavailable = DPKG_BIT(1) , pdb_rejectstatus = DPKG_BIT(2) , pdb_weakclassification = DPKG_BIT(3) ,
  pdb_ignore_archives = DPKG_BIT(4) , pdb_ignoreolder = DPKG_BIT(5) , pdb_lax_version_parser = DPKG_BIT(6) , pdb_lax_stanza_parser = DPKG_BIT(9) ,
  pdb_lax_parser = pdb_lax_stanza_parser | pdb_lax_version_parser , pdb_close_fd = DPKG_BIT(7) , pdb_dash_is_stdin = DPKG_BIT(8) , pdb_allow_empty = DPKG_BIT(9) ,
  pdb_parse_status , pdb_parse_update = pdb_parse_status | pdb_single_stanza , pdb_parse_available , pdb_parse_binary
}
 
enum  versiondisplayepochwhen { vdew_never , vdew_nonambig , vdew_always }
 
enum  pkg_name_arch_when {
  pnaw_never , pnaw_nonambig , pnaw_same , pnaw_foreign ,
  pnaw_always
}
 
enum  writedb_flags { wdb_dump_available = DPKG_BIT(0) , wdb_must_sync = DPKG_BIT(1) }
 

Functions

const char * dpkg_db_set_dir (const char *dir)
 Set current on-disk database directory. More...
 
const char * dpkg_db_get_dir (void)
 Get current on-disk database directory. More...
 
char * dpkg_db_get_path (const char *pathpart)
 Get a pathname to the current on-disk database directory. More...
 
void modstatdb_init (void)
 
void modstatdb_done (void)
 
bool modstatdb_is_locked (void)
 
bool modstatdb_can_lock (void)
 
void modstatdb_lock (void)
 
void modstatdb_unlock (void)
 
enum modstatdb_rw modstatdb_open (enum modstatdb_rw reqrwflags)
 
enum modstatdb_rw modstatdb_get_status (void)
 
void modstatdb_note (struct pkginfo *pkg)
 
void modstatdb_note_ifwrite (struct pkginfo *pkg)
 
void modstatdb_checkpoint (void)
 
void modstatdb_shutdown (void)
 
void pkgset_blank (struct pkgset *set)
 
int pkgset_installed_instances (struct pkgset *set)
 Get the number of installed package instances in a package set. More...
 
void pkg_blank (struct pkginfo *pp)
 
void pkgbin_blank (struct pkgbin *pkgbin)
 
bool pkg_is_informative (struct pkginfo *pkg, struct pkgbin *info)
 Check if a pkg is informative. More...
 
struct pkgsetpkg_hash_find_set (const char *name)
 Return the package set with the given name. More...
 
struct pkginfopkg_hash_get_singleton (struct pkgset *set)
 Return the singleton package instance from a package set. More...
 
struct pkginfopkg_hash_find_singleton (const char *name)
 Return the singleton package instance with the given name. More...
 
struct pkginfopkg_hash_get_pkg (struct pkgset *set, const struct dpkg_arch *arch)
 Return the package instance in a set with the given architecture. More...
 
struct pkginfopkg_hash_find_pkg (const char *name, const struct dpkg_arch *arch)
 Return the package instance with the given name and architecture. More...
 
int pkg_hash_count_set (void)
 Return the number of package sets available in the database. More...
 
int pkg_hash_count_pkg (void)
 Return the number of package instances available in the database. More...
 
void pkg_hash_reset (void)
 
struct pkg_hash_iterpkg_hash_iter_new (void)
 Create a new package iterator. More...
 
struct pkgsetpkg_hash_iter_next_set (struct pkg_hash_iter *iter)
 
struct pkginfopkg_hash_iter_next_pkg (struct pkg_hash_iter *iter)
 
void pkg_hash_iter_free (struct pkg_hash_iter *iter)
 
void pkg_hash_report (FILE *)
 
const char * pkg_name_is_illegal (const char *p)
 
const struct fieldinfofind_field_info (const struct fieldinfo *fields, const char *fieldname)
 
const struct arbitraryfieldfind_arbfield_info (const struct arbitraryfield *arbs, const char *fieldname)
 
int parsedb (const char *filename, enum parsedbflags, struct pkginfo **donep)
 Parse a deb822 style file. More...
 
void copy_dependency_links (struct pkginfo *pkg, struct dependency **updateme, struct dependency *newdepends, bool available)
 Copy dependency links structures. More...
 
void varbufversion (struct varbuf *, const struct dpkg_version *, enum versiondisplayepochwhen)
 
int parseversion (struct dpkg_version *version, const char *, struct dpkg_error *err)
 Parse a version string and check for invalid syntax. More...
 
const char * versiondescribe (const struct dpkg_version *, enum versiondisplayepochwhen)
 
const char * versiondescribe_c (const struct dpkg_version *version, enum versiondisplayepochwhen vdew)
 
void varbuf_add_pkgbin_name (struct varbuf *vb, const struct pkginfo *pkg, const struct pkgbin *pkgbin, enum pkg_name_arch_when pnaw)
 Add a string representation of the package name to a varbuf. More...
 
const char * pkgbin_name_archqual (const struct pkginfo *pkg, const struct pkgbin *pkgbin)
 
const char * pkgbin_name (struct pkginfo *pkg, struct pkgbin *pkgbin, enum pkg_name_arch_when pnaw)
 Return a string representation of the package name. More...
 
const char * pkg_name (struct pkginfo *pkg, enum pkg_name_arch_when pnaw)
 Return a string representation of the installed package name. More...
 
const char * pkgbin_name_const (const struct pkginfo *pkg, const struct pkgbin *pkgbin, enum pkg_name_arch_when pnaw)
 Return a string representation of the package name. More...
 
const char * pkg_name_const (const struct pkginfo *pkg, enum pkg_name_arch_when pnaw)
 Return a string representation of the installed package name. More...
 
void pkg_source_version (struct dpkg_version *version, const struct pkginfo *pkg, const struct pkgbin *pkgbin)
 
void varbuf_add_source_version (struct varbuf *vb, const struct pkginfo *pkg, const struct pkgbin *pkgbin)
 Add a string representation of the source package version to a varbuf. More...
 
const char * pkg_want_name (const struct pkginfo *pkg)
 Return a string representation of the package want status name. More...
 
const char * pkg_status_name (const struct pkginfo *pkg)
 Return a string representation of the package current status name. More...
 
const char * pkg_eflag_name (const struct pkginfo *pkg)
 Return a string representation of the package eflag status name. More...
 
const char * pkg_priority_name (const struct pkginfo *pkg)
 Return a string representation of the package priority name. More...
 
void writerecord (FILE *, const char *, const struct pkginfo *, const struct pkgbin *)
 
void writedb_records (FILE *fp, const char *filename, enum writedb_flags flags)
 
void writedb (const char *filename, enum writedb_flags flags)
 
void varbufrecord (struct varbuf *, const struct pkginfo *, const struct pkgbin *)
 
void varbufdependency (struct varbuf *vb, struct dependency *dep)
 
bool versionsatisfied (struct pkgbin *it, struct deppossi *against)
 
bool deparchsatisfied (struct pkgbin *it, const struct dpkg_arch *arch, struct deppossi *against)
 Check if the architecture qualifier in the dependency is satisfied. More...
 
bool archsatisfied (struct pkgbin *it, struct deppossi *against)
 
bool pkg_virtual_deppossi_satisfied (struct deppossi *dependee, struct deppossi *provider)
 Check if the dependency is satisfied by a virtual package. More...
 
void * nfmalloc (size_t)
 
char * nfstrsave (const char *)
 
char * nfstrnsave (const char *, size_t)
 
void nffreeall (void)
 

Variables

const struct namevalue booleaninfos []
 
const struct namevalue multiarchinfos []
 
const struct namevalue priorityinfos []
 
const struct namevalue statusinfos []
 
const struct namevalue eflaginfos []
 
const struct namevalue wantinfos []
 

Detailed Description

Enumeration Type Documentation

◆ deptype

enum deptype
Enumerator
dep_suggests 
dep_recommends 
dep_depends 
dep_predepends 
dep_breaks 
dep_conflicts 
dep_provides 
dep_replaces 
dep_enhances 

◆ modstatdb_rw

Enumerator
msdbrw_readonly 
msdbrw_needsuperuserlockonly 
msdbrw_writeifposs 
msdbrw_write 
msdbrw_needsuperuser 
msdbrw_available_readonly 
msdbrw_available_write 
msdbrw_available_mask 

◆ parsedbflags

Enumerator
pdb_single_stanza 

Parse a single control stanza.

pdb_recordavailable 

Store in ‘available’ in-core structures, not ‘status’.

pdb_rejectstatus 

Throw up an error if ‘Status’ encountered.

pdb_weakclassification 

Ignore priority/section info if we already have any.

pdb_ignore_archives 

Ignore archives info if we already have them.

pdb_ignoreolder 

Ignore packages with older versions already read.

pdb_lax_version_parser 

Perform laxer version parsing.

pdb_lax_stanza_parser 

Perform laxer control stanza parsing.

pdb_lax_parser 

Perform laxer parsing, used to transition to stricter parsing.

pdb_close_fd 

Close file descriptor on context destruction.

pdb_dash_is_stdin 

Interpret filename ‘-’ as stdin.

pdb_allow_empty 

Allow empty/missing files.

pdb_parse_status 
pdb_parse_update 
pdb_parse_available 
pdb_parse_binary 

◆ pkg_name_arch_when

Enumerator
pnaw_never 

Never display arch.

pnaw_nonambig 

Display arch only when it's non-ambiguous.

pnaw_same 

Display arch only when it's a Multi-Arch same package.

pnaw_foreign 

Display arch only when it's a foreign one.

pnaw_always 

Always display arch.

◆ pkgeflag

enum pkgeflag
Enumerator
PKG_EFLAG_OK 
PKG_EFLAG_REINSTREQ 

◆ pkgmultiarch

Enumerator
PKG_MULTIARCH_NO 
PKG_MULTIARCH_SAME 
PKG_MULTIARCH_ALLOWED 
PKG_MULTIARCH_FOREIGN 

◆ pkgpriority

Enumerator
PKG_PRIO_REQUIRED 
PKG_PRIO_IMPORTANT 
PKG_PRIO_STANDARD 
PKG_PRIO_OPTIONAL 
PKG_PRIO_EXTRA 
PKG_PRIO_OTHER 
PKG_PRIO_UNKNOWN 
PKG_PRIO_UNSET 

◆ pkgstatus

enum pkgstatus
Enumerator
PKG_STAT_NOTINSTALLED 
PKG_STAT_CONFIGFILES 
PKG_STAT_HALFINSTALLED 
PKG_STAT_UNPACKED 
PKG_STAT_HALFCONFIGURED 
PKG_STAT_TRIGGERSAWAITED 
PKG_STAT_TRIGGERSPENDING 
PKG_STAT_INSTALLED 

◆ pkgwant

enum pkgwant
Enumerator
PKG_WANT_UNKNOWN 
PKG_WANT_INSTALL 
PKG_WANT_HOLD 
PKG_WANT_DEINSTALL 
PKG_WANT_PURGE 
PKG_WANT_SENTINEL 

Not allowed except as special sentinel value in some places.

◆ versiondisplayepochwhen

Enumerator
vdew_never 
vdew_nonambig 
vdew_always 

◆ writedb_flags

Enumerator
wdb_dump_available 

Dump ‘available’ in-core structures, not ‘status’.

wdb_must_sync 

Must sync the written file.

Function Documentation

◆ archsatisfied()

bool archsatisfied ( struct pkgbin it,
struct deppossi against 
)

References pkgbin::arch, and deparchsatisfied().

Referenced by deppossi_pkg_iter_next().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ copy_dependency_links()

void copy_dependency_links ( struct pkginfo pkg,
struct dependency **  updateme,
struct dependency newdepends,
bool  available 
)

Copy dependency links structures.

This routine is used to update the ‘reverse’ dependency pointers when new ‘forwards’ information has been constructed. It first removes all the links based on the old information. The old information starts in *updateme; after much brou-ha-ha the reverse structures are created and *updateme is set to the value from newdepends.

Parameters
pkgThe package we're doing this for. This is used to construct correct uplinks.
updatemeThe forwards dependency pointer that we are to update. This starts out containing the old forwards info, which we use to unthread the old reverse links. After we're done it is updated.
newdependsThe value that we ultimately want to have in updateme.
availableThe pkgbin to modify, available or installed.

It is likely that the backward pointer for the package in question (‘depended’) will be updated by this routine, but this will happen by the routine traversing the dependency data structures. It doesn't need to be told where to update that; just mentioned here as something that one should be cautious about.

References pkgset::available, pkgset::depended, deppossi::ed, pkgset::installed, dependency::list, dependency::next, deppossi::next, deppossi::rev_next, deppossi::rev_prev, and dependency::up.

◆ deparchsatisfied()

bool deparchsatisfied ( struct pkgbin it,
const struct dpkg_arch it_arch,
struct deppossi against 
)

Check if the architecture qualifier in the dependency is satisfied.

The rules are supposed to be:

  • unqualified Depends/Pre-Depends/Recommends/Suggests are only satisfied by a package of a different architecture if the target package is Multi-Arch: foreign.
  • Depends/Pre-Depends/Recommends/Suggests on pkg:any are satisfied by a package of a different architecture if the target package is Multi-Arch: allowed.
  • all other Depends/Pre-Depends/Recommends/Suggests are only satisfied by packages of the same architecture.
  • Architecture: all packages are treated the same as packages of the native architecture.
  • Conflicts/Replaces/Breaks are assumed to apply to packages of any arch.

References deppossi::arch, deppossi::arch_is_implicit, dep_breaks, dep_conflicts, dep_replaces, DPKG_ARCH_ALL, dpkg_arch_get(), DPKG_ARCH_NATIVE, DPKG_ARCH_NONE, DPKG_ARCH_WILDCARD, pkgbin::multiarch, PKG_MULTIARCH_ALLOWED, PKG_MULTIARCH_FOREIGN, dpkg_arch::type, dependency::type, and deppossi::up.

Referenced by archsatisfied().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dpkg_db_get_dir()

const char * dpkg_db_get_dir ( void  )

Get current on-disk database directory.

This function will take care of initializing the directory if it has not been initialized before.

Returns
The current database directory.

Referenced by dpkg_db_get_path(), modstatdb_lock(), set_instdir(), and updateavailable().

Here is the caller graph for this function:

◆ dpkg_db_get_path()

char * dpkg_db_get_path ( const char *  pathpart)

Get a pathname to the current on-disk database directory.

This function returns an allocated string, which should be freed with free(2).

Parameters
pathpartThe pathpart to append to the new pathname.
Returns
The newly allocated pathname.

References dpkg_db_get_dir(), and str_fmt().

Referenced by dpkg_arch_load_list(), and updateavailable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dpkg_db_set_dir()

const char * dpkg_db_set_dir ( const char *  dir)

Set current on-disk database directory.

This function can be used to set the directory to a new value, or to reset it to a default value if dir is NULL.

Parameters
dirThe new database directory, or NULL to set to default.
Returns
The new database directory.

Referenced by set_admindir().

Here is the caller graph for this function:

◆ find_arbfield_info()

const struct arbitraryfield * find_arbfield_info ( const struct arbitraryfield arbs,
const char *  fieldname 
)

◆ find_field_info()

const struct fieldinfo * find_field_info ( const struct fieldinfo fields,
const char *  fieldname 
)

References fieldinfo::name.

◆ modstatdb_can_lock()

bool modstatdb_can_lock ( void  )

Referenced by modstatdb_lock().

Here is the caller graph for this function:

◆ modstatdb_checkpoint()

void modstatdb_checkpoint ( void  )

◆ modstatdb_done()

void modstatdb_done ( void  )

Referenced by updateavailable().

Here is the caller graph for this function:

◆ modstatdb_get_status()

enum modstatdb_rw modstatdb_get_status ( void  )

Referenced by post_postinst_tasks().

Here is the caller graph for this function:

◆ modstatdb_init()

void modstatdb_init ( void  )

Referenced by modstatdb_open(), and updateavailable().

Here is the caller graph for this function:

◆ modstatdb_is_locked()

bool modstatdb_is_locked ( void  )

◆ modstatdb_lock()

void modstatdb_lock ( void  )

References _, dpkg_db_get_dir(), modstatdb_can_lock(), and ohshit().

Referenced by updateavailable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ modstatdb_note()

void modstatdb_note ( struct pkginfo pkg)

References trigaw::aw, pkginfo::head, pkginfo::installed, log_message(), trigaw::next, onerr_abort, pkg_name(), PKG_STAT_CONFIGFILES, PKG_STAT_TRIGGERSAWAITED, PKG_STAT_TRIGGERSPENDING, pkg_status_name(), pnaw_always, pnaw_nonambig, trigaw::sameaw, pkginfo::status, pkginfo::status_dirty, statusfd_send(), pkginfo::tail, pkginfo::trigaw, pkginfo::trigpend_head, vdew_nonambig, pkgbin::version, and versiondescribe_c().

Referenced by cu_preinstnew(), cu_preinstupgrade(), cu_preinstverynew(), deferred_configure(), deferred_remove(), post_postinst_tasks(), and trig_clear_awaiters().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ modstatdb_note_ifwrite()

void modstatdb_note_ifwrite ( struct pkginfo pkg)

◆ modstatdb_open()

enum modstatdb_rw modstatdb_open ( enum modstatdb_rw  reqrwflags)

References modstatdb_init().

Referenced by archivefiles(), audit(), clearselections(), packages(), predeppackage(), setselections(), unpackchk(), and verify().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ modstatdb_shutdown()

void modstatdb_shutdown ( void  )

Referenced by clearselections().

Here is the caller graph for this function:

◆ modstatdb_unlock()

void modstatdb_unlock ( void  )

References ehflag_normaltidy, and pop_cleanup().

Referenced by updateavailable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nffreeall()

void nffreeall ( void  )

Referenced by pkg_hash_reset().

Here is the caller graph for this function:

◆ nfmalloc()

void * nfmalloc ( size_t  size)

References OBSTACK_INIT.

Referenced by ensure_package_clientdata(), pkg_files_add_file(), pkg_hash_get_pkg(), pkgbin_name_archqual(), statusfd_add(), trig_note_aw(), and trig_note_pend_core().

Here is the caller graph for this function:

◆ nfstrnsave()

char * nfstrnsave ( const char *  string,
size_t  size 
)

References OBSTACK_INIT.

Referenced by do_split().

Here is the caller graph for this function:

◆ nfstrsave()

char * nfstrsave ( const char *  string)

References OBSTACK_INIT.

Referenced by f_archives(), f_charfield(), and f_section().

Here is the caller graph for this function:

◆ parsedb()

int parsedb ( const char *  filename,
enum parsedbflags  flags,
struct pkginfo **  pkgp 
)

Parse a deb822 style file.

donep may be NULL. If donep is not NULL only one package's information is expected.

References parsedb_state::filename, parsedb_state::flags, parsedb_close(), parsedb_load(), parsedb_open(), and parsedb_parse().

Referenced by updateavailable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parseversion()

int parseversion ( struct dpkg_version rversion,
const char *  string,
struct dpkg_error err 
)

Parse a version string and check for invalid syntax.

Distinguish between lax (warnings) and strict (error) parsing.

Parameters
rversionThe parsed version.
stringThe version string to parse.
errThe warning or error message if any.
Return values
0On success.
-1On failure, and err is set accordingly.

Referenced by cmpversions().

Here is the caller graph for this function:

◆ pkg_blank()

void pkg_blank ( struct pkginfo pp)

References pkgbin::arch, pkginfo::archives, pkginfo::available, pkginfo::clientdata, pkginfo::configversion, dpkg_arch_get(), DPKG_ARCH_NONE, dpkg_version_blank(), pkginfo::eflag, pkginfo::files, pkginfo::files_list_phys_offs, pkginfo::files_list_valid, pkginfo::head, pkginfo::installed, pkgbin::multiarch, pkginfo::otherpriority, pkginfo::othertrigaw_head, PKG_EFLAG_OK, PKG_MULTIARCH_NO, PKG_PRIO_UNKNOWN, PKG_STAT_NOTINSTALLED, PKG_WANT_UNKNOWN, pkgbin_blank(), pkginfo::priority, pkginfo::section, pkginfo::status, pkginfo::status_dirty, pkginfo::tail, pkginfo::trigaw, pkginfo::trigpend_head, and pkginfo::want.

Referenced by pkg_hash_get_pkg(), and pkgset_blank().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pkg_eflag_name()

const char * pkg_eflag_name ( const struct pkginfo pkg)

Return a string representation of the package eflag status name.

Parameters
pkgThe package to consider.
Returns
The string representation.

References pkginfo::eflag, eflaginfos, and namevalue::name.

Referenced by w_status().

Here is the caller graph for this function:

◆ pkg_hash_count_pkg()

int pkg_hash_count_pkg ( void  )

Return the number of package instances available in the database.

Returns
The number of package instances.

Referenced by pkg_array_init_from_hash().

Here is the caller graph for this function:

◆ pkg_hash_count_set()

int pkg_hash_count_set ( void  )

Return the number of package sets available in the database.

Returns
The number of package sets.

◆ pkg_hash_find_pkg()

struct pkginfo * pkg_hash_find_pkg ( const char *  name,
const struct dpkg_arch arch 
)

Return the package instance with the given name and architecture.

Parameters
nameThe package name.
archThe requested architecture.
Returns
The package instance.

References pkg_hash_find_set(), pkg_hash_get_pkg(), and pkginfo::set.

Here is the call graph for this function:

◆ pkg_hash_find_set()

struct pkgset * pkg_hash_find_set ( const char *  inname)

Return the package set with the given name.

If the package already exists in the internal database, then it returns the existing structure. Otherwise it allocates a new one and will return it. The actual name associated to the package set is a lowercase version of the name given in parameter.

A package set (struct pkgset) can be composed of multiple package instances (struct pkginfo) where each instance is distinguished by its architecture (as recorded in pkg.installed.arch and pkg.available.arch).

Parameters
innameName of the package set.
Returns
The package set.

References m_strdup(), and pkgset::name.

Referenced by f_name(), pkg_hash_find_pkg(), pkg_hash_find_singleton(), pkg_spec_is_illegal(), and pkg_spec_iter_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pkg_hash_find_singleton()

struct pkginfo * pkg_hash_find_singleton ( const char *  name)

Return the singleton package instance with the given name.

Parameters
nameThe package name.
Returns
The package instance.

References _, pkgset::name, ohshit(), pkg_hash_find_set(), pkg_hash_get_singleton(), and pkginfo::set.

Here is the call graph for this function:

◆ pkg_hash_get_pkg()

struct pkginfo * pkg_hash_get_pkg ( struct pkgset set,
const struct dpkg_arch arch 
)

Return the package instance in a set with the given architecture.

It traverse the various instances to find out whether there's one matching the given architecture. If found, it returns it. Otherwise it allocates a new instance and registers it in the package set before returning it.

Parameters
setThe package set to use.
archThe requested architecture.
Returns
The package instance.

References pkgbin::arch, pkginfo::arch_next, pkginfo::available, DPKG_ARCH_NONE, pkginfo::installed, internerr, nfmalloc(), pkgset::pkg, pkg_blank(), pkginfo::set, and dpkg_arch::type.

Referenced by pkg_hash_find_pkg().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pkg_hash_get_singleton()

struct pkginfo * pkg_hash_get_singleton ( struct pkgset set)

Return the singleton package instance from a package set.

This means, if none are installed either an instance with native or all arch or the first if none found, the single installed instance, or NULL if more than one instance is installed.

Parameters
setThe package set to use.
Returns
The singleton package instance.

References pkgbin::arch, pkginfo::arch_next, pkginfo::available, DPKG_ARCH_ALL, DPKG_ARCH_NATIVE, internerr, pkgset::name, pkgset::pkg, PKG_STAT_NOTINSTALLED, pkgset_installed_instances(), pkginfo::set, pkginfo::status, and dpkg_arch::type.

Referenced by pkg_hash_find_singleton().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pkg_hash_iter_free()

void pkg_hash_iter_free ( struct pkg_hash_iter iter)

Referenced by clear_istobes(), clearselections(), findbreakcycle(), pkg_array_init_from_hash(), pkg_spec_iter_destroy(), and predeppackage().

Here is the caller graph for this function:

◆ pkg_hash_iter_new()

struct pkg_hash_iter * pkg_hash_iter_new ( void  )

Create a new package iterator.

It can iterate either over package sets or over package instances.

Returns
The iterator.

References m_malloc(), pkg_hash_iter::nbinn, and pkg_hash_iter::pkg.

Referenced by clear_istobes(), clearselections(), findbreakcycle(), pkg_array_init_from_hash(), pkg_spec_iter_init(), predeppackage(), trigproc_populate_deferred(), unpackchk(), and verify().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pkg_hash_iter_next_pkg()

struct pkginfo * pkg_hash_iter_next_pkg ( struct pkg_hash_iter iter)

References BINS, pkg_hash_iter::nbinn, and pkg_hash_iter::pkg.

Referenced by clear_istobes(), clearselections(), findbreakcycle(), pkg_array_init_from_hash(), predeppackage(), trigproc_populate_deferred(), unpackchk(), and verify().

Here is the caller graph for this function:

◆ pkg_hash_iter_next_set()

struct pkgset * pkg_hash_iter_next_set ( struct pkg_hash_iter iter)

◆ pkg_hash_report()

void pkg_hash_report ( FILE *  file)

References m_malloc(), and pkgset::pkg.

Here is the call graph for this function:

◆ pkg_hash_reset()

void pkg_hash_reset ( void  )

References dpkg_arch_reset_list(), and nffreeall().

Here is the call graph for this function:

◆ pkg_is_informative()

bool pkg_is_informative ( struct pkginfo pkg,
struct pkgbin pkgbin 
)

Check if a pkg is informative.

Used by dselect and dpkg query options as an aid to decide whether to display things, and by dump to decide whether to write them out.

References pkginfo::configversion, pkgbin::depends, dpkg_version_is_informative(), pkginfo::eflag, pkginfo::installed, PKG_EFLAG_OK, PKG_STAT_NOTINSTALLED, PKG_WANT_UNKNOWN, pkginfo::status, and pkginfo::want.

Referenced by writedb_records().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pkg_name()

const char * pkg_name ( struct pkginfo pkg,
enum pkg_name_arch_when  pnaw 
)

Return a string representation of the installed package name.

This is equivalent to pkgbin_name() but just for its installed pkgbin.

Parameters
pkgThe package to consider.
pnawWhen to display the architecture qualifier.
Returns
The string representation.

References pkginfo::installed, and pkgbin_name().

Referenced by check_breaks(), conffderef(), conffile_mark_obsolete(), cu_prermdeconfigure(), deferred_configure(), deferred_remove(), depisok(), describedepcon(), dir_has_conffiles(), dir_is_used_by_others(), dir_is_used_by_pkg(), filesavespackage(), maintscript_fallback(), maintscript_new(), md5hash(), modstatdb_note(), parse_filehash(), removal_bulk(), skip_due_to_hold(), trig_activate_packageprocessing(), trig_clear_awaiters(), trigproc(), and wanttoinstall().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pkg_name_const()

const char * pkg_name_const ( const struct pkginfo pkg,
enum pkg_name_arch_when  pnaw 
)

Return a string representation of the installed package name.

This is equivalent to pkgbin_name_const() but just for its installed pkgbin.

Parameters
pkgThe package to consider.
pnawWhen to display the architecture qualifier.
Returns
The string representation.

References pkginfo::installed, and pkgbin_name_const().

Here is the call graph for this function:

◆ pkg_name_is_illegal()

const char * pkg_name_is_illegal ( const char *  p)

References _.

Referenced by f_name(), pkg_spec_is_illegal(), and validate_pkgname().

Here is the caller graph for this function:

◆ pkg_priority_name()

const char * pkg_priority_name ( const struct pkginfo pkg)

Return a string representation of the package priority name.

Parameters
pkgThe package to consider.
Returns
The string representation.

References namevalue::name, pkginfo::otherpriority, PKG_PRIO_OTHER, pkginfo::priority, and priorityinfos.

Referenced by w_priority().

Here is the caller graph for this function:

◆ pkg_source_version()

void pkg_source_version ( struct dpkg_version version,
const struct pkginfo pkg,
const struct pkgbin pkgbin 
)

◆ pkg_status_name()

const char * pkg_status_name ( const struct pkginfo pkg)

Return a string representation of the package current status name.

Parameters
pkgThe package to consider.
Returns
The string representation.

References namevalue::name, pkginfo::status, and statusinfos.

Referenced by deferred_configure(), modstatdb_note(), trigproc(), w_status(), w_trigaw(), and w_trigpend().

Here is the caller graph for this function:

◆ pkg_virtual_deppossi_satisfied()

bool pkg_virtual_deppossi_satisfied ( struct deppossi dependee,
struct deppossi provider 
)

Check if the dependency is satisfied by a virtual package.

For versioned depends, we only check providers with DPKG_RELATION_EQ. It does not make sense to check ones without a version since we have nothing to verify against. Also, it is way too complex to allow anything but an equal in a provided version. A few examples below to deter you from trying:

  • pkg1 depends on virt (>= 0.6), pkg2 provides virt (<= 1.0). Should pass (easy enough).
  • pkg1 depends on virt (>= 0.7) and (<= 1.1), pkg2 provides virt (>= 1.2). Should fail (little harder).
  • pkg1 depends on virt (>= 0.4), pkg2 provides virt (<= 1.0) and (>= 0.5), IOW, inclusive of only those versions. This would require backchecking the other provided versions in the possi, which would make things sickly complex and overly time consuming. Should fail (very hard to implement).

This could be handled by switching to a SAT solver, but that would imply lots of work for very little gain. Packages can easily get around most of these by providing multiple DPKG_RELATION_EQ versions.

References DPKG_RELATION_EQ, DPKG_RELATION_NONE, dpkg_version_relate(), deppossi::verrel, and deppossi::version.

Referenced by depisok(), and predeppackage().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pkg_want_name()

const char * pkg_want_name ( const struct pkginfo pkg)

Return a string representation of the package want status name.

Parameters
pkgThe package to consider.
Returns
The string representation.

References namevalue::name, pkginfo::want, and wantinfos.

Referenced by w_status().

Here is the caller graph for this function:

◆ pkgbin_blank()

void pkgbin_blank ( struct pkgbin pkgbin)

References pkgbin::arbs, pkgbin::bugs, pkgbin::conffiles, pkgbin::depends, pkgbin::description, dpkg_version_blank(), pkgbin::essential, pkgbin::installedsize, pkgbin::is_protected, pkgbin::maintainer, pkgbin::origin, pkgbin::pkgname_archqual, pkgbin::source, and pkgbin::version.

Referenced by cu_preinstverynew(), and pkg_blank().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pkgbin_name()

const char * pkgbin_name ( struct pkginfo pkg,
struct pkgbin pkgbin,
enum pkg_name_arch_when  pnaw 
)

Return a string representation of the package name.

The returned string must not be freed, and it's permanently allocated so can be used as long as the non-freeing memory pool has not been freed.

The pnaw parameter should be one of pnaw_never (never print arch), pnaw_foreign (print arch for foreign packages only), pnaw_nonambig (print arch for non ambiguous cases) or pnaw_always (always print arch),

Parameters
pkgThe package to consider.
pkgbinThe binary package instance to consider.
pnawWhen to display the architecture qualifier.
Returns
The string representation.

Referenced by check_breaks(), cu_prermdeconfigure(), cu_prerminfavour(), depisok(), log_action(), namenodetouse(), pkg_name(), predeppackage(), wanttoinstall(), and writedb_records().

Here is the caller graph for this function:

◆ pkgbin_name_archqual()

const char * pkgbin_name_archqual ( const struct pkginfo pkg,
const struct pkgbin pkgbin 
)

References pkgbin::arch, DPKG_ARCH_EMPTY, DPKG_ARCH_NONE, dpkg_arch::name, pkgset::name, nfmalloc(), pkginfo::set, str_concat(), and dpkg_arch::type.

Here is the call graph for this function:

◆ pkgbin_name_const()

const char * pkgbin_name_const ( const struct pkginfo pkg,
const struct pkgbin pkgbin,
enum pkg_name_arch_when  pnaw 
)

Return a string representation of the package name.

The returned string must not be freed, and it's permanently allocated so can be used as long as the non-freeing memory pool has not been freed.

Note, that this const variant will "leak" a new non-freeing string on each call if the internal cache has not been previously initialized, so it is advised to use it only in error reporting code paths.

The pnaw parameter should be one of pnaw_never (never print arch), pnaw_foreign (print arch for foreign packages only), pnaw_nonambig (print arch for non ambiguous cases) or pnaw_always (always print arch),

Parameters
pkgThe package to consider.
pkgbinThe binary package instance to consider.
pnawWhen to display the architecture qualifier.
Returns
The string representation.

Referenced by pkg_name_const(), w_dependency(), w_priority(), w_status(), w_trigaw(), w_trigpend(), and writerecord().

Here is the caller graph for this function:

◆ pkgset_blank()

void pkgset_blank ( struct pkgset set)

References pkginfo::arch_next, pkgset::available, pkgset::depended, pkgset::installed, pkgset::installed_instances, pkgset::name, pkgset::pkg, pkg_blank(), and pkginfo::set.

Referenced by parsedb_parse().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pkgset_installed_instances()

int pkgset_installed_instances ( struct pkgset set)

Get the number of installed package instances in a package set.

Parameters
setThe package set to use.
Returns
The count of installed packages.

References pkgset::installed_instances.

Referenced by pkg_hash_get_singleton(), and pkg_spec_is_illegal().

Here is the caller graph for this function:

◆ varbuf_add_pkgbin_name()

void varbuf_add_pkgbin_name ( struct varbuf vb,
const struct pkginfo pkg,
const struct pkgbin pkgbin,
enum pkg_name_arch_when  pnaw 
)

Add a string representation of the package name to a varbuf.

Works exactly like pkgbin_name() but acts on the varbuf instead of returning a string. It NUL terminates the varbuf.

Parameters
vbThe varbuf struct to modify.
pkgThe package to consider.
pkgbinThe binary package instance to consider.
pnawWhen to display the architecture qualifier.

References pkgset::name, pkginfo::set, and varbuf_add_str.

Referenced by w_trigaw().

Here is the caller graph for this function:

◆ varbuf_add_source_version()

void varbuf_add_source_version ( struct varbuf vb,
const struct pkginfo pkg,
const struct pkgbin pkgbin 
)

Add a string representation of the source package version to a varbuf.

It parses the Source field (if present), and extracts the optional version enclosed in parenthesis. Otherwise it fallsback to use the binary package version. It NUL terminates the varbuf.

Parameters
vbThe varbuf struct to modify.
pkgThe package to consider.
pkgbinThe binary package instance to consider.

◆ varbufdependency()

void varbufdependency ( struct varbuf vb,
struct dependency dep 
)

References deppossi::arch, deppossi::arch_is_implicit, DPKG_RELATION_EQ, DPKG_RELATION_GE, DPKG_RELATION_GT, DPKG_RELATION_LE, DPKG_RELATION_LT, DPKG_RELATION_NONE, deppossi::ed, internerr, dependency::list, pkgset::name, deppossi::next, deppossi::up, varbuf_add_archqual(), varbuf_add_char(), varbuf_add_str, varbufversion(), vdew_nonambig, deppossi::verrel, and deppossi::version.

Referenced by describedepcon().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ varbufrecord()

void varbufrecord ( struct varbuf vb,
const struct pkginfo pkg,
const struct pkgbin pkgbin 
)

References pkgbin::arbs, fieldinfos, fw_printheader, fieldinfo::name, arbitraryfield::next, varbuf_add_arbfield(), and fieldinfo::wcall.

Referenced by writedb_records(), and writerecord().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ varbufversion()

void varbufversion ( struct varbuf vb,
const struct dpkg_version version,
enum  versiondisplayepochwhen 
)

Referenced by varbufdependency(), w_configversion(), and w_version().

Here is the caller graph for this function:

◆ versiondescribe()

const char * versiondescribe ( const struct dpkg_version version,
enum  versiondisplayepochwhen 
)

Referenced by cu_postrmupgrade(), cu_preinstnew(), cu_preinstupgrade(), cu_prermdeconfigure(), cu_prerminfavour(), cu_prermupgrade(), deferred_configure(), depisok(), maintscript_fallback(), and wanttoinstall().

Here is the caller graph for this function:

◆ versiondescribe_c()

const char * versiondescribe_c ( const struct dpkg_version version,
enum versiondisplayepochwhen  vdew 
)

Referenced by cmpversions(), log_action(), and modstatdb_note().

Here is the caller graph for this function:

◆ versionsatisfied()

bool versionsatisfied ( struct pkgbin it,
struct deppossi against 
)

References dpkg_version_relate(), deppossi::verrel, deppossi::version, and pkgbin::version.

Referenced by depisok(), and predeppackage().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writedb()

void writedb ( const char *  filename,
enum writedb_flags  flags 
)

References ATOMIC_FILE_BACKUP, atomic_file_close(), atomic_file_commit(), atomic_file_free(), atomic_file_new(), atomic_file_open(), atomic_file_sync(), dir_sync_path_parent(), atomic_file::flags, wdb_dump_available, wdb_must_sync, and writedb_records().

Referenced by updateavailable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writedb_records()

void writedb_records ( FILE *  fp,
const char *  filename,
enum writedb_flags  flags 
)

References _, pkginfo::available, varbuf::buf, pkginfo::installed, pkg_array::n_pkgs, ohshite(), pkg_array_destroy(), pkg_array_init_from_hash(), pkg_array_sort(), pkg_is_informative(), pkg_sorter_by_nonambig_name_arch(), pkgbin_name(), pkg_array::pkgs, pnaw_nonambig, varbuf_add_char(), varbuf_destroy(), varbuf_end_str(), VARBUF_INIT, varbuf_reset(), varbufrecord(), and wdb_dump_available.

Referenced by writedb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writerecord()

void writerecord ( FILE *  file,
const char *  filename,
const struct pkginfo pkg,
const struct pkgbin pkgbin 
)

References _, varbuf::buf, ohshite(), pkgbin_name_const(), pnaw_nonambig, varbuf_destroy(), varbuf_end_str(), VARBUF_INIT, and varbufrecord().

Referenced by predeppackage().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ booleaninfos

const struct namevalue booleaninfos[]
extern

◆ eflaginfos

const struct namevalue eflaginfos[]
extern

Referenced by pkg_eflag_name().

◆ multiarchinfos

const struct namevalue multiarchinfos[]
extern

◆ priorityinfos

const struct namevalue priorityinfos[]
extern

Referenced by pkg_priority_name().

◆ statusinfos

const struct namevalue statusinfos[]
extern

Referenced by pkg_status_name().

◆ wantinfos

const struct namevalue wantinfos[]
extern

Referenced by pkg_want_name().