---
name: "libalpm_packages"
section: "3"
platform: "linux"
package: "pacman"
version: "7.1.0.r9.g54d9411-3"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/libalpm_packages"
---

# libalpm\_packages(3)

Package Functions - Functions to manipulate libalpm packages

## NAME

libalpm\_packages - Package Functions

 \- Functions to manipulate libalpm packages

## SYNOPSIS

### Data Structures

struct **alpm\_pkg\_xdata\_t**\
 The extended data type used to store non-standard package data fields.

### Typedefs

typedef struct \_alpm\_pkg\_t **alpm\_pkg\_t**\
 A package.

### Enumerations

enum **alpm\_pkgreason\_t** { **ALPM\_PKG\_REASON\_EXPLICIT** = 0, **ALPM\_PKG\_REASON\_DEPEND** = 1, **ALPM\_PKG\_REASON\_UNKNOWN** = 2 }\
 Package install reasons.  enum **alpm\_pkgfrom\_t** { **ALPM\_PKG\_FROM\_FILE** = 1, **ALPM\_PKG\_FROM\_LOCALDB**, **ALPM\_PKG\_FROM\_SYNCDB** }\
 Location a package object was loaded from.  enum **alpm\_pkgvalidation\_t** { **ALPM\_PKG\_VALIDATION\_UNKNOWN** = 0, **ALPM\_PKG\_VALIDATION\_NONE** = (1 \<\< 0), **ALPM\_PKG\_VALIDATION\_MD5SUM** = (1 \<\< 1), **ALPM\_PKG\_VALIDATION\_SHA256SUM** = (1 \<\< 2), **ALPM\_PKG\_VALIDATION\_SIGNATURE** = (1 \<\< 3) }\
 Method used to validate a package.

### Functions

int **alpm\_pkg\_load** (**alpm\_handle\_t** \*handle, const char \*filename, int full, int level, **alpm\_pkg\_t** \*\*pkg)\
 Create a package from a file.  int **alpm\_fetch\_pkgurl** (**alpm\_handle\_t** \*handle, const **alpm\_list\_t** \*urls, **alpm\_list\_t** \*\*fetched)\
 Fetch a list of remote packages.  **alpm\_pkg\_t** \* **alpm\_pkg\_find** (**alpm\_list\_t** \*haystack, const char \*needle)\
 Find a package in a list by name.  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.  **alpm\_list\_t** \* **alpm\_pkg\_compute\_optionalfor** (**alpm\_pkg\_t** \*pkg)\
 Computes the list of packages optionally requiring a given package.  int **alpm\_pkg\_should\_ignore** (**alpm\_handle\_t** \*handle, **alpm\_pkg\_t** \*pkg)\
 Test if a package should be ignored.

### 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.

For loaded packages, they will be freed when **alpm\_pkg\_free** is called. For database packages, they will be freed when the database is unregistered.  **alpm\_handle\_t** \* **alpm\_pkg\_get\_handle** (**alpm\_pkg\_t** \*pkg)\
 Gets the handle of a package.  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\_base** (**alpm\_pkg\_t** \*pkg)\
 Returns the package base name.  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\_checkdepends** (**alpm\_pkg\_t** \*pkg)\
 Returns a list of package check dependencies.  **alpm\_list\_t** \* **alpm\_pkg\_get\_makedepends** (**alpm\_pkg\_t** \*pkg)\
 Returns a list of package make 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\_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)\
 Returns the base64 encoded package signature.  int **alpm\_pkg\_get\_sig** (**alpm\_pkg\_t** \*pkg, unsigned char \*\*sig, size\_t \*sig\_len)\
 Extracts package signature either from embedded package signature or if it is absent then reads data from detached signature file.  int **alpm\_pkg\_get\_validation** (**alpm\_pkg\_t** \*pkg)\
 Returns the method used to validate a package during install.  **alpm\_list\_t** \* **alpm\_pkg\_get\_xdata** (**alpm\_pkg\_t** \*pkg)\
 Gets the extended data field of a package.  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 the files that will be downloaded to install a package.  int **alpm\_pkg\_set\_reason** (**alpm\_pkg\_t** \*pkg, **alpm\_pkgreason\_t** reason)\
 Set install reason for a package in the local database.

