---
name: "libalpm_trans"
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_trans"
---

# libalpm\_trans(3)

Transaction - Functions to manipulate libalpm transactions

## NAME

libalpm\_trans - Transaction

 \- Functions to manipulate libalpm transactions

## SYNOPSIS

### Enumerations

enum **alpm\_transflag\_t** { **ALPM\_TRANS\_FLAG\_NODEPS** = 1, **ALPM\_TRANS\_FLAG\_NOSAVE** = (1 \<\< 2), **ALPM\_TRANS\_FLAG\_NODEPVERSION** = (1 \<\< 3), **ALPM\_TRANS\_FLAG\_CASCADE** = (1 \<\< 4), **ALPM\_TRANS\_FLAG\_RECURSE** = (1 \<\< 5), **ALPM\_TRANS\_FLAG\_DBONLY** = (1 \<\< 6), **ALPM\_TRANS\_FLAG\_NOHOOKS** = (1 \<\< 7), **ALPM\_TRANS\_FLAG\_ALLDEPS** = (1 \<\< 8), **ALPM\_TRANS\_FLAG\_DOWNLOADONLY** = (1 \<\< 9), **ALPM\_TRANS\_FLAG\_NOSCRIPTLET** = (1 \<\< 10), **ALPM\_TRANS\_FLAG\_NOCONFLICTS** = (1 \<\< 11), **ALPM\_TRANS\_FLAG\_NEEDED** = (1 \<\< 13), **ALPM\_TRANS\_FLAG\_ALLEXPLICIT** = (1 \<\< 14), **ALPM\_TRANS\_FLAG\_UNNEEDED** = (1 \<\< 15), **ALPM\_TRANS\_FLAG\_RECURSEALL** = (1 \<\< 16), **ALPM\_TRANS\_FLAG\_NOLOCK** = (1 \<\< 17) }\
 Transaction flags.

### Functions

int **alpm\_trans\_get\_flags** (**alpm\_handle\_t** \*handle)\
 Returns the bitfield of flags for the current transaction.  **alpm\_list\_t** \* **alpm\_trans\_get\_add** (**alpm\_handle\_t** \*handle)\
 Returns a list of packages added by the transaction.  **alpm\_list\_t** \* **alpm\_trans\_get\_remove** (**alpm\_handle\_t** \*handle)\
 Returns the list of packages removed by the transaction.  int **alpm\_trans\_init** (**alpm\_handle\_t** \*handle, int flags)\
 Initialize the transaction.  int **alpm\_trans\_prepare** (**alpm\_handle\_t** \*handle, **alpm\_list\_t** \*\*data)\
 Prepare a transaction.  int **alpm\_trans\_commit** (**alpm\_handle\_t** \*handle, **alpm\_list\_t** \*\*data)\
 Commit a transaction.  int **alpm\_trans\_interrupt** (**alpm\_handle\_t** \*handle)\
 Interrupt a transaction.  int **alpm\_trans\_release** (**alpm\_handle\_t** \*handle)\
 Release a transaction.

### Add/Remove packages

These functions remove/add packages to the transactions  int **alpm\_sync\_sysupgrade** (**alpm\_handle\_t** \*handle, int enable\_downgrade)\
 Search for packages to upgrade and add them to the transaction.  int **alpm\_add\_pkg** (**alpm\_handle\_t** \*handle, **alpm\_pkg\_t** \*pkg)\
 Add a package to the transaction.  int **alpm\_remove\_pkg** (**alpm\_handle\_t** \*handle, **alpm\_pkg\_t** \*pkg)\
 Add a package removal to the transaction.

## Detailed Description

Functions to manipulate libalpm transactions

Transactions are the way to add/remove packages to/from the system. Only one transaction can exist at a time.

The basic workflow of a transaction is to:

- •

  Initialize with **alpm\_trans\_init**

- •

  Choose which packages to add with **alpm\_add\_pkg** and **alpm\_remove\_pkg**

- •

  Prepare the transaction with **alpm\_trans\_prepare**

- •

  Commit the transaction with **alpm\_trans\_commit**

- •

  Release the transaction with **alpm\_trans\_release**

A transaction can be released at any time. A transaction does not have to be committed.

## Enumeration Type Documentation

### enum alpm\_transflag\_t

Transaction flags.

**Enumerator**

- ***ALPM\_TRANS\_FLAG\_NODEPS***

  Ignore dependency checks.

- ***ALPM\_TRANS\_FLAG\_NOSAVE***

  Delete files even if they are tagged as backup.

- ***ALPM\_TRANS\_FLAG\_NODEPVERSION***

  Ignore version numbers when checking dependencies.

- ***ALPM\_TRANS\_FLAG\_CASCADE***

  Remove also any packages depending on a package being removed.

- ***ALPM\_TRANS\_FLAG\_RECURSE***

  Remove packages and their unneeded deps (not explicitly installed).

