# Command Line API.

## Files

file | rpmcli.h
file | rpmlib.h
| In Memoriam: Steve Taylor <staylor@redhat.com> was here, now he's not.

## Data Structures

struct | rpmQVKArguments_s
| Describe query/verify/signature command line operation. More...
struct | rpmBuildArguments_s
| Describe build command line request. More...
struct | rpmInstallArguments_s
| Describe database command line requests. More...
struct | rpmDatabaseArguments_s
| Describe database command line requests. More...

## RPMQV

enum | rpmQVSources_e { RPMQV_PACKAGE = 0, RPMQV_PATH, RPMQV_ALL, RPMQV_RPM, RPMQV_GROUP, RPMQV_WHATPROVIDES, RPMQV_WHATREQUIRES, RPMQV_TRIGGEREDBY, RPMQV_DBOFFSET, RPMQV_SPECFILE, RPMQV_PKGID, RPMQV_HDRID, RPMQV_FILEID, RPMQV_TID, RPMQV_HDLIST, RPMQV_FTSWALK }
| Query/Verify argument qualifiers. More...

enum

rpmQueryFlags_e {
QUERY_FOR_DEFAULT = 0, QUERY_MD5 = (1 << 0), QUERY_SIZE = (1 << 1), QUERY_LINKTO = (1 << 2),
QUERY_USER = (1 << 3), QUERY_GROUP = (1 << 4), QUERY_MTIME = (1 << 5), QUERY_MODE = (1 << 6),
QUERY_RDEV = (1 << 7), QUERY_CONTEXTS = (1 << 15), QUERY_FILES = (1 << 16), QUERY_DEPS = (1 << 17),
QUERY_SCRIPT = (1 << 18), QUERY_DIGEST = (1 << 19), QUERY_SIGNATURE = (1 << 20), QUERY_PATCHES = (1 << 21),
QUERY_HDRCHK = (1 << 22), QUERY_FOR_LIST = (1 << 23), QUERY_FOR_STATE = (1 << 24), QUERY_FOR_DOCS = (1 << 25),
QUERY_FOR_CONFIG = (1 << 26), QUERY_FOR_DUMPFILES = (1 << 27)
}

| Bit(s) to control rpmQuery() operation, stored in qva_flags. More...
rpmQueryFlags | rpmcliQueryFlags
| Bit(s) from common command line options.
struct rpmQVKArguments_s | rpmQVKArgs
struct poptOption | rpmQVSourcePoptTable []
struct poptOption | rpmQueryPoptTable []
struct poptOption | rpmVerifyPoptTable []
typedef enum rpmQVSources_e | rpmQVSources
| Query/Verify argument qualifiers.
typedef enum rpmQueryFlags_e | rpmQueryFlags
| Bit(s) to control rpmQuery() operation, stored in qva_flags.
typedef struct rpmQVKArguments_s * | QVA_t
typedef int(* | QVF_t )(QVA_t qva, rpmts ts, Header h)
| Function to display iterator matches.
typedef int(* | QSpecF_t )(rpmts ts, QVA_t qva, const char *arg)
| Function to query spec file.
int | rpmcliShowMatches (QVA_t qva, rpmts ts)
| Display query/verify information for each header in iterator.
void | rpmDisplayQueryTags (FILE *fp)
| Display list of tags that can be used in --queryformat.
int | rpmQueryVerify (QVA_t qva, rpmts ts, const char *arg)
| Common query/verify source interface, called once for each CLI arg.
int | showQueryPackage (QVA_t qva, rpmts ts, Header h)
| Display results of package query.
int | rpmcliArgIter (rpmts ts, QVA_t qva, ARGV_const_t argv)
| Iterate over query/verify arg list.
int | rpmcliQuery (rpmts ts, QVA_t qva, ARGV_const_t argv)
| Display package information.
int | showVerifyPackage (QVA_t qva, rpmts ts, Header h)
| Display results of package verify.
int | rpmcliVerify (rpmts ts, QVA_t qva, ARGV_const_t argv)
| Verify package install.

## RPMEIU