### Changelog functions

Functions for reading the changelog  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.

### Mtree functions

Functions for reading the mtree  struct archive \* **alpm\_pkg\_mtree\_open** (**alpm\_pkg\_t** \*pkg)\
 Open a package mtree file for reading.  int **alpm\_pkg\_mtree\_next** (const **alpm\_pkg\_t** \*pkg, struct archive \*archive, struct archive\_entry \*\*entry)\
 Read next entry from a package mtree file.  int **alpm\_pkg\_mtree\_close** (const **alpm\_pkg\_t** \*pkg, struct archive \*archive)\
 Close a package mtree file.

## Detailed Description

Functions to manipulate libalpm packages

## Data Structure Documentation

## struct alpm\_pkg\_xdata\_t

The extended data type used to store non-standard package data fields.

**Data Fields:**

char \* *name* \

char \* *value* \

## Typedef Documentation

### typedef struct \_alpm\_pkg\_t alpm\_pkg\_t

A package. A package can be loaded from disk via **alpm\_pkg\_load** or retrieved from a database. Packages from databases are automatically freed when the database is unregistered. Packages loaded from a file must be freed manually.

Packages can then be queried for metadata or added to a transaction to be added or removed from the system.

## Enumeration Type Documentation

### enum alpm\_pkgfrom\_t

Location a package object was loaded from.

**Enumerator**

- ***ALPM\_PKG\_FROM\_FILE***

  Loaded from a file via **alpm\_pkg\_load**.

- ***ALPM\_PKG\_FROM\_LOCALDB***

  From the local database.

- ***ALPM\_PKG\_FROM\_SYNCDB***

  From a sync database.

### enum alpm\_pkgreason\_t

Package install reasons.

**Enumerator**

- ***ALPM\_PKG\_REASON\_EXPLICIT***

  Explicitly requested by the user.

- ***ALPM\_PKG\_REASON\_DEPEND***

  Installed as a dependency for another package.

- ***ALPM\_PKG\_REASON\_UNKNOWN***

  Failed parsing of local database.

### enum alpm\_pkgvalidation\_t

Method used to validate a package.

**Enumerator**

- ***ALPM\_PKG\_VALIDATION\_UNKNOWN***

  The package's validation type is unknown.

- ***ALPM\_PKG\_VALIDATION\_NONE***

  The package does not have any validation.

- ***ALPM\_PKG\_VALIDATION\_MD5SUM***

  The package is validated with md5.

- ***ALPM\_PKG\_VALIDATION\_SHA256SUM***

  The package is validated with sha256.

- ***ALPM\_PKG\_VALIDATION\_SIGNATURE***

  The package is validated with a PGP signature.

## Function Documentation

### int alpm\_fetch\_pkgurl (alpm\_handle\_t \* handle, const alpm\_list\_t \* urls, alpm\_list\_t \*\* fetched)

Fetch a list of remote packages.

**Parameters**

*handle* the context handle \
 *urls* list of package URLs to download \
 *fetched* list of filepaths to the fetched packages, each item corresponds to one in urls list. This is an output parameter, the caller should provide a pointer to an empty list (\*fetched === NULL) and the callee fills the list with data.

**Returns**

0 on success or -1 on failure

References **alpm\_fetch\_pkgurl()**.

Referenced by **alpm\_fetch\_pkgurl()**.

### int alpm\_pkg\_changelog\_close (const alpm\_pkg\_t \* pkg, void \* fp)

Close a package changelog for reading.

**Parameters**

*pkg* the package to close the changelog of (either file or db) \
 *fp* the 'file stream' to the package changelog to close

**Returns**

0 on success, -1 on error

References **alpm\_pkg\_changelog\_close()**.

Referenced by **alpm\_pkg\_changelog\_close()**.

### 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.

**Parameters**

*pkg* the package to read the changelog of (either file or db)

**Returns**

a 'file stream' to the package changelog

References **alpm\_pkg\_changelog\_open()**.

Referenced by **alpm\_pkg\_changelog\_open()**.

### 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**

*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

**Returns**

the number of characters read, or 0 if there is no more data or an error occurred.