- ***ALPM\_TRANS\_FLAG\_DBONLY***

  Modify database but do not commit changes to the filesystem.

- ***ALPM\_TRANS\_FLAG\_NOHOOKS***

  Do not run hooks during a transaction.

- ***ALPM\_TRANS\_FLAG\_ALLDEPS***

  Use ALPM\_PKG\_REASON\_DEPEND when installing packages.

- ***ALPM\_TRANS\_FLAG\_DOWNLOADONLY***

  Only download packages and do not actually install.

- ***ALPM\_TRANS\_FLAG\_NOSCRIPTLET***

  Do not execute install scriptlets after installing.

- ***ALPM\_TRANS\_FLAG\_NOCONFLICTS***

  Ignore dependency conflicts.

- ***ALPM\_TRANS\_FLAG\_NEEDED***

  Do not install a package if it is already installed and up to date.

- ***ALPM\_TRANS\_FLAG\_ALLEXPLICIT***

  Use ALPM\_PKG\_REASON\_EXPLICIT when installing packages.

- ***ALPM\_TRANS\_FLAG\_UNNEEDED***

  Do not remove a package if it is needed by another one.

- ***ALPM\_TRANS\_FLAG\_RECURSEALL***

  Remove also explicitly installed unneeded deps (use with ALPM\_TRANS\_FLAG\_RECURSE).

- ***ALPM\_TRANS\_FLAG\_NOLOCK***

  Do not lock the database during the operation.

## Function Documentation

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

Add a package to the transaction. If the package was loaded by **alpm\_pkg\_load()**, it will be freed upon **alpm\_trans\_release** invocation.

**Parameters**

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

**Returns**

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

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

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

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

Add a package removal to the transaction.

**Parameters**

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

**Returns**

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

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

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

### int alpm\_sync\_sysupgrade (alpm\_handle\_t \* handle, int enable\_downgrade)

Search for packages to upgrade and add them to the transaction.

**Parameters**

*handle* the context handle \
 *enable\_downgrade* allow downgrading of packages if the remote version is lower

**Returns**

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

References **alpm\_sync\_sysupgrade()**.

Referenced by **alpm\_sync\_sysupgrade()**.

### int alpm\_trans\_commit (alpm\_handle\_t \* handle, alpm\_list\_t \*\* data)

Commit a transaction.

**Parameters**

*handle* the context handle \
 *data* the address of an alpm\_list where detailed description of an error can be dumped (i.e. list of conflicting files)

**Returns**

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

References **alpm\_trans\_commit()**.

Referenced by **alpm\_trans\_commit()**.

### alpm\_list\_t \* alpm\_trans\_get\_add (alpm\_handle\_t \* handle)

Returns a list of packages added by the transaction.

**Parameters**

*handle* the context handle

**Returns**

a list of **alpm\_pkg\_t** structures

References **alpm\_trans\_get\_add()**.

Referenced by **alpm\_trans\_get\_add()**.

### int alpm\_trans\_get\_flags (alpm\_handle\_t \* handle)

Returns the bitfield of flags for the current transaction.

**Parameters**

*handle* the context handle

**Returns**

the bitfield of transaction flags

References **alpm\_trans\_get\_flags()**.

Referenced by **alpm\_trans\_get\_flags()**.

### alpm\_list\_t \* alpm\_trans\_get\_remove (alpm\_handle\_t \* handle)

Returns the list of packages removed by the transaction.

**Parameters**

*handle* the context handle

**Returns**

a list of **alpm\_pkg\_t** structures

References **alpm\_trans\_get\_remove()**.

Referenced by **alpm\_trans\_get\_remove()**.

### int alpm\_trans\_init (alpm\_handle\_t \* handle, int flags)

Initialize the transaction.

**Parameters**

*handle* the context handle \
 *flags* flags of the transaction (like nodeps, etc; see **alpm\_transflag\_t**)

**Returns**

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

References **alpm\_trans\_init()**.

Referenced by **alpm\_trans\_init()**.

### int alpm\_trans\_interrupt (alpm\_handle\_t \* handle)

Interrupt a transaction.

**Parameters**

*handle* the context handle

**Returns**

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

References **alpm\_trans\_interrupt()**.

Referenced by **alpm\_trans\_interrupt()**.

### int alpm\_trans\_prepare (alpm\_handle\_t \* handle, alpm\_list\_t \*\* data)

Prepare a transaction.

**Parameters**

*handle* the context handle \
 *data* the address of an alpm\_list where a list of **alpm\_depmissing\_t** objects is dumped (conflicting packages)

**Returns**

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

References **alpm\_trans\_prepare()**.

Referenced by **alpm\_trans\_prepare()**.

### int alpm\_trans\_release (alpm\_handle\_t \* handle)

Release a transaction.

**Parameters**

*handle* the context handle

**Returns**

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

References **alpm\_trans\_release()**.

Referenced by **alpm\_trans\_release()**.

## Author

Generated automatically by Doxygen for libalpm from the source code.
