12 #define _RPMEVR_INTERNAL
20 #define _RPMTS_INTERNAL
24 #define _RPMGI_INTERNAL
30 #define _RPMROLLBACK_INTERNAL
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');
103 fprintf(stdout,
"#");
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));
120 fprintf(stdout,
"\n");
122 (void) fflush(stdout);
144 const char * filename = (
const char *)key;
146 static FD_t fd = NULL;
151 if (filename == NULL || filename[0] ==
'\0')
153 fd =
Fopen(filename,
"r%{?_rpmgio}");
157 int ut =
urlPath(filename, NULL);
160 fd =
Fopen(filename,
"r%{?_rpmgio}");
164 if (fd == NULL ||
Ferror(fd)) {
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)
182 (void)
Fadvise(fd, 0, 0, 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);
217 fprintf(stdout,
"%s\n", s);
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;
334 s =
_free(s), ts->suggests[i++] = NULL)
338 ts->suggests =
_free(ts->suggests);
403 const char * fn = NULL;
407 if (av != NULL && av[0] != NULL)
408 ftsp =
Fts_open((
char *
const *)av, _ftsOpts, NULL);
410 while((fts =
Fts_read(ftsp)) != NULL) {
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);
548 if (argv == NULL)
goto exit;
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);
604 if (relocations->
newPath == NULL)
613 const char * fn = NULL;;
674 if (xx && he->
c == 1) {
682 _(
"package %s is not relocatable\n"), he->
p.
str);
699 assert(xx != 0 && he->
p.
str != NULL);
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)
899 if (fd == NULL ||
Ferror(fd)) {
905 fprintf(stdout,
_(
"Installing %s\n"), arg);
910 VSF_SET(nvsflags, NEEDPAYLOAD);
919 if (fd != NULL) (void)
Fclose(fd);
rpmRelocation relocations
#define QVA_ISSET(_qvaflags, _FLAG)
int rpmErase(rpmts ts, QVA_t ia, const char **argv)
Erase binary rpm package.
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.
const char bson_timestamp_t * ts
uint32_t rpmmiInstance(rpmmi mi)
Return header instance for current position of rpmdb iterator.
Structures used for an "rpmte" transaction element.
char * xstrdup(const char *str)
FD_t Fopen(const char *path, const char *_fmode)
fopen(3) clone.
rpmuint64_t rpmcliProgressTotal
int rpmtsAddInstallElement(rpmts ts, Header h, fnpyKey key, int upgrade, rpmRelocation relocs)
Add package to be installed to transaction set.
rpmgi rpmgiFree(rpmgi gi)
Destroy a generalized iterator.
rpmuint64_t rpmcliProgressCurrent
char * rpmGetPath(const char *path,...)
Return (malloc'ed) expanded, canonicalized, file path.
enum rpmprobFilterFlags_e rpmprobFilterFlags
struct headerToken_s * Header
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)
static rpmVSFlags vsflags
int rpmtsSetNotifyCallback(rpmts ts, rpmCallbackFunction notify, rpmCallbackData notifyData)
Set transaction notify callback function and argument.
int rpmcliInstallRun(rpmts ts, rpmps okProbs, rpmprobFilterFlags ignoreSet)
Install/erase package elements in a transaction set, reporting problems.
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)
int Fadvise(FD_t fd, off_t offset, off_t length, int advice)
posix_fadvise(2) clone.
int rpmcliInstallProblems(rpmts ts, const char *msg, int rc)
Report package problems (if any).
static void rpmlog(int code, const char *fmt,...)
struct rpmps_s * rpmps
Transaction problems found while processing a transaction set/.
int rpmcliInstallOrder(rpmts ts)
Order package elements in a transaction set, reporting problems.
int rpmcliInstallCheck(rpmts ts)
Check package element dependencies in a transaction set, reporting problems.
Command line option information.
char * headerSprintf(Header h, const char *fmt, headerTagTableEntry tags, headerSprintfExtension exts, errmsg_t *errmsg)
Return formatted output string from header tags.
int rpmpsNumProblems(rpmps ps)
Return number of problems in set.
rpmtransFlags rpmtsSetFlags(rpmts ts, rpmtransFlags transFlags)
Set transaction flags, i.e.
int rpmGlob(const char *patterns, int *argcPtr, const char ***argvPtr)
Return URL path(s) from a (URL prefixed) pattern glob.
void delMacro(MacroContext mc, const char *n)
Delete macro from context.
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.
rpmgi rpmgiNew(rpmts ts, int tag, const void *keyp, size_t keylen)
Return a generalized iterator.
#define VSF_CLR(_vsflags, _FLAG)
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.
const char const bson * data
unsigned long long rpmuint64_t
ARGV_t argvFree(ARGV_t argv)
Destroy an argv array.
int rpmtsNElements(rpmts ts)
Return number of (ordered) transaction set elements.
int rpmInstallSource(rpmts ts, const char *arg, const char **specFilePtr, const char **cookie)
Install source rpm package.
Routines to expand a manifest containing glob expressions into an argv list.
Structure(s) used for dependency tag sets.
rpmRC rpmgiSetArgs(rpmgi gi, ARGV_t argv, int ftsOpts, rpmgiFlags flags)
Load iterator args.
The FD_t File Handle data structure.
rpmmi rpmtsInitIterator(const rpmts ts, rpmTag rpmtag, const void *keyp, size_t keylen)
Return transaction database iterator.
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.
pgpVSFlags rpmVSFlags
Bit(s) to control digest and signature verification.
Header headerFree(Header h)
Dereference a header instance.
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).
void rpmtsSetARBGoal(rpmts ts, rpmuint32_t goal)
Set autorollback goal.
const char const char int arg
int rpmcliInstall(rpmts ts, QVA_t ia, const char **argv)
Install/upgrade/freshen binary rpm package.
rpmInstallInterfaceFlags installInterfaceFlags
static void printHash(const rpmuint64_t amount, const rpmuint64_t total)
Print a CLI progress bar.
rpmmi rpmmiFree(rpmmi mi)
Destroy rpm database iterator.
int Fclose(FD_t fd)
fclose(3) clone.
const char const bson int mongo_write_concern int flags
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.
Header headerLink(Header h)
Reference a header instance.
struct rpmgi_s * rpmgi
Generalized iterator.
enum rpmRC_e rpmRC
RPM return codes.
int Ferror(FD_t fd)
ferror(3) clone.
urltype urlPath(const char *url, const char **pathp)
Return path component of URL.
const char const bson * key
rpmdepFlags rpmtsSetDFlags(rpmts ts, rpmdepFlags depFlags)
Set dependency flags, i.e.
rpmps rpmtsProblems(rpmts ts)
Return current transaction set problems.
enum rpmtransFlags_e rpmtransFlags
Bit(s) to control rpmtsRun() operation.
rpmVSFlags rpmtsSetVSFlags(rpmts ts, rpmVSFlags vsflags)
Set verify signatures flag(s).
struct rpmts_s * rpmts
The RPM Transaction Set.
static void * _free(const void *p)
Wrapper to free(3), hides const compilation noise, permit NULL, return NULL.
Structures and prototypes used for an "rpmts" transaction set.
Header rpmmiNext(rpmmi mi)
Return next package header from iteration.
int(* rpmtsRun)(rpmts ts, rpmps okProbs, rpmprobFilterFlags ignoreSet)
Process all package elements in a transaction set.
rpmVSFlags rpmtsVSFlags(rpmts ts)
Get verify signatures flag(s).
static rpmRC rpmcliEraseElement(rpmts ts, const char *arg)
Structure(s) and routine(s) used for EVR parsing and comparison.
int rpmtsAddEraseElement(rpmts ts, Header h, uint32_t hdrNum)
Add package to be erased to transaction set.
int(* rpmtsCheck)(rpmts ts)
Perform dependency resolution on the transaction set.
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.
rpmRC rpmgiNext(rpmgi gi)
Perform next iteration step.
Header rpmgiReadHeader(rpmgi gi, const char *path)
Return header from package.
const char * rpmgiHdrPath(rpmgi gi)
Return current header path.
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).
int rpmcliInstallSuggests(rpmts ts)
Report packages(if any) that satisfy unresolved dependencies.
unsigned int rpmmiCount(rpmmi mi)
Return number of elements in rpm database iterator.
In Memoriam: Steve Taylor staylor@redhat.com was here, now he's not.
int(* rpmtsOrder)(rpmts ts)
Determine package order in a transaction set according to dependencies.
int rpmExpandNumeric(const char *arg)
Return macro expansion as a numeric value.
void rpmtsEmpty(rpmts ts)
Re-create an empty transaction set.
int rpmVersionCompare(Header A, Header B)
tsmStage rpmtsSetGoal(rpmts ts, tsmStage goal)
Set goal of transaction set.
void rpmtsClean(rpmts ts)
Free memory needed only for dependency checks and ordering.