# lib/transaction.c File Reference

`#include "system.h"`
`#include <rpmio.h>`
`#include <rpmmacro.h>`
`#include <rpmtag.h>`
`#include "rpmcli.h"`
`#include "fsm.h"`
`#include "psm.h"`
`#include "rpmdb.h"`
`#include "rpmds.h"`
`#include "rpmlock.h"`
`#include "cpio.h"`
`#include "fprint.h"`
`#include "legacy.h"`
`#include "misc.h"`
`#include "debug.h"`

Include dependency graph for transaction.c:

Go to the source code of this file.

## Defines

#define | _RPMFI_INTERNAL
#define | _RPMTE_INTERNAL
#define | _RPMTS_INTERNAL
#define | _RPMSQ_INTERNAL
#define | _RPMDB_INTERNAL
#define | ISROOT(_d) (((_d)[0] == '/' && (_d)[1] == '\0') ? "" : (_d))
#define | NOTIFY(_ts, _al) /*@i@*/ if ((_ts)->notify) (void) (_ts)->notify _al

## Functions

static int | sharedCmp (const void *one, const void *two)
static int | handleInstInstalledFiles (const rpmts ts, rpmte p, rpmfi fi, sharedFileInfo shared, int sharedCount, int reportConflicts)
static int | handleRmvdInstalledFiles (const rpmts ts, rpmfi fi, sharedFileInfo shared, int sharedCount)
static int | fpsCompare (const void *one, const void *two)
static int | findFps (const struct fingerPrint_s *fiFps, const struct fingerPrint_s *otherFps, int otherFc)
static void | handleOverlappedFiles (const rpmts ts, const rpmte p, rpmfi fi)
| Update disk space needs on each partition for this package's files.
static int | ensureOlder (rpmts ts, const rpmte p, const Header h)
| Ensure that current package is newer than installed package.
static void | skipFiles (const rpmts ts, rpmfi fi)
| Skip any files that do not match install policies.
static rpmfi | rpmtsiFi (const rpmtsi tsi)
| Return transaction element's file info.
static rpmRC | _processFailedPackage (rpmts ts, rpmte p)
| Force add a failed package into the rpmdb.
rpmRC | rpmtsRollback (rpmts rbts, rpmprobFilterFlags ignoreSet, int running, rpmte rbte)
| Rollback a failed transaction.
static int | cmpArgvStr (const char **AV, const char *B)
| Search for string B in argv array AV.
static int | markLinkedFailed (rpmts ts, rpmte p)
| Mark all erasure elements linked to installed element p as failed.
int | rpmtsRun (rpmts ts, rpmps okProbs, rpmprobFilterFlags ignoreSet)
| Process all package elements in a transaction set.

## Variables

int | _fps_debug = 0
static int | _linear_fps_search = 0

## Detailed Description

Definition in file transaction.c.

## Define Documentation

#define _RPMDB_INTERNAL

Definition at line 20 of file transaction.c.

#define _RPMFI_INTERNAL

Definition at line 11 of file transaction.c.

#define _RPMSQ_INTERNAL

Definition at line 17 of file transaction.c.

#define _RPMTE_INTERNAL

Definition at line 12 of file transaction.c.

#define _RPMTS_INTERNAL

Definition at line 13 of file transaction.c.

#define ISROOT | ( | _d |  | ) | (((_d)[0] == '/' && (_d)[1] == '\0') ? "" : (_d))

Definition at line 268 of file transaction.c.

#define NOTIFY | ( | _ts,
|  | _al |  | ) | /*@i@*/ if ((_ts)->notify) (void) (_ts)->notify _al

Definition at line 1115 of file transaction.c.

Referenced by rpmtsRun().

## Function Documentation

static rpmRC _processFailedPackage | ( | rpmts | ts,
|  | rpmte | p |
| ) |  |  | `[static]`

Force add a failed package into the rpmdb.

Parameters:

  | ts | current transaction set
  | p | failed rpmte.

Returns:
  RPMRC_OK, or RPMRC_FAIL

Definition at line 903 of file transaction.c.

References PSM_RPMDB_ADD, rpmpsmFree(), rpmpsmNew(), rpmpsmStage(), RPMRC_OK, rpmteType(), rpmpsm_s::stepName, and TR_ADDED.

