libalpm
Arch Linux Package Manager Library
Functions
Package Functions
Public API

Functions to manipulate libalpm packages. More...

Collaboration diagram for Package Functions:

Functions

int alpm_pkg_load (alpm_handle_t *handle, const char *filename, int full, alpm_siglevel_t level, alpm_pkg_t **pkg)
 Create a package from a file.
int alpm_pkg_free (alpm_pkg_t *pkg)
 Free a package.
int alpm_pkg_checkmd5sum (alpm_pkg_t *pkg)
 Check the integrity (with md5) of a package from the sync cache.
int alpm_pkg_vercmp (const char *a, const char *b)
 Compare two version strings and determine which one is 'newer'.
alpm_list_talpm_pkg_compute_requiredby (alpm_pkg_t *pkg)
 Computes the list of packages requiring a given package.
void * alpm_pkg_changelog_open (alpm_pkg_t *pkg)
 Open a package changelog for reading.
size_t alpm_pkg_changelog_read (void *ptr, size_t size, const alpm_pkg_t *pkg, void *fp)
 Read data from an open changelog 'file stream'.
int alpm_pkg_changelog_close (const alpm_pkg_t *pkg, void *fp)
 Close a package changelog for reading.
int alpm_pkg_has_scriptlet (alpm_pkg_t *pkg)
 Returns whether the package has an install scriptlet.
off_t alpm_pkg_download_size (alpm_pkg_t *newpkg)
 Returns the size of download.
alpm_list_talpm_pkg_unused_deltas (alpm_pkg_t *pkg)

Package Property Accessors

Any pointer returned by these functions points to internal structures allocated by libalpm.

They should not be freed nor modified in any way.

const char * alpm_pkg_get_filename (alpm_pkg_t *pkg)
 Gets the name of the file from which the package was loaded.
const char * alpm_pkg_get_name (alpm_pkg_t *pkg)
 Returns the package name.
const char * alpm_pkg_get_version (alpm_pkg_t *pkg)
 Returns the package version as a string.
alpm_pkgfrom_t alpm_pkg_get_origin (alpm_pkg_t *pkg)
 Returns the origin of the package.
const char * alpm_pkg_get_desc (alpm_pkg_t *pkg)
 Returns the package description.
const char * alpm_pkg_get_url (alpm_pkg_t *pkg)
 Returns the package URL.
alpm_time_t alpm_pkg_get_builddate (alpm_pkg_t *pkg)
 Returns the build timestamp of the package.
alpm_time_t alpm_pkg_get_installdate (alpm_pkg_t *pkg)
 Returns the install timestamp of the package.
const char * alpm_pkg_get_packager (alpm_pkg_t *pkg)
 Returns the packager's name.
const char * alpm_pkg_get_md5sum (alpm_pkg_t *pkg)
 Returns the package's MD5 checksum as a string.
const char * alpm_pkg_get_sha256sum (alpm_pkg_t *pkg)
 Returns the package's SHA256 checksum as a string.
const char * alpm_pkg_get_arch (alpm_pkg_t *pkg)
 Returns the architecture for which the package was built.
off_t alpm_pkg_get_size (alpm_pkg_t *pkg)
 Returns the size of the package.
off_t alpm_pkg_get_isize (alpm_pkg_t *pkg)
 Returns the installed size of the package.
alpm_pkgreason_t alpm_pkg_get_reason (alpm_pkg_t *pkg)
 Returns the package installation reason.
alpm_list_talpm_pkg_get_licenses (alpm_pkg_t *pkg)
 Returns the list of package licenses.
alpm_list_talpm_pkg_get_groups (alpm_pkg_t *pkg)
 Returns the list of package groups.
alpm_list_talpm_pkg_get_depends (alpm_pkg_t *pkg)
 Returns the list of package dependencies as alpm_depend_t.
alpm_list_talpm_pkg_get_optdepends (alpm_pkg_t *pkg)
 Returns the list of package optional dependencies.
alpm_list_talpm_pkg_get_conflicts (alpm_pkg_t *pkg)
 Returns the list of packages conflicting with pkg.