enum | rpmInstallInterfaceFlags_e { INSTALL_NONE = 0, INSTALL_PERCENT = (1 << 0), INSTALL_HASH = (1 << 1), INSTALL_NODEPS = (1 << 2), INSTALL_NOORDER = (1 << 3), INSTALL_LABEL = (1 << 4), INSTALL_UPGRADE = (1 << 5), INSTALL_FRESHEN = (1 << 6), INSTALL_INSTALL = (1 << 7), INSTALL_ERASE = (1 << 8) }
| Bit(s) to control rpmInstall() operation. More...
enum | rpmEraseInterfaceFlags_e { UNINSTALL_NONE = 0, UNINSTALL_NODEPS = (1 << 0), UNINSTALL_ALLMATCHES = (1 << 1) }
| Bit(s) to control rpmErase() operation. More...
struct rpmInstallArguments_s | rpmIArgs
struct poptOption | rpmInstallPoptTable []
int | rpmcliPackagesTotal
int | rpmcliHashesCurrent
int | rpmcliHashesTotal
int | rpmcliProgressCurrent
int | rpmcliProgressTotal
typedef enum rpmInstallInterfaceFlags_e | rpmInstallInterfaceFlags
| Bit(s) to control rpmInstall() operation.
typedef enum rpmEraseInterfaceFlags_e | rpmEraseInterfaceFlags
| Bit(s) to control rpmErase() operation.
void * | rpmShowProgress (const void *arg, const rpmCallbackType what, const rpm_loff_t amount, const rpm_loff_t total, fnpyKey key, void *data)
| The rpm CLI generic transaction callback handler.
int | rpmInstallSource (rpmts ts, const char *arg, char **specFilePtr, char **cookie)
| Install source rpm package.
int | rpmInstall (rpmts ts, struct rpmInstallArguments_s *ia, ARGV_t fileArgv)
| Install/upgrade/freshen binary rpm package.
int | rpmErase (rpmts ts, struct rpmInstallArguments_s *ia, ARGV_const_t argv)
| Erase binary rpm package.

## RPMK

enum | rpmSignFlags_e { RPMSIGN_NONE = 0, RPMSIGN_CHK_SIGNATURE = 'K', RPMSIGN_NEW_SIGNATURE = 'R', RPMSIGN_ADD_SIGNATURE = 'A', RPMSIGN_DEL_SIGNATURE = 'D', RPMSIGN_IMPORT_PUBKEY = 'I' }
| Bit(s) to control rpmReSign() operation. More...
struct poptOption | rpmSignPoptTable []
typedef enum rpmSignFlags_e | rpmSignFlags
| Bit(s) to control rpmReSign() operation.
int | rpmcliSign (rpmts ts, QVA_t qva, ARGV_const_t argv)
| Create/Modify/Check elements from signature header.

## RPMBT

struct rpmBuildArguments_s | rpmBTArgs
struct poptOption | rpmBuildPoptTable []
typedef struct rpmBuildArguments_s * | BTA_t

## RPMDB

struct rpmDatabaseArguments_s | rpmDBArgs
struct poptOption | rpmDatabasePoptTable []

## Functions

static int | checkSpec (rpmts ts, Header h)
| Parse spec file and build package.
poptContext | rpmcliInit (int argc, char *const argv[], struct poptOption *optionsTable)
| Initialize most everything needed by an rpm CLI executable context.
void | rpmcliConfigured (void)
| Make sure that rpm configuration has been read.
poptContext | rpmcliFini (poptContext optCon)
| Destroy most everything needed by an rpm CLI executable context.

## Variables

int | _noDirTokens
| Should version 3 packages be produced?
struct poptOption | rpmcliAllPoptTable []
| Popt option table for options shared by all modes and executables.

## Typedef Documentation

typedef struct rpmBuildArguments_s* BTA_t

Definition at line 334 of file rpmcli.h.

typedef int(* QSpecF_t)(rpmts ts, QVA_t qva, const char *arg)

Function to query spec file.

Parameters:

  | ts | transaction set
  | qva | parsed query/verify options
  | arg | query argument

Returns:
  0 on success

Definition at line 166 of file rpmcli.h.

typedef struct rpmQVKArguments_s* QVA_t

Definition at line 146 of file rpmcli.h.

typedef int(* QVF_t)(QVA_t qva, rpmts ts, Header h)

Function to display iterator matches.