References **alpm\_pkg\_changelog\_read()**.

Referenced by **alpm\_pkg\_changelog\_read()**.

### int alpm\_pkg\_checkmd5sum (alpm\_pkg\_t \* pkg)

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

**Parameters**

*pkg* package pointer

**Returns**

0 on success, -1 on error (pm\_errno is set accordingly)

References **alpm\_pkg\_checkmd5sum()**.

Referenced by **alpm\_pkg\_checkmd5sum()**.

### alpm\_list\_t \* alpm\_pkg\_compute\_optionalfor (alpm\_pkg\_t \* pkg)

Computes the list of packages optionally 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**

*pkg* a package

**Returns**

the list of packages optionally requiring pkg

References **alpm\_pkg\_compute\_optionalfor()**.

Referenced by **alpm\_pkg\_compute\_optionalfor()**.

### 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.

**Parameters**

*pkg* a package

**Returns**

the list of packages requiring pkg

References **alpm\_pkg\_compute\_requiredby()**.

Referenced by **alpm\_pkg\_compute\_requiredby()**.

### off\_t alpm\_pkg\_download\_size (alpm\_pkg\_t \* newpkg)

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

**Parameters**

*newpkg* the new package to upgrade to

**Returns**

the size of the download

References **alpm\_pkg\_download\_size()**.

Referenced by **alpm\_pkg\_download\_size()**.

### alpm\_pkg\_t \* alpm\_pkg\_find (alpm\_list\_t \* haystack, const char \* needle)

Find a package in a list by name.

**Parameters**

*haystack* a list of **alpm\_pkg\_t** \
 *needle* the package name

**Returns**

a pointer to the package if found or NULL

References **alpm\_pkg\_find()**.

Referenced by **alpm\_pkg\_find()**.

### int alpm\_pkg\_free (alpm\_pkg\_t \* pkg)

Free a package. Only packages loaded with **alpm\_pkg\_load** can be freed. Packages from databases will be freed by libalpm when they are unregistered.

**Parameters**

*pkg* package pointer to free

**Returns**

0 on success, -1 on error (pm\_errno is set accordingly)

References **alpm\_pkg\_free()**.

Referenced by **alpm\_pkg\_free()**.

### const char \* alpm\_pkg\_get\_arch (alpm\_pkg\_t \* pkg)

Returns the architecture for which the package was built.

**Parameters**

*pkg* a pointer to package

**Returns**

a reference to an internal string

References **alpm\_pkg\_get\_arch()**.

Referenced by **alpm\_pkg\_get\_arch()**.

### alpm\_list\_t \* alpm\_pkg\_get\_backup (alpm\_pkg\_t \* pkg)

Returns the list of files backed up when installing pkg.

**Parameters**

*pkg* a pointer to package

**Returns**

a reference to a list of **alpm\_backup\_t** objects

References **alpm\_pkg\_get\_backup()**.

Referenced by **alpm\_pkg\_get\_backup()**.

### const char \* alpm\_pkg\_get\_base (alpm\_pkg\_t \* pkg)

Returns the package base name.

**Parameters**

*pkg* a pointer to package

**Returns**

a reference to an internal string

References **alpm\_pkg\_get\_base()**.

Referenced by **alpm\_pkg\_get\_base()**.

### const char \* alpm\_pkg\_get\_base64\_sig (alpm\_pkg\_t \* pkg)

Returns the base64 encoded package signature.

**Parameters**

*pkg* a pointer to package

**Returns**

a reference to an internal string

References **alpm\_pkg\_get\_base64\_sig()**.

Referenced by **alpm\_pkg\_get\_base64\_sig()**.

### alpm\_time\_t alpm\_pkg\_get\_builddate (alpm\_pkg\_t \* pkg)

Returns the build timestamp of the package.

**Parameters**

*pkg* a pointer to package

**Returns**

the timestamp of the build time

References **alpm\_pkg\_get\_builddate()**.

Referenced by **alpm\_pkg\_get\_builddate()**.

### alpm\_list\_t \* alpm\_pkg\_get\_checkdepends (alpm\_pkg\_t \* pkg)

Returns a list of package check dependencies.

**Parameters**

*pkg* a pointer to package