alpm_list_talpm_pkg_get_provides (alpm_pkg_t *pkg)
 Returns the list of packages provided by pkg.
alpm_list_talpm_pkg_get_deltas (alpm_pkg_t *pkg)
 Returns the list of available deltas for pkg.
alpm_list_talpm_pkg_get_replaces (alpm_pkg_t *pkg)
 Returns the list of packages to be replaced by pkg.
alpm_filelist_talpm_pkg_get_files (alpm_pkg_t *pkg)
 Returns the list of files installed by pkg.
alpm_list_talpm_pkg_get_backup (alpm_pkg_t *pkg)
 Returns the list of files backed up when installing pkg.
alpm_db_talpm_pkg_get_db (alpm_pkg_t *pkg)
 Returns the database containing pkg.
const char * alpm_pkg_get_base64_sig (alpm_pkg_t *pkg)
 Retuns the base64 encoded package signature.

Detailed Description

Functions to manipulate libalpm packages.


Function Documentation

int alpm_pkg_changelog_close ( const alpm_pkg_t pkg,
void *  fp 
)

Close a package changelog for reading.

Definition at line 369 of file lib/libalpm/package.c.

References ASSERT, pkg_operations::changelog_close, __alpm_pkg_t::handle, __alpm_pkg_t::ops, and __alpm_handle_t::pm_errno.

Referenced by dump_pkg_changelog().

Here is the caller graph for this function:

Open a package changelog for reading.

Similar to fopen in functionality, except that the returned 'file stream' could really be from an archive as well as from the database.

Parameters:
pkgthe package to read the changelog of (either file or db)
Returns:
a 'file stream' to the package changelog

Definition at line 352 of file lib/libalpm/package.c.

References ASSERT, pkg_operations::changelog_open, __alpm_pkg_t::handle, __alpm_pkg_t::ops, and __alpm_handle_t::pm_errno.

Referenced by dump_pkg_changelog().

Here is the caller graph for this function:

size_t alpm_pkg_changelog_read ( void *  ptr,
size_t  size,
const alpm_pkg_t pkg,
void *  fp 
)

Read data from an open changelog 'file stream'.

Similar to fread in functionality, this function takes a buffer and amount of data to read. If an error occurs pm_errno will be set.

Parameters:
ptra buffer to fill with raw changelog data
sizethe size of the buffer
pkgthe package that the changelog is being read from
fpa 'file stream' to the package changelog
Returns:
the number of characters read, or 0 if there is no more data or an error occurred.

Definition at line 360 of file lib/libalpm/package.c.

References ASSERT, pkg_operations::changelog_read, __alpm_pkg_t::handle, __alpm_pkg_t::ops, and __alpm_handle_t::pm_errno.

Referenced by dump_pkg_changelog().

Here is the caller graph for this function:

Check the integrity (with md5) of a package from the sync cache.

Parameters:
pkgpackage pointer
Returns:
0 on success, -1 on error (pm_errno is set accordingly)

Definition at line 57 of file lib/libalpm/package.c.

References _alpm_filecache_find(), _alpm_test_checksum(), ALPM_CSUM_MD5, ALPM_ERR_PKG_INVALID, ALPM_ERR_WRONG_ARGS, ASSERT, __alpm_pkg_t::filename, __alpm_pkg_t::handle, __alpm_pkg_t::md5sum, __alpm_pkg_t::origin, PKG_FROM_SYNCDB, __alpm_handle_t::pm_errno, and RET_ERR.

Here is the call graph for this function:

Computes the list of packages requiring a given package.

The return value of this function is a newly allocated list of package names (char*), it should be freed by the caller.

Parameters:
pkga package
Returns:
the list of packages requiring pkg

Definition at line 403 of file lib/libalpm/package.c.

References _alpm_str_cmp(), alpm_list_count(), alpm_list_msort(), ASSERT, __alpm_list_t::data, __alpm_pkg_t::db, __alpm_handle_t::db_local, DB_STATUS_LOCAL, __alpm_handle_t::dbs_sync, __alpm_pkg_t::handle, __alpm_list_t::next, __alpm_pkg_t::origin, __alpm_pkg_t::origin_data, PKG_FROM_FILE, __alpm_handle_t::pm_errno, and __alpm_db_t::status.

