RPM Package Manager, CVS Repository
http://rpm5.org/cvs/
____________________________________________________________________________
Server: rpm5.org Name: Jeff Johnson
Root: /v/rpm/cvs Email: jbj@rpm5.org
Module: rpm Date: 17-Aug-2007 20:06:00
Branch: HEAD Handle: 2007081719055900
Modified files:
rpm CHANGES
rpm/lib rpminstall.c
Log:
- use rpmgi for --install/--upgrade/--freshen. non-functional atm.
Summary:
Revision Changes Path
1.1580 +1 -0 rpm/CHANGES
1.155 +90 -301 rpm/lib/rpminstall.c
____________________________________________________________________________
patch -p0 <<'@@ .'
Index: rpm/CHANGES
============================================================================
$ cvs diff -u -r1.1579 -r1.1580 CHANGES
--- rpm/CHANGES 17 Aug 2007 05:36:03 -0000 1.1579
+++ rpm/CHANGES 17 Aug 2007 18:05:59 -0000 1.1580
@@ -1,4 +1,5 @@
4.5 -> 5.0:
+ - jbj: use rpmgi for --install/--upgrade/--freshen. non-functional atm.
- jbj: add getter/setter for header magic to hide _newmagic construction.
- jbj: functional sign/verify on --nolead --newmagic packages.
- jbj: no-operation code paths for --nolead --nosigh packages.
@@ .
patch -p0 <<'@@ .'
Index: rpm/lib/rpminstall.c
============================================================================
$ cvs diff -u -r1.154 -r1.155 rpminstall.c
--- rpm/lib/rpminstall.c 30 Jul 2007 01:40:35 -0000 1.154
+++ rpm/lib/rpminstall.c 17 Aug 2007 18:05:59 -0000 1.155
@@ -257,46 +257,21 @@
typedef /*@only@*/ /*@null@*/ const char * str_t;
-struct rpmEIU {
- Header h;
- FD_t fd;
- int numFailed;
- int numPkgs;
-/*@only@*/
- str_t * pkgURL;
-/*@dependent@*/ /*@null@*/
- str_t * fnp;
-/*@only@*/
- char * pkgState;
- int prevx;
- int pkgx;
- int numRPMS;
- int numSRPMS;
-/*@only@*/ /*@null@*/
- str_t * sourceURL;
- int isSource;
- int argc;
-/*@only@*/ /*@null@*/
- str_t * argv;
-/*@dependent@*/
- rpmRelocation relocations;
- rpmRC rpmrc;
-};
-
/** @todo Generalize --freshen policies. */
/*@-bounds@*/
int rpmInstall(rpmts ts, QVA_t ia, const char ** fileArgv)
{
- struct rpmEIU * eiu = memset(alloca(sizeof(*eiu)), 0, sizeof(*eiu));
+ int numFailed = 0;
+ int numPkgs = 0;
+ int numRPMS = 0;
+ int numSRPMS = 0;
+ str_t * sourceURL = NULL;
+ rpmRelocation relocations = NULL;
+ rpmRC rpmrc = RPMRC_OK;
+
rpmps ps;
- rpmprobFilterFlags probFilter;
- rpmRelocation relocations;
-/*@only@*/ /*@null@*/ const char * fileURL = NULL;
int stopInstall = 0;
- const char ** av = NULL;
- const char *fn;
- rpmVSFlags vsflags, ovsflags, tvsflags;
- int ac = 0;
+ rpmVSFlags vsflags, ovsflags;
int rc;
int xx;
int i;
@@ -329,9 +304,6 @@
}
}
- probFilter = ia->probFilter;
- relocations = ia->relocations;
-
if (ia->installInterfaceFlags & INSTALL_UPGRADE)
vsflags = rpmExpandNumeric("%{?_vsflags_erase}");
else
@@ -350,56 +322,14 @@
rpmShowProgress, (void *) ((long)notifyFlags));
}
- if ((eiu->relocations = relocations) != NULL) {
- while (eiu->relocations->oldPath)
- eiu->relocations++;
- if (eiu->relocations->newPath == NULL)
- eiu->relocations = NULL;
- }
-
- /* Build fully globbed list of arguments in argv[argc]. */
- /*@-branchstate@*/
- /*@-temptrans@*/
- for (eiu->fnp = fileArgv; *eiu->fnp != NULL; eiu->fnp++) {
- /*@=temptrans@*/
- av = _free(av); ac = 0;
- fn = rpmgiEscapeSpaces(*eiu->fnp);
- rc = rpmGlob(fn, &ac, &av);
- fn = _free(fn);
- if (rc || ac == 0) {
- rpmError(RPMERR_OPEN, _("File not found by glob: %s\n"), *eiu->fnp);
- continue;
- }
-
- eiu->argv = xrealloc(eiu->argv, (eiu->argc+ac+1) * sizeof(*eiu->argv));
- memcpy(eiu->argv+eiu->argc, av, ac * sizeof(*av));
- eiu->argc += ac;
- eiu->argv[eiu->argc] = NULL;
- }
- /*@=branchstate@*/
- av = _free(av); ac = 0;
-
-restart:
- /* Allocate sufficient storage for next set of args. */
- if (eiu->pkgx >= eiu->numPkgs) {
- eiu->numPkgs = eiu->pkgx + eiu->argc;
- eiu->pkgURL = xrealloc(eiu->pkgURL,
- (eiu->numPkgs + 1) * sizeof(*eiu->pkgURL));
- memset(eiu->pkgURL + eiu->pkgx, 0,
- ((eiu->argc + 1) * sizeof(*eiu->pkgURL)));
- eiu->pkgState = xrealloc(eiu->pkgState,
- (eiu->numPkgs + 1) * sizeof(*eiu->pkgState));
- memset(eiu->pkgState + eiu->pkgx, 0,
- ((eiu->argc + 1) * sizeof(*eiu->pkgState)));
+ if ((relocations = ia->relocations) != NULL) {
+ while (relocations->oldPath)
+ relocations++;
+ if (relocations->newPath == NULL)
+ relocations = NULL;
}
- /* Retrieve next set of args, cache on local storage. */
- for (i = 0; i < eiu->argc; i++) {
- fileURL = _free(fileURL);
- fileURL = eiu->argv[i];
- eiu->argv[i] = NULL;
-
-#ifdef NOTYET
+#if defined(REFERENCE_FORNOW)
if (fileURL[0] == '=') {
rpmds this = rpmdsSingle(RPMTAG_REQUIRENAME, fileURL+1, NULL, 0);
@@ -415,248 +345,117 @@
}
ts->suggests = _free(ts->suggests);
rpmMessage(RPMMESS_DEBUG, D_("Adding goal: %s\n"), fileURL);
- eiu->pkgURL[eiu->pkgx] = fileURL;
+ pkgURL[pkgx] = fileURL;
fileURL = NULL;
- eiu->pkgx++;
+ pkgx++;
}
this = rpmdsFree(this);
} else
#endif
- switch (urlIsURL(fileURL)) {
- case URL_IS_HTTPS:
- case URL_IS_HTTP:
- case URL_IS_FTP:
- { const char *tfn;
-
- if (rpmIsVerbose())
- fprintf(stdout, _("Retrieving %s\n"), fileURL);
-
- { char tfnbuf[64];
- const char * rootDir = rpmtsRootDir(ts);
- if (!(rootDir && * rootDir))
- rootDir = "";
- strcpy(tfnbuf, "rpm-xfer.XXXXXX");
-#if defined(HAVE_MKSTEMP)
- (void) close(mkstemp(tfnbuf));
-#else
- (void) mktemp(tfnbuf);
-#endif
- tfn = rpmGenPath(rootDir, "%{_tmppath}/", tfnbuf);
- }
-
- /* XXX undefined %{name}/%{version}/%{release} here */
- /* XXX %{_tmpdir} does not exist */
- rpmMessage(RPMMESS_DEBUG, D_(" ... as %s\n"), tfn);
- rc = urlGetFile(fileURL, tfn);
- if (rc < 0) {
- rpmMessage(RPMMESS_ERROR,
- _("skipping %s - transfer failed - %s\n"),
- fileURL, ftpStrerror(rc));
- eiu->numFailed++;
- eiu->pkgURL[eiu->pkgx] = NULL;
- tfn = _free(tfn);
- /*@switchbreak@*/ break;
- }
- eiu->pkgState[eiu->pkgx] = 1;
- eiu->pkgURL[eiu->pkgx] = tfn;
- eiu->pkgx++;
- } /*@switchbreak@*/ break;
- case URL_IS_PATH:
- case URL_IS_DASH: /* WRONG WRONG WRONG */
- case URL_IS_HKP: /* WRONG WRONG WRONG */
- default:
- eiu->pkgURL[eiu->pkgx] = fileURL;
- fileURL = NULL;
- eiu->pkgx++;
- /*@switchbreak@*/ break;
- }
- }
- fileURL = _free(fileURL);
-
- if (eiu->numFailed) goto exit;
-
- /* Continue processing file arguments, building transaction set. */
- for (eiu->fnp = eiu->pkgURL+eiu->prevx;
- *eiu->fnp != NULL;
- eiu->fnp++, eiu->prevx++)
- {
+{ /* start-of-transaction-build */
+ rpmgi gi = rpmgiNew(ts, RPMDBI_ARGLIST, NULL, 0);
+ int _ftsOpts = 0;
+ rpmgiFlags _giFlags = RPMGI_NONE;
+
+ rc = rpmgiSetArgs(gi, fileArgv, _ftsOpts, _giFlags);
+ while (rpmgiNext(gi) == RPMRC_OK) {
+ Header h = rpmgiHeader(gi);
const char * fileName;
+ int isSource;
- rpmMessage(RPMMESS_DEBUG, "============== %s\n", *eiu->fnp);
- (void) urlPath(*eiu->fnp, &fileName);
-
- /* Try to read the header from a package file. */
- eiu->fd = Fopen(*eiu->fnp, "r.fdio");
- if (eiu->fd == NULL || Ferror(eiu->fd)) {
- rpmError(RPMERR_OPEN, _("open of %s failed: %s\n"), *eiu->fnp,
- Fstrerror(eiu->fd));
- if (eiu->fd != NULL) {
- xx = Fclose(eiu->fd);
- eiu->fd = NULL;
- }
- eiu->numFailed++; *eiu->fnp = NULL;
+ if (h == NULL) {
+ numFailed++;
continue;
}
+ fileName = rpmgiHdrPath(gi);
- /* Read the header, verifying signatures (if present). */
- tvsflags = rpmtsSetVSFlags(ts, vsflags);
- eiu->rpmrc = rpmReadPackageFile(ts, eiu->fd, *eiu->fnp, &eiu->h);
- tvsflags = rpmtsSetVSFlags(ts, tvsflags);
- xx = Fclose(eiu->fd);
- eiu->fd = NULL;
-
- switch (eiu->rpmrc) {
- case RPMRC_FAIL:
- rpmMessage(RPMMESS_ERROR, _("%s cannot be installed\n"), *eiu->fnp);
- eiu->numFailed++; *eiu->fnp = NULL;
- continue;
- /*@notreached@*/ /*@switchbreak@*/ break;
- case RPMRC_NOTFOUND:
- goto maybe_manifest;
- /*@notreached@*/ /*@switchbreak@*/ break;
- case RPMRC_NOTTRUSTED:
- case RPMRC_NOKEY:
- case RPMRC_OK:
- default:
- /*@switchbreak@*/ break;
- }
-
- eiu->isSource = (headerIsEntry(eiu->h, RPMTAG_SOURCERPM) == 0);
-
- if (eiu->isSource) {
- rpmMessage(RPMMESS_DEBUG, D_("\tadded source package [%d]\n"),
- eiu->numSRPMS);
- eiu->sourceURL = xrealloc(eiu->sourceURL,
- (eiu->numSRPMS + 2) * sizeof(*eiu->sourceURL));
- eiu->sourceURL[eiu->numSRPMS] = *eiu->fnp;
- *eiu->fnp = NULL;
- eiu->numSRPMS++;
- eiu->sourceURL[eiu->numSRPMS] = NULL;
+ /* === Check for source package, saving for delayed installs. */
+ isSource = (headerIsEntry(h, RPMTAG_SOURCERPM) == 0);
+ if (isSource) {
+ rpmMessage(RPMMESS_DEBUG, D_("\tadded source package [%d]: %s\n"),
+ numSRPMS, fileName);
+ sourceURL = xrealloc(sourceURL,
+ (numSRPMS + 2) * sizeof(*sourceURL));
+ sourceURL[numSRPMS] = xstrdup(fileName);;
+ numSRPMS++;
+ sourceURL[numSRPMS] = NULL;
continue;
}
- if (eiu->relocations) {
+ /* === Check for relocatable package. */
+ if (relocations) {
const char ** paths;
int pft;
int c;
- if (headerGetEntry(eiu->h, RPMTAG_PREFIXES, &pft, &paths, &c)
+ if (headerGetEntry(h, RPMTAG_PREFIXES, &pft, &paths, &c)
&& c == 1)
{
- eiu->relocations->oldPath = xstrdup(paths[0]);
+ relocations->oldPath = xstrdup(paths[0]);
paths = headerFreeData(paths, pft);
} else {
const char * name;
- xx = headerNVR(eiu->h, &name, NULL, NULL);
+ xx = headerNVR(h, &name, NULL, NULL);
rpmMessage(RPMMESS_ERROR,
_("package %s is not relocatable\n"), name);
- eiu->numFailed++;
+ numFailed++;
goto exit;
/*@notreached@*/
}
}
- /* On --freshen, verify package is installed and newer */
+ /* === On --freshen, verify package is installed and newer */
if (ia->installInterfaceFlags & INSTALL_FRESHEN) {
rpmdbMatchIterator mi;
const char * name;
Header oldH;
int count;
- xx = headerNVR(eiu->h, &name, NULL, NULL);
+ xx = headerNVR(h, &name, NULL, NULL);
mi = rpmtsInitIterator(ts, RPMTAG_NAME, name, 0);
count = rpmdbGetIteratorCount(mi);
while ((oldH = rpmdbNextIterator(mi)) != NULL) {
- if (rpmVersionCompare(oldH, eiu->h) < 0)
+ if (rpmVersionCompare(oldH, h) < 0)
/*@innercontinue@*/ continue;
/* same or newer package already installed */
count = 0;
/*@innerbreak@*/ break;
}
mi = rpmdbFreeIterator(mi);
- if (count == 0) {
- eiu->h = headerFree(eiu->h);
+ if (count == 0)
continue;
- }
/* Package is newer than those currently installed. */
}
- /*@-abstract@*/
- rc = rpmtsAddInstallElement(ts, eiu->h, (fnpyKey)fileName,
+ /* === Add binary package to transaction set. */
+ rc = rpmtsAddInstallElement(ts, h, (fnpyKey)fileName,
(ia->installInterfaceFlags & INSTALL_UPGRADE) != 0,
- relocations);
- /*@=abstract@*/
+ ia->relocations);
- /* XXX reference held by transaction set */
- eiu->h = headerFree(eiu->h);
- if (eiu->relocations)
- eiu->relocations->oldPath = _free(eiu->relocations->oldPath);
-
- switch(rc) {
- case 0:
- rpmMessage(RPMMESS_DEBUG, D_("\tadded binary package [%d]\n"),
- eiu->numRPMS);
- eiu->numRPMS++;
- /*@switchbreak@*/ break;
- case 1:
- rpmMessage(RPMMESS_WARNING,
- _("package file %s was skipped\n"), *eiu->fnp);
- /*@switchbreak@*/ break;
- case 2:
- rpmMessage(RPMMESS_ERROR,
- _("file %s requires a newer version of RPM\n"),
- *eiu->fnp);
- eiu->numFailed++;
- goto exit;
- /*@notreached@*/ /*@switchbreak@*/ break;
- }
-
- continue;
-
-maybe_manifest:
- /* Try to read a package manifest. */
- eiu->fd = Fopen(*eiu->fnp, "r.fpio");
- if (eiu->fd == NULL || Ferror(eiu->fd)) {
- rpmError(RPMERR_OPEN, _("open of %s failed: %s\n"), *eiu->fnp,
- Fstrerror(eiu->fd));
- if (eiu->fd != NULL) {
- xx = Fclose(eiu->fd);
- eiu->fd = NULL;
- }
- eiu->numFailed++; *eiu->fnp = NULL;
- break;
- }
+ if (relocations)
+ relocations->oldPath = _free(relocations->oldPath);
- /* Read list of packages from manifest. */
-/*@-nullstate@*/ /* FIX: *eiu->argv can be NULL */
- rc = rpmReadPackageManifest(eiu->fd, &eiu->argc, &eiu->argv);
-/*@=nullstate@*/
- if (rc != RPMRC_OK)
- rpmError(RPMERR_MANIFEST, _("%s: not an rpm package (or package manifest): %s\n"),
- *eiu->fnp, Fstrerror(eiu->fd));
- xx = Fclose(eiu->fd);
- eiu->fd = NULL;
-
- /* If successful, restart the query loop. */
- if (rc == RPMRC_OK) {
- eiu->prevx++;
- goto restart;
- }
+ rpmMessage(RPMMESS_DEBUG, D_("\tadded binary package [%d]: %s\n"),
+ numRPMS, fileName);
- eiu->numFailed++; *eiu->fnp = NULL;
- break;
+ numRPMS++;
}
+ gi = rpmgiFree(gi);
+ numFailed++; /* XXX force a failure. */
+
+} /* end-of-transaction-build */
+
rpmMessage(RPMMESS_DEBUG, D_("found %d source and %d binary packages\n"),
- eiu->numSRPMS, eiu->numRPMS);
+ numSRPMS, numRPMS);
- if (eiu->numFailed) goto exit;
+ if (numFailed) goto exit;
- if (eiu->numRPMS && !(ia->installInterfaceFlags & INSTALL_NODEPS)) {
+ if (numRPMS && !(ia->installInterfaceFlags & INSTALL_NODEPS)) {
if (rpmtsCheck(ts)) {
- eiu->numFailed = eiu->numPkgs;
+ numFailed = numPkgs;
stopInstall = 1;
}
@@ -664,7 +463,7 @@
if (!stopInstall && rpmpsNumProblems(ps) > 0) {
rpmMessage(RPMMESS_ERROR, _("Failed dependencies:\n"));
rpmpsPrint(NULL, ps);
- eiu->numFailed = eiu->numPkgs;
+ numFailed = numPkgs;
stopInstall = 1;
/*@-branchstate@*/
@@ -688,75 +487,65 @@
ps = rpmpsFree(ps);
}
- if (eiu->numRPMS && !(ia->installInterfaceFlags & INSTALL_NOORDER)) {
+ if (numRPMS && !(ia->installInterfaceFlags & INSTALL_NOORDER)) {
if (rpmtsOrder(ts)) {
- eiu->numFailed = eiu->numPkgs;
+ numFailed = numPkgs;
stopInstall = 1;
}
}
- if (eiu->numRPMS && !stopInstall) {
+ if (numRPMS && !stopInstall) {
- rpmcliPackagesTotal += eiu->numSRPMS;
+ rpmcliPackagesTotal += numSRPMS;
rpmMessage(RPMMESS_DEBUG, D_("installing binary packages\n"));
/* Drop added/available package indices and dependency sets. */
rpmtsClean(ts);
- rc = rpmtsRun(ts, NULL, probFilter);
+ rc = rpmtsRun(ts, NULL, ia->probFilter);
ps = rpmtsProblems(ts);
if (rc < 0) {
- eiu->numFailed += eiu->numRPMS;
+ numFailed += numRPMS;
} else if (rc > 0) {
- eiu->numFailed += rc;
+ numFailed += rc;
if (rpmpsNumProblems(ps) > 0)
rpmpsPrint(stderr, ps);
}
ps = rpmpsFree(ps);
}
- if (eiu->numSRPMS && !stopInstall) {
- if (eiu->sourceURL != NULL)
- for (i = 0; i < eiu->numSRPMS; i++) {
- if (eiu->sourceURL[i] == NULL) continue;
- eiu->fd = Fopen(eiu->sourceURL[i], "r.fdio");
- if (eiu->fd == NULL || Ferror(eiu->fd)) {
+ if (numSRPMS && !stopInstall) {
+ if (sourceURL != NULL)
+ for (i = 0; i < numSRPMS; i++) {
+ FD_t fd;
+ if (sourceURL[i] == NULL) continue;
+ fd = Fopen(sourceURL[i], "r.fdio");
+ if (fd == NULL || Ferror(fd)) {
rpmMessage(RPMMESS_ERROR, _("cannot open file %s: %s\n"),
- eiu->sourceURL[i], Fstrerror(eiu->fd));
- if (eiu->fd != NULL) {
- xx = Fclose(eiu->fd);
- eiu->fd = NULL;
+ sourceURL[i], Fstrerror(fd));
+ if (fd != NULL) {
+ xx = Fclose(fd);
+ fd = NULL;
}
continue;
}
if (!(rpmtsFlags(ts) & RPMTRANS_FLAG_TEST)) {
- eiu->rpmrc = rpmInstallSourcePackage(ts, eiu->fd, NULL, NULL);
- if (eiu->rpmrc != RPMRC_OK) eiu->numFailed++;
+ rpmrc = rpmInstallSourcePackage(ts, fd, NULL, NULL);
+ if (rpmrc != RPMRC_OK) numFailed++;
}
- xx = Fclose(eiu->fd);
- eiu->fd = NULL;
+ xx = Fclose(fd);
+ fd = NULL;
}
}
exit:
- if (eiu->pkgURL != NULL)
- for (i = 0; i < eiu->numPkgs; i++) {
- if (eiu->pkgURL[i] == NULL) continue;
- if (eiu->pkgState[i] == 1)
- (void) Unlink(eiu->pkgURL[i]);
- eiu->pkgURL[i] = _free(eiu->pkgURL[i]);
- }
- eiu->pkgState = _free(eiu->pkgState);
- eiu->pkgURL = _free(eiu->pkgURL);
- eiu->argv = _free(eiu->argv);
-
rpmtsEmpty(ts);
- return eiu->numFailed;
+ return numFailed;
}
/*@=bounds@*/
@@ .
Received on Fri Aug 17 20:06:00 2007