Referenced by rpmtsRollback().

static int cmpArgvStr | ( | const char ** | AV,
|  | const char * | B |
| ) |  |  | `[static]`

Search for string B in argv array AV.

Parameters:

  | AV | argv array
  | B | string

Returns:
  1 if found, 0 otherwise

Definition at line 1060 of file transaction.c.

static int ensureOlder | ( | rpmts | ts,
|  | const rpmte | p,
|  | const Header | h |
| ) |  |  | `[static]`

Ensure that current package is newer than installed package.

Parameters:

  | ts | transaction set
  | p | current transaction element
  | h | installed header

Returns:
  0 if not newer, 1 if okay

Definition at line 590 of file transaction.c.

References _free(), _rpmds_nopromote, alloca(), headerGet(), _HE_s::p, rpmDataType_u::ptr, rpmdsFree(), rpmdsNVRMatchesDep(), rpmdsSingle(), RPMPROB_OLDPACKAGE, rpmpsAppend(), rpmpsFree(), RPMSENSE_EQUAL, RPMSENSE_LESS, RPMTAG_NVRA, RPMTAG_REQUIRENAME, rpmteE(), rpmteKey(), rpmteN(), rpmteNEVR(), rpmteR(), rpmteV(), rpmtsProblems(), stpcpy(), rpmDataType_u::str, and _HE_s::tag.

Referenced by rpmtsRun().

static int findFps | ( | const struct fingerPrint_s * | fiFps,
|  | const struct fingerPrint_s * | otherFps,
|  | int | otherFc |
| ) |  |  | `[static]`

Definition at line 312 of file transaction.c.

References _linear_fps_search, FP_EQUAL, and fpsCompare().

Referenced by handleOverlappedFiles().

static int fpsCompare | ( | const void * | one,
|  | const void * | two |
| ) |  |  | `[static]`

Definition at line 273 of file transaction.c.

References alloca(), fingerPrint_s::baseName, fprintCacheEntry_s::dirName, fingerPrint_s::entry, stpcpy(), and fingerPrint_s::subDir.

Referenced by findFps().

static int handleInstInstalledFiles | ( | const rpmts | ts,
|  | rpmte | p,
|  | rpmfi | fi,
|  | sharedFileInfo | shared,
|  | int | sharedCount,
|  | int | reportConflicts |
| ) |  |  | `[static]`

Parameters:

  | ts | transaction set
  | p | current transaction element
  | fi | file info set
  | shared | shared file info
  | sharedCount | no. of shared elements
  | reportConflicts | XXX only ts->{probs,rpmdb} modified

Definition at line 79 of file transaction.c.

References _free(), alloca(), CPIO_SBIT_CHECK, FA_CREATE, FA_SKIPCOLOR, headerGet(), _HE_s::p, rpmdbFreeIterator(), RPMDBI_PACKAGES, rpmdbNextIterator(), rpmfiBN(), rpmfiCompare(), rpmfiDecideFate(), rpmfiDN(), rpmfiFColor(), rpmfiFFlags(), rpmfiFMode(), rpmfiFree(), rpmfiFSize(), rpmfiInit(), RPMFILE_CONFIG, RPMFILE_GHOST, RPMFILE_STATE_NORMAL, rpmfiNew(), rpmfiNext(), rpmfiSetFX(), RPMPROB_FILE_CONFLICT, rpmpsAppend(), rpmpsFree(), RPMTAG_BASENAMES, RPMTAG_NVRA, rpmteColor(), rpmteKey(), rpmteNEVRA(), RPMTRANS_FLAG_ALLFILES, rpmtsColor(), rpmtsFlags(), rpmtsInitIterator(), rpmtsPrefColor(), rpmtsProblems(), rpmDataType_u::str, _HE_s::tag, xcalloc(), and xrealloc().

Referenced by rpmtsRun().

static void handleOverlappedFiles | ( | const rpmts | ts,
|  | const rpmte | p,
|  | rpmfi | fi |
| ) |  |  | `[static]`

Update disk space needs on each partition for this package's files.

Definition at line 360 of file transaction.c.

