12 #define _RPMEVR_INTERNAL
20 #define _RPMTS_INTERNAL
24 #define _RPMGI_INTERNAL
30 #define _RPMROLLBACK_INTERNAL
31 #include <rpmrollback.h>
42 #define QVA_ISSET(_qvaflags, _FLAG) ((_qvaflags) & (VERIFY_##_FLAG))
44 #define VSF_ISSET(_vsflags, _FLAG) ((_vsflags) & (RPMVSF_##_FLAG))
45 #define VSF_SET(_vsflags, _FLAG) \
46 (*((unsigned *)&(_vsflags)) |= (RPMVSF_##_FLAG))
47 #define VSF_CLR(_vsflags, _FLAG) \
48 (*((unsigned *)&(_vsflags)) &= ~(RPMVSF_##_FLAG))
50 GENfree(
const void **)
54 #define QVA_ISSET(_qvaflags, _FLAG) ((_qvaflags) & (VERIFY_##_FLAG))
56 #define VSF_ISSET(_vsflags, _FLAG) ((_vsflags) & (RPMVSF_##_FLAG))
57 #define VSF_SET(_vsflags, _FLAG) (_vsflags) |= (RPMVSF_##_FLAG)
58 #define VSF_CLR(_vsflags, _FLAG) (_vsflags) &= ~(RPMVSF_##_FLAG)
87 rpmcliHashesTotal = (isatty (STDOUT_FILENO) ? 44 : 50);
89 if (rpmcliHashesCurrent != rpmcliHashesTotal) {
90 float pct = (float) (total ? (((
float) amount) / total) : 1);
91 hashesNeeded = (
int)((rpmcliHashesTotal * pct) + 0.5);
92 while (hashesNeeded > rpmcliHashesCurrent) {
93 if (isatty (STDOUT_FILENO)) {
99 fprintf(stdout,
"(%3d%%)", (
int)((100 * pct) + 0.5));
100 for (i = 0; i < (rpmcliHashesTotal + 6); i++)
101 (
void) putchar (
'\b');
105 rpmcliHashesCurrent++;
107 (
void) fflush(stdout);
109 if (rpmcliHashesCurrent == rpmcliHashesTotal) {
111 rpmcliProgressCurrent++;
112 if (isatty(STDOUT_FILENO)) {
114 (
void) putchar (
'#');
115 pct = (float) (rpmcliProgressTotal
116 ? (((
float) rpmcliProgressCurrent) / rpmcliProgressTotal)
118 fprintf(stdout,
" [%3d%%]", (
int)((100 * pct) + 0.5));
122 (
void) fflush(stdout);
144 const char * filename = (
const char *)key;
151 if (filename ==
NULL || filename[0] ==
'\0')
153 fd =
Fopen(filename,
"r%{?_rpmgio}");
160 fd =
Fopen(filename,
"r%{?_rpmgio}");
173 fd =
fdLink(fd,
"persist (showProgress)");
174 oldfl=
Fcntl(fd, F_GETFD, 0);
177 Fcntl(fd, F_SETFD, (
void*)oldfl);
181 #if defined(POSIX_FADV_WILLNEED)
192 fd =
fdFree(fd,
"persist (showProgress)");
201 rpmcliHashesCurrent = 0;
208 if (isatty (STDOUT_FILENO))
209 fprintf(stdout,
"%4d:%-23.23s", (
int)rpmcliProgressCurrent + 1, s);
211 fprintf(stdout,
"%-28.28s", s);
212 (
void) fflush(stdout);
215 char *
t =
rpmExpand(
"%{?___NVRA}%{!?___NVRA:%%{NAME}-%%{VERSION}-%%{RELEASE}}",
NULL);
218 (
void) fflush(stdout);
228 fprintf(stdout,
"%%%% %f\n", (
double) (total
229 ? ((((
float) amount) / total) * 100)
231 else if (flags & INSTALL_HASH)
234 (
void) fflush(stdout);
238 rpmcliHashesCurrent = 0;
239 rpmcliProgressTotal = 1;
240 rpmcliProgressCurrent = 0;
241 if (!(flags & INSTALL_LABEL))
243 if (flags & INSTALL_HASH)
244 fprintf(stdout,
"%-28s",
_(
"Preparing..."));
246 fprintf(stdout,
"%s\n",
_(
"Preparing packages for installation..."));
247 (
void) fflush(stdout);
251 if (flags & INSTALL_HASH)
254 rpmcliProgressCurrent = 0;
258 rpmcliHashesCurrent = 0;
259 rpmcliProgressTotal = total;
260 rpmcliProgressCurrent = 0;
261 if (!(flags & INSTALL_LABEL))
263 if (flags & INSTALL_HASH)
264 fprintf(stdout,
"%-28s\n",
_(
"Repackaging..."));
266 fprintf(stdout,
"%s\n",
_(
"Repackaging erased files..."));
267 (
void) fflush(stdout);
271 if (amount && (flags & INSTALL_HASH))
276 rpmcliProgressTotal = total;
277 rpmcliProgressCurrent = total;
278 if (flags & INSTALL_HASH)
281 rpmcliProgressCurrent = 0;
282 if (!(flags & INSTALL_LABEL))
284 if (flags & INSTALL_HASH)
285 fprintf(stdout,
"%-28s\n",
_(
"Upgrading..."));
287 fprintf(stdout,
"%s\n",
_(
"Upgrading packages..."));
288 (
void) fflush(stdout);
328 if (ts->suggests !=
NULL && ts->nsuggests > 0) {
333 for (i = 0; i < ts->nsuggests && (s = (
char *)ts->suggests[i]) !=
NULL;
338 ts->suggests =
_free(ts->suggests);
416 if (fts_level > 0 && fts->
fts_level >= fts_level)
459 "%{?_rpmgi_pattern_glob}"
460 "%{!?_rpmgi_pattern_glob:.}",
465 "%{?_rpmgi_pattern_regex:%{_rpmgi_pattern_regex ", arg,
"}}"
466 "%{!?_rpmgi_pattern_regex:", arg,
"-[^-]+-[^-]+\\.[^.]+\\.rpm$}",
479 if (xx || dav ==
NULL)
483 for (i = 0; i < dac; i++) {
492 for (i = 0; i < nac; i++) {
493 const char *
t = nav[
i];
494 size_t nt = strlen(t);
497 if (!(nt > 0 && t[nt-1] ==
'/'))
506 if (nac > 0 && nav !=
NULL)
520 mirePattern =
_free(mirePattern);
551 rpmcliPackagesTotal = 0;
563 time_t ttid = (time_t)ia->
arbtid;
565 ctime(&ttid), ia->
arbtid);
575 #if defined(SUPPORT_NOSIGNATURES)
577 VSF_SET(vsflags, NOSHA1HEADER);
674 if (xx && he->
c == 1) {
682 _(
"package %s is not relocatable\n"), he->
p.
str);
739 numFailed = (numRPMS ? numRPMS : 1);
740 if (numFailed)
goto exit;
751 numFailed = (numRPMS ? numRPMS : 1);
762 numFailed = (numRPMS ? numRPMS : 1);
766 if (numFailed)
goto exit;
789 if (argv ==
NULL)
return 0;
793 #if defined(SUPPORT_NOSIGNATURES)
795 VSF_SET(vsflags, NOSHA1HEADER);
823 time_t ttid = (time_t)ia->
arbtid;
825 ctime(&ttid), ia->
arbtid);
840 for (arg = argv; *arg; arg++) {
869 if (numFailed == 0 && numRPMS > 0) {
884 numFailed += (rc < 0 ? numRPMS :
rc);
894 const char ** specFilePtr,
const char **
cookie)
905 fprintf(stdout,
_(
"Installing %s\n"), arg);
910 VSF_SET(nvsflags, NEEDPAYLOAD);
rpmRelocation relocations
int rpmtsSetNotifyCallback(rpmts ts, rpmCallbackFunction notify, rpmCallbackData notifyData)
Set transaction notify callback function and argument.
rpmuint64_t rpmcliProgressTotal
#define QVA_ISSET(_qvaflags, _FLAG)
int rpmgiRc(rpmgi gi)
Return current iteration item(s) exit code.
miRE mireNew(rpmMireMode mode, int tag)
Create pattern container.
FTS * Fts_open(char *const *argv, int options, int(*compar)(const FTSENT **, const FTSENT **))
Create a handle for file hierarchy traversal.
int Fcntl(FD_t fd, int op, void *lip)
fcntl(2) clone.
rpmlog(RPMLOG_ERR,"%s\n", buf)
int(* rpmtsRun)(rpmts ts, rpmps okProbs, rpmprobFilterFlags ignoreSet)
Process all package elements in a transaction set.
Structures used for an "rpmte" transaction element.
char * xstrdup(const char *str)
FD_t Fopen(const char *path, const char *_fmode)
fopen(3) clone.
rpmgi rpmgiFree(rpmgi gi)
Destroy a generalized iterator.
char * rpmGetPath(const char *path,...)
Return (malloc'ed) expanded, canonicalized, file path.
uint32_t rpmmiInstance(rpmmi mi)
Return header instance for current position of rpmdb iterator.
enum rpmprobFilterFlags_e rpmprobFilterFlags
rpmtransFlags rpmtsSetFlags(rpmts ts, rpmtransFlags transFlags)
Set transaction flags, i.e.
struct rpmts_s * rpmts
The RPM Transaction Set.
void rpmpsPrint(FILE *fp, rpmps ps)
Print problems to file handle.
int mireRegcomp(miRE mire, const char *pattern)
Compile pattern match.
int argvAppend(ARGV_t *argvp, ARGV_t av)
Append one argv array to another.
FD_t fdLink(void *cookie, const char *msg)
Header rpmgiHeader(rpmgi gi)
Return current iteration header.
enum rpmCallbackType_e rpmCallbackType
Bit(s) to identify progress callbacks.
void addMacro(MacroContext mc, const char *n, const char *o, const char *b, int level)
Add macro to context.
#define VSF_SET(_vsflags, _FLAG)
static const char * rpmcliWalkFirst(ARGV_t av, miRE mire)
void rpmtsEmpty(rpmts ts)
Re-create an empty transaction set.
void rpmtsSetARBGoal(rpmts ts, rpmuint32_t goal)
Set autorollback goal.
int Fadvise(FD_t fd, off_t offset, off_t length, int advice)
posix_fadvise(2) clone.
struct rpmps_s * rpmps
Transaction problems found while processing a transaction set/.
tsmStage rpmtsSetGoal(rpmts ts, tsmStage goal)
Set goal of transaction set.
Command line option information.
int rpmpsNumProblems(rpmps ps)
Return number of problems in set.
rpmdepFlags rpmtsSetDFlags(rpmts ts, rpmdepFlags depFlags)
Set dependency flags, i.e.
enum rpmRC_e rpmRC
RPM return codes.
memset(_r, 0, sizeof(*_r))
int rpmGlob(const char *patterns, int *argcPtr, const char ***argvPtr)
Return URL path(s) from a (URL prefixed) pattern glob.
int rpmcliInstallOrder(rpmts ts)
Order package elements in a transaction set, reporting problems.
miRE mireFree(miRE mire)
Free pattern container.
static const char * rpmcliInstallElementPath(rpmts ts, const char *arg)
const char * Fstrerror(FD_t fd)
strerror(3) clone.
assert(key->size==sizeof(hdrNum))
int rpmtsAddEraseElement(rpmts ts, Header h, uint32_t hdrNum)
Add package to be erased to transaction set.
rpmgi rpmgiNew(rpmts ts, int tag, const void *keyp, size_t keylen)
Return a generalized iterator.
#define VSF_CLR(_vsflags, _FLAG)
rpmmi rpmmiFree(rpmmi mi)
Destroy rpm database iterator.
fprintf(stderr,"--> %s(%p,%p,%p) sig %p sigp %p\n", __FUNCTION__, dig, t, rsactx, sig, sigp)
unsigned int rpmmiCount(rpmmi mi)
Return number of elements in rpm database iterator.
FD_t fdFree(FD_t fd, const char *msg)
enum rpmgiFlags_e rpmgiFlags
int argvCount(const ARGV_t argv)
Return no.
rpmRC rpmInstallSourcePackage(rpmts ts, void *_fd, const char **specFilePtr, const char **cookie)
Install source package.
unsigned long long rpmuint64_t
ARGV_t argvFree(ARGV_t argv)
Destroy an argv array.
int rpmcliInstall(rpmts ts, QVA_t ia, const char **argv)
Install/upgrade/freshen binary rpm package.
Routines to expand a manifest containing glob expressions into an argv list.
Header rpmmiNext(rpmmi mi)
Return next package header from iteration.
Structure(s) used for dependency tag sets.
rpmRC rpmgiSetArgs(rpmgi gi, ARGV_t argv, int ftsOpts, rpmgiFlags flags)
Load iterator args.
int rpmtsAddInstallElement(rpmts ts, Header h, fnpyKey key, int upgrade, rpmRelocation relocs)
Add package to be installed to transaction set.
The FD_t File Handle data structure.
int argvAdd(ARGV_t *argvp, ARGstr_t val)
Add a string to an argv array.
int mireRegexec(miRE mire, const char *val, size_t vallen)
Execute pattern match.
FTSENT * Fts_read(FTS *sp)
Return next node in the file hierarchy traversal.
char * rpmExpand(const char *arg,...)
Return (malloc'ed) concatenated macro expansion(s).
pgpVSFlags rpmVSFlags
Bit(s) to control digest and signature verification.
rpmInstallInterfaceFlags installInterfaceFlags
static void printHash(const rpmuint64_t amount, const rpmuint64_t total)
Print a CLI progress bar.
int Fclose(FD_t fd)
fclose(3) clone.
rpmprobFilterFlags probFilter
int Fts_set(FTS *sp, FTSENT *p, int instr)
Modify the traversal for a file set member.
rpmps rpmpsFree(rpmps ps)
Destroy a problem set.
int rpmInstallSource(rpmts ts, const char *arg, const char **specFilePtr, const char **cookie)
Install source rpm package.
rpmVSFlags rpmtsSetVSFlags(rpmts ts, rpmVSFlags vsflags)
Set verify signatures flag(s).
rpmuint64_t rpmcliProgressCurrent
int Ferror(FD_t fd)
ferror(3) clone.
int rpmcliInstallSuggests(rpmts ts)
Report packages(if any) that satisfy unresolved dependencies.
void rpmtsClean(rpmts ts)
Free memory needed only for dependency checks and ordering.
urltype urlPath(const char *url, const char **pathp)
Return path component of URL.
enum rpmtransFlags_e rpmtransFlags
Bit(s) to control rpmtsRun() operation.
int rpmtsNElements(rpmts ts)
Return number of (ordered) transaction set elements.
int(* rpmtsOrder)(rpmts ts)
Determine package order in a transaction set according to dependencies.
int rpmcliInstallProblems(rpmts ts, const char *msg, int rc)
Report package problems (if any).
Structures and prototypes used for an "rpmts" transaction set.
static rpmRC rpmcliEraseElement(rpmts ts, const char *arg)
rpmVSFlags rpmtsVSFlags(rpmts ts)
Get verify signatures flag(s).
int rpmcliInstallCheck(rpmts ts)
Check package element dependencies in a transaction set, reporting problems.
int argvSplit(ARGV_t *argvp, const char *str, const char *seps)
Split a string into an argv array.
int Fts_close(FTS *sp)
Destroy a file hierarchy traversal handle.
int rpmErase(rpmts ts, QVA_t ia, const char **argv)
Erase binary rpm package.
rpmRC rpmgiNext(rpmgi gi)
Perform next iteration step.
static void
Print copy of spec file, filling in Group/Description/Summary from specspo.
Header rpmgiReadHeader(rpmgi gi, const char *path)
Return header from package.
const char * rpmgiHdrPath(rpmgi gi)
Return current header path.
int
Save source and expand field into target.
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.
Access RPM indices using Berkeley DB interface(s).
rpmmi rpmtsInitIterator(const rpmts ts, rpmTag rpmtag, const void *keyp, size_t keylen)
Return transaction database iterator.
static void * _free(const void *p)
Wrapper to free(3), hides const compilation noise, permit NULL, return NULL.
int(* rpmtsCheck)(rpmts ts)
Perform dependency resolution on the transaction set.
In Memoriam: Steve Taylor staylor@redhat.com was here, now he's not.
int rpmExpandNumeric(const char *arg)
Return macro expansion as a numeric value.
struct rpmgi_s * rpmgi
Generalized iterator.
int rpmVersionCompare(Header A, Header B)
int rpmcliInstallRun(rpmts ts, rpmps okProbs, rpmprobFilterFlags ignoreSet)
Install/erase package elements in a transaction set, reporting problems.
rpmps rpmtsProblems(rpmts ts)
Return current transaction set problems.