**Returns**

a reference to an internal list of **alpm\_depend\_t** structures.

References **alpm\_pkg\_get\_checkdepends()**.

Referenced by **alpm\_pkg\_get\_checkdepends()**.

### alpm\_list\_t \* alpm\_pkg\_get\_conflicts (alpm\_pkg\_t \* pkg)

Returns the list of packages conflicting with pkg.

**Parameters**

*pkg* a pointer to package

**Returns**

a reference to an internal list of **alpm\_depend\_t** structures.

References **alpm\_pkg\_get\_conflicts()**.

Referenced by **alpm\_pkg\_get\_conflicts()**.

### 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.

**Parameters**

*pkg* a pointer to package

**Returns**

a pointer to the DB containing pkg, or NULL.

References **alpm\_pkg\_get\_db()**.

Referenced by **alpm\_pkg\_get\_db()**.

### alpm\_list\_t \* alpm\_pkg\_get\_depends (alpm\_pkg\_t \* pkg)

Returns the list of package dependencies as **alpm\_depend\_t**.

**Parameters**

*pkg* a pointer to package

**Returns**

a reference to an internal list of **alpm\_depend\_t** structures.

References **alpm\_pkg\_get\_depends()**.

Referenced by **alpm\_pkg\_get\_depends()**.

### const char \* alpm\_pkg\_get\_desc (alpm\_pkg\_t \* pkg)

Returns the package description.

**Parameters**

*pkg* a pointer to package

**Returns**

a reference to an internal string

References **alpm\_pkg\_get\_desc()**.

Referenced by **alpm\_pkg\_get\_desc()**.

### const char \* alpm\_pkg\_get\_filename (alpm\_pkg\_t \* pkg)

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

**Parameters**

*pkg* a pointer to package

**Returns**

a reference to an internal string

References **alpm\_pkg\_get\_filename()**.

Referenced by **alpm\_pkg\_get\_filename()**.

### 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.

**Parameters**

*pkg* a pointer to package

**Returns**

a pointer to a filelist object containing a count and an array of package file objects

References **alpm\_pkg\_get\_files()**.

Referenced by **alpm\_pkg\_get\_files()**.

### alpm\_list\_t \* alpm\_pkg\_get\_groups (alpm\_pkg\_t \* pkg)

Returns the list of package groups.

**Parameters**

*pkg* a pointer to package

**Returns**

a pointer to an internal list of strings.

References **alpm\_pkg\_get\_groups()**.

Referenced by **alpm\_pkg\_get\_groups()**.

### alpm\_handle\_t \* alpm\_pkg\_get\_handle (alpm\_pkg\_t \* pkg)

Gets the handle of a package.

**Parameters**

*pkg* a pointer to package

**Returns**

the alpm handle that the package belongs to

References **alpm\_pkg\_get\_handle()**.

Referenced by **alpm\_pkg\_get\_handle()**.

### alpm\_time\_t alpm\_pkg\_get\_installdate (alpm\_pkg\_t \* pkg)

Returns the install timestamp of the package.

**Parameters**

*pkg* a pointer to package

**Returns**

the timestamp of the install time

References **alpm\_pkg\_get\_installdate()**.

Referenced by **alpm\_pkg\_get\_installdate()**.

### off\_t alpm\_pkg\_get\_isize (alpm\_pkg\_t \* pkg)

Returns the installed size of the package.

**Parameters**

*pkg* a pointer to package

**Returns**

the total size of files installed by the package.

References **alpm\_pkg\_get\_isize()**.

Referenced by **alpm\_pkg\_get\_isize()**.

### alpm\_list\_t \* alpm\_pkg\_get\_licenses (alpm\_pkg\_t \* pkg)

Returns the list of package licenses.

**Parameters**

*pkg* a pointer to package

**Returns**

a pointer to an internal list of strings.

References **alpm\_pkg\_get\_licenses()**.

Referenced by **alpm\_pkg\_get\_licenses()**.

### alpm\_list\_t \* alpm\_pkg\_get\_makedepends (alpm\_pkg\_t \* pkg)

Returns a list of package make dependencies.

**Parameters**

*pkg* a pointer to package

**Returns**