Parameters:

  | qva | parsed query/verify options
  | ts | transaction set
  | h | header to use for query/verify

Returns:
  0 on success

Definition at line 156 of file rpmcli.h.

typedef enum rpmEraseInterfaceFlags_e rpmEraseInterfaceFlags

Bit(s) to control rpmErase() operation.

typedef enum rpmInstallInterfaceFlags_e rpmInstallInterfaceFlags

Bit(s) to control rpmInstall() operation.

typedef enum rpmQueryFlags_e rpmQueryFlags

Bit(s) to control rpmQuery() operation, stored in qva_flags.

Todo:
  Merge rpmQueryFlags, rpmVerifyFlags, and rpmVerifyAttrs?.

typedef enum rpmQVSources_e rpmQVSources

Query/Verify argument qualifiers.

Todo:
  Reassign to tag values.

typedef enum rpmSignFlags_e rpmSignFlags

Bit(s) to control rpmReSign() operation.

## Enumeration Type Documentation

enum rpmEraseInterfaceFlags_e

Bit(s) to control rpmErase() operation.

Enumerator:

  UNINSTALL_NONE |
  UNINSTALL_NODEPS | from --nodeps
  UNINSTALL_ALLMATCHES | from --allmatches

Definition at line 367 of file rpmcli.h.

enum rpmInstallInterfaceFlags_e

Bit(s) to control rpmInstall() operation.

Enumerator:

  INSTALL_NONE |
  INSTALL_PERCENT | from --percent
  INSTALL_HASH | from --hash
  INSTALL_NODEPS | from --nodeps
  INSTALL_NOORDER | from --noorder
  INSTALL_LABEL | from --verbose (notify)
  INSTALL_UPGRADE | from --upgrade
  INSTALL_FRESHEN | from --freshen
  INSTALL_INSTALL | from --install
  INSTALL_ERASE | from --erase

Definition at line 351 of file rpmcli.h.

enum rpmQueryFlags_e

Bit(s) to control rpmQuery() operation, stored in qva_flags.

Todo:
  Merge rpmQueryFlags, rpmVerifyFlags, and rpmVerifyAttrs?.

Enumerator:

  QUERY_FOR_DEFAULT |
  QUERY_MD5 | from --nomd5
  QUERY_SIZE | from --nosize
  QUERY_LINKTO | from --nolink
  QUERY_USER | from --nouser)
  QUERY_GROUP | from --nogroup)
  QUERY_MTIME | from --nomtime)
  QUERY_MODE | from --nomode)
  QUERY_RDEV | from --nodev
  QUERY_CONTEXTS | verify: from --nocontexts
  QUERY_FILES | verify: from --nofiles
  QUERY_DEPS | verify: from --nodeps
  QUERY_SCRIPT | verify: from --noscripts
  QUERY_DIGEST | verify: from --nodigest
  QUERY_SIGNATURE | verify: from --nosignature
  QUERY_PATCHES | verify: from --nopatches
  QUERY_HDRCHK | verify: from --nohdrchk
  QUERY_FOR_LIST | query: from --list
  QUERY_FOR_STATE | query: from --state
  QUERY_FOR_DOCS | query: from --docfiles
  QUERY_FOR_CONFIG | query: from --configfiles
  QUERY_FOR_DUMPFILES | query: from --dump

Definition at line 109 of file rpmcli.h.

enum rpmQVSources_e

Query/Verify argument qualifiers.

Todo:
  Reassign to tag values.

Enumerator:

  RPMQV_PACKAGE | ... from package name db search.
  RPMQV_PATH | ... from file path db search.
  RPMQV_ALL | ... from each installed package.
  RPMQV_RPM | ... from reading binary rpm package.
  RPMQV_GROUP | ... from group db search.
  RPMQV_WHATPROVIDES | ... from provides db search.
  RPMQV_WHATREQUIRES | ... from requires db search.
  RPMQV_TRIGGEREDBY | ... from trigger db search.
  RPMQV_DBOFFSET | ... from database header instance.
  RPMQV_SPECFILE | ... from spec file parse (query only).
  RPMQV_PKGID | ... from package id (header+payload MD5).
  RPMQV_HDRID | ... from header id (immutable header SHA1).
  RPMQV_FILEID | ... from file id (file MD5).
  RPMQV_TID | ... from install transaction id (time stamp).
  RPMQV_HDLIST | ... from system hdlist.
  RPMQV_FTSWALK | ... from fts(3) walk.