References _free(), fprintCacheEntry_s::dev, dodigest(), fingerPrint_s::entry, FA_ALTNAME, FA_BACKUP, FA_CREATE, FA_ERASE, FA_SKIP, FA_SKIPCOLOR, FA_UNKNOWN, findFps(), htGetEntry(), recs, rpmfiCompare(), rpmfiDigest(), rpmfiFC(), rpmfiFColor(), rpmfiFFlags(), rpmfiFMode(), rpmfiFN(), rpmfiFSize(), rpmfiFState(), rpmfiInit(), RPMFILE_CONFIG, RPMFILE_EXISTS, RPMFILE_NOREPLACE, RPMFILE_SPARSE, RPMFILE_STATE_NORMAL, rpmfiNext(), rpmfiSetFX(), RPMPROB_FILTER_REPLACENEWFILES, RPMPROB_NEW_FILE_CONFLICT, rpmpsAppend(), rpmpsFree(), rpmteKey(), rpmteNEVR(), rpmteType(), rpmtsColor(), rpmtsFilterFlags(), rpmtsPrefColor(), rpmtsProblems(), rpmtsUpdateDSI(), TR_ADDED, TR_REMOVED, and xcalloc().

Referenced by rpmtsRun().

static int handleRmvdInstalledFiles | ( | const rpmts | ts,
|  | rpmfi | fi,
|  | sharedFileInfo | shared,
|  | int | sharedCount |
| ) |  |  | `[static]`

Definition at line 226 of file transaction.c.

References _free(), alloca(), FA_SKIP, headerGet(), _HE_s::p, rpmDataType_u::ptr, rpmdbFreeIterator(), RPMDBI_PACKAGES, rpmdbNextIterator(), RPMFILE_STATE_NORMAL, RPMTAG_FILESTATES, rpmtsInitIterator(), and _HE_s::tag.

Referenced by rpmtsRun().

static int markLinkedFailed | ( | rpmts | ts,
|  | rpmte | p |
| ) |  |  | `[static]`

Mark all erasure elements linked to installed element p as failed.

Parameters:

  | ts | transaction set
  | p | failed install transaction element

Returns:
  0 always

Definition at line 1080 of file transaction.c.

References cmpArgvStr(), rpmtsiFree, rpmtsiInit, rpmtsiNext(), and TR_REMOVED.

Referenced by rpmtsRun().

static rpmfi rpmtsiFi | ( | const rpmtsi | tsi | ) | `[static]`

Return transaction element's file info.

Todo:
  Take a rpmfi refcount here.

Parameters:

  | tsi | transaction element iterator

Returns:
  transaction element file info

Definition at line 877 of file transaction.c.

References rpmtsElement().

Referenced by rpmtsRun().

static int sharedCmp | ( | const void * | one,
|  | const void * | two |
| ) |  |  | `[static]`

Definition at line 55 of file transaction.c.

Referenced by rpmtsRun().

static void skipFiles | ( | const rpmts | ts,
|  | rpmfi | fi |
| ) |  |  | `[static]`

Skip any files that do not match install policies.

Parameters:

  | ts | transaction set
  | fi | file info set

Definition at line 645 of file transaction.c.

References _free(), alloca(), D_, FA_SKIPCOLOR, FA_SKIPNETSHARED, FA_SKIPNSTATE, freeSplitString(), lang, rpmExpand(), rpmExpandNumeric(), rpmfiBN(), rpmfiDC(), rpmfiDN(), rpmfiDX(), rpmfiFColor(), rpmfiFFlags(), rpmfiFMode(), rpmfiInit(), rpmfiInitD(), RPMFILE_CONFIG, RPMFILE_DOC, rpmfiNext(), rpmfiNextD(), rpmlog(), RPMLOG_DEBUG, RPMTRANS_FLAG_NOCONFIGS, RPMTRANS_FLAG_NODOCS, rpmtsColor(), rpmtsFlags(), and splitString().

Referenced by rpmtsRun().

## Variable Documentation

int _fps_debug = 0

Definition at line 271 of file transaction.c.

int _linear_fps_search = 0`[static]`

Definition at line 310 of file transaction.c.

Referenced by findFps().