Referenced by dump_pkg_full().

Here is the call graph for this function:

Here is the caller graph for this function:

off_t alpm_pkg_download_size ( alpm_pkg_t newpkg)

Returns the size of download.

Returns the size of the files that will be downloaded to install a package.

Parameters:
newpkgthe new package to upgrade to
Returns:
the size of the download

Returns the size of download.

Parameters:
newpkgthe new package to upgrade to
Returns:
the size of the download

Definition at line 637 of file lib/libalpm/sync.c.

References __alpm_pkg_t::download_size, __alpm_pkg_t::infolevel, and INFRQ_DSIZE.

int alpm_pkg_free ( alpm_pkg_t pkg)

Free a package.

Parameters:
pkgpackage pointer to free
Returns:
0 on success, -1 on error (pm_errno is set accordingly)

Definition at line 44 of file lib/libalpm/package.c.

References _alpm_pkg_free(), ASSERT, __alpm_pkg_t::origin, and PKG_FROM_FILE.

Referenced by main(), pacman_query(), and pacman_upgrade().

Here is the call graph for this function:

Here is the caller graph for this function:

const char* alpm_pkg_get_arch ( alpm_pkg_t pkg)

Returns the architecture for which the package was built.

Parameters:
pkga pointer to package
Returns:
a reference to an internal string

Definition at line 243 of file lib/libalpm/package.c.

References ASSERT, pkg_operations::get_arch, __alpm_pkg_t::handle, __alpm_pkg_t::ops, and __alpm_handle_t::pm_errno.

Referenced by dump_pkg_full().

Here is the caller graph for this function:

Returns the list of files backed up when installing pkg.

The elements of the returned list have the form "<filename>\t<md5sum>", where the given md5sum is that of the file as provided by the package.

Parameters:
pkga pointer to package
Returns:
a reference to an internal list of strings.

Definition at line 334 of file lib/libalpm/package.c.

References ASSERT, pkg_operations::get_backup, __alpm_pkg_t::handle, __alpm_pkg_t::ops, and __alpm_handle_t::pm_errno.

Referenced by _alpm_needbackup(), and dump_pkg_backups().

Here is the caller graph for this function:

const char* alpm_pkg_get_base64_sig ( alpm_pkg_t pkg)

Retuns the base64 encoded package signature.

Parameters:
pkga pointer to package
Returns:
a reference to an internal string

Definition at line 236 of file lib/libalpm/package.c.

References ASSERT, __alpm_pkg_t::base64_sig, __alpm_pkg_t::handle, and __alpm_handle_t::pm_errno.

Referenced by dump_pkg_full().

Here is the caller graph for this function:

Returns the build timestamp of the package.

Parameters:
pkga pointer to package
Returns:
the timestamp of the build time

Definition at line 201 of file lib/libalpm/package.c.

References ASSERT, pkg_operations::get_builddate, __alpm_pkg_t::handle, __alpm_pkg_t::ops, and __alpm_handle_t::pm_errno.

Referenced by dump_pkg_full().

Here is the caller graph for this function:

Returns the list of packages conflicting with pkg.

Parameters:
pkga pointer to package
Returns:
a reference to an internal list of alpm_depend_t structures.

Definition at line 299 of file lib/libalpm/package.c.

References ASSERT, pkg_operations::get_conflicts, __alpm_pkg_t::handle, __alpm_pkg_t::ops, and __alpm_handle_t::pm_errno.

Referenced by dump_pkg_full().

Here is the caller graph for this function:

Returns the database containing pkg.

Returns a pointer to the alpm_db_t structure the package is originating from, or NULL if the package was loaded from a file.

Parameters:
pkga pointer to package
Returns:
a pointer to the DB containing pkg, or NULL.

Definition at line 341 of file lib/libalpm/package.c.

References ASSERT, __alpm_pkg_t::db, __alpm_pkg_t::handle, __alpm_pkg_t::origin, __alpm_pkg_t::origin_data, PKG_FROM_FILE, and __alpm_handle_t::pm_errno.