Definition at line 86 of file rpmcli.h.

enum rpmSignFlags_e

Bit(s) to control rpmReSign() operation.

Enumerator:

  RPMSIGN_NONE |
  RPMSIGN_CHK_SIGNATURE | from --checksig
  RPMSIGN_NEW_SIGNATURE | from --resign
  RPMSIGN_ADD_SIGNATURE | from --addsign
  RPMSIGN_DEL_SIGNATURE | from --delsign
  RPMSIGN_IMPORT_PUBKEY | from --import

Definition at line 486 of file rpmcli.h.

## Function Documentation

static int checkSpec | ( | rpmts | ts,
|  | Header | h |
| ) |  |  | `[static]`

Parse spec file and build package.

Definition at line 26 of file build.c.

References _, headerIsEntry(), rpmlog(), RPMLOG_ERR, rpmpsFree(), rpmpsNumProblems(), rpmpsPrint(), RPMTAG_CONFLICTNAME, RPMTAG_REQUIRENAME, rpmtsAddInstallElement(), rpmtsCheck(), rpmtsClean(), and rpmtsProblems().

Referenced by buildForTarget().

int rpmcliArgIter | ( | rpmts | ts,
|  | QVA_t | qva,
|  | ARGV_const_t | argv |
| ) |  |  |

Iterate over query/verify arg list.

Parameters:

  | ts | transaction set
  | qva | parsed query/verify options
  | argv | query argument(s) (or NULL)

Returns:
  0 on success, else no. of failures

void rpmcliConfigured | ( | void |  | ) |

Make sure that rpm configuration has been read.

Warning:
  Options like --rcfile and --verbose must precede callers option.

Referenced by main().

poptContext rpmcliFini | ( | poptContext | optCon | ) |

Destroy most everything needed by an rpm CLI executable context.

Parameters:

  | optCon | popt context

Returns:
  NULL always

poptContext rpmcliInit | ( | int | argc,
|  | char *const | argv[],
|  | struct poptOption * | optionsTable |
| ) |  |  |

Initialize most everything needed by an rpm CLI executable context.

Parameters:

  | argc | no. of args
  | argv | arg array
  | optionsTable | popt option table

Returns:
  popt context (or NULL)

int rpmcliQuery | ( | rpmts | ts,
|  | QVA_t | qva,
|  | ARGV_const_t | argv |
| ) |  |  |

Display package information.

Todo:
  hack: RPMQV_ALL can pass char ** arglist = NULL, not char * arg. Union?

Parameters:

  | ts | transaction set
  | qva | parsed query/verify options
  | argv | query argument(s) (or NULL)

Returns:
  0 on success, else no. of failures

Referenced by main().

int rpmcliShowMatches | ( | QVA_t | qva,
|  | rpmts | ts |
| ) |  |  |

Display query/verify information for each header in iterator.

This routine uses:

- qva->qva_mi rpm database iterator
- qva->qva_showPackage query/verify display routine

Parameters:

  | qva | parsed query/verify options
  | ts | transaction set

Returns:
  result of last non-zero showPackage() return

int rpmcliSign | ( | rpmts | ts,
|  | QVA_t | qva,
|  | ARGV_const_t | argv |
| ) |  |  |

Create/Modify/Check elements from signature header.

Parameters:

  | ts | transaction set
  | qva | mode flags and parameters
  | argv | array of arguments (NULL terminated)

Returns:
  0 on success

Referenced by main().

int rpmcliVerify | ( | rpmts | ts,
|  | QVA_t | qva,
|  | ARGV_const_t | argv |
| ) |  |  |

Verify package install.

Todo:
  hack: RPMQV_ALL can pass char ** arglist = NULL, not char * arg. Union?

Parameters:

  | ts | transaction set
  | qva | parsed query/verify options
  | argv | verify argument(s) (or NULL)

Returns:
  0 on success, else no. of failures

Referenced by main().

void rpmDisplayQueryTags | ( | FILE * | fp | ) |

Display list of tags that can be used in --queryformat.

Parameters:

  | fp | file handle to use for display

