rpm  5.4.15
Data Structures | Macros | Functions | Variables
rpminstall.c File Reference
#include "system.h"
#include <rpmio.h>
#include <rpmiotypes.h>
#include <poptIO.h>
#include <rpmtag.h>
#include <rpmevr.h>
#include "rpmdb.h"
#include "rpmte.h"
#include <rpmts.h>
#include "manifest.h"
#include "rpmgi.h"
#include <rpmlib.h>
#include <rpmcli.h>
#include <rpmrollback.h>
#include "debug.h"
Include dependency graph for rpminstall.c:

Go to the source code of this file.

Data Structures

struct  rpmRelocation_s
 

Macros

#define _RPMEVR_INTERNAL   /* XXX expose rpmVersionCompare prototype */
 
#define _RPMTS_INTERNAL   /* XXX ts->suggests */
 
#define _RPMGI_INTERNAL   /* XXX "+bing" args need gi->h. */
 
#define _RPMROLLBACK_INTERNAL
 
#define QVA_ISSET(_qvaflags, _FLAG)   ((_qvaflags) & (VERIFY_##_FLAG))
 
#define VSF_ISSET(_vsflags, _FLAG)   ((_vsflags) & (RPMVSF_##_FLAG))
 
#define VSF_SET(_vsflags, _FLAG)   (_vsflags) |= (RPMVSF_##_FLAG)
 
#define VSF_CLR(_vsflags, _FLAG)   (_vsflags) &= ~(RPMVSF_##_FLAG)
 

Functions

static void printHash (const rpmuint64_t amount, const rpmuint64_t total)
 Print a CLI progress bar. More...
 
void * rpmShowProgress (const void *arg, const rpmCallbackType what, const rpmuint64_t amount, const rpmuint64_t total, fnpyKey key, void *data)
 The rpm CLI generic transaction callback handler. More...
 
int rpmcliInstallProblems (rpmts ts, const char *msg, int rc)
 Report package problems (if any). More...
 
int rpmcliInstallSuggests (rpmts ts)
 Report packages(if any) that satisfy unresolved dependencies. More...
 
int rpmcliInstallCheck (rpmts ts)
 Check package element dependencies in a transaction set, reporting problems. More...
 
int rpmcliInstallOrder (rpmts ts)
 Order package elements in a transaction set, reporting problems. More...
 
int rpmcliInstallRun (rpmts ts, rpmps okProbs, rpmprobFilterFlags ignoreSet)
 Install/erase package elements in a transaction set, reporting problems. More...
 
static rpmRC rpmcliEraseElement (rpmts ts, const char *arg)
 
static const char * rpmcliWalkFirst (ARGV_t av, miRE mire)
 
static const char * rpmcliInstallElementPath (rpmts ts, const char *arg)
 
int rpmcliInstall (rpmts ts, QVA_t ia, const char **argv)
 Install/upgrade/freshen binary rpm package. More...
 
int rpmErase (rpmts ts, QVA_t ia, const char **argv)
 Erase binary rpm package. More...
 
int rpmInstallSource (rpmts ts, const char *arg, const char **specFilePtr, const char **cookie)
 Install source rpm package. More...
 

Variables

int rpmcliPackagesTotal = 0
 
int rpmcliHashesCurrent = 0
 
int rpmcliHashesTotal = 0
 
rpmuint64_t rpmcliProgressCurrent = 0
 
rpmuint64_t rpmcliProgressTotal = 0
 

Macro Definition Documentation

#define _RPMEVR_INTERNAL   /* XXX expose rpmVersionCompare prototype */

Definition at line 12 of file rpminstall.c.

#define _RPMGI_INTERNAL   /* XXX "+bing" args need gi->h. */

Definition at line 24 of file rpminstall.c.

#define _RPMROLLBACK_INTERNAL

Definition at line 30 of file rpminstall.c.

#define _RPMTS_INTERNAL   /* XXX ts->suggests */

Definition at line 20 of file rpminstall.c.