Referenced by dump_pkg_full(), print_packages(), and select_display().

Here is the caller graph for this function:

Returns the list of available deltas for pkg.

Parameters:
pkga pointer to package
Returns:
a reference to an internal list of strings.

Definition at line 320 of file lib/libalpm/package.c.

References ASSERT, __alpm_pkg_t::deltas, __alpm_pkg_t::handle, and __alpm_handle_t::pm_errno.

Returns the list of package dependencies as alpm_depend_t.

Parameters:
pkga pointer to package
Returns:
a reference to an internal list of alpm_depend_t structures.

Definition at line 285 of file lib/libalpm/package.c.

References ASSERT, pkg_operations::get_depends, __alpm_pkg_t::handle, __alpm_pkg_t::ops, and __alpm_handle_t::pm_errno.

Referenced by alpm_checkdeps(), and dump_pkg_full().

Here is the caller graph for this function:

const char* alpm_pkg_get_desc ( alpm_pkg_t pkg)

Returns the package description.

Parameters:
pkga pointer to package
Returns:
a reference to an internal string

Definition at line 187 of file lib/libalpm/package.c.

References ASSERT, pkg_operations::get_desc, __alpm_pkg_t::handle, __alpm_pkg_t::ops, and __alpm_handle_t::pm_errno.

Referenced by _alpm_db_search(), and dump_pkg_full().

Here is the caller graph for this function:

const char* alpm_pkg_get_filename ( alpm_pkg_t pkg)

Gets the name of the file from which the package was loaded.

Parameters:
pkga pointer to package
Returns:
a reference to an internal string

Definition at line 159 of file lib/libalpm/package.c.

References ASSERT, __alpm_pkg_t::filename, __alpm_pkg_t::handle, and __alpm_handle_t::pm_errno.

Returns the list of files installed by pkg.

The filenames are relative to the install root, and do not include leading slashes.

Parameters:
pkga pointer to package
Returns:
a pointer to a filelist object containing a count and an array of package file objects

Definition at line 327 of file lib/libalpm/package.c.

References ASSERT, pkg_operations::get_files, __alpm_pkg_t::handle, __alpm_pkg_t::ops, and __alpm_handle_t::pm_errno.

Referenced by _alpm_db_find_fileconflicts(), and dump_pkg_files().

Here is the caller graph for this function:

Returns the list of package groups.

Parameters:
pkga pointer to package
Returns:
a pointer to an internal list of strings.

Definition at line 278 of file lib/libalpm/package.c.

References ASSERT, pkg_operations::get_groups, __alpm_pkg_t::handle, __alpm_pkg_t::ops, and __alpm_handle_t::pm_errno.

Referenced by _alpm_db_search(), _alpm_pkg_should_ignore(), and dump_pkg_full().

Here is the caller graph for this function:

Returns the install timestamp of the package.

Parameters:
pkga pointer to package
Returns:
the timestamp of the install time

Definition at line 208 of file lib/libalpm/package.c.

References ASSERT, pkg_operations::get_installdate, __alpm_pkg_t::handle, __alpm_pkg_t::ops, and __alpm_handle_t::pm_errno.

Referenced by dump_pkg_full().

Here is the caller graph for this function:

off_t alpm_pkg_get_isize ( alpm_pkg_t pkg)

Returns the installed size of the package.

Parameters:
pkga pointer to package
Returns:
the total size of files installed by the package.

Definition at line 257 of file lib/libalpm/package.c.

References ASSERT, pkg_operations::get_isize, __alpm_pkg_t::handle, __alpm_pkg_t::ops, and __alpm_handle_t::pm_errno.

Referenced by dump_pkg_full().

Here is the caller graph for this function:

Returns the list of package licenses.

Parameters:
pkga pointer to package
Returns:
a pointer to an internal list of strings.

Definition at line 271 of file lib/libalpm/package.c.

References ASSERT, pkg_operations::get_licenses, __alpm_pkg_t::handle, __alpm_pkg_t::ops, and __alpm_handle_t::pm_errno.

Referenced by dump_pkg_full().

Here is the caller graph for this function:

