libalpm
Arch Linux Package Manager Library
|
Functions to manipulate libalpm packages. More...
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_t * | alpm_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_t * | alpm_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_t * | alpm_pkg_get_licenses (alpm_pkg_t *pkg) |
Returns the list of package licenses. | |
alpm_list_t * | alpm_pkg_get_groups (alpm_pkg_t *pkg) |
Returns the list of package groups. | |
alpm_list_t * | alpm_pkg_get_depends (alpm_pkg_t *pkg) |
Returns the list of package dependencies as alpm_depend_t. | |
alpm_list_t * | alpm_pkg_get_optdepends (alpm_pkg_t *pkg) |
Returns the list of package optional dependencies. | |
alpm_list_t * | alpm_pkg_get_conflicts (alpm_pkg_t *pkg) |
Returns the list of packages conflicting with pkg. | |
alpm_list_t * | alpm_pkg_get_provides (alpm_pkg_t *pkg) |
Returns the list of packages provided by pkg. | |
alpm_list_t * | alpm_pkg_get_deltas (alpm_pkg_t *pkg) |
Returns the list of available deltas for pkg. | |
alpm_list_t * | alpm_pkg_get_replaces (alpm_pkg_t *pkg) |
Returns the list of packages to be replaced by pkg. | |
alpm_filelist_t * | alpm_pkg_get_files (alpm_pkg_t *pkg) |
Returns the list of files installed by pkg. | |
alpm_list_t * | alpm_pkg_get_backup (alpm_pkg_t *pkg) |
Returns the list of files backed up when installing pkg. | |
alpm_db_t * | alpm_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. |
Functions to manipulate libalpm packages.
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().
void* alpm_pkg_changelog_open | ( | alpm_pkg_t * | pkg | ) |
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.
pkg | the package to read the changelog of (either file or db) |
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().
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.
ptr | a buffer to fill with raw changelog data |
size | the size of the buffer |
pkg | the package that the changelog is being read from |
fp | a 'file stream' to the package changelog |
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().
int alpm_pkg_checkmd5sum | ( | alpm_pkg_t * | pkg | ) |
Check the integrity (with md5) of a package from the sync cache.
pkg | package pointer |
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.
alpm_list_t* alpm_pkg_compute_requiredby | ( | alpm_pkg_t * | pkg | ) |
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.
pkg | a package |
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().
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.
newpkg | the new package to upgrade to |
Returns the size of download.
newpkg | the new package to upgrade to |
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.
pkg | package pointer to free |
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().
const char* alpm_pkg_get_arch | ( | alpm_pkg_t * | pkg | ) |
Returns the architecture for which the package was built.
pkg | a pointer to package |
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().
alpm_list_t* alpm_pkg_get_backup | ( | alpm_pkg_t * | pkg | ) |
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.
pkg | a pointer to package |
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().
const char* alpm_pkg_get_base64_sig | ( | alpm_pkg_t * | pkg | ) |
Retuns the base64 encoded package signature.
pkg | a pointer to package |
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().
alpm_time_t alpm_pkg_get_builddate | ( | alpm_pkg_t * | pkg | ) |
Returns the build timestamp of the package.
pkg | a pointer to package |
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().
alpm_list_t* alpm_pkg_get_conflicts | ( | alpm_pkg_t * | pkg | ) |
Returns the list of packages conflicting with pkg.
pkg | a pointer to package |
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().
alpm_db_t* alpm_pkg_get_db | ( | alpm_pkg_t * | pkg | ) |
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.
pkg | a pointer to package |
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().
alpm_list_t* alpm_pkg_get_deltas | ( | alpm_pkg_t * | pkg | ) |
Returns the list of available deltas for pkg.
pkg | a pointer to package |
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.
alpm_list_t* alpm_pkg_get_depends | ( | alpm_pkg_t * | pkg | ) |
Returns the list of package dependencies as alpm_depend_t.
pkg | a pointer to package |
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().
const char* alpm_pkg_get_desc | ( | alpm_pkg_t * | pkg | ) |
Returns the package description.
pkg | a pointer to package |
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().
const char* alpm_pkg_get_filename | ( | alpm_pkg_t * | pkg | ) |
Gets the name of the file from which the package was loaded.
pkg | a pointer to package |
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.
alpm_filelist_t* alpm_pkg_get_files | ( | alpm_pkg_t * | pkg | ) |
Returns the list of files installed by pkg.
The filenames are relative to the install root, and do not include leading slashes.
pkg | a pointer to package |
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().
alpm_list_t* alpm_pkg_get_groups | ( | alpm_pkg_t * | pkg | ) |
Returns the list of package groups.
pkg | a pointer to package |
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().
Returns the install timestamp of the package.
pkg | a pointer to package |
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().
off_t alpm_pkg_get_isize | ( | alpm_pkg_t * | pkg | ) |
Returns the installed size of the package.
pkg | a pointer to 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().
alpm_list_t* alpm_pkg_get_licenses | ( | alpm_pkg_t * | pkg | ) |
Returns the list of package licenses.
pkg | a pointer to package |
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().
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.
pkg | a pointer to package |
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().
const char* alpm_pkg_get_name | ( | alpm_pkg_t * | pkg | ) |
Returns the package name.
pkg | a pointer to package |
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().
alpm_list_t* alpm_pkg_get_optdepends | ( | alpm_pkg_t * | pkg | ) |
Returns the list of package optional dependencies.
pkg | a pointer to package |
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().
alpm_pkgfrom_t alpm_pkg_get_origin | ( | alpm_pkg_t * | pkg | ) |
Returns the origin of the package.
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().
const char* alpm_pkg_get_packager | ( | alpm_pkg_t * | pkg | ) |
Returns the packager's name.
pkg | a pointer to package |
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().
alpm_list_t* alpm_pkg_get_provides | ( | alpm_pkg_t * | pkg | ) |
Returns the list of packages provided by pkg.
pkg | a pointer to package |
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().
Returns the package installation reason.
pkg | a pointer to package |
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().
alpm_list_t* alpm_pkg_get_replaces | ( | alpm_pkg_t * | pkg | ) |
Returns the list of packages to be replaced by pkg.
pkg | a pointer to package |
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().
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.
pkg | a pointer to package |
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().
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.
pkg | a pointer to package |
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().
const char* alpm_pkg_get_url | ( | alpm_pkg_t * | pkg | ) |
Returns the package URL.
pkg | a pointer to package |
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().
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.
pkg | a pointer to package |
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().
int alpm_pkg_has_scriptlet | ( | alpm_pkg_t * | pkg | ) |
Returns whether the package has an install scriptlet.
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().
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().
handle | the context handle |
filename | location of the package tarball |
full | whether to stop the load after metadata is read or continue through the full archive |
level | what level of package signature checking to perform on the package; note that this must be a '.sig' file type verification |
pkg | address of the package pointer |
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().
alpm_list_t* alpm_pkg_unused_deltas | ( | alpm_pkg_t * | pkg | ) |
Definition at line 264 of file delta.c.
References ASSERT, __alpm_pkg_t::deltas, __alpm_pkg_t::filename, MAX_DELTA_RATIO, and __alpm_pkg_t::size.
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().