#define QVA_ISSET (   _qvaflags,
  _FLAG 
)    ((_qvaflags) & (VERIFY_##_FLAG))

Definition at line 54 of file rpminstall.c.

Referenced by rpmcliInstall(), and rpmErase().

#define VSF_CLR (   _vsflags,
  _FLAG 
)    (_vsflags) &= ~(RPMVSF_##_FLAG)

Definition at line 58 of file rpminstall.c.

Referenced by rpmErase().

#define VSF_ISSET (   _vsflags,
  _FLAG 
)    ((_vsflags) & (RPMVSF_##_FLAG))

Definition at line 56 of file rpminstall.c.

#define VSF_SET (   _vsflags,
  _FLAG 
)    (_vsflags) |= (RPMVSF_##_FLAG)

Definition at line 57 of file rpminstall.c.

Referenced by rpmcliInstall(), rpmErase(), and rpmInstallSource().

Function Documentation

static void printHash ( const rpmuint64_t  amount,
const rpmuint64_t  total 
)
static

Print a CLI progress bar.

Todo:
Unsnarl isatty(STDOUT_FILENO) from the control flow.
Parameters
amountcurrent
totalfinal

Definition at line 79 of file rpminstall.c.

References i, rpmcliHashesCurrent, and rpmcliHashesTotal.

Referenced by rpmShowProgress().

static rpmRC rpmcliEraseElement ( rpmts  ts,
const char *  arg 
)
static
int rpmcliInstall ( rpmts  ts,
QVA_t  ia,
const char **  argv 
)

Install/upgrade/freshen binary rpm package.

Todo:
Generalize –freshen policies.

Definition at line 535 of file rpminstall.c.

References _, _free(), addMacro(), alloca(), rpmQVKArguments_s::arbtid, rpmDataType_u::argv, argvAdd(), argvFree(), _HE_s::c, D_, delMacro(), rpmQVKArguments_s::depFlags, FTS_COMFOLLOW, FTS_LOGICAL, FTS_NOSTAT, headerFree(), headerGet(), headerLink(), INSTALL_FRESHEN, INSTALL_LABEL, INSTALL_NODEPS, INSTALL_NOORDER, INSTALL_UPGRADE, rpmQVKArguments_s::installInterfaceFlags, rpmRelocation_s::newPath, rpmRelocation_s::oldPath, _HE_s::p, rpmQVKArguments_s::probFilter, rpmDataType_u::ptr, rpmQVKArguments_s::qva_flags, QVA_ISSET, rpmQVKArguments_s::qva_source, rpmQVKArguments_s::relocations, RMIL_GLOBAL, rpmcliEraseElement(), rpmcliInstallCheck(), rpmcliInstallElementPath(), rpmcliInstallOrder(), rpmcliInstallRun(), rpmcliInstallSuggests(), RPMDBI_ARGLIST, RPMDBI_FTSWALK, rpmExpandNumeric(), RPMGI_NONE, rpmgiFree(), rpmgiHdrPath(), rpmgiHeader(), rpmgiNew(), rpmgiNext(), rpmgiRc(), rpmgiReadHeader(), rpmgiSetArgs(), rpmioFtsOpts, rpmIsVerbose, rpmlog(), RPMLOG_DEBUG, RPMLOG_ERR, rpmmiCount(), rpmmiFree(), rpmmiNext(), RPMQV_FTSWALK, RPMRC_NOTFOUND, RPMRC_OK, rpmShowProgress(), RPMTAG_NAME, RPMTAG_NVRA, RPMTAG_PREFIXES, RPMTRANS_FLAG_NOCONTEXTS, RPMTRANS_FLAG_REPACKAGE, rpmtsAddInstallElement(), rpmtsClean(), rpmtsEmpty(), rpmtsInitIterator(), rpmtsNElements(), rpmtsSetARBGoal(), rpmtsSetDFlags(), rpmtsSetFlags(), rpmtsSetGoal(), rpmtsSetNotifyCallback(), rpmtsSetVSFlags(), rpmVersionCompare(), rpmDataType_u::str, _HE_s::tag, rpmQVKArguments_s::transFlags, TSM_INSTALL, VSF_SET, vsflags, and xstrdup().

Referenced by main().

int rpmcliInstallCheck ( rpmts  ts)

Check package element dependencies in a transaction set, reporting problems.

Parameters
tstransaction set
Returns
no. of (added) packages

Definition at line 343 of file rpminstall.c.

References _, rpmcliInstallProblems(), and rpmtsCheck.

Referenced by main(), rpmcliInstall(), rpmErase(), and rpmgiNext().

static const char* rpmcliInstallElementPath ( rpmts  ts,
const char *  arg 
)
static
int rpmcliInstallOrder ( rpmts  ts)

Order package elements in a transaction set, reporting problems.

Parameters
tstransaction set
Returns
no. of (added) packages

Definition at line 350 of file rpminstall.c.

References _, rpmcliInstallProblems(), and rpmtsOrder.

Referenced by main(), rpmcliInstall(), rpmErase(), and rpmgiNew().

int rpmcliInstallProblems ( rpmts  ts,
const char *  msg,
int  rc 
)

Report package problems (if any).

Parameters
tstransaction set
msgproblem context string to display
rcresult of a tranbsaction operation
Returns
no. of (added) packages

Definition at line 311 of file rpminstall.c.

References rpmlog(), RPMLOG_ERR, rpmpsFree(), rpmpsNumProblems(), rpmpsPrint(), and rpmtsProblems().

Referenced by rpmcliInstallCheck(), rpmcliInstallOrder(), rpmcliInstallRun(), and rpmRollback().

int rpmcliInstallRun ( rpmts  ts,
rpmps  okProbs,
rpmprobFilterFlags  ignoreSet 
)

Install/erase package elements in a transaction set, reporting problems.

Parameters
tstransaction set
okProbspreviously known problems (or NULL)
ignoreSetbits to filter problem types
Returns
0 on success, -1 on error, >0 no, of failed elements

Definition at line 357 of file rpminstall.c.

References _, rpmcliInstallProblems(), and rpmtsRun.

Referenced by main(), rpmcliInstall(), and rpmErase().

int rpmcliInstallSuggests ( rpmts  ts)

Report packages(if any) that satisfy unresolved dependencies.

Parameters
tstransaction set
Returns
0 always

Definition at line 326 of file rpminstall.c.

References _, _free(), i, rpmlog(), and RPMLOG_NOTICE.

Referenced by rpmcliInstall(), and rpmgiNext().

static const char* rpmcliWalkFirst ( ARGV_t  av,
miRE  mire 
)
static
int rpmErase ( rpmts  ts,
QVA_t  ia,
const char **  argv 
)
int rpmInstallSource ( rpmts  ts,
const char *  arg,
const char **  specFilePtr,
const char **  cookie 
)

Install source rpm package.

Parameters
tstransaction set
argsource rpm file name
Return values
*specFilePtr(installed) spec file name
*cookie
Returns
0 on success

Definition at line 893 of file rpminstall.c.

References _, Fclose(), Ferror(), Fopen(), Fstrerror(), rpmInstallSourcePackage(), rpmIsVerbose, rpmlog(), RPMLOG_ERR, RPMRC_FAIL, RPMRC_OK, rpmtsSetVSFlags(), rpmtsVSFlags(), and VSF_SET.

Referenced by main().

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

The rpm CLI generic transaction callback handler.

Todo:
Remove headerSprintf() from the progress callback.
Warning
This function's args have changed, so the function cannot be used portably
Deprecated:
Transaction callback arguments need to change, so don't rely on this routine in the rpmcli API.
Parameters
argper-callback private data (e.g. an rpm header)
whatcallback identifier
amountper-callback progress info
totalper-callback progress info
keyopaque header key (e.g. file name or PyObject)
dataprivate data (e.g. rpmInstallInterfaceFlags)
Returns
per-callback data (e.g. an opened FD_t)

Definition at line 126 of file rpminstall.c.

References _, _free(), data, Fadvise(), Fclose(), Fcntl(), fdFree(), fdLink(), Ferror(), flags, Fopen(), Fstrerror(), headerSprintf(), INSTALL_HASH, INSTALL_LABEL, INSTALL_PERCENT, printHash(), RPMCALLBACK_CPIO_ERROR, RPMCALLBACK_INST_CLOSE_FILE, RPMCALLBACK_INST_OPEN_FILE, RPMCALLBACK_INST_PROGRESS, RPMCALLBACK_INST_START, RPMCALLBACK_REPACKAGE_PROGRESS, RPMCALLBACK_REPACKAGE_START, RPMCALLBACK_REPACKAGE_STOP, RPMCALLBACK_SCRIPT_ERROR, RPMCALLBACK_TRANS_PROGRESS, RPMCALLBACK_TRANS_START, RPMCALLBACK_TRANS_STOP, RPMCALLBACK_UNINST_PROGRESS, RPMCALLBACK_UNINST_START, RPMCALLBACK_UNINST_STOP, RPMCALLBACK_UNKNOWN, RPMCALLBACK_UNPACK_ERROR, rpmcliPackagesTotal, rpmExpand(), rpmHeaderFormats, rpmlog(), RPMLOG_ERR, URL_IS_HTTP, URL_IS_HTTPS, and urlPath().

Referenced by rpmcliInstall(), rpmErase(), and rpmRollback().

Variable Documentation

int rpmcliHashesCurrent = 0

Definition at line 65 of file rpminstall.c.

Referenced by printHash().

int rpmcliHashesTotal = 0

Definition at line 67 of file rpminstall.c.

Referenced by printHash().

int rpmcliPackagesTotal = 0

Definition at line 63 of file rpminstall.c.

Referenced by rpmRollback(), rpmShowProgress(), and rpmtsAddInstallElement().

rpmuint64_t rpmcliProgressCurrent = 0

Definition at line 69 of file rpminstall.c.

rpmuint64_t rpmcliProgressTotal = 0

Definition at line 71 of file rpminstall.c.