a reference to an internal list of **alpm\_depend\_t** structures.

References **alpm\_pkg\_get\_makedepends()**.

Referenced by **alpm\_pkg\_get\_makedepends()**.

### 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**

*pkg* a pointer to package

**Returns**

a reference to an internal string

References **alpm\_pkg\_get\_md5sum()**.

Referenced by **alpm\_pkg\_get\_md5sum()**.

### const char \* alpm\_pkg\_get\_name (alpm\_pkg\_t \* pkg)

Returns the package name.

**Parameters**

*pkg* a pointer to package

**Returns**

a reference to an internal string

References **alpm\_pkg\_get\_name()**.

Referenced by **alpm\_pkg\_get\_name()**.

### alpm\_list\_t \* alpm\_pkg\_get\_optdepends (alpm\_pkg\_t \* pkg)

Returns the list of package optional dependencies.

**Parameters**

*pkg* a pointer to package

**Returns**

a reference to an internal list of **alpm\_depend\_t** structures.

References **alpm\_pkg\_get\_optdepends()**.

Referenced by **alpm\_pkg\_get\_optdepends()**.

### alpm\_pkgfrom\_t alpm\_pkg\_get\_origin (alpm\_pkg\_t \* pkg)

Returns the origin of the package.

**Returns**

an **alpm\_pkgfrom\_t** constant, -1 on error

References **alpm\_pkg\_get\_origin()**.

Referenced by **alpm\_pkg\_get\_origin()**.

### const char \* alpm\_pkg\_get\_packager (alpm\_pkg\_t \* pkg)

Returns the packager's name.

**Parameters**

*pkg* a pointer to package

**Returns**

a reference to an internal string

References **alpm\_pkg\_get\_packager()**.

Referenced by **alpm\_pkg\_get\_packager()**.

### alpm\_list\_t \* alpm\_pkg\_get\_provides (alpm\_pkg\_t \* pkg)

Returns the list of packages provided by pkg.

**Parameters**

*pkg* a pointer to package

**Returns**

a reference to an internal list of **alpm\_depend\_t** structures.

References **alpm\_pkg\_get\_provides()**.

Referenced by **alpm\_pkg\_get\_provides()**.

### alpm\_pkgreason\_t alpm\_pkg\_get\_reason (alpm\_pkg\_t \* pkg)

Returns the package installation reason.

**Parameters**

*pkg* a pointer to package

**Returns**

an enum member giving the install reason.

References **alpm\_pkg\_get\_reason()**.

Referenced by **alpm\_pkg\_get\_reason()**.

### alpm\_list\_t \* alpm\_pkg\_get\_replaces (alpm\_pkg\_t \* pkg)

Returns the list of packages to be replaced by pkg.

**Parameters**

*pkg* a pointer to package

**Returns**

a reference to an internal list of **alpm\_depend\_t** structures.

References **alpm\_pkg\_get\_replaces()**.

Referenced by **alpm\_pkg\_get\_replaces()**.

### 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**

*pkg* a pointer to package

**Returns**

a reference to an internal string

References **alpm\_pkg\_get\_sha256sum()**.

Referenced by **alpm\_pkg\_get\_sha256sum()**.

### int alpm\_pkg\_get\_sig (alpm\_pkg\_t \* pkg, unsigned char \*\* sig, size\_t \* sig\_len)

Extracts package signature either from embedded package signature or if it is absent then reads data from detached signature file.

**Parameters**

*pkg* a pointer to package. \
 *sig* output parameter for signature data. Callee function allocates a buffer needed for the signature data. Caller is responsible for freeing this buffer. \
 *sig\_len* output parameter for the signature data length.

**Returns**

0 on success, negative number on error.

References **alpm\_pkg\_get\_sig()**.

Referenced by **alpm\_pkg\_get\_sig()**.

### 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**

*pkg* a pointer to package

**Returns**

the size of the package in bytes.

References **alpm\_pkg\_get\_size()**.

Referenced by **alpm\_pkg\_get\_size()**.

### const char \* alpm\_pkg\_get\_url (alpm\_pkg\_t \* pkg)

Returns the package URL.

**Parameters**

*pkg* a pointer to package

**Returns**

