Main Page   Modules   Data Structures   File List   Data Fields   Globals   Related Pages  

lib/rpminstall.c

Go to the documentation of this file.
00001 
00005 #include "system.h"
00006 
00007 #include <rpmcli.h>
00008 
00009 #include "rpmdb.h"
00010 #include "rpmds.h"
00011 
00012 #define _RPMTS_INTERNAL         /* ts->goal, ts->dbmode, ts->suggests */
00013 #include "rpmts.h"
00014 
00015 #include "manifest.h"
00016 #include "misc.h"       /* XXX for rpmGlob() */
00017 #include "debug.h"
00018 
00019 /*@access rpmts @*/     /* XXX ts->goal, ts->dbmode */
00020 /*@access IDTX @*/
00021 /*@access IDT @*/
00022 
00023 /*@unchecked@*/
00024 int rpmcliPackagesTotal = 0;
00025 /*@unchecked@*/
00026 int rpmcliHashesCurrent = 0;
00027 /*@unchecked@*/
00028 int rpmcliHashesTotal = 0;
00029 /*@unchecked@*/
00030 int rpmcliProgressCurrent = 0;
00031 /*@unchecked@*/
00032 int rpmcliProgressTotal = 0;
00033 
00040 static void printHash(const unsigned long amount, const unsigned long total)
00041         /*@globals rpmcliHashesCurrent, rpmcliHashesTotal,
00042                 rpmcliProgressCurrent, fileSystem @*/
00043         /*@modifies rpmcliHashesCurrent, rpmcliHashesTotal,
00044                 rpmcliProgressCurrent, fileSystem @*/
00045 {
00046     int hashesNeeded;
00047 
00048     rpmcliHashesTotal = (isatty (STDOUT_FILENO) ? 44 : 50);
00049 
00050     if (rpmcliHashesCurrent != rpmcliHashesTotal) {
00051 /*@+relaxtypes@*/
00052         float pct = (total ? (((float) amount) / total) : 1.0);
00053         hashesNeeded = (rpmcliHashesTotal * pct) + 0.5;
00054 /*@=relaxtypes@*/
00055         while (hashesNeeded > rpmcliHashesCurrent) {
00056             if (isatty (STDOUT_FILENO)) {
00057                 int i;
00058                 for (i = 0; i < rpmcliHashesCurrent; i++)
00059                     (void) putchar ('#');
00060                 for (; i < rpmcliHashesTotal; i++)
00061                     (void) putchar (' ');
00062                 fprintf(stdout, "(%3d%%)", (int)((100 * pct) + 0.5));
00063                 for (i = 0; i < (rpmcliHashesTotal + 6); i++)
00064                     (void) putchar ('\b');
00065             } else
00066                 fprintf(stdout, "#");
00067 
00068             rpmcliHashesCurrent++;
00069         }
00070         (void) fflush(stdout);
00071 
00072         if (rpmcliHashesCurrent == rpmcliHashesTotal) {
00073             int i;
00074             rpmcliProgressCurrent++;
00075             if (isatty(STDOUT_FILENO)) {
00076                 for (i = 1; i < rpmcliHashesCurrent; i++)
00077                     (void) putchar ('#');
00078 /*@+relaxtypes@*/
00079                 pct = (rpmcliProgressTotal
00080                     ? (((float) rpmcliProgressCurrent) / rpmcliProgressTotal)
00081                     : 1);
00082 /*@=relaxtypes@*/
00083                 fprintf(stdout, " [%3d%%]", (int)((100 * pct) + 0.5));
00084             }
00085             fprintf(stdout, "\n");
00086         }
00087         (void) fflush(stdout);
00088     }
00089 }
00090 
00091 void * rpmShowProgress(/*@null@*/ const void * arg,
00092                         const rpmCallbackType what,
00093                         const unsigned long amount,
00094                         const unsigned long total,
00095                         /*@null@*/ fnpyKey key,
00096                         /*@null@*/ void * data)
00097         /*@globals rpmcliHashesCurrent, rpmcliProgressCurrent, rpmcliProgressTotal,
00098                 fileSystem @*/
00099         /*@modifies rpmcliHashesCurrent, rpmcliProgressCurrent, rpmcliProgressTotal,
00100                 fileSystem @*/
00101 {
00102 /*@-abstract -castexpose @*/
00103     Header h = (Header) arg;
00104 /*@=abstract =castexpose @*/
00105     char * s;
00106     int flags = (int) ((long)data);
00107     void * rc = NULL;
00108 /*@-abstract -assignexpose @*/
00109     const char * filename = (const char *)key;
00110 /*@=abstract =assignexpose @*/
00111     static FD_t fd = NULL;
00112     int xx;
00113 
00114     switch (what) {
00115     case RPMCALLBACK_INST_OPEN_FILE:
00116 /*@-boundsread@*/
00117         if (filename == NULL || filename[0] == '\0')
00118             return NULL;
00119 /*@=boundsread@*/
00120         fd = Fopen(filename, "r.ufdio");
00121         /*@-type@*/ /* FIX: still necessary? */
00122         if (fd == NULL || Ferror(fd)) {
00123             rpmError(RPMERR_OPEN, _("open of %s failed: %s\n"), filename,
00124                         Fstrerror(fd));
00125             if (fd != NULL) {
00126                 xx = Fclose(fd);
00127                 fd = NULL;
00128             }
00129         } else
00130             fd = fdLink(fd, "persist (showProgress)");
00131         /*@=type@*/
00132 /*@+voidabstract@*/
00133         return (void *)fd;
00134 /*@=voidabstract@*/
00135         /*@notreached@*/ break;
00136 
00137     case RPMCALLBACK_INST_CLOSE_FILE:
00138         /*@-type@*/ /* FIX: still necessary? */
00139         fd = fdFree(fd, "persist (showProgress)");
00140         /*@=type@*/
00141         if (fd != NULL) {
00142             xx = Fclose(fd);
00143             fd = NULL;
00144         }
00145         break;
00146 
00147     case RPMCALLBACK_INST_START:
00148         rpmcliHashesCurrent = 0;
00149         if (h == NULL || !(flags & INSTALL_LABEL))
00150             break;
00151         /* @todo Remove headerSprintf() on a progress callback. */
00152         if (flags & INSTALL_HASH) {
00153             s = headerSprintf(h, "%{NAME}",
00154                                 rpmTagTable, rpmHeaderFormats, NULL);
00155             if (isatty (STDOUT_FILENO))
00156                 fprintf(stdout, "%4d:%-23.23s", rpmcliProgressCurrent + 1, s);
00157             else
00158                 fprintf(stdout, "%-28.28s", s);
00159             (void) fflush(stdout);
00160             s = _free(s);
00161         } else {
00162             s = headerSprintf(h, "%{NAME}-%{VERSION}-%{RELEASE}",
00163                                   rpmTagTable, rpmHeaderFormats, NULL);
00164             fprintf(stdout, "%s\n", s);
00165             (void) fflush(stdout);
00166             s = _free(s);
00167         }
00168         break;
00169 
00170     case RPMCALLBACK_TRANS_PROGRESS:
00171     case RPMCALLBACK_INST_PROGRESS:
00172 /*@+relaxtypes@*/
00173         if (flags & INSTALL_PERCENT)
00174             fprintf(stdout, "%%%% %f\n", (double) (total
00175                                 ? ((((float) amount) / total) * 100)
00176                                 : 100.0));
00177         else if (flags & INSTALL_HASH)
00178             printHash(amount, total);
00179 /*@=relaxtypes@*/
00180         (void) fflush(stdout);
00181         break;
00182 
00183     case RPMCALLBACK_TRANS_START:
00184         rpmcliHashesCurrent = 0;
00185         rpmcliProgressTotal = 1;
00186         rpmcliProgressCurrent = 0;
00187         if (!(flags & INSTALL_LABEL))
00188             break;
00189         if (flags & INSTALL_HASH)
00190             fprintf(stdout, "%-28s", _("Preparing..."));
00191         else
00192             fprintf(stdout, "%s\n", _("Preparing packages for installation..."));
00193         (void) fflush(stdout);
00194         break;
00195 
00196     case RPMCALLBACK_TRANS_STOP:
00197         if (flags & INSTALL_HASH)
00198             printHash(1, 1);    /* Fixes "preparing..." progress bar */
00199         rpmcliProgressTotal = rpmcliPackagesTotal;
00200         rpmcliProgressCurrent = 0;
00201         break;
00202 
00203     case RPMCALLBACK_REPACKAGE_START:
00204         rpmcliHashesCurrent = 0;
00205         rpmcliProgressTotal = total;
00206         rpmcliProgressCurrent = 0;
00207         if (!(flags & INSTALL_LABEL))
00208             break;
00209         if (flags & INSTALL_HASH)
00210             fprintf(stdout, "%-28s\n", _("Repackaging..."));
00211         else
00212             fprintf(stdout, "%s\n", _("Repackaging erased files..."));
00213         (void) fflush(stdout);
00214         break;
00215 
00216     case RPMCALLBACK_REPACKAGE_PROGRESS:
00217         if (amount && (flags & INSTALL_HASH))
00218             printHash(1, 1);    /* Fixes "preparing..." progress bar */
00219         break;
00220 
00221     case RPMCALLBACK_REPACKAGE_STOP:
00222         rpmcliProgressTotal = total;
00223         rpmcliProgressCurrent = total;
00224         if (flags & INSTALL_HASH)
00225             printHash(1, 1);    /* Fixes "preparing..." progress bar */
00226         rpmcliProgressTotal = rpmcliPackagesTotal;
00227         rpmcliProgressCurrent = 0;
00228         if (!(flags & INSTALL_LABEL))
00229             break;
00230         if (flags & INSTALL_HASH)
00231             fprintf(stdout, "%-28s\n", _("Upgrading..."));
00232         else
00233             fprintf(stdout, "%s\n", _("Upgrading packages..."));
00234         (void) fflush(stdout);
00235         break;
00236 
00237     case RPMCALLBACK_UNINST_PROGRESS:
00238         break;
00239     case RPMCALLBACK_UNINST_START:
00240         break;
00241     case RPMCALLBACK_UNINST_STOP:
00242         break;
00243     case RPMCALLBACK_UNPACK_ERROR:
00244         break;
00245     case RPMCALLBACK_CPIO_ERROR:
00246         break;
00247     case RPMCALLBACK_UNKNOWN:
00248     default:
00249         break;
00250     }
00251 
00252     return rc;
00253 }       
00254 
00255 typedef /*@only@*/ /*@null@*/ const char * str_t;
00256 
00257 struct rpmEIU {
00258     Header h;
00259     FD_t fd;
00260     int numFailed;
00261     int numPkgs;
00262 /*@only@*/
00263     str_t * pkgURL;
00264 /*@dependent@*/ /*@null@*/
00265     str_t * fnp;
00266 /*@only@*/
00267     char * pkgState;
00268     int prevx;
00269     int pkgx;
00270     int numRPMS;
00271     int numSRPMS;
00272 /*@only@*/ /*@null@*/
00273     str_t * sourceURL;
00274     int isSource;
00275     int argc;
00276 /*@only@*/ /*@null@*/
00277     str_t * argv;
00278 /*@dependent@*/
00279     rpmRelocation * relocations;
00280     rpmRC rpmrc;
00281 };
00282 
00284 /*@-bounds@*/
00285 int rpmInstall(rpmts ts,
00286                 struct rpmInstallArguments_s * ia,
00287                 const char ** fileArgv)
00288 {
00289     struct rpmEIU * eiu = memset(alloca(sizeof(*eiu)), 0, sizeof(*eiu));
00290     rpmps ps;
00291     rpmprobFilterFlags probFilter;
00292     rpmRelocation * relocations;
00293 /*@only@*/ /*@null@*/ const char * fileURL = NULL;
00294     int stopInstall = 0;
00295     const char ** av = NULL;
00296     rpmVSFlags vsflags, ovsflags, tvsflags;
00297     int ac = 0;
00298     int rc;
00299     int xx;
00300     int i;
00301 
00302     if (fileArgv == NULL) goto exit;
00303 
00304     ts->goal = TSM_INSTALL;
00305     rpmcliPackagesTotal = 0;
00306 
00307     if (rpmExpandNumeric("%{?_repackage_all_erasures}"))
00308         ia->transFlags |= RPMTRANS_FLAG_REPACKAGE;
00309 
00310     (void) rpmtsSetFlags(ts, ia->transFlags);
00311     probFilter = ia->probFilter;
00312     relocations = ia->relocations;
00313 
00314     if (ia->installInterfaceFlags & INSTALL_UPGRADE)
00315         vsflags = rpmExpandNumeric("%{?_vsflags_erase}");
00316     else
00317         vsflags = rpmExpandNumeric("%{?_vsflags_install}");
00318     if (ia->qva_flags & VERIFY_DIGEST)
00319         vsflags |= _RPMVSF_NODIGESTS;
00320     if (ia->qva_flags & VERIFY_SIGNATURE)
00321         vsflags |= _RPMVSF_NOSIGNATURES;
00322     if (ia->qva_flags & VERIFY_HDRCHK)
00323         vsflags |= RPMVSF_NOHDRCHK;
00324     ovsflags = rpmtsSetVSFlags(ts, (vsflags | RPMVSF_NEEDPAYLOAD));
00325 
00326     {   int notifyFlags;
00327         notifyFlags = ia->installInterfaceFlags | (rpmIsVerbose() ? INSTALL_LABEL : 0 );
00328         xx = rpmtsSetNotifyCallback(ts,
00329                         rpmShowProgress, (void *) ((long)notifyFlags));
00330     }
00331 
00332     if ((eiu->relocations = relocations) != NULL) {
00333         while (eiu->relocations->oldPath)
00334             eiu->relocations++;
00335         if (eiu->relocations->newPath == NULL)
00336             eiu->relocations = NULL;
00337     }
00338 
00339     /* Build fully globbed list of arguments in argv[argc]. */
00340     /*@-branchstate@*/
00341     /*@-temptrans@*/
00342     for (eiu->fnp = fileArgv; *eiu->fnp != NULL; eiu->fnp++) {
00343     /*@=temptrans@*/
00344         av = _free(av); ac = 0;
00345         rc = rpmGlob(*eiu->fnp, &ac, &av);
00346         if (rc || ac == 0) {
00347             rpmError(RPMERR_OPEN, _("File not found by glob: %s\n"), *eiu->fnp);
00348             continue;
00349         }
00350 
00351         eiu->argv = xrealloc(eiu->argv, (eiu->argc+ac+1) * sizeof(*eiu->argv));
00352         memcpy(eiu->argv+eiu->argc, av, ac * sizeof(*av));
00353         eiu->argc += ac;
00354         eiu->argv[eiu->argc] = NULL;
00355     }
00356     /*@=branchstate@*/
00357     av = _free(av);     ac = 0;
00358 
00359 restart:
00360     /* Allocate sufficient storage for next set of args. */
00361     if (eiu->pkgx >= eiu->numPkgs) {
00362         eiu->numPkgs = eiu->pkgx + eiu->argc;
00363         eiu->pkgURL = xrealloc(eiu->pkgURL,
00364                         (eiu->numPkgs + 1) * sizeof(*eiu->pkgURL));
00365         memset(eiu->pkgURL + eiu->pkgx, 0,
00366                         ((eiu->argc + 1) * sizeof(*eiu->pkgURL)));
00367         eiu->pkgState = xrealloc(eiu->pkgState,
00368                         (eiu->numPkgs + 1) * sizeof(*eiu->pkgState));
00369         memset(eiu->pkgState + eiu->pkgx, 0,
00370                         ((eiu->argc + 1) * sizeof(*eiu->pkgState)));
00371     }
00372 
00373     /* Retrieve next set of args, cache on local storage. */
00374     for (i = 0; i < eiu->argc; i++) {
00375         fileURL = _free(fileURL);
00376         fileURL = eiu->argv[i];
00377         eiu->argv[i] = NULL;
00378 
00379 #ifdef  NOTYET
00380 if (fileURL[0] == '=') {
00381     rpmds this = rpmdsSingle(RPMTAG_REQUIRENAME, fileURL+1, NULL, 0);
00382 
00383     xx = rpmtsSolve(ts, this, NULL);
00384     if (ts->suggests && ts->nsuggests > 0) {
00385         fileURL = _free(fileURL);
00386         fileURL = ts->suggests[0];
00387         ts->suggests[0] = NULL;
00388         while (ts->nsuggests-- > 0) {
00389             if (ts->suggests[ts->nsuggests] == NULL)
00390                 continue;
00391             ts->suggests[ts->nsuggests] = _free(ts->suggests[ts->nsuggests]);
00392         }
00393         ts->suggests = _free(ts->suggests);
00394         rpmMessage(RPMMESS_DEBUG, _("Adding goal: %s\n"), fileURL);
00395         eiu->pkgURL[eiu->pkgx] = fileURL;
00396         fileURL = NULL;
00397         eiu->pkgx++;
00398     }
00399     this = rpmdsFree(this);
00400 } else
00401 #endif
00402 
00403         switch (urlIsURL(fileURL)) {
00404         case URL_IS_FTP:
00405         case URL_IS_HTTP:
00406         {   const char *tfn;
00407 
00408             if (rpmIsVerbose())
00409                 fprintf(stdout, _("Retrieving %s\n"), fileURL);
00410 
00411             {   char tfnbuf[64];
00412                 const char * rootDir = rpmtsRootDir(ts);
00413                 if (!(rootDir && * rootDir))
00414                     rootDir = "";
00415                 strcpy(tfnbuf, "rpm-xfer.XXXXXX");
00416                 (void) mktemp(tfnbuf);
00417                 tfn = rpmGenPath(rootDir, "%{_tmppath}/", tfnbuf);
00418             }
00419 
00420             /* XXX undefined %{name}/%{version}/%{release} here */
00421             /* XXX %{_tmpdir} does not exist */
00422             rpmMessage(RPMMESS_DEBUG, _(" ... as %s\n"), tfn);
00423             rc = urlGetFile(fileURL, tfn);
00424             if (rc < 0) {
00425                 rpmMessage(RPMMESS_ERROR,
00426                         _("skipping %s - transfer failed - %s\n"),
00427                         fileURL, ftpStrerror(rc));
00428                 eiu->numFailed++;
00429                 eiu->pkgURL[eiu->pkgx] = NULL;
00430                 tfn = _free(tfn);
00431                 /*@switchbreak@*/ break;
00432             }
00433             eiu->pkgState[eiu->pkgx] = 1;
00434             eiu->pkgURL[eiu->pkgx] = tfn;
00435             eiu->pkgx++;
00436         }   /*@switchbreak@*/ break;
00437         case URL_IS_PATH:
00438         default:
00439             eiu->pkgURL[eiu->pkgx] = fileURL;
00440             fileURL = NULL;
00441             eiu->pkgx++;
00442             /*@switchbreak@*/ break;
00443         }
00444     }
00445     fileURL = _free(fileURL);
00446 
00447     if (eiu->numFailed) goto exit;
00448 
00449     /* Continue processing file arguments, building transaction set. */
00450     for (eiu->fnp = eiu->pkgURL+eiu->prevx;
00451          *eiu->fnp != NULL;
00452          eiu->fnp++, eiu->prevx++)
00453     {
00454         const char * fileName;
00455 
00456         rpmMessage(RPMMESS_DEBUG, "============== %s\n", *eiu->fnp);
00457         (void) urlPath(*eiu->fnp, &fileName);
00458 
00459         /* Try to read the header from a package file. */
00460         eiu->fd = Fopen(*eiu->fnp, "r.ufdio");
00461         if (eiu->fd == NULL || Ferror(eiu->fd)) {
00462             rpmError(RPMERR_OPEN, _("open of %s failed: %s\n"), *eiu->fnp,
00463                         Fstrerror(eiu->fd));
00464             if (eiu->fd != NULL) {
00465                 xx = Fclose(eiu->fd);
00466                 eiu->fd = NULL;
00467             }
00468             eiu->numFailed++; *eiu->fnp = NULL;
00469             continue;
00470         }
00471 
00472         /* Read the header, verifying signatures (if present). */
00473         tvsflags = rpmtsSetVSFlags(ts, vsflags);
00474         eiu->rpmrc = rpmReadPackageFile(ts, eiu->fd, *eiu->fnp, &eiu->h);
00475         tvsflags = rpmtsSetVSFlags(ts, tvsflags);
00476         xx = Fclose(eiu->fd);
00477         eiu->fd = NULL;
00478 
00479         switch (eiu->rpmrc) {
00480         case RPMRC_FAIL:
00481             rpmMessage(RPMMESS_ERROR, _("%s cannot be installed\n"), *eiu->fnp);
00482             eiu->numFailed++; *eiu->fnp = NULL;
00483             continue;
00484             /*@notreached@*/ /*@switchbreak@*/ break;
00485         case RPMRC_NOTFOUND:
00486             goto maybe_manifest;
00487             /*@notreached@*/ /*@switchbreak@*/ break;
00488         case RPMRC_NOTTRUSTED:
00489         case RPMRC_NOKEY:
00490         case RPMRC_OK:
00491         default:
00492             /*@switchbreak@*/ break;
00493         }
00494 
00495         eiu->isSource = headerIsEntry(eiu->h, RPMTAG_SOURCEPACKAGE);
00496 
00497         if (eiu->isSource) {
00498             rpmMessage(RPMMESS_DEBUG, "\tadded source package [%d]\n",
00499                 eiu->numSRPMS);
00500             eiu->sourceURL = xrealloc(eiu->sourceURL,
00501                                 (eiu->numSRPMS + 2) * sizeof(*eiu->sourceURL));
00502             eiu->sourceURL[eiu->numSRPMS] = *eiu->fnp;
00503             *eiu->fnp = NULL;
00504             eiu->numSRPMS++;
00505             eiu->sourceURL[eiu->numSRPMS] = NULL;
00506             continue;
00507         }
00508 
00509         if (eiu->relocations) {
00510             const char ** paths;
00511             int pft;
00512             int c;
00513 
00514             if (headerGetEntry(eiu->h, RPMTAG_PREFIXES, &pft,
00515                                        (void **) &paths, &c) && (c == 1))
00516             {
00517                 eiu->relocations->oldPath = xstrdup(paths[0]);
00518                 paths = headerFreeData(paths, pft);
00519             } else {
00520                 const char * name;
00521                 xx = headerNVR(eiu->h, &name, NULL, NULL);
00522                 rpmMessage(RPMMESS_ERROR,
00523                                _("package %s is not relocateable\n"), name);
00524                 eiu->numFailed++;
00525                 goto exit;
00526                 /*@notreached@*/
00527             }
00528         }
00529 
00530         /* On --freshen, verify package is installed and newer */
00531         if (ia->installInterfaceFlags & INSTALL_FRESHEN) {
00532             rpmdbMatchIterator mi;
00533             const char * name;
00534             Header oldH;
00535             int count;
00536 
00537             xx = headerNVR(eiu->h, &name, NULL, NULL);
00538             mi = rpmtsInitIterator(ts, RPMTAG_NAME, name, 0);
00539             count = rpmdbGetIteratorCount(mi);
00540             while ((oldH = rpmdbNextIterator(mi)) != NULL) {
00541                 if (rpmVersionCompare(oldH, eiu->h) < 0)
00542                     /*@innercontinue@*/ continue;
00543                 /* same or newer package already installed */
00544                 count = 0;
00545                 /*@innerbreak@*/ break;
00546             }
00547             mi = rpmdbFreeIterator(mi);
00548             if (count == 0) {
00549                 eiu->h = headerFree(eiu->h);
00550                 continue;
00551             }
00552             /* Package is newer than those currently installed. */
00553         }
00554 
00555         /*@-abstract@*/
00556         rc = rpmtsAddInstallElement(ts, eiu->h, (fnpyKey)fileName,
00557                         (ia->installInterfaceFlags & INSTALL_UPGRADE) != 0,
00558                         relocations);
00559         /*@=abstract@*/
00560 
00561         /* XXX reference held by transaction set */
00562         eiu->h = headerFree(eiu->h);
00563         if (eiu->relocations)
00564             eiu->relocations->oldPath = _free(eiu->relocations->oldPath);
00565 
00566         switch(rc) {
00567         case 0:
00568             rpmMessage(RPMMESS_DEBUG, "\tadded binary package [%d]\n",
00569                         eiu->numRPMS);
00570             /*@switchbreak@*/ break;
00571         case 1:
00572             rpmMessage(RPMMESS_ERROR,
00573                             _("error reading from file %s\n"), *eiu->fnp);
00574             eiu->numFailed++;
00575             goto exit;
00576             /*@notreached@*/ /*@switchbreak@*/ break;
00577         case 2:
00578             rpmMessage(RPMMESS_ERROR,
00579                             _("file %s requires a newer version of RPM\n"),
00580                             *eiu->fnp);
00581             eiu->numFailed++;
00582             goto exit;
00583             /*@notreached@*/ /*@switchbreak@*/ break;
00584         }
00585 
00586         eiu->numRPMS++;
00587         continue;
00588 
00589 maybe_manifest:
00590         /* Try to read a package manifest. */
00591         eiu->fd = Fopen(*eiu->fnp, "r.fpio");
00592         if (eiu->fd == NULL || Ferror(eiu->fd)) {
00593             rpmError(RPMERR_OPEN, _("open of %s failed: %s\n"), *eiu->fnp,
00594                         Fstrerror(eiu->fd));
00595             if (eiu->fd != NULL) {
00596                 xx = Fclose(eiu->fd);
00597                 eiu->fd = NULL;
00598             }
00599             eiu->numFailed++; *eiu->fnp = NULL;
00600             break;
00601         }
00602 
00603         /* Read list of packages from manifest. */
00604         rc = rpmReadPackageManifest(eiu->fd, &eiu->argc, &eiu->argv);
00605         if (rc != RPMRC_OK)
00606             rpmError(RPMERR_MANIFEST, _("%s: not an rpm package (or package manifest): %s\n"),
00607                         *eiu->fnp, Fstrerror(eiu->fd));
00608         xx = Fclose(eiu->fd);
00609         eiu->fd = NULL;
00610 
00611         /* If successful, restart the query loop. */
00612         if (rc == RPMRC_OK) {
00613             eiu->prevx++;
00614             goto restart;
00615         }
00616 
00617         eiu->numFailed++; *eiu->fnp = NULL;
00618         break;
00619     }
00620 
00621     rpmMessage(RPMMESS_DEBUG, _("found %d source and %d binary packages\n"),
00622                 eiu->numSRPMS, eiu->numRPMS);
00623 
00624     if (eiu->numFailed) goto exit;
00625 
00626     if (eiu->numRPMS && !(ia->installInterfaceFlags & INSTALL_NODEPS)) {
00627 
00628         if (rpmtsCheck(ts)) {
00629             eiu->numFailed = eiu->numPkgs;
00630             stopInstall = 1;
00631         }
00632 
00633         ps = rpmtsProblems(ts);
00634         if (!stopInstall && rpmpsNumProblems(ps) > 0) {
00635             rpmMessage(RPMMESS_ERROR, _("Failed dependencies:\n"));
00636             rpmpsPrint(NULL, ps);
00637             eiu->numFailed = eiu->numPkgs;
00638             stopInstall = 1;
00639 
00640             /*@-branchstate@*/
00641             if (ts->suggests != NULL && ts->nsuggests > 0) {
00642                 rpmMessage(RPMMESS_NORMAL, _("    Suggested resolutions:\n"));
00643                 for (i = 0; i < ts->nsuggests; i++) {
00644                     const char * str = ts->suggests[i];
00645 
00646                     if (str == NULL)
00647                         break;
00648 
00649                     rpmMessage(RPMMESS_NORMAL, "\t%s\n", str);
00650                 
00651                     ts->suggests[i] = NULL;
00652                     str = _free(str);
00653                 }
00654                 ts->suggests = _free(ts->suggests);
00655             }
00656             /*@=branchstate@*/
00657         }
00658         ps = rpmpsFree(ps);
00659     }
00660 
00661     if (eiu->numRPMS && !(ia->installInterfaceFlags & INSTALL_NOORDER)) {
00662         if (rpmtsOrder(ts)) {
00663             eiu->numFailed = eiu->numPkgs;
00664             stopInstall = 1;
00665         }
00666     }
00667 
00668     if (eiu->numRPMS && !stopInstall) {
00669 
00670         rpmcliPackagesTotal += eiu->numSRPMS;
00671 
00672         rpmMessage(RPMMESS_DEBUG, _("installing binary packages\n"));
00673 
00674         /* Drop added/available package indices and dependency sets. */
00675         rpmtsClean(ts);
00676 
00677         rc = rpmtsRun(ts, NULL, probFilter);
00678         ps = rpmtsProblems(ts);
00679 
00680         if (rc < 0) {
00681             eiu->numFailed += eiu->numRPMS;
00682         } else if (rc > 0) {
00683             eiu->numFailed += rc;
00684             if (rpmpsNumProblems(ps) > 0)
00685                 rpmpsPrint(stderr, ps);
00686         }
00687         ps = rpmpsFree(ps);
00688     }
00689 
00690     if (eiu->numSRPMS && !stopInstall) {
00691         if (eiu->sourceURL != NULL)
00692         for (i = 0; i < eiu->numSRPMS; i++) {
00693             if (eiu->sourceURL[i] == NULL) continue;
00694             eiu->fd = Fopen(eiu->sourceURL[i], "r.ufdio");
00695             if (eiu->fd == NULL || Ferror(eiu->fd)) {
00696                 rpmMessage(RPMMESS_ERROR, _("cannot open file %s: %s\n"),
00697                            eiu->sourceURL[i], Fstrerror(eiu->fd));
00698                 if (eiu->fd != NULL) {
00699                     xx = Fclose(eiu->fd);
00700                     eiu->fd = NULL;
00701                 }
00702                 continue;
00703             }
00704 
00705             if (!(rpmtsFlags(ts) & RPMTRANS_FLAG_TEST)) {
00706                 eiu->rpmrc = rpmInstallSourcePackage(ts, eiu->fd, NULL, NULL);
00707                 if (eiu->rpmrc != RPMRC_OK) eiu->numFailed++;
00708             }
00709 
00710             xx = Fclose(eiu->fd);
00711             eiu->fd = NULL;
00712         }
00713     }
00714 
00715 exit:
00716     if (eiu->pkgURL != NULL)
00717     for (i = 0; i < eiu->numPkgs; i++) {
00718         if (eiu->pkgURL[i] == NULL) continue;
00719         if (eiu->pkgState[i] == 1)
00720             (void) Unlink(eiu->pkgURL[i]);
00721         eiu->pkgURL[i] = _free(eiu->pkgURL[i]);
00722     }
00723     eiu->pkgState = _free(eiu->pkgState);
00724     eiu->pkgURL = _free(eiu->pkgURL);
00725     eiu->argv = _free(eiu->argv);
00726 
00727     rpmtsEmpty(ts);
00728 
00729     return eiu->numFailed;
00730 }
00731 /*@=bounds@*/
00732 
00733 int rpmErase(rpmts ts, struct rpmInstallArguments_s * ia,
00734                 const char ** argv)
00735 {
00736     int count;
00737     const char ** arg;
00738     int numFailed = 0;
00739     int stopUninstall = 0;
00740     int numPackages = 0;
00741     rpmVSFlags vsflags, ovsflags;
00742     rpmps ps;
00743 
00744     if (argv == NULL) return 0;
00745 
00746     vsflags = rpmExpandNumeric("%{?_vsflags_erase}");
00747     if (ia->qva_flags & VERIFY_DIGEST)
00748         vsflags |= _RPMVSF_NODIGESTS;
00749     if (ia->qva_flags & VERIFY_SIGNATURE)
00750         vsflags |= _RPMVSF_NOSIGNATURES;
00751     if (ia->qva_flags & VERIFY_HDRCHK)
00752         vsflags |= RPMVSF_NOHDRCHK;
00753     ovsflags = rpmtsSetVSFlags(ts, vsflags);
00754 
00755     if (rpmExpandNumeric("%{?_repackage_all_erasures}"))
00756         ia->transFlags |= RPMTRANS_FLAG_REPACKAGE;
00757 
00758     (void) rpmtsSetFlags(ts, ia->transFlags);
00759 
00760 #ifdef  NOTYET  /* XXX no callbacks on erase yet */
00761     {   int notifyFlags;
00762         notifyFlags = ia->eraseInterfaceFlags | (rpmIsVerbose() ? INSTALL_LABEL : 0 );
00763         xx = rpmtsSetNotifyCallback(ts,
00764                         rpmShowProgress, (void *) ((long)notifyFlags)
00765     }
00766 #endif
00767 
00768     ts->goal = TSM_ERASE;
00769 
00770     for (arg = argv; *arg; arg++) {
00771         rpmdbMatchIterator mi;
00772 
00773         /* XXX HACK to get rpmdbFindByLabel out of the API */
00774         mi = rpmtsInitIterator(ts, RPMDBI_LABEL, *arg, 0);
00775         if (mi == NULL) {
00776             rpmMessage(RPMMESS_ERROR, _("package %s is not installed\n"), *arg);
00777             numFailed++;
00778         } else {
00779             Header h;   /* XXX iterator owns the reference */
00780             count = 0;
00781             while ((h = rpmdbNextIterator(mi)) != NULL) {
00782                 unsigned int recOffset = rpmdbGetIteratorOffset(mi);
00783 
00784                 if (!(count++ == 0 || (ia->eraseInterfaceFlags & UNINSTALL_ALLMATCHES))) {
00785                     rpmMessage(RPMMESS_ERROR, _("\"%s\" specifies multiple packages\n"),
00786                         *arg);
00787                     numFailed++;
00788                     break;
00789                 }
00790                 if (recOffset) {
00791                     (void) rpmtsAddEraseElement(ts, h, recOffset);
00792                     numPackages++;
00793                 }
00794             }
00795         }
00796         mi = rpmdbFreeIterator(mi);
00797     }
00798 
00799     if (!(ia->eraseInterfaceFlags & UNINSTALL_NODEPS)) {
00800 
00801         if (rpmtsCheck(ts)) {
00802             numFailed = numPackages;
00803             stopUninstall = 1;
00804         }
00805 
00806         ps = rpmtsProblems(ts);
00807         if (!stopUninstall && rpmpsNumProblems(ps) > 0) {
00808             rpmMessage(RPMMESS_ERROR, _("Failed dependencies:\n"));
00809             rpmpsPrint(NULL, ps);
00810             numFailed += numPackages;
00811             stopUninstall = 1;
00812         }
00813         ps = rpmpsFree(ps);
00814     }
00815 
00816     if (!stopUninstall) {
00817         (void) rpmtsSetFlags(ts, (rpmtsFlags(ts) | RPMTRANS_FLAG_REVERSE));
00818 
00819         /* Drop added/available package indices and dependency sets. */
00820         rpmtsClean(ts);
00821 
00822         numPackages = rpmtsRun(ts, NULL, 0);
00823         ps = rpmtsProblems(ts);
00824         if (rpmpsNumProblems(ps) > 0)
00825             rpmpsPrint(NULL, ps);
00826         numFailed += numPackages;
00827         stopUninstall = 1;
00828         ps = rpmpsFree(ps);
00829     }
00830 
00831     rpmtsEmpty(ts);
00832 
00833     return numFailed;
00834 }
00835 
00836 int rpmInstallSource(rpmts ts, const char * arg,
00837                 const char ** specFilePtr, const char ** cookie)
00838 {
00839     FD_t fd;
00840     int rc;
00841 
00842 
00843     fd = Fopen(arg, "r.ufdio");
00844     if (fd == NULL || Ferror(fd)) {
00845         rpmMessage(RPMMESS_ERROR, _("cannot open %s: %s\n"), arg, Fstrerror(fd));
00846         if (fd != NULL) (void) Fclose(fd);
00847         return 1;
00848     }
00849 
00850     if (rpmIsVerbose())
00851         fprintf(stdout, _("Installing %s\n"), arg);
00852 
00853     {
00854         rpmVSFlags ovsflags =
00855                 rpmtsSetVSFlags(ts, (rpmtsVSFlags(ts) | RPMVSF_NEEDPAYLOAD));
00856         rpmRC rpmrc = rpmInstallSourcePackage(ts, fd, specFilePtr, cookie);
00857         rc = (rpmrc == RPMRC_OK ? 0 : 1);
00858         ovsflags = rpmtsSetVSFlags(ts, ovsflags);
00859     }
00860     if (rc != 0) {
00861         rpmMessage(RPMMESS_ERROR, _("%s cannot be installed\n"), arg);
00862         /*@-unqualifiedtrans@*/
00863         if (specFilePtr && *specFilePtr)
00864             *specFilePtr = _free(*specFilePtr);
00865         if (cookie && *cookie)
00866             *cookie = _free(*cookie);
00867         /*@=unqualifiedtrans@*/
00868     }
00869 
00870     (void) Fclose(fd);
00871 
00872     return rc;
00873 }
00874 
00875 /*@unchecked@*/
00876 static int reverse = -1;
00877 
00880 static int IDTintcmp(const void * a, const void * b)
00881         /*@*/
00882 {
00883     /*@-castexpose@*/
00884     return ( reverse * (((IDT)a)->val.u32 - ((IDT)b)->val.u32) );
00885     /*@=castexpose@*/
00886 }
00887 
00888 IDTX IDTXfree(IDTX idtx)
00889 {
00890     if (idtx) {
00891         int i;
00892         if (idtx->idt)
00893         for (i = 0; i < idtx->nidt; i++) {
00894             IDT idt = idtx->idt + i;
00895             idt->h = headerFree(idt->h);
00896             idt->key = _free(idt->key);
00897         }
00898         idtx->idt = _free(idtx->idt);
00899         idtx = _free(idtx);
00900     }
00901     return NULL;
00902 }
00903 
00904 IDTX IDTXnew(void)
00905 {
00906     IDTX idtx = xcalloc(1, sizeof(*idtx));
00907     idtx->delta = 10;
00908     idtx->size = sizeof(*((IDT)0));
00909     return idtx;
00910 }
00911 
00912 IDTX IDTXgrow(IDTX idtx, int need)
00913 {
00914     if (need < 0) return NULL;
00915     if (idtx == NULL)
00916         idtx = IDTXnew();
00917     if (need == 0) return idtx;
00918 
00919     if ((idtx->nidt + need) > idtx->alloced) {
00920         while (need > 0) {
00921             idtx->alloced += idtx->delta;
00922             need -= idtx->delta;
00923         }
00924         idtx->idt = xrealloc(idtx->idt, (idtx->alloced * idtx->size) );
00925     }
00926     return idtx;
00927 }
00928 
00929 IDTX IDTXsort(IDTX idtx)
00930 {
00931     if (idtx != NULL && idtx->idt != NULL && idtx->nidt > 0)
00932         qsort(idtx->idt, idtx->nidt, idtx->size, IDTintcmp);
00933     return idtx;
00934 }
00935 
00936 IDTX IDTXload(rpmts ts, rpmTag tag)
00937 {
00938     IDTX idtx = NULL;
00939     rpmdbMatchIterator mi;
00940     HGE_t hge = (HGE_t) headerGetEntry;
00941     Header h;
00942 
00943     /*@-branchstate@*/
00944     mi = rpmtsInitIterator(ts, tag, NULL, 0);
00945 #ifdef  NOTYET
00946     (void) rpmdbSetIteratorRE(mi, RPMTAG_NAME, RPMMIRE_DEFAULT, '!gpg-pubkey');
00947 #endif
00948     while ((h = rpmdbNextIterator(mi)) != NULL) {
00949         rpmTagType type = RPM_NULL_TYPE;
00950         int_32 count = 0;
00951         int_32 * tidp;
00952 
00953         tidp = NULL;
00954         if (!hge(h, tag, &type, (void **)&tidp, &count) || tidp == NULL)
00955             continue;
00956 
00957         if (type == RPM_INT32_TYPE && (*tidp == 0 || *tidp == -1))
00958             continue;
00959 
00960         idtx = IDTXgrow(idtx, 1);
00961         if (idtx == NULL)
00962             continue;
00963         if (idtx->idt == NULL)
00964             continue;
00965 
00966         {   IDT idt;
00967             /*@-nullderef@*/
00968             idt = idtx->idt + idtx->nidt;
00969             /*@=nullderef@*/
00970             idt->h = headerLink(h);
00971             idt->key = NULL;
00972             idt->instance = rpmdbGetIteratorOffset(mi);
00973             idt->val.u32 = *tidp;
00974         }
00975         idtx->nidt++;
00976     }
00977     mi = rpmdbFreeIterator(mi);
00978     /*@=branchstate@*/
00979 
00980     return IDTXsort(idtx);
00981 }
00982 
00983 IDTX IDTXglob(rpmts ts, const char * globstr, rpmTag tag)
00984 {
00985     IDTX idtx = NULL;
00986     HGE_t hge = (HGE_t) headerGetEntry;
00987     Header h;
00988     int_32 * tidp;
00989     FD_t fd;
00990     const char ** av = NULL;
00991     int ac = 0;
00992     rpmRC rpmrc;
00993     int xx;
00994     int i;
00995 
00996     av = NULL;  ac = 0;
00997     xx = rpmGlob(globstr, &ac, &av);
00998 
00999     if (xx == 0)
01000     for (i = 0; i < ac; i++) {
01001         rpmTagType type;
01002         int_32 count;
01003         int isSource;
01004 
01005         fd = Fopen(av[i], "r.ufdio");
01006         if (fd == NULL || Ferror(fd)) {
01007             rpmError(RPMERR_OPEN, _("open of %s failed: %s\n"), av[i],
01008                         Fstrerror(fd));
01009             if (fd != NULL) (void) Fclose(fd);
01010             continue;
01011         }
01012 
01013         rpmrc = rpmReadPackageFile(ts, fd, av[i], &h);
01014         (void) Fclose(fd);
01015         switch (rpmrc) {
01016         default:
01017             goto bottom;
01018             /*@notreached@*/ /*@switchbreak@*/ break;
01019         case RPMRC_NOTTRUSTED:
01020         case RPMRC_NOKEY:
01021         case RPMRC_OK:
01022             isSource = headerIsEntry(h, RPMTAG_SOURCEPACKAGE);
01023             if (isSource)
01024                 goto bottom;
01025             /*@switchbreak@*/ break;
01026         }
01027 
01028         tidp = NULL;
01029         /*@-branchstate@*/
01030         if (hge(h, tag, &type, (void **) &tidp, &count) && tidp) {
01031 
01032             idtx = IDTXgrow(idtx, 1);
01033             if (idtx == NULL || idtx->idt == NULL)
01034                 goto bottom;
01035 
01036             {   IDT idt;
01037                 idt = idtx->idt + idtx->nidt;
01038                 idt->h = headerLink(h);
01039                 idt->key = av[i];
01040                 av[i] = NULL;
01041                 idt->instance = 0;
01042                 idt->val.u32 = *tidp;
01043             }
01044             idtx->nidt++;
01045         }
01046         /*@=branchstate@*/
01047 bottom:
01048         h = headerFree(h);
01049     }
01050 
01051     for (i = 0; i < ac; i++)
01052         av[i] = _free(av[i]);
01053     av = _free(av);     ac = 0;
01054 
01055     return IDTXsort(idtx);
01056 }
01057 
01059 int rpmRollback(rpmts ts, struct rpmInstallArguments_s * ia, const char ** argv)
01060 {
01061     int ifmask= (INSTALL_UPGRADE|INSTALL_FRESHEN|INSTALL_INSTALL|INSTALL_ERASE);
01062     unsigned thistid = 0xffffffff;
01063     unsigned prevtid;
01064     time_t tid;
01065     IDTX itids = NULL;
01066     IDTX rtids = NULL;
01067     IDT rp;
01068     int nrids = 0;
01069     IDT ip;
01070     int niids = 0;
01071     int rc = 0;
01072     int vsflags, ovsflags;
01073     int numAdded;
01074     int numRemoved;
01075     rpmps ps;
01076     int _unsafe_rollbacks = 0;
01077     rpmtransFlags transFlags = ia->transFlags;
01078 
01079     if (argv != NULL && *argv != NULL) {
01080         rc = -1;
01081         goto exit;
01082     }
01083 
01084     _unsafe_rollbacks = rpmExpandNumeric("%{?_unsafe_rollbacks}");
01085 
01086     vsflags = rpmExpandNumeric("%{?_vsflags_erase}");
01087     if (ia->qva_flags & VERIFY_DIGEST)
01088         vsflags |= _RPMVSF_NODIGESTS;
01089     if (ia->qva_flags & VERIFY_SIGNATURE)
01090         vsflags |= _RPMVSF_NOSIGNATURES;
01091     if (ia->qva_flags & VERIFY_HDRCHK)
01092         vsflags |= RPMVSF_NOHDRCHK;
01093     vsflags |= RPMVSF_NEEDPAYLOAD;      /* XXX no legacy signatures */
01094     ovsflags = rpmtsSetVSFlags(ts, vsflags);
01095 
01096     (void) rpmtsSetFlags(ts, transFlags);
01097 
01098     itids = IDTXload(ts, RPMTAG_INSTALLTID);
01099     if (itids != NULL) {
01100         ip = itids->idt;
01101         niids = itids->nidt;
01102     } else {
01103         ip = NULL;
01104         niids = 0;
01105     }
01106 
01107     {   const char * globstr = rpmExpand("%{_repackage_dir}/*.rpm", NULL);
01108         if (globstr == NULL || *globstr == '%') {
01109             globstr = _free(globstr);
01110             rc = -1;
01111             goto exit;
01112         }
01113         rtids = IDTXglob(ts, globstr, RPMTAG_REMOVETID);
01114 
01115         if (rtids != NULL) {
01116             rp = rtids->idt;
01117             nrids = rtids->nidt;
01118         } else {
01119             rp = NULL;
01120             nrids = 0;
01121         }
01122         globstr = _free(globstr);
01123     }
01124 
01125     {   int notifyFlags, xx;
01126         notifyFlags = ia->installInterfaceFlags | (rpmIsVerbose() ? INSTALL_LABEL : 0 );
01127         xx = rpmtsSetNotifyCallback(ts,
01128                         rpmShowProgress, (void *) ((long)notifyFlags));
01129     }
01130 
01131     /* Run transactions until rollback goal is achieved. */
01132     do {
01133         prevtid = thistid;
01134         rc = 0;
01135         rpmcliPackagesTotal = 0;
01136         numAdded = 0;
01137         numRemoved = 0;
01138         ia->installInterfaceFlags &= ~ifmask;
01139 
01140         /* Find larger of the remaining install/erase transaction id's. */
01141         thistid = 0;
01142         if (ip != NULL && ip->val.u32 > thistid)
01143             thistid = ip->val.u32;
01144         if (rp != NULL && rp->val.u32 > thistid)
01145             thistid = rp->val.u32;
01146 
01147         /* If we've achieved the rollback goal, then we're done. */
01148         if (thistid == 0 || thistid < ia->rbtid)
01149             break;
01150 
01151         /* If we've reached the (configured) rollback goal, then we're done. */
01152         if (_unsafe_rollbacks && thistid <= _unsafe_rollbacks)
01153             break;
01154 
01155         rpmtsEmpty(ts);
01156         (void) rpmtsSetFlags(ts, transFlags);
01157 
01158         /* Install the previously erased packages for this transaction. */
01159         while (rp != NULL && rp->val.u32 == thistid) {
01160 
01161             rpmMessage(RPMMESS_DEBUG, "\t+++ install %s\n",
01162                         (rp->key ? rp->key : "???"));
01163 
01164 /*@-abstract@*/
01165             rc = rpmtsAddInstallElement(ts, rp->h, (fnpyKey)rp->key,
01166                                0, ia->relocations);
01167 /*@=abstract@*/
01168             if (rc != 0)
01169                 goto exit;
01170 
01171             numAdded++;
01172             rpmcliPackagesTotal++;
01173             if (!(ia->installInterfaceFlags & ifmask))
01174                 ia->installInterfaceFlags |= INSTALL_UPGRADE;
01175 
01176 #ifdef  NOTYET
01177             rp->h = headerFree(rp->h);
01178 #endif
01179             nrids--;
01180             if (nrids > 0)
01181                 rp++;
01182             else
01183                 rp = NULL;
01184         }
01185 
01186         /* Erase the previously installed packages for this transaction. */
01187         while (ip != NULL && ip->val.u32 == thistid) {
01188 
01189             rpmMessage(RPMMESS_DEBUG,
01190                         "\t--- erase h#%u\n", ip->instance);
01191 
01192             rc = rpmtsAddEraseElement(ts, ip->h, ip->instance);
01193             if (rc != 0)
01194                 goto exit;
01195 
01196             numRemoved++;
01197 
01198             if (_unsafe_rollbacks)
01199                 rpmcliPackagesTotal++;
01200 
01201             if (!(ia->installInterfaceFlags & ifmask)) {
01202                 ia->installInterfaceFlags |= INSTALL_ERASE;
01203                 (void) rpmtsSetFlags(ts, (transFlags | RPMTRANS_FLAG_REVERSE));
01204             }
01205 
01206 #ifdef  NOTYET
01207             ip->instance = 0;
01208 #endif
01209             niids--;
01210             if (niids > 0)
01211                 ip++;
01212             else
01213                 ip = NULL;
01214         }
01215 
01216         /* Anything to do? */
01217         if (rpmcliPackagesTotal <= 0)
01218             break;
01219 
01220         tid = (time_t)thistid;
01221         rpmMessage(RPMMESS_NORMAL,
01222                 _("Rollback packages (+%d/-%d) to %-24.24s (0x%08x):\n"),
01223                         numAdded, numRemoved, ctime(&tid), tid);
01224 
01225         rc = rpmtsCheck(ts);
01226         ps = rpmtsProblems(ts);
01227         if (rc != 0 && rpmpsNumProblems(ps) > 0) {
01228             rpmMessage(RPMMESS_ERROR, _("Failed dependencies:\n"));
01229             rpmpsPrint(NULL, ps);
01230             ps = rpmpsFree(ps);
01231             goto exit;
01232         }
01233         ps = rpmpsFree(ps);
01234 
01235         rc = rpmtsOrder(ts);
01236         if (rc != 0)
01237             goto exit;
01238 
01239         /* Drop added/available package indices and dependency sets. */
01240         rpmtsClean(ts);
01241 
01242         rc = rpmtsRun(ts, NULL, (ia->probFilter|RPMPROB_FILTER_OLDPACKAGE));
01243         ps = rpmtsProblems(ts);
01244         if (rc > 0 && rpmpsNumProblems(ps) > 0)
01245             rpmpsPrint(stderr, ps);
01246         ps = rpmpsFree(ps);
01247         if (rc)
01248             goto exit;
01249 
01250         /* Clean up after successful rollback. */
01251         if (rtids && !rpmIsDebug()) {
01252             int i;
01253             if (rtids->idt)
01254             for (i = 0; i < rtids->nidt; i++) {
01255                 IDT rrp = rtids->idt + i;
01256                 if (rrp->val.u32 != thistid)
01257                     /*@innercontinue@*/ continue;
01258                 if (rrp->key)   /* XXX can't happen */
01259                     (void) unlink(rrp->key);
01260             }
01261         }
01262 
01263 
01264     } while (1);
01265 
01266 exit:
01267     rtids = IDTXfree(rtids);
01268     itids = IDTXfree(itids);
01269 
01270     rpmtsEmpty(ts);
01271     (void) rpmtsSetFlags(ts, transFlags);
01272 
01273     return rc;
01274 }

Generated on Sun Oct 26 13:02:00 2003 for rpm by doxygen1.2.18