return rc;
}
-int rpmtsCloseSDB(rpmts ts)
-{
- int rc = 0;
-
- if (ts->sdb != NULL) {
- (void) rpmswAdd(rpmtsOp(ts, RPMTS_OP_DBGET),
- rpmdbOp(ts->sdb, RPMDB_OP_DBGET));
- (void) rpmswAdd(rpmtsOp(ts, RPMTS_OP_DBPUT),
- rpmdbOp(ts->sdb, RPMDB_OP_DBPUT));
- (void) rpmswAdd(rpmtsOp(ts, RPMTS_OP_DBDEL),
- rpmdbOp(ts->sdb, RPMDB_OP_DBDEL));
- rc = rpmdbClose(ts->sdb);
- ts->sdb = NULL;
- }
- return rc;
-}
-
-int rpmtsOpenSDB(rpmts ts, int dbmode)
-{
- static int has_sdbpath = -1;
- int rc = 0;
-
- if (ts->sdb != NULL && ts->sdbmode == dbmode)
- return 0;
-
- if (has_sdbpath < 0)
- has_sdbpath = rpmExpandNumeric("%{?_solve_dbpath:1}");
-
- /* If not configured, don't try to open. */
- if (has_sdbpath <= 0)
- return 1;
-
- addMacro(NULL, "_dbpath", NULL, "%{_solve_dbpath}", RMIL_DEFAULT);
-
- rc = rpmdbOpen(ts->rootDir, &ts->sdb, ts->sdbmode, 0644);
- if (rc) {
- char * dn = rpmGetPath(ts->rootDir, "%{_dbpath}", NULL);
- rpmlog(RPMLOG_WARNING,
- _("cannot open Solve database in %s\n"), dn);
- dn = _free(dn);
- }
- delMacro(NULL, "_dbpath");
-
- 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(rpmts ts, rpmds ds, const void * data)
-{
- const char * errstr;
- char * str;
- char * qfmt;
- rpmdbMatchIterator mi;
- Header bh;
- Header h;
- size_t bhnamelen;
- time_t bhtime;
- rpmTag rpmtag;
- const char * keyp;
- size_t keylen;
- int rc = 1; /* assume not found */
- int xx;
-
- if (rpmdsTagN(ds) != RPMTAG_REQUIRENAME)
- return rc;
-
- keyp = rpmdsN(ds);
- if (keyp == NULL)
- return rc;
-
- if (ts->sdb == NULL) {
- xx = rpmtsOpenSDB(ts, ts->sdbmode);
- if (xx) return rc;
- }
-
- /* Look for a matching Provides: in suggested universe. */
- rpmtag = (*keyp == '/' ? RPMTAG_BASENAMES : RPMTAG_PROVIDENAME);
- keylen = 0;
- mi = rpmdbInitIterator(ts->sdb, rpmtag, keyp, keylen);
- bhnamelen = 0;
- bhtime = 0;
- bh = NULL;
- while ((h = rpmdbNextIterator(mi)) != NULL) {
- struct rpmtd_s name, btime;
- size_t hnamelen;
- time_t htime;
-
- if (rpmtag == RPMTAG_PROVIDENAME && !rpmdsAnyMatchesDep(h, ds, 1))
- continue;
-
- /* XXX Prefer the shortest name if given alternatives. */
- hnamelen = 0;
- if (headerGet(h, RPMTAG_NAME, &name, HEADERGET_MINMEM)) {
- const char * hname = rpmtdGetString(&name);
- if (hname)
- hnamelen = strlen(hname);
- rpmtdFreeData(&name);
- }
- if (bhnamelen > 0 && hnamelen > bhnamelen)
- continue;
-
- /* XXX Prefer the newest build if given alternatives. */
- htime = 0;
- if (headerGet(h, RPMTAG_BUILDTIME, &btime, HEADERGET_MINMEM)) {
- rpm_time_t *bt = rpmtdGetUint32(&btime);
- htime = bt ? (time_t)*bt : 0;
- rpmtdFreeData(&btime);
- }
-
- if (htime <= bhtime)
- continue;
-
- bh = headerFree(bh);
- bh = headerLink(h);
- bhtime = htime;
- bhnamelen = hnamelen;
- }
- mi = rpmdbFreeIterator(mi);
-
- /* 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 = headerFormat(bh, qfmt, &errstr);
- bh = headerFree(bh);
- qfmt = _free(qfmt);
- if (str == NULL) {
- rpmlog(RPMLOG_ERR, _("incorrect format: %s\n"), errstr);
- goto exit;
- }
-
- if (ts->transFlags & RPMTRANS_FLAG_ADDINDEPS) {
- FD_t fd;
- rpmRC rpmrc;
-
- h = headerFree(h);
- fd = Fopen(str, "r.ufdio");
- if (fd == NULL || Ferror(fd)) {
- rpmlog(RPMLOG_ERR, _("open of %s failed: %s\n"), str,
- Fstrerror(fd));
- if (fd != NULL) {
- xx = Fclose(fd);
- fd = NULL;
- }
- str = _free(str);
- goto exit;
- }
- rpmrc = rpmReadPackageFile(ts, fd, str, &h);
- xx = Fclose(fd);
- switch (rpmrc) {
- default:
- str = _free(str);
- break;
- case RPMRC_NOTTRUSTED:
- case RPMRC_NOKEY:
- case RPMRC_OK:
- if (h != NULL &&
- !rpmtsAddInstallElement(ts, h, (fnpyKey)str, 1, NULL))
- {
- rpmlog(RPMLOG_DEBUG, "Adding: %s\n", str);
- rc = -1;
- /* XXX str memory leak */
- break;
- }
- str = _free(str);
- break;
- }
- h = headerFree(h);
- goto exit;
- }
-
- rpmlog(RPMLOG_DEBUG, "Suggesting: %s\n", str);
- /* 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:
-/* FIX: ts->suggests[] may be NULL */
- return rc;
-}
-
int rpmtsSetSolveCallback(rpmts ts,
int (*solve) (rpmts ts, rpmds key, const void * data),
const void * solveData)
return rc;
}
-void rpmtsPrintSuggests(rpmts ts)
-{
- if (ts->suggests != NULL && ts->nsuggests > 0) {
- int i;
- rpmlog(RPMLOG_NOTICE, _(" Suggested resolutions:\n"));
- for (i = 0; i < ts->nsuggests; i++) {
- const char * str = ts->suggests[i];
-
- if (str == NULL)
- break;
-
- rpmlog(RPMLOG_NOTICE, "\t%s\n", str);
- }
- }
-}
-
-
rpmps rpmtsProblems(rpmts ts)
{
rpmps ps = NULL;
void rpmtsClean(rpmts ts)
{
rpmtsi pi; rpmte p;
- int i;
if (ts == NULL)
return;
ts->addedPackages = rpmalFree(ts->addedPackages);
ts->numAddedPackages = 0;
- for (i = 0; i < ts->nsuggests; i++) {
- const char * str = ts->suggests[i];
- ts->suggests[i] = NULL;
- _constfree(str);
- }
- ts->suggests = _free(ts->suggests);
- ts->nsuggests = 0;
-
rpmtsCleanProblems(ts);
}
(void) rpmtsCloseDB(ts);
- (void) rpmtsCloseSDB(ts);
-
ts->removedPackages = _free(ts->removedPackages);
ts->dsi = _free(ts->dsi);
ts->filesystems = NULL;
ts->dsi = NULL;
- ts->solve = rpmtsSolve;
+ ts->solve = NULL;
ts->solveData = NULL;
- ts->nsuggests = 0;
- ts->suggests = NULL;
- ts->sdb = NULL;
- ts->sdbmode = O_RDONLY;
ts->rdb = NULL;
ts->dbmode = O_RDONLY;
int rpmtsSetKeyring(rpmts ts, rpmKeyring keyring);
/** \ingroup rpmts
- * Close the database used by the transaction to solve dependencies.
- * @param ts transaction set
- * @return 0 on success
- */
-int rpmtsCloseSDB(rpmts ts);
-
-/** \ingroup rpmts
- * Open the database used by the transaction to solve dependencies.
- * @param ts transaction set
- * @param dbmode O_RDONLY or O_RDWR
- * @return 0 on success
- */
-int rpmtsOpenSDB(rpmts ts, int dbmode);
-
-/** \ingroup rpmts
- * Attempt to solve a needed dependency using the solve database.
- * @param ts transaction set
- * @param ds dependency set
- * @param data opaque data associated with callback
- * @return -1 retry, 0 ignore, 1 not found
- */
-int rpmtsSolve(rpmts ts, rpmds ds, const void * data);
-
-/** \ingroup rpmts
* Set dependency solver callback.
* @param ts transaction set
* @param (*solve) dependency solver callback
const void * solveData);
/** \ingroup rpmts
- * Print possible suggestions for current transaction set, assuming
- * solvedb exists etc.
- * @todo The whole suggests handling needs rework, this
- * is just a temporary measure...
- * @param ts transaction set
- */
-void rpmtsPrintSuggests(rpmts ts);
-
-/** \ingroup rpmts
* Return current transaction set problems.
* @param ts transaction set
* @return current problem set (or NULL)
# 2 Elf64 permitted
%_transaction_color @RPMCANONCOLOR@
-# The path to the dependency universe database. The default value
-# is the rpmdb-redhat location. The macro is usually defined in
-# /etc/rpm/macros.solve, installed with the rpmdb-redhat package.
-#%_solve_dbpath /usr/lib/rpmdb/%{_arch}-%{_vendor}-%{_os}/redhat
-
-# The path to the dependency universe packages. This should
-# be a path to the packages contained in the solve database.
-#%_solve_pkgsdir /mnt/redhat/test/latest-i386/RedHat/RPMS/
-
-# The output binary package file name template used when suggesting
-# binary packages that solve a dependency. The macro is usually defined
-# in /etc/rpm/macros.solve, installed with the rpmdb-redhat package.
-#
-# XXX Note: escaped %% for use in headerSprintf()
-#%_solve_name_fmt %{?_solve_pkgsdir}%%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm
-
# Verify digest/signature flags for various rpm modes:
# 0x30300 (_RPMVSF_NODIGESTS) --nohdrchk if set, don't check digest(s)
# 0xc0c00 (_RPMVSF_NOSIGNATURES) --nosignature if set, don't check signature(s)
%_rpmlock_path %{_dbpath}/__db.000
#==============================================================================
-# ---- Cache configuration macros.
-# Macro(s) used to configure the universe of headers used to
-# solve dependencies using rpmcache(8).
-#
-# Note: These values are specific to my machine, and most certainly
-# are incorrect for any non-redhat.com machine. The macros are
-# included here only to document the macro names and usage.
-%_bhpath file://localhost/mnt/dist
-%_bhcoll @(7.3|7.2|7.1|7.1sbe|7.1k|7.0|7.01j|7.0j|7.0sbe|7.0tc|6.2|6.2ha|6.2ee|6.1|6.0|5.2|5.1|5.0)
-%_bhN @(SRPMS|i386|alpha|sparc|s390|ia64)
-%_bhVR RedHat
-%_bhA RPMS
-
-# The cache database directory.
-%_cache_dbpath /var/spool/up2date/cache
-
-#==============================================================================
# ---- per-platform macros.
# Macros that are specific to an individual platform. The values here
# will be used if the per-platform macro file does not exist..