a reference to an internal string

References **alpm\_pkg\_get\_url()**.

Referenced by **alpm\_pkg\_get\_url()**.

### int alpm\_pkg\_get\_validation (alpm\_pkg\_t \* pkg)

Returns the method used to validate a package during install.

**Parameters**

*pkg* a pointer to package

**Returns**

an enum member giving the validation method

References **alpm\_pkg\_get\_validation()**.

Referenced by **alpm\_pkg\_get\_validation()**.

### 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**

*pkg* a pointer to package

**Returns**

a reference to an internal string

References **alpm\_pkg\_get\_version()**.

Referenced by **alpm\_pkg\_get\_version()**.

### alpm\_list\_t \* alpm\_pkg\_get\_xdata (alpm\_pkg\_t \* pkg)

Gets the extended data field of a package.

**Parameters**

*pkg* a pointer to package

**Returns**

a reference to a list of **alpm\_pkg\_xdata\_t** objects

References **alpm\_pkg\_get\_xdata()**.

Referenced by **alpm\_pkg\_get\_xdata()**.

### int alpm\_pkg\_has\_scriptlet (alpm\_pkg\_t \* pkg)

Returns whether the package has an install scriptlet.

**Returns**

0 if FALSE, TRUE otherwise

References **alpm\_pkg\_has\_scriptlet()**.

Referenced by **alpm\_pkg\_has\_scriptlet()**.

### int alpm\_pkg\_load (alpm\_handle\_t \* handle, const char \* filename, int full, int 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**

*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

**Returns**

0 on success, -1 on error (pm\_errno is set accordingly)

References **alpm\_pkg\_load()**.

Referenced by **alpm\_pkg\_load()**.

### int alpm\_pkg\_mtree\_close (const alpm\_pkg\_t \* pkg, struct archive \* archive)

Close a package mtree file.

**Parameters**

*pkg* the local package to close the mtree of \
 *archive* the archive to close

References **alpm\_pkg\_mtree\_close()**.

Referenced by **alpm\_pkg\_mtree\_close()**.

### int alpm\_pkg\_mtree\_next (const alpm\_pkg\_t \* pkg, struct archive \* archive, struct archive\_entry \*\* entry)

Read next entry from a package mtree file.

**Parameters**

*pkg* the package that the mtree file is being read from \
 *archive* the archive structure reading from the mtree file \
 *entry* an archive\_entry to store the entry header information

**Returns**

0 on success, 1 if end of archive is reached, -1 otherwise.

References **alpm\_pkg\_mtree\_next()**.

Referenced by **alpm\_pkg\_mtree\_next()**.

### struct archive \* alpm\_pkg\_mtree\_open (alpm\_pkg\_t \* pkg)

Open a package mtree file for reading.

**Parameters**

*pkg* the local package to read the mtree of

**Returns**

an archive structure for the package mtree file

References **alpm\_pkg\_mtree\_open()**.

Referenced by **alpm\_pkg\_mtree\_open()**.

### int alpm\_pkg\_set\_reason (alpm\_pkg\_t \* pkg, alpm\_pkgreason\_t reason)

Set install reason for a package in the local database. The provided package object must be from the local database or this method will fail. The write to the local database is performed immediately.

**Parameters**

*pkg* the package to update \
 *reason* the new install reason

**Returns**

0 on success, -1 on error (pm\_errno is set accordingly)

References **alpm\_pkg\_set\_reason()**.

Referenced by **alpm\_pkg\_set\_reason()**.

### int alpm\_pkg\_should\_ignore (alpm\_handle\_t \* handle, alpm\_pkg\_t \* pkg)

Test if a package should be ignored. Checks if the package is ignored via IgnorePkg, or if the package is in a group ignored via IgnoreGroup.

**Parameters**

*handle* the context handle \
 *pkg* the package to test

**Returns**

1 if the package should be ignored, 0 otherwise

References **alpm\_pkg\_should\_ignore()**.

Referenced by **alpm\_pkg\_should\_ignore()**.

### 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.

References **alpm\_pkg\_vercmp()**.

Referenced by **alpm\_pkg\_vercmp()**.

## Author

Generated automatically by Doxygen for libalpm from the source code.
