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"
|
|
|
|
|
2007-12-08 20:02:32 +08:00
|
|
|
#include <rpm/rpmcli.h>
|
2008-01-30 19:53:51 +08:00
|
|
|
#include <rpm/rpmtag.h>
|
|
|
|
#include <rpm/rpmlib.h> /* rpmReadPackageFile, vercmp etc */
|
2007-12-08 20:02:32 +08:00
|
|
|
#include <rpm/rpmdb.h>
|
|
|
|
#include <rpm/rpmds.h>
|
|
|
|
#include <rpm/rpmts.h>
|
|
|
|
#include <rpm/rpmlog.h>
|
|
|
|
#include <rpm/rpmfileutil.h>
|
2002-04-12 00:55:19 +08:00
|
|
|
|
2007-11-23 18:39:29 +08:00
|
|
|
#include "lib/manifest.h"
|
2000-12-13 04:03:45 +08:00
|
|
|
#include "debug.h"
|
1999-12-13 01:46:22 +08:00
|
|
|
|
2002-08-05 00:55:55 +08:00
|
|
|
int rpmcliPackagesTotal = 0;
|
|
|
|
int rpmcliHashesCurrent = 0;
|
|
|
|
int rpmcliHashesTotal = 0;
|
|
|
|
int rpmcliProgressCurrent = 0;
|
|
|
|
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
|
|
|
*/
|
2008-06-09 17:00:12 +08:00
|
|
|
static void printHash(const rpm_loff_t amount, const rpm_loff_t total)
|
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-08-08 05:55:43 +08:00
|
|
|
float pct = (total ? (((float) amount) / total) : 1.0);
|
|
|
|
hashesNeeded = (rpmcliHashesTotal * pct) + 0.5;
|
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 ('#');
|
|
|
|
pct = (rpmcliProgressTotal
|
|
|
|
? (((float) rpmcliProgressCurrent) / rpmcliProgressTotal)
|
|
|
|
: 1);
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-09-12 01:07:39 +08:00
|
|
|
void * rpmShowProgress(const void * arg,
|
2001-07-07 04:37:42 +08:00
|
|
|
const rpmCallbackType what,
|
2008-06-09 17:00:12 +08:00
|
|
|
const rpm_loff_t amount,
|
|
|
|
const rpm_loff_t total,
|
2007-09-12 01:07:39 +08:00
|
|
|
fnpyKey key,
|
|
|
|
void * data)
|
2000-06-19 19:35:29 +08:00
|
|
|
{
|
|
|
|
Header h = (Header) arg;
|
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;
|
2001-11-08 08:12:49 +08:00
|
|
|
const char * filename = (const char *)key;
|
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:
|
2001-05-04 05:00:18 +08:00
|
|
|
if (filename == NULL || filename[0] == '\0')
|
|
|
|
return NULL;
|
1999-11-10 04:57:38 +08:00
|
|
|
fd = Fopen(filename, "r.ufdio");
|
2007-09-12 01:07:39 +08:00
|
|
|
/* FIX: still necessary? */
|
2002-08-14 00:36:44 +08:00
|
|
|
if (fd == NULL || Ferror(fd)) {
|
2007-11-19 22:25:24 +08:00
|
|
|
rpmlog(RPMLOG_ERR, _("open of %s failed: %s\n"), filename,
|
2002-08-14 00:36:44 +08:00
|
|
|
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
|
2007-12-04 17:25:46 +08:00
|
|
|
fd = fdLink(fd, RPMDBG_M("persist (showProgress)"));
|
2003-01-24 04:23:24 +08:00
|
|
|
return (void *)fd;
|
2007-09-12 01:07:39 +08:00
|
|
|
break;
|
1999-07-14 23:28:03 +08:00
|
|
|
|
2001-01-25 20:58:03 +08:00
|
|
|
case RPMCALLBACK_INST_CLOSE_FILE:
|
2007-09-12 01:07:39 +08:00
|
|
|
/* FIX: still necessary? */
|
2007-12-04 17:25:46 +08:00
|
|
|
fd = fdFree(fd, RPMDBG_M("persist (showProgress)"));
|
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;
|
2008-05-12 21:20:13 +08:00
|
|
|
/* @todo Remove headerFormat() on a progress callback. */
|
2001-01-25 20:58:03 +08:00
|
|
|
if (flags & INSTALL_HASH) {
|
2008-05-12 21:20:13 +08:00
|
|
|
s = headerFormat(h, "%{NAME}", 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 {
|
2008-05-12 21:20:13 +08:00
|
|
|
s = headerFormat(h, "%{NAME}-%{VERSION}-%{RELEASE}", 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:
|
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);
|
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;
|
|
|
|
|
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;
|
2007-12-07 22:19:21 +08:00
|
|
|
case RPMCALLBACK_SCRIPT_ERROR:
|
|
|
|
break;
|
2002-08-05 00:55:55 +08:00
|
|
|
case RPMCALLBACK_UNKNOWN:
|
|
|
|
default:
|
1999-07-14 23:28:03 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2001-09-15 21:49:11 +08:00
|
|
|
struct rpmEIU {
|
|
|
|
Header h;
|
|
|
|
FD_t fd;
|
|
|
|
int numFailed;
|
|
|
|
int numPkgs;
|
2007-12-18 18:08:13 +08:00
|
|
|
char ** pkgURL;
|
2008-04-07 17:11:16 +08:00
|
|
|
char ** fnp;
|
2002-03-13 23:06:07 +08:00
|
|
|
char * pkgState;
|
2001-09-15 21:49:11 +08:00
|
|
|
int prevx;
|
|
|
|
int pkgx;
|
|
|
|
int numRPMS;
|
|
|
|
int numSRPMS;
|
2008-04-07 17:11:16 +08:00
|
|
|
char ** sourceURL;
|
2001-09-15 21:49:11 +08:00
|
|
|
int isSource;
|
|
|
|
int argc;
|
2007-12-18 18:08:13 +08:00
|
|
|
char ** argv;
|
2002-03-13 23:06:07 +08:00
|
|
|
rpmRelocation * relocations;
|
2001-09-15 21:49:11 +08:00
|
|
|
rpmRC rpmrc;
|
|
|
|
};
|
|
|
|
|
2000-09-02 05:15:40 +08:00
|
|
|
/** @todo Generalize --freshen policies. */
|
2008-04-07 17:11:16 +08:00
|
|
|
int rpmInstall(rpmts ts, struct rpmInstallArguments_s * ia, ARGV_t fileArgv)
|
1999-11-27 00:19:30 +08:00
|
|
|
{
|
2008-04-25 18:54:59 +08:00
|
|
|
struct rpmEIU * eiu = xcalloc(1, sizeof(*eiu));
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmps ps;
|
2002-03-13 23:06:07 +08:00
|
|
|
rpmprobFilterFlags probFilter;
|
|
|
|
rpmRelocation * relocations;
|
2007-12-18 18:08:13 +08:00
|
|
|
char * fileURL = NULL;
|
1999-07-14 23:28:03 +08:00
|
|
|
int stopInstall = 0;
|
2002-08-06 09:41:44 +08:00
|
|
|
rpmVSFlags vsflags, ovsflags, tvsflags;
|
2001-04-10 20:36:45 +08:00
|
|
|
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
|
|
|
rpmcliPackagesTotal = 0;
|
|
|
|
|
2002-03-17 23:49:09 +08:00
|
|
|
(void) rpmtsSetFlags(ts, ia->transFlags);
|
2003-12-26 07:00:44 +08:00
|
|
|
|
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-09-15 21:49:11 +08:00
|
|
|
for (eiu->fnp = fileArgv; *eiu->fnp != NULL; eiu->fnp++) {
|
2008-04-21 15:33:02 +08:00
|
|
|
ARGV_t av = NULL;
|
|
|
|
int ac = 0;
|
2008-01-09 16:21:01 +08:00
|
|
|
char * fn;
|
2008-04-21 15:33:02 +08:00
|
|
|
|
2008-01-09 16:21:01 +08:00
|
|
|
fn = rpmEscapeSpaces(*eiu->fnp);
|
|
|
|
rc = rpmGlob(fn, &ac, &av);
|
|
|
|
fn = _free(fn);
|
2002-10-26 22:43:43 +08:00
|
|
|
if (rc || ac == 0) {
|
2007-11-19 22:25:24 +08:00
|
|
|
rpmlog(RPMLOG_ERR, _("File not found by glob: %s\n"), *eiu->fnp);
|
2008-08-05 20:32:49 +08:00
|
|
|
eiu->numFailed++;
|
2002-10-26 22:43:43 +08:00
|
|
|
continue;
|
|
|
|
}
|
1999-07-14 23:28:03 +08:00
|
|
|
|
2008-04-21 15:33:02 +08:00
|
|
|
argvAppend(&(eiu->argv), av);
|
|
|
|
argvFree(av);
|
2001-09-15 21:49:11 +08:00
|
|
|
eiu->argc += ac;
|
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
|
|
|
|
2001-04-10 20:36:45 +08:00
|
|
|
switch (urlIsURL(fileURL)) {
|
2004-11-04 21:29:11 +08:00
|
|
|
case URL_IS_HTTPS:
|
1999-07-14 23:28:03 +08:00
|
|
|
case URL_IS_HTTP:
|
2004-11-04 21:29:11 +08:00
|
|
|
case URL_IS_FTP:
|
2007-12-15 17:03:46 +08:00
|
|
|
{ char *tfn;
|
2008-04-11 16:45:35 +08:00
|
|
|
FD_t tfd;
|
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
|
|
|
|
2008-05-03 17:34:19 +08:00
|
|
|
tfd = rpmMkTempFile(rpmtsRootDir(ts), &tfn);
|
2008-04-11 16:45:35 +08:00
|
|
|
if (tfd && tfn) {
|
|
|
|
Fclose(tfd);
|
|
|
|
rc = urlGetFile(fileURL, tfn);
|
|
|
|
} else {
|
|
|
|
rc = -1;
|
1999-12-13 01:46:22 +08:00
|
|
|
}
|
2001-04-10 20:36:45 +08:00
|
|
|
|
2008-04-11 16:45:35 +08:00
|
|
|
if (rc != 0) {
|
2007-10-09 19:49:02 +08:00
|
|
|
rpmlog(RPMLOG_ERR,
|
2008-07-07 15:48:06 +08:00
|
|
|
_("skipping %s - transfer failed\n"), fileURL);
|
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);
|
2007-09-12 01:07:39 +08:00
|
|
|
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++;
|
2007-09-12 01:07:39 +08:00
|
|
|
} break;
|
1999-11-27 00:19:30 +08:00
|
|
|
case URL_IS_PATH:
|
2004-11-29 05:14:41 +08:00
|
|
|
case URL_IS_DASH: /* WRONG WRONG WRONG */
|
|
|
|
case URL_IS_HKP: /* WRONG WRONG WRONG */
|
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++;
|
2007-09-12 01:07:39 +08:00
|
|
|
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. */
|
2008-04-07 17:11:16 +08:00
|
|
|
for (eiu->fnp = eiu->pkgURL+eiu->prevx;
|
2001-09-15 21:49:11 +08:00
|
|
|
*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
|
|
|
|
2007-10-09 19:48:04 +08:00
|
|
|
rpmlog(RPMLOG_DEBUG, "============== %s\n", *eiu->fnp);
|
2001-09-15 21:49:11 +08:00
|
|
|
(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)) {
|
2007-11-19 22:25:24 +08:00
|
|
|
rpmlog(RPMLOG_ERR, _("open of %s failed: %s\n"), *eiu->fnp,
|
2001-09-15 21:49:11 +08:00
|
|
|
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:
|
2007-10-09 19:49:02 +08:00
|
|
|
rpmlog(RPMLOG_ERR, _("%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;
|
2007-09-12 01:07:39 +08:00
|
|
|
break;
|
2002-08-24 05:01:59 +08:00
|
|
|
case RPMRC_NOTFOUND:
|
|
|
|
goto maybe_manifest;
|
2007-09-12 01:07:39 +08:00
|
|
|
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:
|
2007-09-12 01:07:39 +08:00
|
|
|
break;
|
2001-04-10 20:36:45 +08:00
|
|
|
}
|
2001-09-15 21:49:11 +08:00
|
|
|
|
2007-12-02 01:29:57 +08:00
|
|
|
eiu->isSource = headerIsSource(eiu->h);
|
2002-08-24 05:01:59 +08:00
|
|
|
|
|
|
|
if (eiu->isSource) {
|
2008-03-07 15:47:51 +08:00
|
|
|
rpmlog(RPMLOG_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) {
|
2008-05-26 18:17:07 +08:00
|
|
|
struct rpmtd_s prefixes;
|
|
|
|
|
|
|
|
headerGet(eiu->h, RPMTAG_PREFIXES, &prefixes, HEADERGET_DEFAULT);
|
|
|
|
if (rpmtdCount(&prefixes) == 1) {
|
|
|
|
eiu->relocations->oldPath = xstrdup(rpmtdGetString(&prefixes));
|
|
|
|
rpmtdFreeData(&prefixes);
|
2002-08-24 05:01:59 +08:00
|
|
|
} else {
|
|
|
|
const char * name;
|
|
|
|
xx = headerNVR(eiu->h, &name, NULL, NULL);
|
2007-10-09 19:49:02 +08:00
|
|
|
rpmlog(RPMLOG_ERR,
|
2003-12-30 21:14:49 +08:00
|
|
|
_("package %s is not relocatable\n"), name);
|
2002-08-24 05:01:59 +08:00
|
|
|
eiu->numFailed++;
|
|
|
|
goto exit;
|
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)
|
2007-09-12 01:07:39 +08:00
|
|
|
continue;
|
2002-08-24 05:01:59 +08:00
|
|
|
/* same or newer package already installed */
|
|
|
|
count = 0;
|
2007-09-12 01:07:39 +08:00
|
|
|
break;
|
2002-08-24 05:01:59 +08:00
|
|
|
}
|
|
|
|
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
|
|
|
rc = rpmtsAddInstallElement(ts, eiu->h, (fnpyKey)fileName,
|
2002-03-17 23:49:09 +08:00
|
|
|
(ia->installInterfaceFlags & INSTALL_UPGRADE) != 0,
|
|
|
|
relocations);
|
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)
|
2008-03-25 04:42:34 +08:00
|
|
|
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:
|
2008-03-07 15:47:51 +08:00
|
|
|
rpmlog(RPMLOG_DEBUG, "\tadded binary package [%d]\n",
|
2001-09-15 21:49:11 +08:00
|
|
|
eiu->numRPMS);
|
2007-09-12 01:07:39 +08:00
|
|
|
break;
|
2002-08-24 05:01:59 +08:00
|
|
|
case 1:
|
2007-10-09 19:49:02 +08:00
|
|
|
rpmlog(RPMLOG_ERR,
|
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;
|
2007-09-12 01:07:39 +08:00
|
|
|
break;
|
2002-08-24 05:01:59 +08:00
|
|
|
case 2:
|
2007-10-09 19:49:02 +08:00
|
|
|
rpmlog(RPMLOG_ERR,
|
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;
|
2007-09-12 01:07:39 +08:00
|
|
|
break;
|
2007-04-16 20:16:35 +08:00
|
|
|
default:
|
|
|
|
eiu->numFailed++;
|
|
|
|
goto exit;
|
2007-09-12 01:07:39 +08:00
|
|
|
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)) {
|
2007-11-19 22:25:24 +08:00
|
|
|
rpmlog(RPMLOG_ERR, _("open of %s failed: %s\n"), *eiu->fnp,
|
2001-09-15 21:49:11 +08:00
|
|
|
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. */
|
2007-09-12 01:07:39 +08:00
|
|
|
/* FIX: *eiu->argv can be NULL */
|
2001-09-15 21:49:11 +08:00
|
|
|
rc = rpmReadPackageManifest(eiu->fd, &eiu->argc, &eiu->argv);
|
2002-05-14 06:34:25 +08:00
|
|
|
if (rc != RPMRC_OK)
|
2008-10-06 23:49:33 +08:00
|
|
|
rpmlog(RPMLOG_ERR, _("%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
|
|
|
}
|
|
|
|
|
2008-03-07 15:47:51 +08:00
|
|
|
rpmlog(RPMLOG_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) {
|
2007-10-09 19:49:02 +08:00
|
|
|
rpmlog(RPMLOG_ERR, _("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-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
|
|
|
|
2008-03-07 15:47:51 +08:00
|
|
|
rpmlog(RPMLOG_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++) {
|
2007-10-09 20:47:15 +08:00
|
|
|
rpmdbCheckSignals();
|
2001-09-15 21:49:11 +08:00
|
|
|
if (eiu->sourceURL[i] == NULL) continue;
|
|
|
|
eiu->fd = Fopen(eiu->sourceURL[i], "r.ufdio");
|
|
|
|
if (eiu->fd == NULL || Ferror(eiu->fd)) {
|
2007-10-09 19:49:02 +08:00
|
|
|
rpmlog(RPMLOG_ERR, _("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)
|
2007-12-03 22:33:18 +08:00
|
|
|
(void) unlink(eiu->pkgURL[i]);
|
2001-09-15 21:49:11 +08:00
|
|
|
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);
|
2008-05-07 17:15:22 +08:00
|
|
|
rc = eiu->numFailed;
|
2008-04-25 18:54:59 +08:00
|
|
|
free(eiu);
|
2001-10-26 12:16:19 +08:00
|
|
|
|
2002-08-16 02:50:46 +08:00
|
|
|
rpmtsEmpty(ts);
|
|
|
|
|
2008-05-07 17:15:22 +08:00
|
|
|
return rc;
|
1999-07-14 23:28:03 +08:00
|
|
|
}
|
|
|
|
|
2008-04-07 17:11:16 +08:00
|
|
|
int rpmErase(rpmts ts, struct rpmInstallArguments_s * ia, ARGV_const_t argv)
|
2000-03-23 23:49:50 +08:00
|
|
|
{
|
2008-04-07 17:11:16 +08:00
|
|
|
char * const * arg;
|
2008-09-18 15:26:39 +08:00
|
|
|
char *qfmt = NULL;
|
1999-07-14 23:28:03 +08:00
|
|
|
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
|
|
|
|
2007-10-31 16:15:05 +08:00
|
|
|
/* XXX suggest mechanism only meaningful when installing */
|
|
|
|
ia->transFlags |= RPMTRANS_FLAG_NOSUGGEST;
|
|
|
|
|
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 */
|
2007-10-26 17:08:34 +08:00
|
|
|
{ int notifyFlags, xx;
|
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,
|
2007-10-26 17:08:34 +08:00
|
|
|
rpmShowProgress, (void *) ((long)notifyFlags));
|
2002-03-14 04:01:50 +08:00
|
|
|
}
|
|
|
|
#endif
|
2002-03-13 23:06:07 +08:00
|
|
|
|
2008-09-18 15:26:39 +08:00
|
|
|
qfmt = rpmExpand("%{?_query_all_fmt}\n", NULL);
|
1999-07-14 23:28:03 +08:00
|
|
|
for (arg = argv; *arg; arg++) {
|
2000-04-27 08:10:28 +08:00
|
|
|
rpmdbMatchIterator mi;
|
2008-09-18 15:04:51 +08:00
|
|
|
int matches = 0;
|
2008-09-18 15:26:39 +08:00
|
|
|
int erasing = 1;
|
2000-04-27 08:10:28 +08:00
|
|
|
|
2008-09-18 15:04:51 +08:00
|
|
|
/* Iterator count isn't reliable with labels, count manually... */
|
2001-10-28 04:09:20 +08:00
|
|
|
mi = rpmtsInitIterator(ts, RPMDBI_LABEL, *arg, 0);
|
2008-09-18 15:04:51 +08:00
|
|
|
while (rpmdbNextIterator(mi) != NULL) {
|
|
|
|
matches++;
|
|
|
|
}
|
|
|
|
rpmdbFreeIterator(mi);
|
|
|
|
|
|
|
|
if (! matches) {
|
2007-10-09 19:49:02 +08:00
|
|
|
rpmlog(RPMLOG_ERR, _("package %s is not installed\n"), *arg);
|
2000-04-27 08:10:28 +08:00
|
|
|
numFailed++;
|
|
|
|
} else {
|
|
|
|
Header h; /* XXX iterator owns the reference */
|
2003-06-25 03:29:36 +08:00
|
|
|
|
2008-09-18 15:26:39 +08:00
|
|
|
if (matches > 1 &&
|
|
|
|
!(ia->eraseInterfaceFlags & UNINSTALL_ALLMATCHES)) {
|
|
|
|
rpmlog(RPMLOG_ERR, _("\"%s\" specifies multiple packages:\n"),
|
2003-06-25 03:29:36 +08:00
|
|
|
*arg);
|
2008-09-18 15:26:39 +08:00
|
|
|
numFailed++;
|
|
|
|
erasing = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
mi = rpmtsInitIterator(ts, RPMDBI_LABEL, *arg, 0);
|
|
|
|
while ((h = rpmdbNextIterator(mi)) != NULL) {
|
|
|
|
unsigned int recOffset;
|
|
|
|
if (erasing && (recOffset = rpmdbGetIteratorOffset(mi))) {
|
2002-05-28 05:40:08 +08:00
|
|
|
(void) rpmtsAddEraseElement(ts, h, recOffset);
|
2000-04-27 08:10:28 +08:00
|
|
|
numPackages++;
|
2008-09-18 15:26:39 +08:00
|
|
|
} else {
|
|
|
|
char *nevra = headerFormat(h, qfmt, NULL);
|
|
|
|
rpmlog(RPMLOG_NOTICE, " %s", nevra);
|
|
|
|
free(nevra);
|
2000-04-27 08:10:28 +08:00
|
|
|
}
|
|
|
|
}
|
2008-09-18 15:04:51 +08:00
|
|
|
mi = rpmdbFreeIterator(mi);
|
2000-04-27 08:10:28 +08:00
|
|
|
}
|
1999-07-14 23:28:03 +08:00
|
|
|
}
|
2008-09-18 15:26:39 +08:00
|
|
|
free(qfmt);
|
1999-07-14 23:28:03 +08:00
|
|
|
|
2004-10-10 03:40:09 +08:00
|
|
|
if (numFailed) goto exit;
|
|
|
|
|
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) {
|
2007-10-09 19:49:02 +08:00
|
|
|
rpmlog(RPMLOG_ERR, _("Failed dependencies:\n"));
|
2002-06-29 05:54:24 +08:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2003-04-25 03:29:52 +08:00
|
|
|
if (!stopUninstall && !(ia->installInterfaceFlags & INSTALL_NOORDER)) {
|
|
|
|
if (rpmtsOrder(ts)) {
|
|
|
|
numFailed += numPackages;
|
|
|
|
stopUninstall = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-04-16 20:15:54 +08:00
|
|
|
if (numPackages && !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);
|
|
|
|
|
2007-04-16 20:15:10 +08:00
|
|
|
numPackages = rpmtsRun(ts, NULL, ia->probFilter & (RPMPROB_FILTER_DISKSPACE|RPMPROB_FILTER_DISKNODES));
|
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
|
|
|
}
|
|
|
|
|
2004-10-10 03:40:09 +08:00
|
|
|
exit:
|
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,
|
2007-12-18 17:56:54 +08:00
|
|
|
char ** specFilePtr, 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)) {
|
2007-10-09 19:49:02 +08:00
|
|
|
rpmlog(RPMLOG_ERR, _("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) {
|
2007-10-09 19:49:02 +08:00
|
|
|
rpmlog(RPMLOG_ERR, _("%s cannot be installed\n"), arg);
|
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);
|
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
|
|
|
|