int rpmErase | ( | rpmts | ts,
|  | struct rpmInstallArguments_s * | ia,
|  | ARGV_const_t | argv |
| ) |  |  |

Erase binary rpm package.

Parameters:

  | ts | transaction set
  | ia | control args/bits
  | argv | array of package file names (NULL terminated)

Returns:
  0 on success

Referenced by main().

int rpmInstall | ( | rpmts | ts,
|  | struct rpmInstallArguments_s * | ia,
|  | ARGV_t | fileArgv |
| ) |  |  |

Install/upgrade/freshen binary rpm package.

Parameters:

  | ts | transaction set
  | ia | mode flags and parameters
  | fileArgv | array of package file names (NULL terminated)

Returns:
  0 on success

Todo:
  fileArgv is modified on errors, should be ARGV_const_t

Referenced by main().

int rpmInstallSource | ( | rpmts | ts,
|  | const char * | arg,
|  | char ** | specFilePtr,
|  | char ** | cookie |
| ) |  |  |

Install source rpm package.

Parameters:

  | ts | transaction set
  | arg | source rpm file name

Return values:

  | *specFilePtr | (installed) spec file name
  | *cookie |

Returns:
  0 on success

Referenced by main().

int rpmQueryVerify | ( | QVA_t | qva,
|  | rpmts | ts,
|  | const char * | arg |
| ) |  |  |

Common query/verify source interface, called once for each CLI arg.

This routine uses:

- qva->qva_mi rpm database iterator
- qva->qva_showPackage query/verify display routine

Parameters:

  | qva | parsed query/verify options
  | ts | transaction set
  | arg | name of source to query/verify

Returns:
  showPackage() result, 1 if rpmdbInitIterator() is NULL

void* rpmShowProgress | ( | const void * | arg,
|  | const rpmCallbackType | what,
|  | const rpm_loff_t | amount,
|  | const rpm_loff_t | total,
|  | fnpyKey | key,
|  | void * | data |
| ) |  |  |

The rpm CLI generic transaction callback handler.

Todo:
  Remove headerFormat() from the progress callback.

Deprecated:
  Transaction callback arguments need to change, so don't rely on this routine in the rpmcli API.

Parameters:

  | arg | per-callback private data (e.g. an rpm header)
  | what | callback identifier
  | amount | per-callback progress info
  | total | per-callback progress info
  | key | opaque header key (e.g. file name or PyObject)
  | data | private data (e.g. rpmInstallInterfaceFlags)

Returns:
  per-callback data (e.g. an opened FD_t)

int showQueryPackage | ( | QVA_t | qva,
|  | rpmts | ts,
|  | Header | h |
| ) |  |  |

Display results of package query.

Todo:
  Devise a meaningful return code.

Parameters:

  | qva | parsed query/verify options
  | ts | transaction set
  | h | header to use for query

Returns:
  0 always

int showVerifyPackage | ( | QVA_t | qva,
|  | rpmts | ts,
|  | Header | h |
| ) |  |  |

Display results of package verify.

Parameters:

  | qva | parsed query/verify options
  | ts | transaction set
  | h | header to use for verify

Returns:
  result of last non-zero verify return

## Variable Documentation

int _noDirTokens

Should version 3 packages be produced?

struct rpmBuildArguments_s rpmBTArgs

Referenced by main().

struct poptOption rpmBuildPoptTable[]

struct poptOption rpmcliAllPoptTable[]

Popt option table for options shared by all modes and executables.

int rpmcliHashesCurrent

int rpmcliHashesTotal

int rpmcliPackagesTotal

int rpmcliProgressCurrent

int rpmcliProgressTotal

rpmQueryFlags rpmcliQueryFlags

Bit(s) from common command line options.

struct poptOption rpmDatabasePoptTable[]

struct rpmDatabaseArguments_s rpmDBArgs

Referenced by main().

struct rpmInstallArguments_s rpmIArgs

Referenced by main().

struct poptOption rpmInstallPoptTable[]

struct poptOption rpmQueryPoptTable[]

struct rpmQVKArguments_s rpmQVKArgs

Referenced by main().

struct poptOption rpmQVSourcePoptTable[]

struct poptOption rpmSignPoptTable[]

struct poptOption rpmVerifyPoptTable[]