const char* alpm_pkg_get_md5sum ( alpm_pkg_t pkg)

Returns the package's MD5 checksum as a string.

The returned string is a sequence of 32 lowercase hexadecimal digits.

Parameters:
pkga pointer to package
Returns:
a reference to an internal string

Definition at line 222 of file lib/libalpm/package.c.

References ASSERT, __alpm_pkg_t::handle, __alpm_pkg_t::md5sum, and __alpm_handle_t::pm_errno.

Referenced by dump_pkg_full().

Here is the caller graph for this function:

const char* alpm_pkg_get_name ( alpm_pkg_t pkg)

Returns the package name.

Parameters:
pkga pointer to package
Returns:
a reference to an internal string

Definition at line 166 of file lib/libalpm/package.c.

References ASSERT, __alpm_pkg_t::handle, __alpm_pkg_t::name, and __alpm_handle_t::pm_errno.

Referenced by cb_event(), cb_question(), display_new_optdepends(), display_optdepends(), display_targets(), dump_pkg_changelog(), dump_pkg_files(), dump_pkg_full(), main(), pacman_remove(), print_packages(), and select_display().

Here is the caller graph for this function:

Returns the list of package optional dependencies.

Parameters:
pkga pointer to package
Returns:
a reference to an internal list of strings.

Definition at line 292 of file lib/libalpm/package.c.

References ASSERT, pkg_operations::get_optdepends, __alpm_pkg_t::handle, __alpm_pkg_t::ops, and __alpm_handle_t::pm_errno.

Referenced by display_new_optdepends(), display_optdepends(), and dump_pkg_full().

Here is the caller graph for this function:

Returns the origin of the package.

Returns:
an alpm_pkgfrom_t constant, -1 on error

Definition at line 180 of file lib/libalpm/package.c.

References ASSERT, __alpm_pkg_t::handle, __alpm_pkg_t::origin, and __alpm_handle_t::pm_errno.

Referenced by dump_pkg_full().

Here is the caller graph for this function:

const char* alpm_pkg_get_packager ( alpm_pkg_t pkg)

Returns the packager's name.

Parameters:
pkga pointer to package
Returns:
a reference to an internal string

Definition at line 215 of file lib/libalpm/package.c.

References ASSERT, pkg_operations::get_packager, __alpm_pkg_t::handle, __alpm_pkg_t::ops, and __alpm_handle_t::pm_errno.

Referenced by dump_pkg_full().

Here is the caller graph for this function:

Returns the list of packages provided by pkg.

Parameters:
pkga pointer to package
Returns:
a reference to an internal list of alpm_depend_t structures.

Definition at line 306 of file lib/libalpm/package.c.

References ASSERT, pkg_operations::get_provides, __alpm_pkg_t::handle, __alpm_pkg_t::ops, and __alpm_handle_t::pm_errno.

Referenced by _alpm_db_search(), _alpm_depcmp(), and dump_pkg_full().

Here is the caller graph for this function:

Returns the package installation reason.

Parameters:
pkga pointer to package
Returns:
an enum member giving the install reason.

Definition at line 264 of file lib/libalpm/package.c.

References ASSERT, pkg_operations::get_reason, __alpm_pkg_t::handle, __alpm_pkg_t::ops, and __alpm_handle_t::pm_errno.

Referenced by alpm_db_set_pkgreason(), and dump_pkg_full().

Here is the caller graph for this function:

Returns the list of packages to be replaced by pkg.

Parameters:
pkga pointer to package
Returns:
a reference to an internal list of alpm_depend_t structures.

Definition at line 313 of file lib/libalpm/package.c.

References ASSERT, pkg_operations::get_replaces, __alpm_pkg_t::handle, __alpm_pkg_t::ops, and __alpm_handle_t::pm_errno.

Referenced by dump_pkg_full().

Here is the caller graph for this function:

const char* alpm_pkg_get_sha256sum ( alpm_pkg_t pkg)

Returns the package's SHA256 checksum as a string.

The returned string is a sequence of 64 lowercase hexadecimal digits.

Parameters:
pkga pointer to package
Returns:
a reference to an internal string

