2000-08-28 03:27:03 +08:00
|
|
|
/** \ingroup rpmcli
|
|
|
|
* \file lib/rpminstall.c
|
|
|
|
*/
|
|
|
|
|
1999-07-14 23:28:03 +08:00
|
|
|
#include "system.h"
|
|
|
|
|
2001-06-09 04:45:59 +08:00
|
|
|
#include <rpmcli.h>
|
1999-07-14 23:28:03 +08:00
|
|
|
|
2002-05-17 00:55:21 +08:00
|
|
|
#include "rpmdb.h"
|
2002-08-14 00:36:44 +08:00
|
|
|
#include "rpmds.h"
|
2002-05-20 07:37:24 +08:00
|
|
|
|
|
|
|
#define _RPMTS_INTERNAL /* ts->goal, ts->dbmode, ts->suggests */
|
2002-05-18 05:08:39 +08:00
|
|
|
#include "rpmts.h"
|
2002-04-12 00:55:19 +08:00
|
|
|
|
2001-04-10 20:36:45 +08:00
|
|
|
#include "manifest.h"
|
2001-06-18 06:18:03 +08:00
|
|
|
#include "misc.h" /* XXX for rpmGlob() */
|
2000-12-13 04:03:45 +08:00
|
|
|
#include "debug.h"
|
1999-12-13 01:46:22 +08:00
|
|
|
|
2002-05-20 02:42:25 +08:00
|
|
|
/*@access rpmts @*/ /* XXX ts->goal, ts->dbmode */
|
2001-07-07 04:37:42 +08:00
|
|
|
/*@access IDTX @*/
|
|
|
|
/*@access IDT @*/
|
2000-10-29 01:16:25 +08:00
|
|
|
|
2001-10-15 11:22:10 +08:00
|
|
|
/*@unchecked@*/
|
2002-08-05 00:55:55 +08:00
|
|
|
int rpmcliPackagesTotal = 0;
|
|
|
|
/*@unchecked@*/
|
|
|
|
int rpmcliHashesCurrent = 0;
|
2001-10-15 11:22:10 +08:00
|
|
|
/*@unchecked@*/
|
2002-08-05 00:55:55 +08:00
|
|
|
int rpmcliHashesTotal = 0;
|
2001-10-15 11:22:10 +08:00
|
|
|
/*@unchecked@*/
|
2002-08-05 00:55:55 +08:00
|
|
|
int rpmcliProgressCurrent = 0;
|
2001-10-15 11:22:10 +08:00
|
|
|
/*@unchecked@*/
|
2002-08-05 00:55:55 +08:00
|
|
|
int rpmcliProgressTotal = 0;
|
2000-10-29 02:45:58 +08:00
|
|
|
|
2001-03-24 04:27:48 +08:00
|
|
|
/**
|
2002-08-05 00:55:55 +08:00
|
|
|
* Print a CLI progress bar.
|
|
|
|
* @todo Unsnarl isatty(STDOUT_FILENO) from the control flow.
|
|
|
|
* @param amount current
|
|
|
|
* @param total final
|
2001-03-24 04:27:48 +08:00
|
|
|
*/
|
2000-06-19 19:35:29 +08:00
|
|
|
static void printHash(const unsigned long amount, const unsigned long total)
|
2002-08-09 00:06:13 +08:00
|
|
|
/*@globals rpmcliHashesCurrent, rpmcliHashesTotal,
|
|
|
|
rpmcliProgressCurrent, fileSystem @*/
|
|
|
|
/*@modifies rpmcliHashesCurrent, rpmcliHashesTotal,
|
|
|
|
rpmcliProgressCurrent, fileSystem @*/
|
2000-06-19 19:35:29 +08:00
|
|
|
{
|
1999-07-14 23:28:03 +08:00
|
|
|
int hashesNeeded;
|
|
|
|
|
2002-08-05 00:55:55 +08:00
|
|
|
rpmcliHashesTotal = (isatty (STDOUT_FILENO) ? 44 : 50);
|
2000-10-29 02:45:58 +08:00
|
|
|
|
2002-08-05 00:55:55 +08:00
|
|
|
if (rpmcliHashesCurrent != rpmcliHashesTotal) {
|
2002-12-29 09:06:58 +08:00
|
|
|
/*@+relaxtypes@*/
|
2002-08-08 05:55:43 +08:00
|
|
|
float pct = (total ? (((float) amount) / total) : 1.0);
|
|
|
|
hashesNeeded = (rpmcliHashesTotal * pct) + 0.5;
|
2002-12-29 09:06:58 +08:00
|
|
|
/*@=relaxtypes@*/
|
2002-08-05 00:55:55 +08:00
|
|
|
while (hashesNeeded > rpmcliHashesCurrent) {
|
2001-01-25 20:58:03 +08:00
|
|
|
if (isatty (STDOUT_FILENO)) {
|
|
|
|
int i;
|
2002-08-05 00:55:55 +08:00
|
|
|
for (i = 0; i < rpmcliHashesCurrent; i++)
|
|
|
|
(void) putchar ('#');
|
|
|
|
for (; i < rpmcliHashesTotal; i++)
|
|
|
|
(void) putchar (' ');
|
2002-08-08 05:55:43 +08:00
|
|
|
fprintf(stdout, "(%3d%%)", (int)((100 * pct) + 0.5));
|
2002-08-05 00:55:55 +08:00
|
|
|
for (i = 0; i < (rpmcliHashesTotal + 6); i++)
|
|
|
|
(void) putchar ('\b');
|
2001-01-25 20:58:03 +08:00
|
|
|
} else
|
2001-09-15 21:49:11 +08:00
|
|
|
fprintf(stdout, "#");
|
2000-10-29 02:45:58 +08:00
|
|
|
|
2002-08-05 00:55:55 +08:00
|
|
|
rpmcliHashesCurrent++;
|
1999-07-14 23:28:03 +08:00
|
|
|
}
|
2001-05-01 06:32:22 +08:00
|
|
|
(void) fflush(stdout);
|
1999-07-14 23:28:03 +08:00
|
|
|
|
2002-08-05 00:55:55 +08:00
|
|
|
if (rpmcliHashesCurrent == rpmcliHashesTotal) {
|
2001-01-25 20:58:03 +08:00
|
|
|
int i;
|
2002-08-05 00:55:55 +08:00
|
|
|
rpmcliProgressCurrent++;
|
2002-01-28 00:49:06 +08:00
|
|
|
if (isatty(STDOUT_FILENO)) {
|
2002-08-05 00:55:55 +08:00
|
|
|
for (i = 1; i < rpmcliHashesCurrent; i++)
|
|
|
|
(void) putchar ('#');
|
2002-12-29 09:06:58 +08:00
|
|
|
/*@+relaxtypes@*/
|
2002-08-05 00:55:55 +08:00
|
|
|
pct = (rpmcliProgressTotal
|
|
|
|
? (((float) rpmcliProgressCurrent) / rpmcliProgressTotal)
|
|
|
|
: 1);
|
2002-12-29 09:06:58 +08:00
|
|
|
/*@=relaxtypes@*/
|
2002-08-08 05:55:43 +08:00
|
|
|
fprintf(stdout, " [%3d%%]", (int)((100 * pct) + 0.5));
|
2002-01-28 00:49:06 +08:00
|
|
|
}
|
|
|
|
fprintf(stdout, "\n");
|
2001-01-25 20:58:03 +08:00
|
|
|
}
|
2001-05-01 06:32:22 +08:00
|
|
|
(void) fflush(stdout);
|
1999-07-14 23:28:03 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-07-07 04:37:42 +08:00
|
|
|
void * rpmShowProgress(/*@null@*/ const void * arg,
|
|
|
|
const rpmCallbackType what,
|
2001-05-04 05:00:18 +08:00
|
|
|
const unsigned long amount,
|
|
|
|
const unsigned long total,
|
2001-11-08 08:12:49 +08:00
|
|
|
/*@null@*/ fnpyKey key,
|
2001-05-04 05:00:18 +08:00
|
|
|
/*@null@*/ void * data)
|
2002-08-05 00:55:55 +08:00
|
|
|
/*@globals rpmcliHashesCurrent, rpmcliProgressCurrent, rpmcliProgressTotal,
|
2001-10-18 00:43:36 +08:00
|
|
|
fileSystem @*/
|
2002-08-05 00:55:55 +08:00
|
|
|
/*@modifies rpmcliHashesCurrent, rpmcliProgressCurrent, rpmcliProgressTotal,
|
2001-10-18 00:43:36 +08:00
|
|
|
fileSystem @*/
|
2000-06-19 19:35:29 +08:00
|
|
|
{
|
2003-01-24 04:23:24 +08:00
|
|
|
/*@-abstract -castexpose @*/
|
2000-06-19 19:35:29 +08:00
|
|
|
Header h = (Header) arg;
|
2003-01-24 04:23:24 +08:00
|
|
|
/*@=abstract =castexpose @*/
|
1999-07-14 23:28:03 +08:00
|
|
|
char * s;
|
2000-05-13 07:12:15 +08:00
|
|
|
int flags = (int) ((long)data);
|
1999-07-14 23:28:03 +08:00
|
|
|
void * rc = NULL;
|
2003-01-24 04:23:24 +08:00
|
|
|
/*@-abstract -assignexpose @*/
|
2001-11-08 08:12:49 +08:00
|
|
|
const char * filename = (const char *)key;
|
2003-01-24 04:23:24 +08:00
|
|
|
/*@=abstract =assignexpose @*/
|
2001-05-04 05:00:18 +08:00
|
|
|
static FD_t fd = NULL;
|
2002-08-14 00:36:44 +08:00
|
|
|
int xx;
|
1999-07-14 23:28:03 +08:00
|
|
|
|
|
|
|
switch (what) {
|
2001-01-25 20:58:03 +08:00
|
|
|
case RPMCALLBACK_INST_OPEN_FILE:
|
2002-06-23 02:51:56 +08:00
|
|
|
/*@-boundsread@*/
|
2001-05-04 05:00:18 +08:00
|
|
|
if (filename == NULL || filename[0] == '\0')
|
|
|
|
return NULL;
|
2002-06-23 02:51:56 +08:00
|
|
|
/*@=boundsread@*/
|
1999-11-10 04:57:38 +08:00
|
|
|
fd = Fopen(filename, "r.ufdio");
|
2001-10-17 01:42:18 +08:00
|
|
|
/*@-type@*/ /* FIX: still necessary? */
|
2002-08-14 00:36:44 +08:00
|
|
|
if (fd == NULL || Ferror(fd)) {
|
|
|
|
rpmError(RPMERR_OPEN, _("open of %s failed: %s\n"), filename,
|
|
|
|
Fstrerror(fd));
|
2003-01-24 04:23:24 +08:00
|
|
|
if (fd != NULL) {
|
2002-08-14 00:36:44 +08:00
|
|
|
xx = Fclose(fd);
|
|
|
|
fd = NULL;
|
|
|
|
}
|
|
|
|
} else
|
2001-01-25 20:58:03 +08:00
|
|
|
fd = fdLink(fd, "persist (showProgress)");
|
2001-10-17 01:42:18 +08:00
|
|
|
/*@=type@*/
|
2003-01-24 04:23:24 +08:00
|
|
|
/*@+voidabstract@*/
|
|
|
|
return (void *)fd;
|
|
|
|
/*@=voidabstract@*/
|
2001-01-25 20:58:03 +08:00
|
|
|
/*@notreached@*/ break;
|
1999-07-14 23:28:03 +08:00
|
|
|
|
2001-01-25 20:58:03 +08:00
|
|
|
case RPMCALLBACK_INST_CLOSE_FILE:
|
2001-10-17 01:42:18 +08:00
|
|
|
/*@-type@*/ /* FIX: still necessary? */
|
1999-11-16 07:57:18 +08:00
|
|
|
fd = fdFree(fd, "persist (showProgress)");
|
2001-10-17 01:42:18 +08:00
|
|
|
/*@=type@*/
|
2003-01-24 04:23:24 +08:00
|
|
|
if (fd != NULL) {
|
2002-08-14 00:36:44 +08:00
|
|
|
xx = Fclose(fd);
|
1999-11-16 07:57:18 +08:00
|
|
|
fd = NULL;
|
|
|
|
}
|
1999-07-14 23:28:03 +08:00
|
|
|
break;
|
|
|
|
|
2001-01-25 20:58:03 +08:00
|
|
|
case RPMCALLBACK_INST_START:
|
2002-08-05 00:55:55 +08:00
|
|
|
rpmcliHashesCurrent = 0;
|
2001-05-04 05:00:18 +08:00
|
|
|
if (h == NULL || !(flags & INSTALL_LABEL))
|
2001-01-25 20:58:03 +08:00
|
|
|
break;
|
2002-08-05 00:55:55 +08:00
|
|
|
/* @todo Remove headerSprintf() on a progress callback. */
|
2001-01-25 20:58:03 +08:00
|
|
|
if (flags & INSTALL_HASH) {
|
2001-05-04 05:00:18 +08:00
|
|
|
s = headerSprintf(h, "%{NAME}",
|
|
|
|
rpmTagTable, rpmHeaderFormats, NULL);
|
2001-01-25 20:58:03 +08:00
|
|
|
if (isatty (STDOUT_FILENO))
|
2002-08-05 00:55:55 +08:00
|
|
|
fprintf(stdout, "%4d:%-23.23s", rpmcliProgressCurrent + 1, s);
|
2002-01-28 00:49:06 +08:00
|
|
|
else
|
|
|
|
fprintf(stdout, "%-28.28s", s);
|
2001-05-01 06:32:22 +08:00
|
|
|
(void) fflush(stdout);
|
2001-05-04 05:00:18 +08:00
|
|
|
s = _free(s);
|
2001-01-25 20:58:03 +08:00
|
|
|
} else {
|
2001-04-10 20:36:45 +08:00
|
|
|
s = headerSprintf(h, "%{NAME}-%{VERSION}-%{RELEASE}",
|
1999-07-14 23:28:03 +08:00
|
|
|
rpmTagTable, rpmHeaderFormats, NULL);
|
2001-01-25 20:58:03 +08:00
|
|
|
fprintf(stdout, "%s\n", s);
|
2001-05-01 06:32:22 +08:00
|
|
|
(void) fflush(stdout);
|
2001-05-04 05:00:18 +08:00
|
|
|
s = _free(s);
|
1999-07-14 23:28:03 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2001-01-25 20:58:03 +08:00
|
|
|
case RPMCALLBACK_TRANS_PROGRESS:
|
|
|
|
case RPMCALLBACK_INST_PROGRESS:
|
2002-12-29 09:06:58 +08:00
|
|
|
/*@+relaxtypes@*/
|
2001-02-28 05:30:27 +08:00
|
|
|
if (flags & INSTALL_PERCENT)
|
2001-06-04 21:55:58 +08:00
|
|
|
fprintf(stdout, "%%%% %f\n", (double) (total
|
|
|
|
? ((((float) amount) / total) * 100)
|
1999-07-14 23:28:03 +08:00
|
|
|
: 100.0));
|
2001-02-28 05:30:27 +08:00
|
|
|
else if (flags & INSTALL_HASH)
|
1999-07-14 23:28:03 +08:00
|
|
|
printHash(amount, total);
|
2002-12-29 09:06:58 +08:00
|
|
|
/*@=relaxtypes@*/
|
2001-05-01 06:32:22 +08:00
|
|
|
(void) fflush(stdout);
|
1999-07-14 23:28:03 +08:00
|
|
|
break;
|
|
|
|
|
2001-01-25 20:58:03 +08:00
|
|
|
case RPMCALLBACK_TRANS_START:
|
2002-08-05 00:55:55 +08:00
|
|
|
rpmcliHashesCurrent = 0;
|
|
|
|
rpmcliProgressTotal = 1;
|
|
|
|
rpmcliProgressCurrent = 0;
|
2001-01-25 20:58:03 +08:00
|
|
|
if (!(flags & INSTALL_LABEL))
|
|
|
|
break;
|
2001-02-28 05:30:27 +08:00
|
|
|
if (flags & INSTALL_HASH)
|
2001-01-25 20:58:03 +08:00
|
|
|
fprintf(stdout, "%-28s", _("Preparing..."));
|
2001-02-28 05:30:27 +08:00
|
|
|
else
|
2002-01-28 00:49:06 +08:00
|
|
|
fprintf(stdout, "%s\n", _("Preparing packages for installation..."));
|
2001-05-01 06:32:22 +08:00
|
|
|
(void) fflush(stdout);
|
2001-01-25 20:58:03 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case RPMCALLBACK_TRANS_STOP:
|
|
|
|
if (flags & INSTALL_HASH)
|
|
|
|
printHash(1, 1); /* Fixes "preparing..." progress bar */
|
2002-08-05 00:55:55 +08:00
|
|
|
rpmcliProgressTotal = rpmcliPackagesTotal;
|
|
|
|
rpmcliProgressCurrent = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RPMCALLBACK_REPACKAGE_START:
|
|
|
|
rpmcliHashesCurrent = 0;
|
|
|
|
rpmcliProgressTotal = total;
|
|
|
|
rpmcliProgressCurrent = 0;
|
|
|
|
if (!(flags & INSTALL_LABEL))
|
|
|
|
break;
|
|
|
|
if (flags & INSTALL_HASH)
|
|
|
|
fprintf(stdout, "%-28s\n", _("Repackaging..."));
|
|
|
|
else
|
|
|
|
fprintf(stdout, "%s\n", _("Repackaging erased files..."));
|
|
|
|
(void) fflush(stdout);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RPMCALLBACK_REPACKAGE_PROGRESS:
|
|
|
|
if (amount && (flags & INSTALL_HASH))
|
|
|
|
printHash(1, 1); /* Fixes "preparing..." progress bar */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RPMCALLBACK_REPACKAGE_STOP:
|
|
|
|
rpmcliProgressTotal = total;
|
|
|
|
rpmcliProgressCurrent = total;
|
|
|
|
if (flags & INSTALL_HASH)
|
|
|
|
printHash(1, 1); /* Fixes "preparing..." progress bar */
|
|
|
|
rpmcliProgressTotal = rpmcliPackagesTotal;
|
|
|
|
rpmcliProgressCurrent = 0;
|
|
|
|
if (!(flags & INSTALL_LABEL))
|
|
|
|
break;
|
|
|
|
if (flags & INSTALL_HASH)
|
|
|
|
fprintf(stdout, "%-28s\n", _("Upgrading..."));
|
|
|
|
else
|
|
|
|
fprintf(stdout, "%s\n", _("Upgrading packages..."));
|
|
|
|
(void) fflush(stdout);
|
2001-01-25 20:58:03 +08:00
|
|
|
break;
|
2000-10-29 02:45:58 +08:00
|
|
|
|
2001-01-25 20:58:03 +08:00
|
|
|
case RPMCALLBACK_UNINST_PROGRESS:
|
2002-08-05 00:55:55 +08:00
|
|
|
break;
|
2001-01-25 20:58:03 +08:00
|
|
|
case RPMCALLBACK_UNINST_START:
|
2002-08-05 00:55:55 +08:00
|
|
|
break;
|
2001-01-25 20:58:03 +08:00
|
|
|
case RPMCALLBACK_UNINST_STOP:
|
2002-08-05 00:55:55 +08:00
|
|
|
break;
|
2002-04-11 06:10:13 +08:00
|
|
|
case RPMCALLBACK_UNPACK_ERROR:
|
2002-08-05 00:55:55 +08:00
|
|
|
break;
|
2002-04-11 06:10:13 +08:00
|
|
|
case RPMCALLBACK_CPIO_ERROR:
|
2002-08-05 00:55:55 +08:00
|
|
|
break;
|
|
|
|
case RPMCALLBACK_UNKNOWN:
|
|
|
|
default:
|
1999-07-14 23:28:03 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2001-09-15 21:49:11 +08:00
|
|
|
typedef /*@only@*/ /*@null@*/ const char * str_t;
|
|
|
|
|
|
|
|
struct rpmEIU {
|
|
|
|
Header h;
|
|
|
|
FD_t fd;
|
|
|
|
int numFailed;
|
|
|
|
int numPkgs;
|
2002-03-13 23:06:07 +08:00
|
|
|
/*@only@*/
|
|
|
|
str_t * pkgURL;
|
|
|
|
/*@dependent@*/ /*@null@*/
|
|
|
|
str_t * fnp;
|
|
|
|
/*@only@*/
|
|
|
|
char * pkgState;
|
2001-09-15 21:49:11 +08:00
|
|
|
int prevx;
|
|
|
|
int pkgx;
|
|
|
|
int numRPMS;
|
|
|
|
int numSRPMS;
|
2002-03-13 23:06:07 +08:00
|
|
|
/*@only@*/ /*@null@*/
|
|
|
|
str_t * sourceURL;
|
2001-09-15 21:49:11 +08:00
|
|
|
int isSource;
|
|
|
|
int argc;
|
2002-03-13 23:06:07 +08:00
|
|
|
/*@only@*/ /*@null@*/
|
|
|
|
str_t * argv;
|
|
|
|
/*@dependent@*/
|
|
|
|
rpmRelocation * relocations;
|
2001-09-15 21:49:11 +08:00
|
|
|
rpmRC rpmrc;
|
|
|
|
};
|
|
|
|
|
2000-09-02 05:15:40 +08:00
|
|
|
/** @todo Generalize --freshen policies. */
|
2002-06-20 02:52:46 +08:00
|
|
|
/*@-bounds@*/
|
2002-05-20 02:42:25 +08:00
|
|
|
int rpmInstall(rpmts ts,
|
2002-03-13 23:06:07 +08:00
|
|
|
struct rpmInstallArguments_s * ia,
|
|
|
|
const char ** fileArgv)
|
1999-11-27 00:19:30 +08:00
|
|
|
{
|
2001-10-26 12:16:19 +08:00
|
|
|
struct rpmEIU * eiu = memset(alloca(sizeof(*eiu)), 0, sizeof(*eiu));
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmps ps;
|
2002-03-13 23:06:07 +08:00
|
|
|
rpmprobFilterFlags probFilter;
|
|
|
|
rpmRelocation * relocations;
|
2001-10-26 12:16:19 +08:00
|
|
|
/*@only@*/ /*@null@*/ const char * fileURL = NULL;
|
1999-07-14 23:28:03 +08:00
|
|
|
int stopInstall = 0;
|
2001-04-10 20:36:45 +08:00
|
|
|
const char ** av = NULL;
|
2002-08-06 09:41:44 +08:00
|
|
|
rpmVSFlags vsflags, ovsflags, tvsflags;
|
2001-04-10 20:36:45 +08:00
|
|
|
int ac = 0;
|
|
|
|
int rc;
|
2001-09-15 21:49:11 +08:00
|
|
|
int xx;
|
2001-04-10 20:36:45 +08:00
|
|
|
int i;
|
1999-07-14 23:28:03 +08:00
|
|
|
|
2001-10-26 12:16:19 +08:00
|
|
|
if (fileArgv == NULL) goto exit;
|
2001-05-04 05:00:18 +08:00
|
|
|
|
2002-08-14 00:36:44 +08:00
|
|
|
ts->goal = TSM_INSTALL;
|
|
|
|
rpmcliPackagesTotal = 0;
|
|
|
|
|
2002-09-01 06:39:34 +08:00
|
|
|
if (rpmExpandNumeric("%{?_repackage_all_erasures}"))
|
|
|
|
ia->transFlags |= RPMTRANS_FLAG_REPACKAGE;
|
|
|
|
|
2002-03-17 23:49:09 +08:00
|
|
|
(void) rpmtsSetFlags(ts, ia->transFlags);
|
2002-03-13 23:06:07 +08:00
|
|
|
probFilter = ia->probFilter;
|
|
|
|
relocations = ia->relocations;
|
|
|
|
|
2002-07-25 00:21:23 +08:00
|
|
|
if (ia->installInterfaceFlags & INSTALL_UPGRADE)
|
2002-08-03 05:52:01 +08:00
|
|
|
vsflags = rpmExpandNumeric("%{?_vsflags_erase}");
|
2002-07-25 00:21:23 +08:00
|
|
|
else
|
2002-08-03 05:52:01 +08:00
|
|
|
vsflags = rpmExpandNumeric("%{?_vsflags_install}");
|
2002-05-17 00:55:21 +08:00
|
|
|
if (ia->qva_flags & VERIFY_DIGEST)
|
2002-08-06 09:41:44 +08:00
|
|
|
vsflags |= _RPMVSF_NODIGESTS;
|
2002-05-17 00:55:21 +08:00
|
|
|
if (ia->qva_flags & VERIFY_SIGNATURE)
|
2002-08-06 09:41:44 +08:00
|
|
|
vsflags |= _RPMVSF_NOSIGNATURES;
|
2002-07-25 00:21:23 +08:00
|
|
|
if (ia->qva_flags & VERIFY_HDRCHK)
|
2002-08-06 09:41:44 +08:00
|
|
|
vsflags |= RPMVSF_NOHDRCHK;
|
2002-08-07 21:47:59 +08:00
|
|
|
ovsflags = rpmtsSetVSFlags(ts, (vsflags | RPMVSF_NEEDPAYLOAD));
|
2002-03-14 04:01:50 +08:00
|
|
|
|
|
|
|
{ int notifyFlags;
|
2002-03-17 23:49:09 +08:00
|
|
|
notifyFlags = ia->installInterfaceFlags | (rpmIsVerbose() ? INSTALL_LABEL : 0 );
|
2002-03-14 04:01:50 +08:00
|
|
|
xx = rpmtsSetNotifyCallback(ts,
|
|
|
|
rpmShowProgress, (void *) ((long)notifyFlags));
|
|
|
|
}
|
2001-09-15 21:49:11 +08:00
|
|
|
|
|
|
|
if ((eiu->relocations = relocations) != NULL) {
|
|
|
|
while (eiu->relocations->oldPath)
|
|
|
|
eiu->relocations++;
|
|
|
|
if (eiu->relocations->newPath == NULL)
|
|
|
|
eiu->relocations = NULL;
|
|
|
|
}
|
1999-07-14 23:28:03 +08:00
|
|
|
|
2001-04-10 20:36:45 +08:00
|
|
|
/* Build fully globbed list of arguments in argv[argc]. */
|
2001-10-16 01:53:34 +08:00
|
|
|
/*@-branchstate@*/
|
2001-09-15 21:49:11 +08:00
|
|
|
/*@-temptrans@*/
|
|
|
|
for (eiu->fnp = fileArgv; *eiu->fnp != NULL; eiu->fnp++) {
|
|
|
|
/*@=temptrans@*/
|
|
|
|
av = _free(av); ac = 0;
|
|
|
|
rc = rpmGlob(*eiu->fnp, &ac, &av);
|
2002-10-26 22:43:43 +08:00
|
|
|
if (rc || ac == 0) {
|
|
|
|
rpmError(RPMERR_OPEN, _("File not found by glob: %s\n"), *eiu->fnp);
|
|
|
|
continue;
|
|
|
|
}
|
1999-07-14 23:28:03 +08:00
|
|
|
|
2001-09-15 21:49:11 +08:00
|
|
|
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;
|
2001-04-10 20:36:45 +08:00
|
|
|
}
|
2001-10-16 01:53:34 +08:00
|
|
|
/*@=branchstate@*/
|
2001-09-15 21:49:11 +08:00
|
|
|
av = _free(av); ac = 0;
|
2001-04-10 20:36:45 +08:00
|
|
|
|
|
|
|
restart:
|
|
|
|
/* Allocate sufficient storage for next set of args. */
|
2001-09-15 21:49:11 +08:00
|
|
|
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)));
|
2001-04-10 20:36:45 +08:00
|
|
|
}
|
1999-07-14 23:28:03 +08:00
|
|
|
|
2001-04-10 20:36:45 +08:00
|
|
|
/* Retrieve next set of args, cache on local storage. */
|
2001-09-15 21:49:11 +08:00
|
|
|
for (i = 0; i < eiu->argc; i++) {
|
2001-04-10 20:36:45 +08:00
|
|
|
fileURL = _free(fileURL);
|
2001-09-15 21:49:11 +08:00
|
|
|
fileURL = eiu->argv[i];
|
|
|
|
eiu->argv[i] = NULL;
|
1999-07-14 23:28:03 +08:00
|
|
|
|
2002-08-14 00:36:44 +08:00
|
|
|
#ifdef NOTYET
|
|
|
|
if (fileURL[0] == '=') {
|
|
|
|
rpmds this = rpmdsSingle(RPMTAG_REQUIRENAME, fileURL+1, NULL, 0);
|
|
|
|
|
|
|
|
xx = rpmtsSolve(ts, this, NULL);
|
|
|
|
if (ts->suggests && ts->nsuggests > 0) {
|
|
|
|
fileURL = _free(fileURL);
|
|
|
|
fileURL = ts->suggests[0];
|
|
|
|
ts->suggests[0] = NULL;
|
|
|
|
while (ts->nsuggests-- > 0) {
|
|
|
|
if (ts->suggests[ts->nsuggests] == NULL)
|
|
|
|
continue;
|
|
|
|
ts->suggests[ts->nsuggests] = _free(ts->suggests[ts->nsuggests]);
|
|
|
|
}
|
|
|
|
ts->suggests = _free(ts->suggests);
|
|
|
|
rpmMessage(RPMMESS_DEBUG, _("Adding goal: %s\n"), fileURL);
|
|
|
|
eiu->pkgURL[eiu->pkgx] = fileURL;
|
|
|
|
fileURL = NULL;
|
|
|
|
eiu->pkgx++;
|
|
|
|
}
|
|
|
|
this = rpmdsFree(this);
|
|
|
|
} else
|
|
|
|
#endif
|
|
|
|
|
2001-04-10 20:36:45 +08:00
|
|
|
switch (urlIsURL(fileURL)) {
|
1999-07-14 23:28:03 +08:00
|
|
|
case URL_IS_FTP:
|
|
|
|
case URL_IS_HTTP:
|
2001-04-10 20:36:45 +08:00
|
|
|
{ const char *tfn;
|
1999-12-13 01:46:22 +08:00
|
|
|
|
2001-04-10 20:36:45 +08:00
|
|
|
if (rpmIsVerbose())
|
|
|
|
fprintf(stdout, _("Retrieving %s\n"), fileURL);
|
1999-12-13 01:46:22 +08:00
|
|
|
|
2001-04-10 20:36:45 +08:00
|
|
|
{ char tfnbuf[64];
|
2002-05-20 07:37:24 +08:00
|
|
|
const char * rootDir = rpmtsRootDir(ts);
|
2002-05-18 05:08:39 +08:00
|
|
|
if (!(rootDir && * rootDir))
|
|
|
|
rootDir = "";
|
2001-04-10 20:36:45 +08:00
|
|
|
strcpy(tfnbuf, "rpm-xfer.XXXXXX");
|
2001-10-09 00:12:33 +08:00
|
|
|
(void) mktemp(tfnbuf);
|
2001-10-26 12:16:19 +08:00
|
|
|
tfn = rpmGenPath(rootDir, "%{_tmppath}/", tfnbuf);
|
1999-12-13 01:46:22 +08:00
|
|
|
}
|
2001-04-10 20:36:45 +08:00
|
|
|
|
|
|
|
/* XXX undefined %{name}/%{version}/%{release} here */
|
|
|
|
/* XXX %{_tmpdir} does not exist */
|
|
|
|
rpmMessage(RPMMESS_DEBUG, _(" ... as %s\n"), tfn);
|
|
|
|
rc = urlGetFile(fileURL, tfn);
|
|
|
|
if (rc < 0) {
|
|
|
|
rpmMessage(RPMMESS_ERROR,
|
|
|
|
_("skipping %s - transfer failed - %s\n"),
|
|
|
|
fileURL, ftpStrerror(rc));
|
2001-09-15 21:49:11 +08:00
|
|
|
eiu->numFailed++;
|
|
|
|
eiu->pkgURL[eiu->pkgx] = NULL;
|
2001-04-10 20:36:45 +08:00
|
|
|
tfn = _free(tfn);
|
2001-10-14 06:01:38 +08:00
|
|
|
/*@switchbreak@*/ break;
|
1999-07-14 23:28:03 +08:00
|
|
|
}
|
2001-09-15 21:49:11 +08:00
|
|
|
eiu->pkgState[eiu->pkgx] = 1;
|
|
|
|
eiu->pkgURL[eiu->pkgx] = tfn;
|
|
|
|
eiu->pkgx++;
|
2001-10-14 06:01:38 +08:00
|
|
|
} /*@switchbreak@*/ break;
|
1999-11-27 00:19:30 +08:00
|
|
|
case URL_IS_PATH:
|
1999-07-14 23:28:03 +08:00
|
|
|
default:
|
2001-09-15 21:49:11 +08:00
|
|
|
eiu->pkgURL[eiu->pkgx] = fileURL;
|
2001-04-10 20:36:45 +08:00
|
|
|
fileURL = NULL;
|
2001-09-15 21:49:11 +08:00
|
|
|
eiu->pkgx++;
|
2001-10-14 06:01:38 +08:00
|
|
|
/*@switchbreak@*/ break;
|
1999-07-14 23:28:03 +08:00
|
|
|
}
|
|
|
|
}
|
2001-04-10 20:36:45 +08:00
|
|
|
fileURL = _free(fileURL);
|
1999-07-14 23:28:03 +08:00
|
|
|
|
2001-09-15 21:49:11 +08:00
|
|
|
if (eiu->numFailed) goto exit;
|
1999-07-14 23:28:03 +08:00
|
|
|
|
2001-04-10 20:36:45 +08:00
|
|
|
/* Continue processing file arguments, building transaction set. */
|
2001-09-15 21:49:11 +08:00
|
|
|
for (eiu->fnp = eiu->pkgURL+eiu->prevx;
|
|
|
|
*eiu->fnp != NULL;
|
|
|
|
eiu->fnp++, eiu->prevx++)
|
|
|
|
{
|
1999-11-27 00:19:30 +08:00
|
|
|
const char * fileName;
|
2001-04-10 20:36:45 +08:00
|
|
|
|
2001-09-15 21:49:11 +08:00
|
|
|
rpmMessage(RPMMESS_DEBUG, "============== %s\n", *eiu->fnp);
|
|
|
|
(void) urlPath(*eiu->fnp, &fileName);
|
2001-02-13 03:02:15 +08:00
|
|
|
|
2001-04-10 20:36:45 +08:00
|
|
|
/* Try to read the header from a package file. */
|
2001-09-15 21:49:11 +08:00
|
|
|
eiu->fd = Fopen(*eiu->fnp, "r.ufdio");
|
|
|
|
if (eiu->fd == NULL || Ferror(eiu->fd)) {
|
|
|
|
rpmError(RPMERR_OPEN, _("open of %s failed: %s\n"), *eiu->fnp,
|
|
|
|
Fstrerror(eiu->fd));
|
2003-01-24 04:23:24 +08:00
|
|
|
if (eiu->fd != NULL) {
|
2001-09-15 21:49:11 +08:00
|
|
|
xx = Fclose(eiu->fd);
|
|
|
|
eiu->fd = NULL;
|
|
|
|
}
|
|
|
|
eiu->numFailed++; *eiu->fnp = NULL;
|
1999-07-14 23:28:03 +08:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2002-05-17 00:55:21 +08:00
|
|
|
/* Read the header, verifying signatures (if present). */
|
2002-08-06 09:41:44 +08:00
|
|
|
tvsflags = rpmtsSetVSFlags(ts, vsflags);
|
2001-10-28 04:09:20 +08:00
|
|
|
eiu->rpmrc = rpmReadPackageFile(ts, eiu->fd, *eiu->fnp, &eiu->h);
|
2002-08-06 09:41:44 +08:00
|
|
|
tvsflags = rpmtsSetVSFlags(ts, tvsflags);
|
2001-09-15 21:49:11 +08:00
|
|
|
xx = Fclose(eiu->fd);
|
|
|
|
eiu->fd = NULL;
|
|
|
|
|
2002-08-24 05:01:59 +08:00
|
|
|
switch (eiu->rpmrc) {
|
|
|
|
case RPMRC_FAIL:
|
|
|
|
rpmMessage(RPMMESS_ERROR, _("%s cannot be installed\n"), *eiu->fnp);
|
2001-09-15 21:49:11 +08:00
|
|
|
eiu->numFailed++; *eiu->fnp = NULL;
|
2001-04-10 20:36:45 +08:00
|
|
|
continue;
|
2002-08-24 05:01:59 +08:00
|
|
|
/*@notreached@*/ /*@switchbreak@*/ break;
|
|
|
|
case RPMRC_NOTFOUND:
|
|
|
|
goto maybe_manifest;
|
|
|
|
/*@notreached@*/ /*@switchbreak@*/ break;
|
2002-08-28 04:50:21 +08:00
|
|
|
case RPMRC_NOTTRUSTED:
|
|
|
|
case RPMRC_NOKEY:
|
2002-08-24 05:01:59 +08:00
|
|
|
case RPMRC_OK:
|
|
|
|
default:
|
|
|
|
/*@switchbreak@*/ break;
|
2001-04-10 20:36:45 +08:00
|
|
|
}
|
2001-09-15 21:49:11 +08:00
|
|
|
|
2002-08-24 05:01:59 +08:00
|
|
|
eiu->isSource = headerIsEntry(eiu->h, RPMTAG_SOURCEPACKAGE);
|
|
|
|
|
|
|
|
if (eiu->isSource) {
|
2001-04-24 04:56:59 +08:00
|
|
|
rpmMessage(RPMMESS_DEBUG, "\tadded source package [%d]\n",
|
2001-09-15 21:49:11 +08:00
|
|
|
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;
|
2001-04-10 20:36:45 +08:00
|
|
|
continue;
|
|
|
|
}
|
2001-09-15 21:49:11 +08:00
|
|
|
|
2002-08-24 05:01:59 +08:00
|
|
|
if (eiu->relocations) {
|
|
|
|
const char ** paths;
|
|
|
|
int pft;
|
|
|
|
int c;
|
1999-07-14 23:28:03 +08:00
|
|
|
|
2002-08-24 05:01:59 +08:00
|
|
|
if (headerGetEntry(eiu->h, RPMTAG_PREFIXES, &pft,
|
2002-05-18 05:08:39 +08:00
|
|
|
(void **) &paths, &c) && (c == 1))
|
2002-08-24 05:01:59 +08:00
|
|
|
{
|
|
|
|
eiu->relocations->oldPath = xstrdup(paths[0]);
|
|
|
|
paths = headerFreeData(paths, pft);
|
|
|
|
} else {
|
|
|
|
const char * name;
|
|
|
|
xx = headerNVR(eiu->h, &name, NULL, NULL);
|
|
|
|
rpmMessage(RPMMESS_ERROR,
|
1999-07-14 23:28:03 +08:00
|
|
|
_("package %s is not relocateable\n"), name);
|
2002-08-24 05:01:59 +08:00
|
|
|
eiu->numFailed++;
|
|
|
|
goto exit;
|
|
|
|
/*@notreached@*/
|
2001-04-10 20:36:45 +08:00
|
|
|
}
|
2002-08-24 05:01:59 +08:00
|
|
|
}
|
1999-07-14 23:28:03 +08:00
|
|
|
|
2002-08-24 05:01:59 +08:00
|
|
|
/* 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);
|
|
|
|
mi = rpmtsInitIterator(ts, RPMTAG_NAME, name, 0);
|
|
|
|
count = rpmdbGetIteratorCount(mi);
|
|
|
|
while ((oldH = rpmdbNextIterator(mi)) != NULL) {
|
|
|
|
if (rpmVersionCompare(oldH, eiu->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);
|
|
|
|
continue;
|
2001-04-10 20:36:45 +08:00
|
|
|
}
|
2002-08-24 05:01:59 +08:00
|
|
|
/* Package is newer than those currently installed. */
|
|
|
|
}
|
2000-06-23 08:49:43 +08:00
|
|
|
|
2002-08-24 05:01:59 +08:00
|
|
|
/*@-abstract@*/
|
|
|
|
rc = rpmtsAddInstallElement(ts, eiu->h, (fnpyKey)fileName,
|
2002-03-17 23:49:09 +08:00
|
|
|
(ia->installInterfaceFlags & INSTALL_UPGRADE) != 0,
|
|
|
|
relocations);
|
2002-08-24 05:01:59 +08:00
|
|
|
/*@=abstract@*/
|
2001-10-28 06:31:10 +08:00
|
|
|
|
2002-08-24 05:01:59 +08:00
|
|
|
/* XXX reference held by transaction set */
|
|
|
|
eiu->h = headerFree(eiu->h);
|
|
|
|
if (eiu->relocations)
|
|
|
|
eiu->relocations->oldPath = _free(eiu->relocations->oldPath);
|
1999-09-21 11:22:53 +08:00
|
|
|
|
2002-08-24 05:01:59 +08:00
|
|
|
switch(rc) {
|
|
|
|
case 0:
|
|
|
|
rpmMessage(RPMMESS_DEBUG, "\tadded binary package [%d]\n",
|
2001-09-15 21:49:11 +08:00
|
|
|
eiu->numRPMS);
|
2002-08-24 05:01:59 +08:00
|
|
|
/*@switchbreak@*/ break;
|
|
|
|
case 1:
|
|
|
|
rpmMessage(RPMMESS_ERROR,
|
2001-09-15 21:49:11 +08:00
|
|
|
_("error reading from file %s\n"), *eiu->fnp);
|
2002-08-24 05:01:59 +08:00
|
|
|
eiu->numFailed++;
|
|
|
|
goto exit;
|
|
|
|
/*@notreached@*/ /*@switchbreak@*/ break;
|
|
|
|
case 2:
|
|
|
|
rpmMessage(RPMMESS_ERROR,
|
1999-07-14 23:28:03 +08:00
|
|
|
_("file %s requires a newer version of RPM\n"),
|
2001-09-15 21:49:11 +08:00
|
|
|
*eiu->fnp);
|
2002-08-24 05:01:59 +08:00
|
|
|
eiu->numFailed++;
|
|
|
|
goto exit;
|
|
|
|
/*@notreached@*/ /*@switchbreak@*/ break;
|
2001-04-10 20:36:45 +08:00
|
|
|
}
|
1999-07-14 23:28:03 +08:00
|
|
|
|
2002-08-24 05:01:59 +08:00
|
|
|
eiu->numRPMS++;
|
|
|
|
continue;
|
2001-04-10 20:36:45 +08:00
|
|
|
|
2002-08-24 05:01:59 +08:00
|
|
|
maybe_manifest:
|
2001-04-10 20:36:45 +08:00
|
|
|
/* Try to read a package manifest. */
|
2001-09-15 21:49:11 +08:00
|
|
|
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));
|
2003-01-24 04:23:24 +08:00
|
|
|
if (eiu->fd != NULL) {
|
2001-09-15 21:49:11 +08:00
|
|
|
xx = Fclose(eiu->fd);
|
|
|
|
eiu->fd = NULL;
|
|
|
|
}
|
|
|
|
eiu->numFailed++; *eiu->fnp = NULL;
|
1999-07-14 23:28:03 +08:00
|
|
|
break;
|
|
|
|
}
|
2001-04-10 20:36:45 +08:00
|
|
|
|
|
|
|
/* Read list of packages from manifest. */
|
2003-04-03 05:16:26 +08:00
|
|
|
/*@-nullstate@*/ /* FIX: *eiu->argv can be NULL */
|
2001-09-15 21:49:11 +08:00
|
|
|
rc = rpmReadPackageManifest(eiu->fd, &eiu->argc, &eiu->argv);
|
2003-04-03 05:16:26 +08:00
|
|
|
/*@=nullstate@*/
|
2002-05-14 06:34:25 +08:00
|
|
|
if (rc != RPMRC_OK)
|
2002-08-06 03:45:52 +08:00
|
|
|
rpmError(RPMERR_MANIFEST, _("%s: not an rpm package (or package manifest): %s\n"),
|
2001-09-15 21:49:11 +08:00
|
|
|
*eiu->fnp, Fstrerror(eiu->fd));
|
|
|
|
xx = Fclose(eiu->fd);
|
|
|
|
eiu->fd = NULL;
|
2001-04-10 20:36:45 +08:00
|
|
|
|
|
|
|
/* If successful, restart the query loop. */
|
2002-08-24 05:01:59 +08:00
|
|
|
if (rc == RPMRC_OK) {
|
2001-09-15 21:49:11 +08:00
|
|
|
eiu->prevx++;
|
2001-04-10 20:36:45 +08:00
|
|
|
goto restart;
|
|
|
|
}
|
|
|
|
|
2001-09-15 21:49:11 +08:00
|
|
|
eiu->numFailed++; *eiu->fnp = NULL;
|
2001-04-10 20:36:45 +08:00
|
|
|
break;
|
1999-07-14 23:28:03 +08:00
|
|
|
}
|
|
|
|
|
2001-04-10 20:36:45 +08:00
|
|
|
rpmMessage(RPMMESS_DEBUG, _("found %d source and %d binary packages\n"),
|
2001-09-15 21:49:11 +08:00
|
|
|
eiu->numSRPMS, eiu->numRPMS);
|
1999-07-14 23:28:03 +08:00
|
|
|
|
2001-09-15 21:49:11 +08:00
|
|
|
if (eiu->numFailed) goto exit;
|
2001-02-10 22:35:55 +08:00
|
|
|
|
2002-03-17 23:49:09 +08:00
|
|
|
if (eiu->numRPMS && !(ia->installInterfaceFlags & INSTALL_NODEPS)) {
|
2001-04-10 20:36:45 +08:00
|
|
|
|
2002-05-17 00:55:21 +08:00
|
|
|
if (rpmtsCheck(ts)) {
|
2001-09-15 21:49:11 +08:00
|
|
|
eiu->numFailed = eiu->numPkgs;
|
1999-07-14 23:28:03 +08:00
|
|
|
stopInstall = 1;
|
|
|
|
}
|
|
|
|
|
2002-05-28 05:40:08 +08:00
|
|
|
ps = rpmtsProblems(ts);
|
2002-06-12 22:52:59 +08:00
|
|
|
if (!stopInstall && rpmpsNumProblems(ps) > 0) {
|
2002-04-13 09:28:20 +08:00
|
|
|
rpmMessage(RPMMESS_ERROR, _("Failed dependencies:\n"));
|
2002-06-29 05:54:24 +08:00
|
|
|
rpmpsPrint(NULL, ps);
|
2001-09-15 21:49:11 +08:00
|
|
|
eiu->numFailed = eiu->numPkgs;
|
1999-07-14 23:28:03 +08:00
|
|
|
stopInstall = 1;
|
2002-04-13 09:28:20 +08:00
|
|
|
|
2002-04-14 02:52:18 +08:00
|
|
|
/*@-branchstate@*/
|
2002-04-13 09:28:20 +08:00
|
|
|
if (ts->suggests != NULL && ts->nsuggests > 0) {
|
|
|
|
rpmMessage(RPMMESS_NORMAL, _(" Suggested resolutions:\n"));
|
|
|
|
for (i = 0; i < ts->nsuggests; i++) {
|
|
|
|
const char * str = ts->suggests[i];
|
|
|
|
|
|
|
|
if (str == NULL)
|
|
|
|
break;
|
|
|
|
|
|
|
|
rpmMessage(RPMMESS_NORMAL, "\t%s\n", str);
|
|
|
|
|
|
|
|
ts->suggests[i] = NULL;
|
|
|
|
str = _free(str);
|
|
|
|
}
|
|
|
|
ts->suggests = _free(ts->suggests);
|
|
|
|
}
|
2002-04-14 02:52:18 +08:00
|
|
|
/*@=branchstate@*/
|
1999-07-14 23:28:03 +08:00
|
|
|
}
|
2002-05-20 02:42:25 +08:00
|
|
|
ps = rpmpsFree(ps);
|
1999-07-14 23:28:03 +08:00
|
|
|
}
|
|
|
|
|
2002-03-17 23:49:09 +08:00
|
|
|
if (eiu->numRPMS && !(ia->installInterfaceFlags & INSTALL_NOORDER)) {
|
2002-05-17 00:55:21 +08:00
|
|
|
if (rpmtsOrder(ts)) {
|
2001-09-15 21:49:11 +08:00
|
|
|
eiu->numFailed = eiu->numPkgs;
|
1999-07-14 23:28:03 +08:00
|
|
|
stopInstall = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-09-15 21:49:11 +08:00
|
|
|
if (eiu->numRPMS && !stopInstall) {
|
2000-10-29 02:45:58 +08:00
|
|
|
|
2002-08-14 00:36:44 +08:00
|
|
|
rpmcliPackagesTotal += eiu->numSRPMS;
|
2001-09-15 21:49:11 +08:00
|
|
|
|
1999-07-14 23:28:03 +08:00
|
|
|
rpmMessage(RPMMESS_DEBUG, _("installing binary packages\n"));
|
2001-10-28 06:31:10 +08:00
|
|
|
|
2002-07-15 05:23:29 +08:00
|
|
|
/* Drop added/available package indices and dependency sets. */
|
|
|
|
rpmtsClean(ts);
|
|
|
|
|
2002-05-17 00:55:21 +08:00
|
|
|
rc = rpmtsRun(ts, NULL, probFilter);
|
2002-05-28 05:40:08 +08:00
|
|
|
ps = rpmtsProblems(ts);
|
1999-07-14 23:28:03 +08:00
|
|
|
|
|
|
|
if (rc < 0) {
|
2001-09-15 21:49:11 +08:00
|
|
|
eiu->numFailed += eiu->numRPMS;
|
2002-04-15 05:48:44 +08:00
|
|
|
} else if (rc > 0) {
|
2001-09-15 21:49:11 +08:00
|
|
|
eiu->numFailed += rc;
|
2002-06-12 22:52:59 +08:00
|
|
|
if (rpmpsNumProblems(ps) > 0)
|
|
|
|
rpmpsPrint(stderr, ps);
|
1999-07-14 23:28:03 +08:00
|
|
|
}
|
2002-05-20 02:42:25 +08:00
|
|
|
ps = rpmpsFree(ps);
|
1999-07-14 23:28:03 +08:00
|
|
|
}
|
|
|
|
|
2001-09-15 21:49:11 +08:00
|
|
|
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.ufdio");
|
|
|
|
if (eiu->fd == NULL || Ferror(eiu->fd)) {
|
2001-04-10 20:36:45 +08:00
|
|
|
rpmMessage(RPMMESS_ERROR, _("cannot open file %s: %s\n"),
|
2001-09-15 21:49:11 +08:00
|
|
|
eiu->sourceURL[i], Fstrerror(eiu->fd));
|
2003-01-24 04:23:24 +08:00
|
|
|
if (eiu->fd != NULL) {
|
2001-09-15 21:49:11 +08:00
|
|
|
xx = Fclose(eiu->fd);
|
|
|
|
eiu->fd = NULL;
|
|
|
|
}
|
1999-07-14 23:28:03 +08:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2002-05-20 07:37:24 +08:00
|
|
|
if (!(rpmtsFlags(ts) & RPMTRANS_FLAG_TEST)) {
|
2002-03-14 04:01:50 +08:00
|
|
|
eiu->rpmrc = rpmInstallSourcePackage(ts, eiu->fd, NULL, NULL);
|
2001-09-15 21:49:11 +08:00
|
|
|
if (eiu->rpmrc != RPMRC_OK) eiu->numFailed++;
|
2001-02-13 03:02:15 +08:00
|
|
|
}
|
1999-07-14 23:28:03 +08:00
|
|
|
|
2001-09-15 21:49:11 +08:00
|
|
|
xx = Fclose(eiu->fd);
|
|
|
|
eiu->fd = NULL;
|
1999-07-14 23:28:03 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-04-10 20:36:45 +08:00
|
|
|
exit:
|
2001-09-15 21:49:11 +08:00
|
|
|
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]);
|
1999-07-14 23:28:03 +08:00
|
|
|
}
|
2001-09-15 21:49:11 +08:00
|
|
|
eiu->pkgState = _free(eiu->pkgState);
|
|
|
|
eiu->pkgURL = _free(eiu->pkgURL);
|
|
|
|
eiu->argv = _free(eiu->argv);
|
2001-10-26 12:16:19 +08:00
|
|
|
|
2002-08-16 02:50:46 +08:00
|
|
|
rpmtsEmpty(ts);
|
|
|
|
|
2001-09-15 21:49:11 +08:00
|
|
|
return eiu->numFailed;
|
1999-07-14 23:28:03 +08:00
|
|
|
}
|
2002-06-20 02:52:46 +08:00
|
|
|
/*@=bounds@*/
|
1999-07-14 23:28:03 +08:00
|
|
|
|
2002-10-10 03:07:43 +08:00
|
|
|
int rpmErase(rpmts ts, struct rpmInstallArguments_s * ia,
|
2002-03-13 23:06:07 +08:00
|
|
|
const char ** argv)
|
2000-03-23 23:49:50 +08:00
|
|
|
{
|
1999-07-14 23:28:03 +08:00
|
|
|
int count;
|
|
|
|
const char ** arg;
|
|
|
|
int numFailed = 0;
|
|
|
|
int stopUninstall = 0;
|
|
|
|
int numPackages = 0;
|
2002-08-08 05:55:43 +08:00
|
|
|
rpmVSFlags vsflags, ovsflags;
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmps ps;
|
1999-07-14 23:28:03 +08:00
|
|
|
|
2001-05-04 05:00:18 +08:00
|
|
|
if (argv == NULL) return 0;
|
|
|
|
|
2002-08-03 05:52:01 +08:00
|
|
|
vsflags = rpmExpandNumeric("%{?_vsflags_erase}");
|
2002-07-25 00:21:23 +08:00
|
|
|
if (ia->qva_flags & VERIFY_DIGEST)
|
2002-08-06 09:41:44 +08:00
|
|
|
vsflags |= _RPMVSF_NODIGESTS;
|
2002-07-25 00:21:23 +08:00
|
|
|
if (ia->qva_flags & VERIFY_SIGNATURE)
|
2002-08-06 09:41:44 +08:00
|
|
|
vsflags |= _RPMVSF_NOSIGNATURES;
|
2002-07-25 00:21:23 +08:00
|
|
|
if (ia->qva_flags & VERIFY_HDRCHK)
|
2002-08-06 09:41:44 +08:00
|
|
|
vsflags |= RPMVSF_NOHDRCHK;
|
|
|
|
ovsflags = rpmtsSetVSFlags(ts, vsflags);
|
2002-07-25 00:21:23 +08:00
|
|
|
|
2002-09-01 06:39:34 +08:00
|
|
|
if (rpmExpandNumeric("%{?_repackage_all_erasures}"))
|
|
|
|
ia->transFlags |= RPMTRANS_FLAG_REPACKAGE;
|
|
|
|
|
2002-03-17 23:49:09 +08:00
|
|
|
(void) rpmtsSetFlags(ts, ia->transFlags);
|
2002-03-13 23:06:07 +08:00
|
|
|
|
2002-03-14 04:01:50 +08:00
|
|
|
#ifdef NOTYET /* XXX no callbacks on erase yet */
|
|
|
|
{ int notifyFlags;
|
2002-03-17 23:49:09 +08:00
|
|
|
notifyFlags = ia->eraseInterfaceFlags | (rpmIsVerbose() ? INSTALL_LABEL : 0 );
|
2002-03-14 04:01:50 +08:00
|
|
|
xx = rpmtsSetNotifyCallback(ts,
|
|
|
|
rpmShowProgress, (void *) ((long)notifyFlags)
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2002-04-13 09:28:20 +08:00
|
|
|
ts->goal = TSM_ERASE;
|
2002-03-13 23:06:07 +08:00
|
|
|
|
1999-07-14 23:28:03 +08:00
|
|
|
for (arg = argv; *arg; arg++) {
|
2000-04-27 08:10:28 +08:00
|
|
|
rpmdbMatchIterator mi;
|
|
|
|
|
|
|
|
/* XXX HACK to get rpmdbFindByLabel out of the API */
|
2001-10-28 04:09:20 +08:00
|
|
|
mi = rpmtsInitIterator(ts, RPMDBI_LABEL, *arg, 0);
|
2000-04-27 08:10:28 +08:00
|
|
|
count = rpmdbGetIteratorCount(mi);
|
|
|
|
if (count <= 0) {
|
|
|
|
rpmMessage(RPMMESS_ERROR, _("package %s is not installed\n"), *arg);
|
|
|
|
numFailed++;
|
2002-03-17 23:49:09 +08:00
|
|
|
} else if (!(count == 1 || (ia->eraseInterfaceFlags & UNINSTALL_ALLMATCHES))) {
|
2000-04-27 08:10:28 +08:00
|
|
|
rpmMessage(RPMMESS_ERROR, _("\"%s\" specifies multiple packages\n"),
|
|
|
|
*arg);
|
|
|
|
numFailed++;
|
|
|
|
} else {
|
|
|
|
Header h; /* XXX iterator owns the reference */
|
|
|
|
while ((h = rpmdbNextIterator(mi)) != NULL) {
|
|
|
|
unsigned int recOffset = rpmdbGetIteratorOffset(mi);
|
|
|
|
if (recOffset) {
|
2002-05-28 05:40:08 +08:00
|
|
|
(void) rpmtsAddEraseElement(ts, h, recOffset);
|
2000-04-27 08:10:28 +08:00
|
|
|
numPackages++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-04-30 06:43:01 +08:00
|
|
|
mi = rpmdbFreeIterator(mi);
|
1999-07-14 23:28:03 +08:00
|
|
|
}
|
|
|
|
|
2002-03-17 23:49:09 +08:00
|
|
|
if (!(ia->eraseInterfaceFlags & UNINSTALL_NODEPS)) {
|
2002-04-14 02:52:18 +08:00
|
|
|
|
2002-05-17 00:55:21 +08:00
|
|
|
if (rpmtsCheck(ts)) {
|
1999-07-14 23:28:03 +08:00
|
|
|
numFailed = numPackages;
|
|
|
|
stopUninstall = 1;
|
|
|
|
}
|
|
|
|
|
2002-05-28 05:40:08 +08:00
|
|
|
ps = rpmtsProblems(ts);
|
2002-06-12 22:52:59 +08:00
|
|
|
if (!stopUninstall && rpmpsNumProblems(ps) > 0) {
|
2002-06-29 05:54:24 +08:00
|
|
|
rpmMessage(RPMMESS_ERROR, _("Failed dependencies:\n"));
|
|
|
|
rpmpsPrint(NULL, ps);
|
1999-07-14 23:28:03 +08:00
|
|
|
numFailed += numPackages;
|
|
|
|
stopUninstall = 1;
|
|
|
|
}
|
2002-05-20 02:42:25 +08:00
|
|
|
ps = rpmpsFree(ps);
|
1999-07-14 23:28:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!stopUninstall) {
|
2002-05-20 07:37:24 +08:00
|
|
|
(void) rpmtsSetFlags(ts, (rpmtsFlags(ts) | RPMTRANS_FLAG_REVERSE));
|
2002-07-15 05:23:29 +08:00
|
|
|
|
|
|
|
/* Drop added/available package indices and dependency sets. */
|
|
|
|
rpmtsClean(ts);
|
|
|
|
|
2002-06-29 05:54:24 +08:00
|
|
|
numPackages = rpmtsRun(ts, NULL, 0);
|
2002-05-28 05:40:08 +08:00
|
|
|
ps = rpmtsProblems(ts);
|
2002-06-29 05:54:24 +08:00
|
|
|
if (rpmpsNumProblems(ps) > 0)
|
|
|
|
rpmpsPrint(NULL, ps);
|
|
|
|
numFailed += numPackages;
|
|
|
|
stopUninstall = 1;
|
2002-05-20 02:42:25 +08:00
|
|
|
ps = rpmpsFree(ps);
|
1999-07-14 23:28:03 +08:00
|
|
|
}
|
|
|
|
|
2002-08-16 02:50:46 +08:00
|
|
|
rpmtsEmpty(ts);
|
|
|
|
|
1999-07-14 23:28:03 +08:00
|
|
|
return numFailed;
|
|
|
|
}
|
|
|
|
|
2002-05-20 02:42:25 +08:00
|
|
|
int rpmInstallSource(rpmts ts, const char * arg,
|
2002-04-11 06:10:13 +08:00
|
|
|
const char ** specFilePtr, const char ** cookie)
|
2000-06-19 19:35:29 +08:00
|
|
|
{
|
1999-07-14 23:28:03 +08:00
|
|
|
FD_t fd;
|
|
|
|
int rc;
|
|
|
|
|
2002-08-08 05:55:43 +08:00
|
|
|
|
1999-11-05 05:26:08 +08:00
|
|
|
fd = Fopen(arg, "r.ufdio");
|
1999-12-13 01:46:22 +08:00
|
|
|
if (fd == NULL || Ferror(fd)) {
|
1999-11-11 06:09:49 +08:00
|
|
|
rpmMessage(RPMMESS_ERROR, _("cannot open %s: %s\n"), arg, Fstrerror(fd));
|
2003-01-24 04:23:24 +08:00
|
|
|
if (fd != NULL) (void) Fclose(fd);
|
1999-07-14 23:28:03 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rpmIsVerbose())
|
|
|
|
fprintf(stdout, _("Installing %s\n"), arg);
|
|
|
|
|
2001-05-04 05:00:18 +08:00
|
|
|
{
|
2002-08-09 00:06:13 +08:00
|
|
|
rpmVSFlags ovsflags =
|
|
|
|
rpmtsSetVSFlags(ts, (rpmtsVSFlags(ts) | RPMVSF_NEEDPAYLOAD));
|
2002-04-11 06:10:13 +08:00
|
|
|
rpmRC rpmrc = rpmInstallSourcePackage(ts, fd, specFilePtr, cookie);
|
2001-02-13 03:02:15 +08:00
|
|
|
rc = (rpmrc == RPMRC_OK ? 0 : 1);
|
2002-08-08 05:55:43 +08:00
|
|
|
ovsflags = rpmtsSetVSFlags(ts, ovsflags);
|
2001-02-13 03:02:15 +08:00
|
|
|
}
|
|
|
|
if (rc != 0) {
|
1999-07-14 23:28:03 +08:00
|
|
|
rpmMessage(RPMMESS_ERROR, _("%s cannot be installed\n"), arg);
|
2001-04-30 06:43:01 +08:00
|
|
|
/*@-unqualifiedtrans@*/
|
2002-04-11 06:10:13 +08:00
|
|
|
if (specFilePtr && *specFilePtr)
|
|
|
|
*specFilePtr = _free(*specFilePtr);
|
2001-03-24 04:27:48 +08:00
|
|
|
if (cookie && *cookie)
|
|
|
|
*cookie = _free(*cookie);
|
2001-04-30 06:43:01 +08:00
|
|
|
/*@=unqualifiedtrans@*/
|
1999-07-14 23:28:03 +08:00
|
|
|
}
|
|
|
|
|
2001-05-01 06:32:22 +08:00
|
|
|
(void) Fclose(fd);
|
1999-07-14 23:28:03 +08:00
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
2001-07-07 04:37:42 +08:00
|
|
|
|
2001-10-15 11:22:10 +08:00
|
|
|
/*@unchecked@*/
|
2001-07-07 04:37:42 +08:00
|
|
|
static int reverse = -1;
|
|
|
|
|
|
|
|
/**
|
|
|
|
*/
|
|
|
|
static int IDTintcmp(const void * a, const void * b)
|
|
|
|
/*@*/
|
|
|
|
{
|
|
|
|
/*@-castexpose@*/
|
2002-01-28 23:51:06 +08:00
|
|
|
return ( reverse * (((IDT)a)->val.u32 - ((IDT)b)->val.u32) );
|
2001-07-07 04:37:42 +08:00
|
|
|
/*@=castexpose@*/
|
|
|
|
}
|
|
|
|
|
|
|
|
IDTX IDTXfree(IDTX idtx)
|
|
|
|
{
|
|
|
|
if (idtx) {
|
|
|
|
int i;
|
|
|
|
if (idtx->idt)
|
|
|
|
for (i = 0; i < idtx->nidt; i++) {
|
|
|
|
IDT idt = idtx->idt + i;
|
2002-07-14 03:08:51 +08:00
|
|
|
idt->h = headerFree(idt->h);
|
2001-07-07 04:37:42 +08:00
|
|
|
idt->key = _free(idt->key);
|
|
|
|
}
|
|
|
|
idtx->idt = _free(idtx->idt);
|
|
|
|
idtx = _free(idtx);
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
IDTX IDTXnew(void)
|
|
|
|
{
|
|
|
|
IDTX idtx = xcalloc(1, sizeof(*idtx));
|
|
|
|
idtx->delta = 10;
|
|
|
|
idtx->size = sizeof(*((IDT)0));
|
|
|
|
return idtx;
|
|
|
|
}
|
|
|
|
|
|
|
|
IDTX IDTXgrow(IDTX idtx, int need)
|
|
|
|
{
|
|
|
|
if (need < 0) return NULL;
|
|
|
|
if (idtx == NULL)
|
|
|
|
idtx = IDTXnew();
|
|
|
|
if (need == 0) return idtx;
|
|
|
|
|
|
|
|
if ((idtx->nidt + need) > idtx->alloced) {
|
|
|
|
while (need > 0) {
|
|
|
|
idtx->alloced += idtx->delta;
|
|
|
|
need -= idtx->delta;
|
|
|
|
}
|
|
|
|
idtx->idt = xrealloc(idtx->idt, (idtx->alloced * idtx->size) );
|
|
|
|
}
|
|
|
|
return idtx;
|
|
|
|
}
|
|
|
|
|
|
|
|
IDTX IDTXsort(IDTX idtx)
|
|
|
|
{
|
|
|
|
if (idtx != NULL && idtx->idt != NULL && idtx->nidt > 0)
|
|
|
|
qsort(idtx->idt, idtx->nidt, idtx->size, IDTintcmp);
|
|
|
|
return idtx;
|
|
|
|
}
|
|
|
|
|
2002-05-20 02:42:25 +08:00
|
|
|
IDTX IDTXload(rpmts ts, rpmTag tag)
|
2001-07-07 04:37:42 +08:00
|
|
|
{
|
|
|
|
IDTX idtx = NULL;
|
|
|
|
rpmdbMatchIterator mi;
|
|
|
|
HGE_t hge = (HGE_t) headerGetEntry;
|
|
|
|
Header h;
|
|
|
|
|
2001-10-16 01:53:34 +08:00
|
|
|
/*@-branchstate@*/
|
2001-10-28 04:09:20 +08:00
|
|
|
mi = rpmtsInitIterator(ts, tag, NULL, 0);
|
2002-12-04 10:01:47 +08:00
|
|
|
#ifdef NOTYET
|
|
|
|
(void) rpmdbSetIteratorRE(mi, RPMTAG_NAME, RPMMIRE_DEFAULT, '!gpg-pubkey');
|
|
|
|
#endif
|
2001-07-07 04:37:42 +08:00
|
|
|
while ((h = rpmdbNextIterator(mi)) != NULL) {
|
2001-09-21 23:07:11 +08:00
|
|
|
rpmTagType type = RPM_NULL_TYPE;
|
|
|
|
int_32 count = 0;
|
2001-07-07 04:37:42 +08:00
|
|
|
int_32 * tidp;
|
|
|
|
|
|
|
|
tidp = NULL;
|
|
|
|
if (!hge(h, tag, &type, (void **)&tidp, &count) || tidp == NULL)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (type == RPM_INT32_TYPE && (*tidp == 0 || *tidp == -1))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
idtx = IDTXgrow(idtx, 1);
|
|
|
|
if (idtx == NULL)
|
|
|
|
continue;
|
|
|
|
if (idtx->idt == NULL)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
{ IDT idt;
|
|
|
|
/*@-nullderef@*/
|
|
|
|
idt = idtx->idt + idtx->nidt;
|
|
|
|
/*@=nullderef@*/
|
2002-07-14 03:08:51 +08:00
|
|
|
idt->h = headerLink(h);
|
2001-07-07 04:37:42 +08:00
|
|
|
idt->key = NULL;
|
|
|
|
idt->instance = rpmdbGetIteratorOffset(mi);
|
2002-01-28 23:51:06 +08:00
|
|
|
idt->val.u32 = *tidp;
|
2001-07-07 04:37:42 +08:00
|
|
|
}
|
|
|
|
idtx->nidt++;
|
|
|
|
}
|
|
|
|
mi = rpmdbFreeIterator(mi);
|
2001-10-16 01:53:34 +08:00
|
|
|
/*@=branchstate@*/
|
2001-07-07 04:37:42 +08:00
|
|
|
|
|
|
|
return IDTXsort(idtx);
|
|
|
|
}
|
|
|
|
|
2002-05-20 02:42:25 +08:00
|
|
|
IDTX IDTXglob(rpmts ts, const char * globstr, rpmTag tag)
|
2001-07-07 04:37:42 +08:00
|
|
|
{
|
|
|
|
IDTX idtx = NULL;
|
|
|
|
HGE_t hge = (HGE_t) headerGetEntry;
|
|
|
|
Header h;
|
|
|
|
int_32 * tidp;
|
|
|
|
FD_t fd;
|
|
|
|
const char ** av = NULL;
|
|
|
|
int ac = 0;
|
2002-08-24 05:01:59 +08:00
|
|
|
rpmRC rpmrc;
|
2001-10-26 12:16:19 +08:00
|
|
|
int xx;
|
2001-07-07 04:37:42 +08:00
|
|
|
int i;
|
|
|
|
|
2001-09-15 21:49:11 +08:00
|
|
|
av = NULL; ac = 0;
|
2002-08-24 05:01:59 +08:00
|
|
|
xx = rpmGlob(globstr, &ac, &av);
|
2001-07-07 04:37:42 +08:00
|
|
|
|
2002-08-24 05:01:59 +08:00
|
|
|
if (xx == 0)
|
2001-07-07 04:37:42 +08:00
|
|
|
for (i = 0; i < ac; i++) {
|
|
|
|
rpmTagType type;
|
|
|
|
int_32 count;
|
|
|
|
int isSource;
|
|
|
|
|
|
|
|
fd = Fopen(av[i], "r.ufdio");
|
|
|
|
if (fd == NULL || Ferror(fd)) {
|
|
|
|
rpmError(RPMERR_OPEN, _("open of %s failed: %s\n"), av[i],
|
|
|
|
Fstrerror(fd));
|
2003-01-24 04:23:24 +08:00
|
|
|
if (fd != NULL) (void) Fclose(fd);
|
2001-07-07 04:37:42 +08:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2002-08-24 05:01:59 +08:00
|
|
|
rpmrc = rpmReadPackageFile(ts, fd, av[i], &h);
|
|
|
|
(void) Fclose(fd);
|
|
|
|
switch (rpmrc) {
|
|
|
|
default:
|
|
|
|
goto bottom;
|
|
|
|
/*@notreached@*/ /*@switchbreak@*/ break;
|
2002-08-28 04:50:21 +08:00
|
|
|
case RPMRC_NOTTRUSTED:
|
|
|
|
case RPMRC_NOKEY:
|
2002-08-24 05:01:59 +08:00
|
|
|
case RPMRC_OK:
|
|
|
|
isSource = headerIsEntry(h, RPMTAG_SOURCEPACKAGE);
|
|
|
|
if (isSource)
|
|
|
|
goto bottom;
|
|
|
|
/*@switchbreak@*/ break;
|
2001-07-07 04:37:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
tidp = NULL;
|
2001-10-16 01:53:34 +08:00
|
|
|
/*@-branchstate@*/
|
2003-04-03 05:16:26 +08:00
|
|
|
if (hge(h, tag, &type, (void **) &tidp, &count) && tidp != NULL) {
|
2001-07-07 04:37:42 +08:00
|
|
|
|
|
|
|
idtx = IDTXgrow(idtx, 1);
|
2002-08-24 05:01:59 +08:00
|
|
|
if (idtx == NULL || idtx->idt == NULL)
|
|
|
|
goto bottom;
|
|
|
|
|
2001-07-07 04:37:42 +08:00
|
|
|
{ IDT idt;
|
|
|
|
idt = idtx->idt + idtx->nidt;
|
2002-07-14 03:08:51 +08:00
|
|
|
idt->h = headerLink(h);
|
2001-07-07 04:37:42 +08:00
|
|
|
idt->key = av[i];
|
|
|
|
av[i] = NULL;
|
|
|
|
idt->instance = 0;
|
2002-01-28 23:51:06 +08:00
|
|
|
idt->val.u32 = *tidp;
|
2001-07-07 04:37:42 +08:00
|
|
|
}
|
|
|
|
idtx->nidt++;
|
|
|
|
}
|
2001-10-16 01:53:34 +08:00
|
|
|
/*@=branchstate@*/
|
2002-08-24 05:01:59 +08:00
|
|
|
bottom:
|
2002-07-14 03:08:51 +08:00
|
|
|
h = headerFree(h);
|
2001-07-07 04:37:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < ac; i++)
|
|
|
|
av[i] = _free(av[i]);
|
2001-09-15 21:49:11 +08:00
|
|
|
av = _free(av); ac = 0;
|
2001-07-07 04:37:42 +08:00
|
|
|
|
|
|
|
return idtx;
|
|
|
|
}
|
|
|
|
|
2002-01-28 23:51:06 +08:00
|
|
|
/** @todo Transaction handling, more, needs work. */
|
2002-08-09 00:06:13 +08:00
|
|
|
int rpmRollback(rpmts ts, struct rpmInstallArguments_s * ia, const char ** argv)
|
2001-07-07 04:37:42 +08:00
|
|
|
{
|
2002-01-28 23:51:06 +08:00
|
|
|
int ifmask= (INSTALL_UPGRADE|INSTALL_FRESHEN|INSTALL_INSTALL|INSTALL_ERASE);
|
|
|
|
unsigned thistid = 0xffffffff;
|
|
|
|
unsigned prevtid;
|
|
|
|
time_t tid;
|
2001-07-07 04:37:42 +08:00
|
|
|
IDTX itids = NULL;
|
|
|
|
IDTX rtids = NULL;
|
2002-01-28 23:51:06 +08:00
|
|
|
IDT rp;
|
|
|
|
int nrids = 0;
|
|
|
|
IDT ip;
|
|
|
|
int niids = 0;
|
|
|
|
int rc = 0;
|
2002-08-05 00:55:55 +08:00
|
|
|
int vsflags, ovsflags;
|
|
|
|
int numAdded;
|
|
|
|
int numRemoved;
|
|
|
|
rpmps ps;
|
2002-08-16 02:50:46 +08:00
|
|
|
int _unsafe_rollbacks = 0;
|
|
|
|
rpmtransFlags transFlags = ia->transFlags;
|
2002-01-28 23:51:06 +08:00
|
|
|
|
|
|
|
if (argv != NULL && *argv != NULL) {
|
|
|
|
rc = -1;
|
|
|
|
goto exit;
|
|
|
|
}
|
2001-07-07 04:37:42 +08:00
|
|
|
|
2002-08-16 02:50:46 +08:00
|
|
|
_unsafe_rollbacks = rpmExpandNumeric("%{?_unsafe_rollbacks}");
|
|
|
|
|
2002-08-05 00:55:55 +08:00
|
|
|
vsflags = rpmExpandNumeric("%{?_vsflags_erase}");
|
|
|
|
if (ia->qva_flags & VERIFY_DIGEST)
|
2002-08-06 09:41:44 +08:00
|
|
|
vsflags |= _RPMVSF_NODIGESTS;
|
2002-08-05 00:55:55 +08:00
|
|
|
if (ia->qva_flags & VERIFY_SIGNATURE)
|
2002-08-06 09:41:44 +08:00
|
|
|
vsflags |= _RPMVSF_NOSIGNATURES;
|
2002-08-05 00:55:55 +08:00
|
|
|
if (ia->qva_flags & VERIFY_HDRCHK)
|
2002-08-06 09:41:44 +08:00
|
|
|
vsflags |= RPMVSF_NOHDRCHK;
|
|
|
|
vsflags |= RPMVSF_NEEDPAYLOAD; /* XXX no legacy signatures */
|
|
|
|
ovsflags = rpmtsSetVSFlags(ts, vsflags);
|
2002-08-05 00:55:55 +08:00
|
|
|
|
2002-08-16 02:50:46 +08:00
|
|
|
(void) rpmtsSetFlags(ts, transFlags);
|
2002-08-05 00:55:55 +08:00
|
|
|
|
2001-10-25 09:36:32 +08:00
|
|
|
itids = IDTXload(ts, RPMTAG_INSTALLTID);
|
2002-01-28 23:51:06 +08:00
|
|
|
if (itids != NULL) {
|
|
|
|
ip = itids->idt;
|
|
|
|
niids = itids->nidt;
|
|
|
|
} else {
|
|
|
|
ip = NULL;
|
|
|
|
niids = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
{ const char * globstr = rpmExpand("%{_repackage_dir}/*.rpm", NULL);
|
|
|
|
if (globstr == NULL || *globstr == '%') {
|
|
|
|
globstr = _free(globstr);
|
|
|
|
rc = -1;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
rtids = IDTXglob(ts, globstr, RPMTAG_REMOVETID);
|
2002-11-13 06:56:03 +08:00
|
|
|
|
2002-01-28 23:51:06 +08:00
|
|
|
if (rtids != NULL) {
|
|
|
|
rp = rtids->idt;
|
|
|
|
nrids = rtids->nidt;
|
|
|
|
} else {
|
|
|
|
rp = NULL;
|
|
|
|
nrids = 0;
|
|
|
|
}
|
|
|
|
globstr = _free(globstr);
|
|
|
|
}
|
|
|
|
|
2002-08-05 00:55:55 +08:00
|
|
|
{ int notifyFlags, xx;
|
2002-03-17 23:49:09 +08:00
|
|
|
notifyFlags = ia->installInterfaceFlags | (rpmIsVerbose() ? INSTALL_LABEL : 0 );
|
|
|
|
xx = rpmtsSetNotifyCallback(ts,
|
|
|
|
rpmShowProgress, (void *) ((long)notifyFlags));
|
|
|
|
}
|
|
|
|
|
2002-01-28 23:51:06 +08:00
|
|
|
/* Run transactions until rollback goal is achieved. */
|
|
|
|
do {
|
|
|
|
prevtid = thistid;
|
|
|
|
rc = 0;
|
2002-08-05 00:55:55 +08:00
|
|
|
rpmcliPackagesTotal = 0;
|
|
|
|
numAdded = 0;
|
|
|
|
numRemoved = 0;
|
2002-01-28 23:51:06 +08:00
|
|
|
ia->installInterfaceFlags &= ~ifmask;
|
|
|
|
|
|
|
|
/* Find larger of the remaining install/erase transaction id's. */
|
|
|
|
thistid = 0;
|
|
|
|
if (ip != NULL && ip->val.u32 > thistid)
|
|
|
|
thistid = ip->val.u32;
|
|
|
|
if (rp != NULL && rp->val.u32 > thistid)
|
|
|
|
thistid = rp->val.u32;
|
|
|
|
|
|
|
|
/* If we've achieved the rollback goal, then we're done. */
|
|
|
|
if (thistid == 0 || thistid < ia->rbtid)
|
|
|
|
break;
|
|
|
|
|
2002-09-01 06:39:34 +08:00
|
|
|
/* If we've reached the (configured) rollback goal, then we're done. */
|
|
|
|
if (_unsafe_rollbacks && thistid <= _unsafe_rollbacks)
|
|
|
|
break;
|
|
|
|
|
2002-08-16 02:50:46 +08:00
|
|
|
rpmtsEmpty(ts);
|
|
|
|
(void) rpmtsSetFlags(ts, transFlags);
|
|
|
|
|
2002-01-28 23:51:06 +08:00
|
|
|
/* Install the previously erased packages for this transaction. */
|
|
|
|
while (rp != NULL && rp->val.u32 == thistid) {
|
|
|
|
|
2002-08-16 02:50:46 +08:00
|
|
|
rpmMessage(RPMMESS_DEBUG, "\t+++ install %s\n",
|
|
|
|
(rp->key ? rp->key : "???"));
|
2002-01-28 23:51:06 +08:00
|
|
|
|
2002-08-09 00:06:13 +08:00
|
|
|
/*@-abstract@*/
|
2002-05-28 05:40:08 +08:00
|
|
|
rc = rpmtsAddInstallElement(ts, rp->h, (fnpyKey)rp->key,
|
2002-01-28 23:51:06 +08:00
|
|
|
0, ia->relocations);
|
2002-08-09 00:06:13 +08:00
|
|
|
/*@=abstract@*/
|
2002-01-28 23:51:06 +08:00
|
|
|
if (rc != 0)
|
|
|
|
goto exit;
|
|
|
|
|
2002-08-05 00:55:55 +08:00
|
|
|
numAdded++;
|
|
|
|
rpmcliPackagesTotal++;
|
2002-01-28 23:51:06 +08:00
|
|
|
if (!(ia->installInterfaceFlags & ifmask))
|
|
|
|
ia->installInterfaceFlags |= INSTALL_UPGRADE;
|
|
|
|
|
|
|
|
#ifdef NOTYET
|
|
|
|
rp->h = headerFree(rp->h);
|
|
|
|
#endif
|
|
|
|
nrids--;
|
|
|
|
if (nrids > 0)
|
|
|
|
rp++;
|
|
|
|
else
|
|
|
|
rp = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Erase the previously installed packages for this transaction. */
|
|
|
|
while (ip != NULL && ip->val.u32 == thistid) {
|
|
|
|
|
|
|
|
rpmMessage(RPMMESS_DEBUG,
|
2002-08-16 02:50:46 +08:00
|
|
|
"\t--- erase h#%u\n", ip->instance);
|
2002-01-28 23:51:06 +08:00
|
|
|
|
2002-08-05 00:55:55 +08:00
|
|
|
rc = rpmtsAddEraseElement(ts, ip->h, ip->instance);
|
2002-01-28 23:51:06 +08:00
|
|
|
if (rc != 0)
|
|
|
|
goto exit;
|
|
|
|
|
2002-08-05 00:55:55 +08:00
|
|
|
numRemoved++;
|
2002-08-16 02:50:46 +08:00
|
|
|
|
|
|
|
if (_unsafe_rollbacks)
|
|
|
|
rpmcliPackagesTotal++;
|
|
|
|
|
|
|
|
if (!(ia->installInterfaceFlags & ifmask)) {
|
2002-01-28 23:51:06 +08:00
|
|
|
ia->installInterfaceFlags |= INSTALL_ERASE;
|
2002-08-16 02:50:46 +08:00
|
|
|
(void) rpmtsSetFlags(ts, (transFlags | RPMTRANS_FLAG_REVERSE));
|
|
|
|
}
|
2002-01-28 23:51:06 +08:00
|
|
|
|
|
|
|
#ifdef NOTYET
|
|
|
|
ip->instance = 0;
|
|
|
|
#endif
|
|
|
|
niids--;
|
|
|
|
if (niids > 0)
|
|
|
|
ip++;
|
|
|
|
else
|
|
|
|
ip = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Anything to do? */
|
2002-08-05 00:55:55 +08:00
|
|
|
if (rpmcliPackagesTotal <= 0)
|
2002-01-28 23:51:06 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
tid = (time_t)thistid;
|
2002-08-05 00:55:55 +08:00
|
|
|
rpmMessage(RPMMESS_NORMAL,
|
|
|
|
_("Rollback packages (+%d/-%d) to %-24.24s (0x%08x):\n"),
|
|
|
|
numAdded, numRemoved, ctime(&tid), tid);
|
2002-01-28 23:51:06 +08:00
|
|
|
|
2002-05-17 00:55:21 +08:00
|
|
|
rc = rpmtsCheck(ts);
|
2002-05-28 05:40:08 +08:00
|
|
|
ps = rpmtsProblems(ts);
|
2002-06-12 22:52:59 +08:00
|
|
|
if (rc != 0 && rpmpsNumProblems(ps) > 0) {
|
2002-04-14 02:52:18 +08:00
|
|
|
rpmMessage(RPMMESS_ERROR, _("Failed dependencies:\n"));
|
2002-06-29 05:54:24 +08:00
|
|
|
rpmpsPrint(NULL, ps);
|
2002-05-20 02:42:25 +08:00
|
|
|
ps = rpmpsFree(ps);
|
2002-01-28 23:51:06 +08:00
|
|
|
goto exit;
|
|
|
|
}
|
2002-05-20 02:42:25 +08:00
|
|
|
ps = rpmpsFree(ps);
|
2001-10-28 04:09:20 +08:00
|
|
|
|
2002-05-17 00:55:21 +08:00
|
|
|
rc = rpmtsOrder(ts);
|
2002-01-28 23:51:06 +08:00
|
|
|
if (rc != 0)
|
|
|
|
goto exit;
|
|
|
|
|
2002-07-15 05:23:29 +08:00
|
|
|
/* Drop added/available package indices and dependency sets. */
|
|
|
|
rpmtsClean(ts);
|
|
|
|
|
2002-05-17 00:55:21 +08:00
|
|
|
rc = rpmtsRun(ts, NULL, (ia->probFilter|RPMPROB_FILTER_OLDPACKAGE));
|
2002-05-28 05:40:08 +08:00
|
|
|
ps = rpmtsProblems(ts);
|
2002-06-12 22:52:59 +08:00
|
|
|
if (rc > 0 && rpmpsNumProblems(ps) > 0)
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmpsPrint(stderr, ps);
|
|
|
|
ps = rpmpsFree(ps);
|
2002-02-03 06:45:41 +08:00
|
|
|
if (rc)
|
2002-01-28 23:51:06 +08:00
|
|
|
goto exit;
|
2002-02-03 06:45:41 +08:00
|
|
|
|
|
|
|
/* Clean up after successful rollback. */
|
2002-08-09 00:06:13 +08:00
|
|
|
if (rtids && !rpmIsDebug()) {
|
2002-02-10 06:39:29 +08:00
|
|
|
int i;
|
2002-08-09 00:06:13 +08:00
|
|
|
if (rtids->idt)
|
2002-02-10 06:39:29 +08:00
|
|
|
for (i = 0; i < rtids->nidt; i++) {
|
|
|
|
IDT rrp = rtids->idt + i;
|
|
|
|
if (rrp->val.u32 != thistid)
|
2002-08-09 00:06:13 +08:00
|
|
|
/*@innercontinue@*/ continue;
|
|
|
|
if (rrp->key) /* XXX can't happen */
|
|
|
|
(void) unlink(rrp->key);
|
2002-02-10 06:39:29 +08:00
|
|
|
}
|
2002-01-28 23:51:06 +08:00
|
|
|
}
|
|
|
|
|
2002-08-16 02:50:46 +08:00
|
|
|
|
2002-01-28 23:51:06 +08:00
|
|
|
} while (1);
|
|
|
|
|
|
|
|
exit:
|
2001-07-07 04:37:42 +08:00
|
|
|
rtids = IDTXfree(rtids);
|
|
|
|
itids = IDTXfree(itids);
|
|
|
|
|
2002-08-16 02:50:46 +08:00
|
|
|
rpmtsEmpty(ts);
|
|
|
|
(void) rpmtsSetFlags(ts, transFlags);
|
|
|
|
|
2002-01-28 23:51:06 +08:00
|
|
|
return rc;
|
2001-07-07 04:37:42 +08:00
|
|
|
}
|