diff options
author | jbj <devnull@localhost> | 2002-04-14 21:48:44 +0000 |
---|---|---|
committer | jbj <devnull@localhost> | 2002-04-14 21:48:44 +0000 |
commit | b463db44dced1a5dd6bab2cb04e8f1a55aa72c67 (patch) | |
tree | 8798f1833bd6834a790f370b21a20b1141316496 /lib | |
parent | e6ebdb1d9fe1fb6077dacd6be378bab982ddcd34 (diff) | |
download | librpm-tizen-b463db44dced1a5dd6bab2cb04e8f1a55aa72c67.tar.gz librpm-tizen-b463db44dced1a5dd6bab2cb04e8f1a55aa72c67.tar.bz2 librpm-tizen-b463db44dced1a5dd6bab2cb04e8f1a55aa72c67.zip |
- use build time to choose one of multiple alternative suggestions.
- add --nosuggests to disable suggested resolutions.
- splint fiddles.
CVS patchset: 5406
CVS date: 2002/04/14 21:48:44
Diffstat (limited to 'lib')
-rw-r--r-- | lib/depends.c | 7 | ||||
-rw-r--r-- | lib/poptI.c | 12 | ||||
-rw-r--r-- | lib/poptQV.c | 12 | ||||
-rw-r--r-- | lib/psm.c | 1 | ||||
-rw-r--r-- | lib/rpmds.c | 3 | ||||
-rw-r--r-- | lib/rpminstall.c | 2 | ||||
-rw-r--r-- | lib/rpmlib.h | 7 | ||||
-rw-r--r-- | lib/rpmts.c | 81 | ||||
-rw-r--r-- | lib/transaction.c | 16 |
9 files changed, 104 insertions, 37 deletions
diff --git a/lib/depends.c b/lib/depends.c index d9f4c9d6e..5cf50c4ab 100644 --- a/lib/depends.c +++ b/lib/depends.c @@ -95,7 +95,8 @@ static int removePackage(rpmTransactionSet ts, Header h, int dboffset, if (ts->removedPackages != NULL) { /* XXX can't happen. */ ts->removedPackages[ts->numRemovedPackages] = dboffset; ts->numRemovedPackages++; - qsort(ts->removedPackages, ts->numRemovedPackages, + if (ts->numRemovedPackages > 1) + qsort(ts->removedPackages, ts->numRemovedPackages, sizeof(*ts->removedPackages), intcmp); } @@ -461,9 +462,9 @@ static int unsatisfiedDepend(rpmTransactionSet ts, rpmDepSet key) } /* - * Search for an unsatisifed dependency. + * Search for an unsatisfied dependency. */ - if (ts->solve) + if (!(ts->transFlags & RPMTRANS_FLAG_NOSUGGESTS) && ts->solve != NULL) xx = (*ts->solve) (ts, key); unsatisfied: diff --git a/lib/poptI.c b/lib/poptI.c index 058b99a66..ae14b6c7c 100644 --- a/lib/poptI.c +++ b/lib/poptI.c @@ -152,11 +152,11 @@ struct poptOption rpmInstallPoptTable[] = { { "ignoresize", '\0', POPT_BIT_SET, &rpmIArgs.probFilter, (RPMPROB_FILTER_DISKSPACE|RPMPROB_FILTER_DISKNODES), N_("don't check disk space before installing"), NULL}, - { "includedocs", '\0', 0, &rpmIArgs.incldocs, 0, + { "includedocs", '\0', POPT_ARGFLAG_DOC_HIDDEN, &rpmIArgs.incldocs, 0, N_("install documentation"), NULL}, { "install", '\0', POPT_BIT_SET, &rpmIArgs.installInterfaceFlags, INSTALL_INSTALL, - N_("install package"), N_("<packagefile>+") }, + N_("install package(s)"), N_("<packagefile>+") }, { "justdb", '\0', POPT_BIT_SET, &rpmIArgs.transFlags, RPMTRANS_FLAG_JUSTDB, N_("update the database, but do not modify the filesystem"), NULL}, { "nodeps", '\0', 0, &rpmIArgs.noDeps, 0, @@ -166,6 +166,10 @@ struct poptOption rpmInstallPoptTable[] = { N_("do not reorder package installation to satisfy dependencies"), NULL}, + { "nosuggests", '\0', POPT_BIT_SET, &rpmIArgs.transFlags, + RPMTRANS_FLAG_NOSUGGESTS, + N_("do not suggest missing dependency resolution(s)"), NULL}, + { "noscripts", '\0', POPT_BIT_SET, &rpmIArgs.transFlags, (_noTransScripts|_noTransTriggers), N_("do not execute package scriptlet(s)"), NULL }, @@ -183,9 +187,9 @@ struct poptOption rpmInstallPoptTable[] = { N_("do not execute %%postun scriptlet (if any)"), NULL }, { "nodigest", '\0', POPT_BIT_SET, &rpmIArgs.qva_flags, VERIFY_DIGEST, - N_("don't verify digest(s)"), NULL }, + N_("don't verify package digest(s)"), NULL }, { "nosignature", '\0', POPT_BIT_SET, &rpmIArgs.qva_flags, VERIFY_SIGNATURE, - N_("don't verify signature(s)"), NULL }, + N_("don't verify package signature(s)"), NULL }, { "notriggers", '\0', POPT_BIT_SET, &rpmIArgs.transFlags, _noTransTriggers, diff --git a/lib/poptQV.c b/lib/poptQV.c index 51206b694..6eabc8740 100644 --- a/lib/poptQV.c +++ b/lib/poptQV.c @@ -269,10 +269,10 @@ struct poptOption rpmVerifyPoptTable[] = { N_("don't execute verify script(s)"), NULL }, { "nodigest", '\0', POPT_BIT_SET, &rpmQVKArgs.qva_flags, VERIFY_DIGEST, - N_("don't verify digest(s)"), NULL }, + N_("don't verify package digest(s)"), NULL }, { "nosignature", '\0', POPT_BIT_SET, &rpmQVKArgs.qva_flags, VERIFY_SIGNATURE, - N_("don't verify signature(s)"), NULL }, + N_("don't verify package signature(s)"), NULL }, /** @todo Add --nogpg/--nopgp aliases to rpmpopt, eliminate. */ { "nogpg", '\0', POPT_BIT_SET|POPT_ARGFLAG_DOC_HIDDEN, @@ -295,20 +295,20 @@ struct poptOption rpmSignPoptTable[] = { rpmQVSourceArgCallback, 0, NULL, NULL }, /*@=type@*/ { "addsign", '\0', 0, NULL, 'A', - N_("sign a packagei (identical to --resign)"), NULL }, + N_("sign package(s) (identical to --resign)"), NULL }, { "checksig", 'K', 0, NULL, 'K', N_("verify package signature(s)"), NULL }, { "import", '\0', 0, NULL, 'I', N_("import an armored public key"), NULL }, { "resign", '\0', 0, NULL, 'R', - N_("sign a packagei (identical to --addsign)"), NULL }, + N_("sign package(s) (identical to --addsign)"), NULL }, { "sign", '\0', POPT_ARGFLAG_DOC_HIDDEN, &rpmQVKArgs.sign, 0, N_("generate signature"), NULL }, { "nodigest", '\0', POPT_BIT_SET, &rpmQVKArgs.qva_flags, VERIFY_DIGEST, - N_("don't verify digest(s)"), NULL }, + N_("don't verify package digest(s)"), NULL }, { "nosignature", '\0', POPT_BIT_SET, &rpmQVKArgs.qva_flags, VERIFY_SIGNATURE, - N_("don't verify signature(s)"), NULL }, + N_("don't verify package signature(s)"), NULL }, POPT_TABLEEND }; @@ -370,6 +370,7 @@ static int markReplacedFiles(const PSM_t psm) return 0; offsets = alloca(num * sizeof(*offsets)); + offsets[0] = 0; num = prev = 0; for (sfi = replaced; sfi->otherPkg; sfi++) { if (prev && prev == sfi->otherPkg) diff --git a/lib/rpmds.c b/lib/rpmds.c index bbd5685b7..4275640fc 100644 --- a/lib/rpmds.c +++ b/lib/rpmds.c @@ -671,7 +671,8 @@ int headerMatchesDepFlags(const Header h, const rpmDepSet req) /* Get package information from header */ (void) headerNVR(h, &pkgN, &v, &r); - pkgEVR = t = alloca(21 + strlen(v) + 1 + strlen(r) + 1); + t = alloca(21 + strlen(v) + 1 + strlen(r) + 1); + pkgEVR = t; *t = '\0'; if (hge(h, RPMTAG_EPOCH, NULL, (void **) &epoch, NULL)) { sprintf(t, "%d:", *epoch); diff --git a/lib/rpminstall.c b/lib/rpminstall.c index 8389f2c71..2878e61a1 100644 --- a/lib/rpminstall.c +++ b/lib/rpminstall.c @@ -583,7 +583,7 @@ restart: if (rc < 0) { eiu->numFailed += eiu->numRPMS; - } else if (rc > 0 || ps) { + } else if (rc > 0) { eiu->numFailed += rc; rpmProblemSetPrint(stderr, ps); } diff --git a/lib/rpmlib.h b/lib/rpmlib.h index 26f029c85..a8c3f873b 100644 --- a/lib/rpmlib.h +++ b/lib/rpmlib.h @@ -1097,9 +1097,9 @@ void rpmProblemPrint(FILE *fp, rpmProblem prob) * @param fp file handle * @param ps problem set */ -void rpmProblemSetPrint(FILE *fp, rpmProblemSet ps) +void rpmProblemSetPrint(FILE *fp, /*@null@*/ rpmProblemSet ps) /*@globals fileSystem @*/ - /*@modifies ps, *fp, fileSystem @*/; + /*@modifies *fp, ps, fileSystem @*/; /** * Append a problem to set. @@ -1580,7 +1580,8 @@ typedef enum rpmtransFlags_e { /*@-enummemuse@*/ RPMTRANS_FLAG_CHAINSAW = (1 << 26), /*@=enummemuse@*/ - RPMTRANS_FLAG_NOMD5 = (1 << 27) /*!< from --nomd5 */ + RPMTRANS_FLAG_NOMD5 = (1 << 27), /*!< from --nomd5 */ + RPMTRANS_FLAG_NOSUGGESTS = (1 << 28) /*!< from --nosuggests */ } rpmtransFlags; #define _noTransScripts \ diff --git a/lib/rpmts.c b/lib/rpmts.c index 11b2ee9ee..1856acf73 100644 --- a/lib/rpmts.c +++ b/lib/rpmts.c @@ -141,19 +141,35 @@ static int rpmtsOpenSDB(rpmTransactionSet ts) return rc; } +/** + * Compare suggested package resolutions (qsort/bsearch). + * @param a 1st instance address + * @param b 2nd instance address + * @return result of comparison + */ +static int sugcmp(const void * a, const void * b) /*@*/ +{ + const char * astr = *(const char **)a; + const char * bstr = *(const char **)b; + return strcmp(astr, bstr); +} + int rpmtsSolve(rpmTransactionSet ts, rpmDepSet ds) { const char * errstr; const char * str; const char * qfmt; rpmdbMatchIterator mi; + Header bh; Header h; + time_t bhtime; int rpmtag; const char * keyp; size_t keylen; int rc = 1; /* assume not found */ int xx; + /* Make suggestions only for install Requires: */ if (ts->goal != TSM_INSTALL) return rc; @@ -169,36 +185,67 @@ int rpmtsSolve(rpmTransactionSet ts, rpmDepSet ds) if (xx) return rc; } - qfmt = rpmExpand("%{?_solve_name_fmt}", NULL); - if (qfmt == NULL || *qfmt == '\0') - goto exit; - + /* Look for a matching Provides: in suggested universe. */ rpmtag = (*keyp == '/' ? RPMTAG_BASENAMES : RPMTAG_PROVIDENAME); keylen = 0; mi = rpmdbInitIterator(ts->sdb, rpmtag, keyp, keylen); + bhtime = 0; + bh = NULL; while ((h = rpmdbNextIterator(mi)) != NULL) { + time_t htime; + int_32 * ip; if (rpmtag == RPMTAG_PROVIDENAME && !rangeMatchesDepFlags(h, ds)) continue; - str = headerSprintf(h, qfmt, rpmTagTable, rpmHeaderFormats, &errstr); - if (str == NULL) { - rpmError(RPMERR_QFMT, _("incorrect format: %s\n"), errstr); - break; - } - - ts->suggests = xrealloc(ts->suggests, - sizeof(*ts->suggests) * (ts->nsuggests + 2)); - ts->suggests[ts->nsuggests] = str; + htime = 0; + if (headerGetEntry(h, RPMTAG_BUILDTIME, NULL, (void **)&ip, NULL)) + htime = (time_t)*ip; - ts->nsuggests++; - ts->suggests[ts->nsuggests] = NULL; - break; /* XXX no alternatives yet */ + /* XXX Prefer the newest build if given alternatives. */ + if (htime <= bhtime) + continue; + if (bh) + bh = headerFree(bh, NULL); + bh = headerLink(h, NULL); + bhtime = htime; } mi = rpmdbFreeIterator(mi); -exit: + /* Is there a suggested resolution? */ + if (bh == NULL) + goto exit; + + /* Format the suggestion. */ + qfmt = rpmExpand("%{?_solve_name_fmt}", NULL); + if (qfmt == NULL || *qfmt == '\0') + goto exit; + str = headerSprintf(bh, qfmt, rpmTagTable, rpmHeaderFormats, &errstr); + bh = headerFree(bh, NULL); qfmt = _free(qfmt); + if (str == NULL) { + rpmError(RPMERR_QFMT, _("incorrect format: %s\n"), errstr); + goto exit; + } + + /* If suggestion is already present, don't bother. */ + if (ts->suggests != NULL && ts->nsuggests > 0) { + if (bsearch(&str, ts->suggests, ts->nsuggests, + sizeof(*ts->suggests), sugcmp)) + goto exit; + } + + /* Add a new (unique) suggestion. */ + ts->suggests = xrealloc(ts->suggests, + sizeof(*ts->suggests) * (ts->nsuggests + 2)); + ts->suggests[ts->nsuggests] = str; + ts->nsuggests++; + ts->suggests[ts->nsuggests] = NULL; + + if (ts->nsuggests > 1) + qsort(ts->suggests, ts->nsuggests, sizeof(*ts->suggests), sugcmp); + +exit: /*@-nullstate@*/ /* FIX: ts->suggests[] may be NULL */ return rc; /*@=nullstate@*/ diff --git a/lib/transaction.c b/lib/transaction.c index 72e14af15..69c6f0586 100644 --- a/lib/transaction.c +++ b/lib/transaction.c @@ -208,7 +208,9 @@ static fileAction decideFileFate(const rpmTransactionSet ts, * possible in case something else (like the timestamp) has changed. */ if (dbWhat == REG) { +#ifdef DYING if (ofi->md5s != NULL && nfi->md5s != NULL) { +#endif const unsigned char * omd5 = ofi->md5s + (16 * ofi->i); const unsigned char * nmd5 = nfi->md5s + (16 * nfi->i); if (domd5(fn, buffer, 0)) @@ -217,6 +219,7 @@ static fileAction decideFileFate(const rpmTransactionSet ts, return FA_CREATE; /* unmodified config file, replace. */ if (!memcmp(omd5, nmd5, 16)) return FA_SKIP; /* identical file, don't bother. */ +#ifdef DYING } else { const char * omd5 = ofi->fmd5s[ofi->i]; const char * nmd5 = nfi->fmd5s[nfi->i]; @@ -227,6 +230,7 @@ static fileAction decideFileFate(const rpmTransactionSet ts, if (!strcmp(omd5, nmd5)) return FA_SKIP; /* identical file, don't bother. */ } +#endif } else /* dbWhat == LINK */ { memset(buffer, 0, sizeof(buffer)); if (readlink(fn, buffer, sizeof(buffer) - 1) == -1) @@ -261,15 +265,19 @@ static int filecmp(TFI_t afi, TFI_t bfi) const char * blink = bfi->flinks[bfi->i]; return strcmp(alink, blink); } else if (awhat == REG) { +#ifdef DYING if (afi->md5s != NULL && bfi->md5s != NULL) { +#endif const unsigned char * amd5 = afi->md5s + (16 * afi->i); const unsigned char * bmd5 = bfi->md5s + (16 * bfi->i); return memcmp(amd5, bmd5, 16); +#ifdef DYING } else { const char * amd5 = afi->fmd5s[afi->i]; const char * bmd5 = bfi->fmd5s[bfi->i]; return strcmp(amd5, bmd5); } +#endif } return 0; @@ -703,12 +711,15 @@ assert(otherFi != NULL); /* Here is a pre-existing modified config file that needs saving. */ { char md5sum[50]; +#ifdef DYING if (fi->md5s != NULL) { - const unsigned char * fmd5 = fi->md5s + (16 * i); - if (!domd5(fn, md5sum, 0) && memcmp(fmd5, md5sum, 16)) { +#endif + const unsigned char * md5 = fi->md5s + (16 * i); + if (!domd5(fn, md5sum, 0) && memcmp(md5, md5sum, 16)) { fi->actions[i] = FA_BACKUP; /*@switchbreak@*/ break; } +#ifdef DYING } else { const char * fmd5 = fi->fmd5s[i]; if (!domd5(fn, md5sum, 1) && strcmp(fmd5, md5sum)) { @@ -716,6 +727,7 @@ assert(otherFi != NULL); /*@switchbreak@*/ break; } } +#endif } fi->actions[i] = FA_ERASE; /*@switchbreak@*/ break; |