Definition at line 229 of file lib/libalpm/package.c.

References ASSERT, __alpm_pkg_t::handle, __alpm_handle_t::pm_errno, and __alpm_pkg_t::sha256sum.

Referenced by dump_pkg_full().

Here is the caller graph for this function:

off_t alpm_pkg_get_size ( alpm_pkg_t pkg)

Returns the size of the package.

This is only available for sync database packages and package files, not those loaded from the local database.

Parameters:
pkga pointer to package
Returns:
the size of the package in bytes.

Definition at line 250 of file lib/libalpm/package.c.

References ASSERT, __alpm_pkg_t::handle, __alpm_handle_t::pm_errno, and __alpm_pkg_t::size.

Referenced by dump_pkg_full().

Here is the caller graph for this function:

const char* alpm_pkg_get_url ( alpm_pkg_t pkg)

Returns the package URL.

Parameters:
pkga pointer to package
Returns:
a reference to an internal string

Definition at line 194 of file lib/libalpm/package.c.

References ASSERT, pkg_operations::get_url, __alpm_pkg_t::handle, __alpm_pkg_t::ops, and __alpm_handle_t::pm_errno.

Referenced by dump_pkg_full().

Here is the caller graph for this function:

const char* alpm_pkg_get_version ( alpm_pkg_t pkg)

Returns the package version as a string.

This includes all available epoch, version, and pkgrel components. Use alpm_pkg_vercmp() to compare version strings if necessary.

Parameters:
pkga pointer to package
Returns:
a reference to an internal string

Definition at line 173 of file lib/libalpm/package.c.

References ASSERT, __alpm_pkg_t::handle, __alpm_handle_t::pm_errno, and __alpm_pkg_t::version.

Referenced by cb_event(), cb_question(), dump_pkg_full(), and print_packages().

Here is the caller graph for this function:

Returns whether the package has an install scriptlet.

Returns:
0 if FALSE, TRUE otherwise

Definition at line 376 of file lib/libalpm/package.c.

References ASSERT, __alpm_pkg_t::handle, pkg_operations::has_scriptlet, __alpm_pkg_t::ops, and __alpm_handle_t::pm_errno.

Referenced by _alpm_remove_single_package(), and dump_pkg_full().

Here is the caller graph for this function:

int alpm_pkg_load ( alpm_handle_t handle,
const char *  filename,
int  full,
alpm_siglevel_t  level,
alpm_pkg_t **  pkg 
)

Create a package from a file.

If full is false, the archive is read only until all necessary metadata is found. If it is true, the entire archive is read, which serves as a verification of integrity and the filelist can be created. The allocated structure should be freed using alpm_pkg_free().

Parameters:
handlethe context handle
filenamelocation of the package tarball
fullwhether to stop the load after metadata is read or continue through the full archive
levelwhat level of package signature checking to perform on the package; note that this must be a '.sig' file type verification
pkgaddress of the package pointer
Returns:
0 on success, -1 on error (pm_errno is set accordingly)

Definition at line 526 of file be_package.c.

References _alpm_pkg_load_internal(), _alpm_pkg_validate_internal(), ALPM_ERR_WRONG_ARGS, ASSERT, CHECK_HANDLE, and RET_ERR.

Referenced by main(), pacman_query(), and pacman_upgrade().

Here is the call graph for this function:

Here is the caller graph for this function:

int alpm_pkg_vercmp ( const char *  a,
const char *  b 
)

Compare two version strings and determine which one is 'newer'.

Returns a value comparable to the way strcmp works. Returns 1 if a is newer than b, 0 if a and b are the same version, or -1 if b is newer than a.

Different epoch values for version strings will override any further comparison. If no epoch is provided, 0 is assumed.

Keep in mind that the pkgrel is only compared if it is available on both versions handed to this function. For example, comparing 1.5-1 and 1.5 will yield 0; comparing 1.5-1 and 1.5-2 will yield -1 as expected. This is mainly for supporting versioned dependencies that do not include the pkgrel.

Definition at line 232 of file version.c.

Referenced by _alpm_pkg_compare_versions(), and main().

Here is the caller graph for this function: