2002-05-17 00:55:21 +08:00
|
|
|
/** \ingroup rpmts
|
2000-08-28 03:40:35 +08:00
|
|
|
* \file lib/transaction.c
|
|
|
|
*/
|
|
|
|
|
1998-12-19 03:09:38 +08:00
|
|
|
#include "system.h"
|
2002-04-13 09:28:20 +08:00
|
|
|
#include <rpmlib.h>
|
1998-12-19 03:09:38 +08:00
|
|
|
|
2001-11-11 09:46:43 +08:00
|
|
|
#include <rpmmacro.h> /* XXX for rpmExpand */
|
|
|
|
|
2002-07-28 08:41:15 +08:00
|
|
|
#include "fsm.h"
|
2001-09-26 04:51:34 +08:00
|
|
|
#include "psm.h"
|
2001-11-04 23:43:26 +08:00
|
|
|
|
2002-07-14 03:08:51 +08:00
|
|
|
#include "rpmdb.h"
|
2002-05-20 02:42:25 +08:00
|
|
|
|
2002-04-12 00:55:19 +08:00
|
|
|
#include "rpmds.h"
|
2002-05-20 07:37:24 +08:00
|
|
|
|
|
|
|
#define _RPMFI_INTERNAL
|
2002-04-12 00:55:19 +08:00
|
|
|
#include "rpmfi.h"
|
2002-05-20 07:37:24 +08:00
|
|
|
|
|
|
|
#define _RPMTE_INTERNAL
|
2002-04-12 00:55:19 +08:00
|
|
|
#include "rpmte.h"
|
2002-05-20 07:37:24 +08:00
|
|
|
|
|
|
|
#define _RPMTS_INTERNAL
|
2002-04-12 00:55:19 +08:00
|
|
|
#include "rpmts.h"
|
|
|
|
|
2002-07-26 07:36:32 +08:00
|
|
|
#include "cpio.h"
|
1998-12-27 02:32:08 +08:00
|
|
|
#include "fprint.h"
|
2001-11-19 01:49:21 +08:00
|
|
|
#include "legacy.h" /* XXX domd5 */
|
2001-06-18 06:18:03 +08:00
|
|
|
#include "misc.h" /* XXX stripTrailingChar, splitString, currentDirectory */
|
1998-12-19 03:09:38 +08:00
|
|
|
|
2000-12-13 04:03:45 +08:00
|
|
|
#include "debug.h"
|
|
|
|
|
2003-01-24 04:23:24 +08:00
|
|
|
/*@access Header @*/ /* XXX ts->notify arg1 is void ptr */
|
2002-05-20 02:42:25 +08:00
|
|
|
/*@access rpmps @*/ /* XXX need rpmProblemSetOK() */
|
2001-11-10 04:41:18 +08:00
|
|
|
/*@access dbiIndexSet @*/
|
1999-09-18 04:52:46 +08:00
|
|
|
|
2002-08-20 06:27:44 +08:00
|
|
|
/*@access rpmpsm @*/
|
2001-10-31 02:00:21 +08:00
|
|
|
|
2001-11-10 04:41:18 +08:00
|
|
|
/*@access alKey @*/
|
|
|
|
/*@access fnpyKey @*/
|
2001-11-05 06:00:11 +08:00
|
|
|
|
2002-05-20 02:42:25 +08:00
|
|
|
/*@access rpmfi @*/
|
1999-04-19 04:56:19 +08:00
|
|
|
|
2002-06-06 06:07:55 +08:00
|
|
|
/*@access rpmte @*/
|
2002-05-28 05:40:08 +08:00
|
|
|
/*@access rpmtsi @*/
|
2002-05-20 02:42:25 +08:00
|
|
|
/*@access rpmts @*/
|
1999-03-19 11:39:17 +08:00
|
|
|
|
2001-09-26 04:51:34 +08:00
|
|
|
/**
|
|
|
|
*/
|
2001-11-11 03:24:19 +08:00
|
|
|
static int archOkay(/*@null@*/ const char * pkgArch)
|
|
|
|
/*@*/
|
1999-07-14 22:36:10 +08:00
|
|
|
{
|
2001-11-11 03:24:19 +08:00
|
|
|
if (pkgArch == NULL) return 0;
|
|
|
|
return (rpmMachineScore(RPM_MACHTABLE_INSTARCH, pkgArch) ? 1 : 0);
|
1999-07-14 22:36:10 +08:00
|
|
|
}
|
1999-02-17 12:32:55 +08:00
|
|
|
|
2001-09-26 04:51:34 +08:00
|
|
|
/**
|
|
|
|
*/
|
2001-11-11 03:24:19 +08:00
|
|
|
static int osOkay(/*@null@*/ const char * pkgOs)
|
|
|
|
/*@*/
|
1999-07-14 22:36:10 +08:00
|
|
|
{
|
2001-11-11 03:24:19 +08:00
|
|
|
if (pkgOs == NULL) return 0;
|
|
|
|
return (rpmMachineScore(RPM_MACHTABLE_INSTOS, pkgOs) ? 1 : 0);
|
1999-07-14 22:36:10 +08:00
|
|
|
}
|
1999-01-05 00:44:20 +08:00
|
|
|
|
2001-09-26 04:51:34 +08:00
|
|
|
/**
|
|
|
|
*/
|
1999-07-14 22:36:10 +08:00
|
|
|
static int sharedCmp(const void * one, const void * two)
|
2001-06-06 03:26:22 +08:00
|
|
|
/*@*/
|
1999-07-14 22:36:10 +08:00
|
|
|
{
|
2001-11-11 20:47:08 +08:00
|
|
|
sharedFileInfo a = (sharedFileInfo) one;
|
|
|
|
sharedFileInfo b = (sharedFileInfo) two;
|
1998-12-31 07:03:43 +08:00
|
|
|
|
1999-07-14 22:36:10 +08:00
|
|
|
if (a->otherPkg < b->otherPkg)
|
|
|
|
return -1;
|
|
|
|
else if (a->otherPkg > b->otherPkg)
|
|
|
|
return 1;
|
1999-03-19 11:39:17 +08:00
|
|
|
|
1999-07-14 22:36:10 +08:00
|
|
|
return 0;
|
|
|
|
}
|
1999-03-19 11:39:17 +08:00
|
|
|
|
2001-09-26 04:51:34 +08:00
|
|
|
/**
|
|
|
|
*/
|
2002-07-03 07:54:35 +08:00
|
|
|
/*@-boundsread@*/
|
2002-05-20 02:42:25 +08:00
|
|
|
static fileAction decideFileFate(const rpmts ts,
|
|
|
|
const rpmfi ofi, rpmfi nfi)
|
2002-07-08 22:21:26 +08:00
|
|
|
/*@globals fileSystem, internalState @*/
|
|
|
|
/*@modifies nfi, fileSystem, internalState @*/
|
1999-07-14 22:36:10 +08:00
|
|
|
{
|
2002-05-20 02:42:25 +08:00
|
|
|
const char * fn = rpmfiFN(nfi);
|
|
|
|
int newFlags = rpmfiFFlags(nfi);
|
1999-07-14 22:36:10 +08:00
|
|
|
char buffer[1024];
|
2001-02-11 00:47:40 +08:00
|
|
|
fileTypes dbWhat, newWhat, diskWhat;
|
1999-07-14 22:36:10 +08:00
|
|
|
struct stat sb;
|
|
|
|
int save = (newFlags & RPMFILE_NOREPLACE) ? FA_ALTNAME : FA_SAVE;
|
1999-10-20 18:22:46 +08:00
|
|
|
|
2001-11-14 08:14:01 +08:00
|
|
|
if (lstat(fn, &sb)) {
|
1999-09-22 01:21:57 +08:00
|
|
|
/*
|
|
|
|
* The file doesn't exist on the disk. Create it unless the new
|
|
|
|
* package has marked it as missingok, or allfiles is requested.
|
|
|
|
*/
|
2002-05-20 07:37:24 +08:00
|
|
|
if (!(rpmtsFlags(ts) & RPMTRANS_FLAG_ALLFILES)
|
2001-11-19 01:49:21 +08:00
|
|
|
&& (newFlags & RPMFILE_MISSINGOK))
|
|
|
|
{
|
1999-07-14 22:36:10 +08:00
|
|
|
rpmMessage(RPMMESS_DEBUG, _("%s skipped due to missingok flag\n"),
|
2001-11-14 08:14:01 +08:00
|
|
|
fn);
|
1999-07-14 22:36:10 +08:00
|
|
|
return FA_SKIP;
|
1999-08-17 06:10:27 +08:00
|
|
|
} else {
|
1999-07-14 22:36:10 +08:00
|
|
|
return FA_CREATE;
|
1999-08-17 06:10:27 +08:00
|
|
|
}
|
1998-12-31 00:59:54 +08:00
|
|
|
}
|
1999-03-06 06:41:10 +08:00
|
|
|
|
2002-07-28 08:41:15 +08:00
|
|
|
diskWhat = whatis((int_16)sb.st_mode);
|
|
|
|
dbWhat = whatis(rpmfiFMode(ofi));
|
|
|
|
newWhat = whatis(rpmfiFMode(nfi));
|
1999-01-01 03:16:31 +08:00
|
|
|
|
2001-11-19 01:49:21 +08:00
|
|
|
/*
|
|
|
|
* RPM >= 2.3.10 shouldn't create config directories -- we'll ignore
|
|
|
|
* them in older packages as well.
|
|
|
|
*/
|
|
|
|
if (newWhat == XDIR)
|
1999-07-14 22:36:10 +08:00
|
|
|
return FA_CREATE;
|
1999-01-01 03:16:31 +08:00
|
|
|
|
2001-11-19 01:49:21 +08:00
|
|
|
if (diskWhat != newWhat)
|
1999-07-14 22:36:10 +08:00
|
|
|
return save;
|
2001-11-19 01:49:21 +08:00
|
|
|
else if (newWhat != dbWhat && diskWhat != dbWhat)
|
1999-07-14 22:36:10 +08:00
|
|
|
return save;
|
2001-11-19 01:49:21 +08:00
|
|
|
else if (dbWhat != newWhat)
|
1999-07-14 22:36:10 +08:00
|
|
|
return FA_CREATE;
|
2001-11-19 01:49:21 +08:00
|
|
|
else if (dbWhat != LINK && dbWhat != REG)
|
1999-07-14 22:36:10 +08:00
|
|
|
return FA_CREATE;
|
1998-12-19 03:09:38 +08:00
|
|
|
|
2001-11-19 01:49:21 +08:00
|
|
|
/*
|
|
|
|
* This order matters - we'd prefer to CREATE the file if at all
|
|
|
|
* possible in case something else (like the timestamp) has changed.
|
|
|
|
*/
|
1999-07-14 22:36:10 +08:00
|
|
|
if (dbWhat == REG) {
|
2002-07-28 08:41:15 +08:00
|
|
|
const unsigned char * omd5, * nmd5;
|
|
|
|
if (domd5(fn, buffer, 0, NULL))
|
|
|
|
return FA_CREATE; /* assume file has been removed */
|
|
|
|
omd5 = rpmfiMD5(ofi);
|
2002-07-28 22:52:33 +08:00
|
|
|
if (omd5 && !memcmp(omd5, buffer, 16))
|
2002-07-28 08:41:15 +08:00
|
|
|
return FA_CREATE; /* unmodified config file, replace. */
|
|
|
|
nmd5 = rpmfiMD5(nfi);
|
2002-07-28 22:52:33 +08:00
|
|
|
/*@-nullpass@*/
|
|
|
|
if (omd5 && nmd5 && !memcmp(omd5, nmd5, 16))
|
2002-07-28 08:41:15 +08:00
|
|
|
return FA_SKIP; /* identical file, don't bother. */
|
2002-07-28 22:52:33 +08:00
|
|
|
/*@=nullpass@*/
|
1999-07-14 22:36:10 +08:00
|
|
|
} else /* dbWhat == LINK */ {
|
2002-07-28 08:41:15 +08:00
|
|
|
const char * oFLink, * nFLink;
|
1999-07-14 22:36:10 +08:00
|
|
|
memset(buffer, 0, sizeof(buffer));
|
2001-11-19 01:49:21 +08:00
|
|
|
if (readlink(fn, buffer, sizeof(buffer) - 1) == -1)
|
|
|
|
return FA_CREATE; /* assume file has been removed */
|
2002-07-28 08:41:15 +08:00
|
|
|
oFLink = rpmfiFLink(ofi);
|
2002-07-28 22:52:33 +08:00
|
|
|
if (oFLink && !strcmp(oFLink, buffer))
|
2001-11-19 01:49:21 +08:00
|
|
|
return FA_CREATE; /* unmodified config file, replace. */
|
2002-07-28 08:41:15 +08:00
|
|
|
nFLink = rpmfiFLink(nfi);
|
2002-07-28 22:52:33 +08:00
|
|
|
/*@-nullpass@*/
|
|
|
|
if (oFLink && nFLink && !strcmp(oFLink, nFLink))
|
2001-11-19 01:49:21 +08:00
|
|
|
return FA_SKIP; /* identical file, don't bother. */
|
2002-07-28 22:52:33 +08:00
|
|
|
/*@=nullpass@*/
|
2003-01-02 01:26:46 +08:00
|
|
|
}
|
1999-01-01 03:16:31 +08:00
|
|
|
|
1999-09-22 01:21:57 +08:00
|
|
|
/*
|
|
|
|
* The config file on the disk has been modified, but
|
|
|
|
* the ones in the two packages are different. It would
|
|
|
|
* be nice if RPM was smart enough to at least try and
|
|
|
|
* merge the difference ala CVS, but...
|
|
|
|
*/
|
1999-07-14 22:36:10 +08:00
|
|
|
return save;
|
1998-12-19 03:09:38 +08:00
|
|
|
}
|
2002-07-03 07:54:35 +08:00
|
|
|
/*@=boundsread@*/
|
1998-12-19 03:09:38 +08:00
|
|
|
|
2001-09-26 04:51:34 +08:00
|
|
|
/**
|
|
|
|
*/
|
2002-07-03 07:54:35 +08:00
|
|
|
/*@-boundsread@*/
|
2002-05-20 02:42:25 +08:00
|
|
|
static int filecmp(rpmfi afi, rpmfi bfi)
|
2001-06-06 03:26:22 +08:00
|
|
|
/*@*/
|
1999-07-14 22:36:10 +08:00
|
|
|
{
|
2002-07-28 08:41:15 +08:00
|
|
|
fileTypes awhat = whatis(rpmfiFMode(afi));
|
|
|
|
fileTypes bwhat = whatis(rpmfiFMode(bfi));
|
2001-11-19 01:49:21 +08:00
|
|
|
|
|
|
|
if (awhat != bwhat) return 1;
|
|
|
|
|
|
|
|
if (awhat == LINK) {
|
2002-07-28 08:41:15 +08:00
|
|
|
const char * alink = rpmfiFLink(afi);
|
|
|
|
const char * blink = rpmfiFLink(bfi);
|
2002-07-28 22:52:33 +08:00
|
|
|
if (alink == blink) return 0;
|
|
|
|
if (alink == NULL) return 1;
|
|
|
|
if (blink == NULL) return -1;
|
2001-11-19 01:49:21 +08:00
|
|
|
return strcmp(alink, blink);
|
|
|
|
} else if (awhat == REG) {
|
2002-07-28 08:41:15 +08:00
|
|
|
const unsigned char * amd5 = rpmfiMD5(afi);
|
|
|
|
const unsigned char * bmd5 = rpmfiMD5(bfi);
|
2002-07-28 22:52:33 +08:00
|
|
|
if (amd5 == bmd5) return 0;
|
|
|
|
if (amd5 == NULL) return 1;
|
|
|
|
if (bmd5 == NULL) return -1;
|
2002-07-28 08:41:15 +08:00
|
|
|
return memcmp(amd5, bmd5, 16);
|
2001-11-19 01:49:21 +08:00
|
|
|
}
|
1999-07-14 22:36:10 +08:00
|
|
|
|
|
|
|
return 0;
|
1998-12-19 03:09:38 +08:00
|
|
|
}
|
2002-07-03 07:54:35 +08:00
|
|
|
/*@=boundsread@*/
|
1998-12-19 03:09:38 +08:00
|
|
|
|
2001-09-26 04:51:34 +08:00
|
|
|
/**
|
|
|
|
*/
|
2001-10-19 09:24:21 +08:00
|
|
|
/* XXX only ts->{probs,rpmdb} modified */
|
2002-06-23 02:51:56 +08:00
|
|
|
/*@-bounds@*/
|
2002-05-20 02:42:25 +08:00
|
|
|
static int handleInstInstalledFiles(const rpmts ts,
|
|
|
|
rpmte p, rpmfi fi,
|
2001-11-11 20:47:08 +08:00
|
|
|
sharedFileInfo shared,
|
2001-10-19 00:39:54 +08:00
|
|
|
int sharedCount, int reportConflicts)
|
2002-07-22 06:06:19 +08:00
|
|
|
/*@globals rpmGlobalMacroContext, fileSystem, internalState @*/
|
|
|
|
/*@modifies ts, fi, rpmGlobalMacroContext, fileSystem, internalState @*/
|
1999-07-14 22:36:10 +08:00
|
|
|
{
|
2003-01-18 01:43:04 +08:00
|
|
|
uint_32 tscolor = rpmtsColor(ts);
|
|
|
|
uint_32 otecolor, tecolor;
|
|
|
|
uint_32 oficolor, ficolor;
|
2001-11-19 01:49:21 +08:00
|
|
|
const char * altNEVR = NULL;
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmfi otherFi = NULL;
|
1999-07-14 22:36:10 +08:00
|
|
|
int numReplaced = 0;
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmps ps;
|
2001-11-19 01:49:21 +08:00
|
|
|
int i;
|
1998-12-19 03:09:38 +08:00
|
|
|
|
2001-11-19 01:49:21 +08:00
|
|
|
{ rpmdbMatchIterator mi;
|
|
|
|
Header h;
|
|
|
|
int scareMem = 0;
|
2000-04-27 08:10:28 +08:00
|
|
|
|
2001-11-19 01:49:21 +08:00
|
|
|
mi = rpmtsInitIterator(ts, RPMDBI_PACKAGES,
|
2001-11-10 01:22:08 +08:00
|
|
|
&shared->otherPkg, sizeof(shared->otherPkg));
|
2001-11-19 01:49:21 +08:00
|
|
|
while ((h = rpmdbNextIterator(mi)) != NULL) {
|
|
|
|
altNEVR = hGetNEVR(h, NULL);
|
2002-08-20 06:27:44 +08:00
|
|
|
otherFi = rpmfiNew(ts, h, RPMTAG_BASENAMES, scareMem);
|
2001-11-19 01:49:21 +08:00
|
|
|
break;
|
|
|
|
}
|
2001-04-30 06:43:01 +08:00
|
|
|
mi = rpmdbFreeIterator(mi);
|
2000-04-27 08:10:28 +08:00
|
|
|
}
|
1999-01-06 11:16:35 +08:00
|
|
|
|
2003-01-18 01:43:04 +08:00
|
|
|
/* Compute package color. */
|
|
|
|
tecolor = rpmteColor(p);
|
|
|
|
tecolor &= tscolor;
|
|
|
|
|
|
|
|
/* Compute other pkg color. */
|
|
|
|
otecolor = 0;
|
|
|
|
otherFi = rpmfiInit(otherFi, 0);
|
|
|
|
if (otherFi != NULL)
|
|
|
|
while (rpmfiNext(otherFi) >= 0)
|
|
|
|
otecolor |= rpmfiFColor(otherFi);
|
|
|
|
otecolor &= tscolor;
|
|
|
|
|
2003-01-21 07:52:04 +08:00
|
|
|
if (otherFi == NULL)
|
|
|
|
return 1;
|
|
|
|
|
2001-11-14 08:14:01 +08:00
|
|
|
fi->replaced = xcalloc(sharedCount, sizeof(*fi->replaced));
|
1998-12-19 03:09:38 +08:00
|
|
|
|
2002-05-28 05:40:08 +08:00
|
|
|
ps = rpmtsProblems(ts);
|
1999-07-14 22:36:10 +08:00
|
|
|
for (i = 0; i < sharedCount; i++, shared++) {
|
1999-08-14 04:05:57 +08:00
|
|
|
int otherFileNum, fileNum;
|
2002-07-28 08:41:15 +08:00
|
|
|
int isCfgFile;
|
2001-11-14 08:14:01 +08:00
|
|
|
|
1999-07-14 22:36:10 +08:00
|
|
|
otherFileNum = shared->otherFileNum;
|
2002-05-20 02:42:25 +08:00
|
|
|
(void) rpmfiSetFX(otherFi, otherFileNum);
|
2003-01-18 01:43:04 +08:00
|
|
|
oficolor = rpmfiFColor(otherFi);
|
|
|
|
oficolor &= tscolor;
|
1999-08-14 04:05:57 +08:00
|
|
|
|
2001-11-19 01:49:21 +08:00
|
|
|
fileNum = shared->pkgFileNum;
|
2002-05-20 02:42:25 +08:00
|
|
|
(void) rpmfiSetFX(fi, fileNum);
|
2003-01-18 01:43:04 +08:00
|
|
|
ficolor = rpmfiFColor(fi);
|
|
|
|
ficolor &= tscolor;
|
2001-11-14 08:14:01 +08:00
|
|
|
|
2002-07-28 08:41:15 +08:00
|
|
|
isCfgFile = ((rpmfiFFlags(otherFi) | rpmfiFFlags(fi)) & RPMFILE_CONFIG);
|
|
|
|
|
2001-11-19 01:49:21 +08:00
|
|
|
#ifdef DYING
|
2000-12-14 06:00:33 +08:00
|
|
|
/* XXX another tedious segfault, assume file state normal. */
|
|
|
|
if (otherStates && otherStates[otherFileNum] != RPMFILE_STATE_NORMAL)
|
1999-08-14 04:05:57 +08:00
|
|
|
continue;
|
2001-11-19 01:49:21 +08:00
|
|
|
#endif
|
1999-08-14 04:05:57 +08:00
|
|
|
|
2001-01-09 12:07:49 +08:00
|
|
|
if (XFA_SKIPPING(fi->actions[fileNum]))
|
2000-07-06 04:39:15 +08:00
|
|
|
continue;
|
|
|
|
|
2001-11-19 01:49:21 +08:00
|
|
|
if (filecmp(otherFi, fi)) {
|
2003-01-18 01:43:04 +08:00
|
|
|
/* Report conflicts only for packages/files of same color. */
|
|
|
|
if (tscolor == 0 || (tecolor == otecolor && ficolor == oficolor))
|
2001-11-10 01:22:08 +08:00
|
|
|
if (reportConflicts) {
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmpsAppend(ps, RPMPROB_FILE_CONFLICT,
|
|
|
|
rpmteNEVR(p), rpmteKey(p),
|
|
|
|
rpmfiDN(fi), rpmfiBN(fi),
|
2001-11-10 01:22:08 +08:00
|
|
|
altNEVR,
|
2001-10-31 02:00:21 +08:00
|
|
|
0);
|
2001-11-10 01:22:08 +08:00
|
|
|
}
|
2002-07-28 08:41:15 +08:00
|
|
|
if (!isCfgFile) {
|
2001-11-13 06:54:39 +08:00
|
|
|
/*@-assignexpose@*/ /* FIX: p->replaced, not fi */
|
1999-08-14 04:05:57 +08:00
|
|
|
if (!shared->isRemoved)
|
|
|
|
fi->replaced[numReplaced++] = *shared;
|
2001-06-06 03:26:22 +08:00
|
|
|
/*@=assignexpose@*/
|
1999-07-14 22:36:10 +08:00
|
|
|
}
|
1999-08-14 04:05:57 +08:00
|
|
|
}
|
1998-12-19 03:09:38 +08:00
|
|
|
|
2002-07-28 08:41:15 +08:00
|
|
|
if (isCfgFile) {
|
2001-11-19 01:49:21 +08:00
|
|
|
fileAction action;
|
|
|
|
action = decideFileFate(ts, otherFi, fi);
|
|
|
|
fi->actions[fileNum] = action;
|
1998-12-19 03:09:38 +08:00
|
|
|
}
|
2002-07-28 08:41:15 +08:00
|
|
|
fi->replacedSizes[fileNum] = rpmfiFSize(otherFi);
|
1998-12-19 03:09:38 +08:00
|
|
|
}
|
2002-05-20 02:42:25 +08:00
|
|
|
ps = rpmpsFree(ps);
|
1998-12-19 03:09:38 +08:00
|
|
|
|
2001-11-19 01:49:21 +08:00
|
|
|
altNEVR = _free(altNEVR);
|
2002-08-20 06:27:44 +08:00
|
|
|
otherFi = rpmfiFree(otherFi);
|
1998-12-19 03:09:38 +08:00
|
|
|
|
1999-09-22 01:21:57 +08:00
|
|
|
fi->replaced = xrealloc(fi->replaced, /* XXX memory leak */
|
1999-07-14 22:36:10 +08:00
|
|
|
sizeof(*fi->replaced) * (numReplaced + 1));
|
|
|
|
fi->replaced[numReplaced].otherPkg = 0;
|
1998-12-19 03:09:38 +08:00
|
|
|
|
1999-07-14 22:36:10 +08:00
|
|
|
return 0;
|
1998-12-19 03:09:38 +08:00
|
|
|
}
|
2002-06-23 02:51:56 +08:00
|
|
|
/*@=bounds@*/
|
1998-12-19 03:09:38 +08:00
|
|
|
|
2001-09-26 04:51:34 +08:00
|
|
|
/**
|
|
|
|
*/
|
2001-10-19 09:24:21 +08:00
|
|
|
/* XXX only ts->rpmdb modified */
|
2002-05-20 02:42:25 +08:00
|
|
|
static int handleRmvdInstalledFiles(const rpmts ts, rpmfi fi,
|
2001-11-11 20:47:08 +08:00
|
|
|
sharedFileInfo shared, int sharedCount)
|
2002-07-22 06:06:19 +08:00
|
|
|
/*@globals rpmGlobalMacroContext, fileSystem, internalState @*/
|
|
|
|
/*@modifies ts, fi, rpmGlobalMacroContext, fileSystem, internalState @*/
|
1999-07-14 22:36:10 +08:00
|
|
|
{
|
2001-02-05 06:15:30 +08:00
|
|
|
HGE_t hge = fi->hge;
|
1998-12-19 03:09:38 +08:00
|
|
|
Header h;
|
1999-08-14 04:05:57 +08:00
|
|
|
const char * otherStates;
|
2001-10-16 22:58:57 +08:00
|
|
|
int i, xx;
|
1999-08-07 05:35:15 +08:00
|
|
|
|
2000-04-27 08:10:28 +08:00
|
|
|
rpmdbMatchIterator mi;
|
|
|
|
|
2001-10-28 04:09:20 +08:00
|
|
|
mi = rpmtsInitIterator(ts, RPMDBI_PACKAGES,
|
2001-02-05 06:15:30 +08:00
|
|
|
&shared->otherPkg, sizeof(shared->otherPkg));
|
2000-04-27 08:10:28 +08:00
|
|
|
h = rpmdbNextIterator(mi);
|
|
|
|
if (h == NULL) {
|
2001-04-30 06:43:01 +08:00
|
|
|
mi = rpmdbFreeIterator(mi);
|
2000-04-27 08:10:28 +08:00
|
|
|
return 1;
|
|
|
|
}
|
1998-12-19 03:09:38 +08:00
|
|
|
|
2001-10-16 22:58:57 +08:00
|
|
|
xx = hge(h, RPMTAG_FILESTATES, NULL, (void **) &otherStates, NULL);
|
1999-04-07 03:08:27 +08:00
|
|
|
|
2002-06-23 02:51:56 +08:00
|
|
|
/*@-boundswrite@*/
|
1999-07-14 22:36:10 +08:00
|
|
|
for (i = 0; i < sharedCount; i++, shared++) {
|
1999-08-14 04:05:57 +08:00
|
|
|
int otherFileNum, fileNum;
|
1999-07-14 22:36:10 +08:00
|
|
|
otherFileNum = shared->otherFileNum;
|
|
|
|
fileNum = shared->pkgFileNum;
|
1999-04-07 03:08:27 +08:00
|
|
|
|
1999-08-15 04:01:38 +08:00
|
|
|
if (otherStates[otherFileNum] != RPMFILE_STATE_NORMAL)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
fi->actions[fileNum] = FA_SKIP;
|
1999-04-07 03:08:27 +08:00
|
|
|
}
|
2002-06-23 02:51:56 +08:00
|
|
|
/*@=boundswrite@*/
|
1998-12-19 03:09:38 +08:00
|
|
|
|
2001-04-30 06:43:01 +08:00
|
|
|
mi = rpmdbFreeIterator(mi);
|
1998-12-19 03:09:38 +08:00
|
|
|
|
1999-07-14 22:36:10 +08:00
|
|
|
return 0;
|
|
|
|
}
|
1998-12-19 03:09:38 +08:00
|
|
|
|
2001-11-16 02:22:33 +08:00
|
|
|
#define ISROOT(_d) (((_d)[0] == '/' && (_d)[1] == '\0') ? "" : (_d))
|
|
|
|
|
|
|
|
/*@unchecked@*/
|
2002-07-28 22:52:33 +08:00
|
|
|
int _fps_debug = 0;
|
2001-11-16 02:22:33 +08:00
|
|
|
|
|
|
|
static int fpsCompare (const void * one, const void * two)
|
2002-05-20 02:42:25 +08:00
|
|
|
/*@*/
|
2001-11-16 02:22:33 +08:00
|
|
|
{
|
|
|
|
const struct fingerPrint_s * a = (const struct fingerPrint_s *)one;
|
|
|
|
const struct fingerPrint_s * b = (const struct fingerPrint_s *)two;
|
|
|
|
int adnlen = strlen(a->entry->dirName);
|
|
|
|
int asnlen = (a->subDir ? strlen(a->subDir) : 0);
|
|
|
|
int abnlen = strlen(a->baseName);
|
|
|
|
int bdnlen = strlen(b->entry->dirName);
|
|
|
|
int bsnlen = (b->subDir ? strlen(b->subDir) : 0);
|
|
|
|
int bbnlen = strlen(b->baseName);
|
|
|
|
char * afn, * bfn, * t;
|
|
|
|
int rc = 0;
|
|
|
|
|
|
|
|
if (adnlen == 1 && asnlen != 0) adnlen = 0;
|
|
|
|
if (bdnlen == 1 && bsnlen != 0) bdnlen = 0;
|
|
|
|
|
2002-06-23 02:51:56 +08:00
|
|
|
/*@-boundswrite@*/
|
2001-11-16 02:22:33 +08:00
|
|
|
afn = t = alloca(adnlen+asnlen+abnlen+2);
|
|
|
|
if (adnlen) t = stpcpy(t, a->entry->dirName);
|
|
|
|
*t++ = '/';
|
|
|
|
if (a->subDir && asnlen) t = stpcpy(t, a->subDir);
|
|
|
|
if (abnlen) t = stpcpy(t, a->baseName);
|
|
|
|
if (afn[0] == '/' && afn[1] == '/') afn++;
|
|
|
|
|
|
|
|
bfn = t = alloca(bdnlen+bsnlen+bbnlen+2);
|
|
|
|
if (bdnlen) t = stpcpy(t, b->entry->dirName);
|
|
|
|
*t++ = '/';
|
|
|
|
if (b->subDir && bsnlen) t = stpcpy(t, b->subDir);
|
|
|
|
if (bbnlen) t = stpcpy(t, b->baseName);
|
|
|
|
if (bfn[0] == '/' && bfn[1] == '/') bfn++;
|
2002-06-23 02:51:56 +08:00
|
|
|
/*@=boundswrite@*/
|
2001-11-16 02:22:33 +08:00
|
|
|
|
|
|
|
rc = strcmp(afn, bfn);
|
|
|
|
/*@-modfilesys@*/
|
|
|
|
if (_fps_debug)
|
|
|
|
fprintf(stderr, "\trc(%d) = strcmp(\"%s\", \"%s\")\n", rc, afn, bfn);
|
|
|
|
/*@=modfilesys@*/
|
|
|
|
|
|
|
|
/*@-modfilesys@*/
|
|
|
|
if (_fps_debug)
|
|
|
|
fprintf(stderr, "\t%s/%s%s\trc %d\n",
|
|
|
|
ISROOT(b->entry->dirName),
|
|
|
|
(b->subDir ? b->subDir : ""),
|
|
|
|
b->baseName,
|
|
|
|
rc
|
|
|
|
);
|
|
|
|
/*@=modfilesys@*/
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*@unchecked@*/
|
|
|
|
static int _linear_fps_search = 0;
|
|
|
|
|
|
|
|
static int findFps(const struct fingerPrint_s * fiFps,
|
|
|
|
const struct fingerPrint_s * otherFps,
|
|
|
|
int otherFc)
|
|
|
|
/*@*/
|
|
|
|
{
|
|
|
|
int otherFileNum;
|
|
|
|
|
|
|
|
/*@-modfilesys@*/
|
|
|
|
if (_fps_debug)
|
|
|
|
fprintf(stderr, "==> %s/%s%s\n",
|
|
|
|
ISROOT(fiFps->entry->dirName),
|
|
|
|
(fiFps->subDir ? fiFps->subDir : ""),
|
|
|
|
fiFps->baseName);
|
|
|
|
/*@=modfilesys@*/
|
|
|
|
|
|
|
|
if (_linear_fps_search) {
|
|
|
|
|
|
|
|
linear:
|
|
|
|
for (otherFileNum = 0; otherFileNum < otherFc; otherFileNum++, otherFps++) {
|
|
|
|
|
|
|
|
/*@-modfilesys@*/
|
|
|
|
if (_fps_debug)
|
|
|
|
fprintf(stderr, "\t%4d %s/%s%s\n", otherFileNum,
|
|
|
|
ISROOT(otherFps->entry->dirName),
|
|
|
|
(otherFps->subDir ? otherFps->subDir : ""),
|
|
|
|
otherFps->baseName);
|
|
|
|
/*@=modfilesys@*/
|
|
|
|
|
|
|
|
/* If the addresses are the same, so are the values. */
|
|
|
|
if (fiFps == otherFps)
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* Otherwise, compare fingerprints by value. */
|
|
|
|
/*@-nullpass@*/ /* LCL: looks good to me */
|
|
|
|
if (FP_EQUAL((*fiFps), (*otherFps)))
|
|
|
|
break;
|
|
|
|
/*@=nullpass@*/
|
|
|
|
}
|
|
|
|
|
|
|
|
if (otherFileNum == otherFc) {
|
|
|
|
/*@-modfilesys@*/
|
|
|
|
if (_fps_debug)
|
2002-07-28 08:41:15 +08:00
|
|
|
fprintf(stderr, "*** FP_EQUAL NULL %s/%s%s\n",
|
2001-11-16 02:22:33 +08:00
|
|
|
ISROOT(fiFps->entry->dirName),
|
|
|
|
(fiFps->subDir ? fiFps->subDir : ""),
|
|
|
|
fiFps->baseName);
|
|
|
|
/*@=modfilesys@*/
|
|
|
|
}
|
|
|
|
|
|
|
|
return otherFileNum;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
const struct fingerPrint_s * bingoFps;
|
|
|
|
|
2002-06-23 02:51:56 +08:00
|
|
|
/*@-boundswrite@*/
|
2001-11-16 02:22:33 +08:00
|
|
|
bingoFps = bsearch(fiFps, otherFps, otherFc, sizeof(*otherFps), fpsCompare);
|
2002-06-23 02:51:56 +08:00
|
|
|
/*@=boundswrite@*/
|
2001-11-16 02:22:33 +08:00
|
|
|
if (bingoFps == NULL) {
|
|
|
|
/*@-modfilesys@*/
|
2002-07-28 08:41:15 +08:00
|
|
|
if (_fps_debug)
|
|
|
|
fprintf(stderr, "*** bingoFps NULL %s/%s%s\n",
|
2001-11-16 02:22:33 +08:00
|
|
|
ISROOT(fiFps->entry->dirName),
|
|
|
|
(fiFps->subDir ? fiFps->subDir : ""),
|
|
|
|
fiFps->baseName);
|
|
|
|
/*@=modfilesys@*/
|
|
|
|
goto linear;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If the addresses are the same, so are the values. */
|
|
|
|
/*@-nullpass@*/ /* LCL: looks good to me */
|
|
|
|
if (!(fiFps == bingoFps || FP_EQUAL((*fiFps), (*bingoFps)))) {
|
|
|
|
/*@-modfilesys@*/
|
2002-07-28 08:41:15 +08:00
|
|
|
if (_fps_debug)
|
2001-11-16 02:22:33 +08:00
|
|
|
fprintf(stderr, "*** BAD %s/%s%s\n",
|
|
|
|
ISROOT(bingoFps->entry->dirName),
|
|
|
|
(bingoFps->subDir ? bingoFps->subDir : ""),
|
|
|
|
bingoFps->baseName);
|
|
|
|
/*@=modfilesys@*/
|
|
|
|
goto linear;
|
|
|
|
}
|
|
|
|
|
|
|
|
otherFileNum = (bingoFps != NULL ? (bingoFps - otherFps) : 0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return otherFileNum;
|
|
|
|
}
|
|
|
|
|
2000-10-21 00:47:00 +08:00
|
|
|
/**
|
2002-05-20 02:42:25 +08:00
|
|
|
* Update disk space needs on each partition for this package's files.
|
2000-10-21 00:47:00 +08:00
|
|
|
*/
|
2001-10-19 09:24:21 +08:00
|
|
|
/* XXX only ts->{probs,di} modified */
|
2002-05-20 02:42:25 +08:00
|
|
|
static void handleOverlappedFiles(const rpmts ts,
|
|
|
|
const rpmte p, rpmfi fi)
|
2002-07-08 22:21:26 +08:00
|
|
|
/*@globals fileSystem, internalState @*/
|
|
|
|
/*@modifies ts, fi, fileSystem, internalState @*/
|
1999-07-14 22:36:10 +08:00
|
|
|
{
|
|
|
|
uint_32 fixupSize = 0;
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmps ps;
|
2001-11-14 08:14:01 +08:00
|
|
|
const char * fn;
|
2001-10-19 00:39:54 +08:00
|
|
|
int i, j;
|
1999-08-07 05:35:15 +08:00
|
|
|
|
2002-05-28 05:40:08 +08:00
|
|
|
ps = rpmtsProblems(ts);
|
2002-05-20 02:42:25 +08:00
|
|
|
fi = rpmfiInit(fi, 0);
|
|
|
|
if (fi != NULL)
|
|
|
|
while ((i = rpmfiNext(fi)) >= 0) {
|
2001-11-16 02:22:33 +08:00
|
|
|
struct fingerPrint_s * fiFps;
|
1999-08-15 04:01:38 +08:00
|
|
|
int otherPkgNum, otherFileNum;
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmfi otherFi;
|
2002-07-28 08:41:15 +08:00
|
|
|
int_32 FFlags;
|
|
|
|
int_16 FMode;
|
2002-05-20 02:42:25 +08:00
|
|
|
const rpmfi * recs;
|
1999-08-15 04:01:38 +08:00
|
|
|
int numRecs;
|
|
|
|
|
1999-08-16 03:11:40 +08:00
|
|
|
if (XFA_SKIPPING(fi->actions[i]))
|
1999-07-14 22:36:10 +08:00
|
|
|
continue;
|
1998-12-19 03:09:38 +08:00
|
|
|
|
2002-05-20 02:42:25 +08:00
|
|
|
fn = rpmfiFN(fi);
|
2001-11-16 02:22:33 +08:00
|
|
|
fiFps = fi->fps + i;
|
2002-07-28 08:41:15 +08:00
|
|
|
FFlags = rpmfiFFlags(fi);
|
|
|
|
FMode = rpmfiFMode(fi);
|
1999-10-20 18:22:46 +08:00
|
|
|
|
2002-05-20 02:42:25 +08:00
|
|
|
fixupSize = 0;
|
1998-12-19 03:09:38 +08:00
|
|
|
|
1999-08-18 07:05:24 +08:00
|
|
|
/*
|
|
|
|
* Retrieve all records that apply to this file. Note that the
|
|
|
|
* file info records were built in the same order as the packages
|
|
|
|
* will be installed and removed so the records for an overlapped
|
|
|
|
* files will be sorted in exactly the same order.
|
|
|
|
*/
|
2001-11-16 02:22:33 +08:00
|
|
|
(void) htGetEntry(ts->ht, fiFps,
|
2001-10-30 00:35:01 +08:00
|
|
|
(const void ***) &recs, &numRecs, NULL);
|
1999-08-18 07:05:24 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* If this package is being added, look only at other packages
|
|
|
|
* being added -- removed packages dance to a different tune.
|
2002-05-20 02:42:25 +08:00
|
|
|
*
|
1999-08-18 07:05:24 +08:00
|
|
|
* If both this and the other package are being added, overlapped
|
|
|
|
* files must be identical (or marked as a conflict). The
|
|
|
|
* disposition of already installed config files leads to
|
|
|
|
* a small amount of extra complexity.
|
|
|
|
*
|
|
|
|
* If this package is being removed, then there are two cases that
|
|
|
|
* need to be worried about:
|
|
|
|
* If the other package is being added, then skip any overlapped files
|
|
|
|
* so that this package removal doesn't nuke the overlapped files
|
|
|
|
* that were just installed.
|
|
|
|
* If both this and the other package are being removed, then each
|
|
|
|
* file removal from preceding packages needs to be skipped so that
|
|
|
|
* the file removal occurs only on the last occurence of an overlapped
|
|
|
|
* file in the transaction set.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Locate this overlapped file in the set of added/removed packages. */
|
2001-01-09 12:07:49 +08:00
|
|
|
for (j = 0; j < numRecs && recs[j] != fi; j++)
|
2001-06-06 03:26:22 +08:00
|
|
|
{};
|
1999-07-14 22:36:10 +08:00
|
|
|
|
1999-08-18 07:05:24 +08:00
|
|
|
/* Find what the previous disposition of this file was. */
|
1999-07-14 22:36:10 +08:00
|
|
|
otherFileNum = -1; /* keep gcc quiet */
|
2001-11-17 03:26:33 +08:00
|
|
|
otherFi = NULL;
|
1999-08-14 04:05:57 +08:00
|
|
|
for (otherPkgNum = j - 1; otherPkgNum >= 0; otherPkgNum--) {
|
2001-11-16 02:22:33 +08:00
|
|
|
struct fingerPrint_s * otherFps;
|
|
|
|
int otherFc;
|
|
|
|
|
|
|
|
otherFi = recs[otherPkgNum];
|
|
|
|
|
1999-08-18 07:05:24 +08:00
|
|
|
/* Added packages need only look at other added packages. */
|
2002-05-20 02:42:25 +08:00
|
|
|
if (rpmteType(p) == TR_ADDED && rpmteType(otherFi->te) != TR_ADDED)
|
2001-10-14 06:01:38 +08:00
|
|
|
/*@innercontinue@*/ continue;
|
1999-08-14 04:05:57 +08:00
|
|
|
|
2001-11-16 02:22:33 +08:00
|
|
|
otherFps = otherFi->fps;
|
2002-05-20 02:42:25 +08:00
|
|
|
otherFc = rpmfiFC(otherFi);
|
2000-06-17 03:12:09 +08:00
|
|
|
|
2001-11-16 02:22:33 +08:00
|
|
|
otherFileNum = findFps(fiFps, otherFps, otherFc);
|
2002-05-20 02:42:25 +08:00
|
|
|
(void) rpmfiSetFX(otherFi, otherFileNum);
|
2000-06-17 03:12:09 +08:00
|
|
|
|
2002-06-22 02:00:50 +08:00
|
|
|
/* XXX Happens iff fingerprint for incomplete package install. */
|
2001-11-16 02:22:33 +08:00
|
|
|
if (otherFi->actions[otherFileNum] != FA_UNKNOWN)
|
2001-06-06 03:26:22 +08:00
|
|
|
/*@innerbreak@*/ break;
|
1998-12-19 03:09:38 +08:00
|
|
|
}
|
|
|
|
|
2002-06-23 02:51:56 +08:00
|
|
|
/*@-boundswrite@*/
|
2002-05-20 02:42:25 +08:00
|
|
|
switch (rpmteType(p)) {
|
1999-08-14 04:05:57 +08:00
|
|
|
case TR_ADDED:
|
2001-09-21 23:07:11 +08:00
|
|
|
{ struct stat sb;
|
1999-08-15 04:01:38 +08:00
|
|
|
if (otherPkgNum < 0) {
|
1999-08-18 07:05:24 +08:00
|
|
|
/* XXX is this test still necessary? */
|
1999-08-15 04:01:38 +08:00
|
|
|
if (fi->actions[i] != FA_UNKNOWN)
|
2001-10-14 06:01:38 +08:00
|
|
|
/*@switchbreak@*/ break;
|
2002-07-28 08:41:15 +08:00
|
|
|
if ((FFlags & RPMFILE_CONFIG) && !lstat(fn, &sb)) {
|
1999-08-18 07:05:24 +08:00
|
|
|
/* Here is a non-overlapped pre-existing config file. */
|
2002-07-28 08:41:15 +08:00
|
|
|
fi->actions[i] = (FFlags & RPMFILE_NOREPLACE)
|
1999-07-14 22:36:10 +08:00
|
|
|
? FA_ALTNAME : FA_BACKUP;
|
1999-08-17 06:10:27 +08:00
|
|
|
} else {
|
1999-07-14 22:36:10 +08:00
|
|
|
fi->actions[i] = FA_CREATE;
|
1999-08-17 06:10:27 +08:00
|
|
|
}
|
2001-10-14 06:01:38 +08:00
|
|
|
/*@switchbreak@*/ break;
|
1999-07-14 22:36:10 +08:00
|
|
|
}
|
1999-08-17 06:10:27 +08:00
|
|
|
|
2001-11-16 08:26:30 +08:00
|
|
|
assert(otherFi != NULL);
|
2000-10-21 00:47:00 +08:00
|
|
|
/* Mark added overlapped non-identical files as a conflict. */
|
2003-01-04 05:30:33 +08:00
|
|
|
if (!(rpmtsFilterFlags(ts) & RPMPROB_FILTER_REPLACENEWFILES)
|
2001-11-19 01:49:21 +08:00
|
|
|
&& filecmp(otherFi, fi))
|
2001-10-31 02:00:21 +08:00
|
|
|
{
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmpsAppend(ps, RPMPROB_NEW_FILE_CONFLICT,
|
|
|
|
rpmteNEVR(p), rpmteKey(p),
|
2001-11-14 08:14:01 +08:00
|
|
|
fn, NULL,
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmteNEVR(otherFi->te),
|
2001-10-31 02:00:21 +08:00
|
|
|
0);
|
1999-07-14 22:36:10 +08:00
|
|
|
}
|
1998-12-19 03:09:38 +08:00
|
|
|
|
1999-08-18 07:05:24 +08:00
|
|
|
/* Try to get the disk accounting correct even if a conflict. */
|
2002-07-28 08:41:15 +08:00
|
|
|
fixupSize = rpmfiFSize(otherFi);
|
1998-12-19 03:09:38 +08:00
|
|
|
|
2002-07-28 08:41:15 +08:00
|
|
|
if ((FFlags & RPMFILE_CONFIG) && !lstat(fn, &sb)) {
|
1999-08-18 07:05:24 +08:00
|
|
|
/* Here is an overlapped pre-existing config file. */
|
2002-07-28 08:41:15 +08:00
|
|
|
fi->actions[i] = (FFlags & RPMFILE_NOREPLACE)
|
1999-08-17 06:10:27 +08:00
|
|
|
? FA_ALTNAME : FA_SKIP;
|
|
|
|
} else {
|
|
|
|
fi->actions[i] = FA_CREATE;
|
|
|
|
}
|
2001-10-14 06:01:38 +08:00
|
|
|
} /*@switchbreak@*/ break;
|
2001-11-16 02:22:33 +08:00
|
|
|
|
1999-08-14 04:05:57 +08:00
|
|
|
case TR_REMOVED:
|
1999-08-15 04:01:38 +08:00
|
|
|
if (otherPkgNum >= 0) {
|
2001-11-16 08:26:30 +08:00
|
|
|
assert(otherFi != NULL);
|
2000-10-21 00:47:00 +08:00
|
|
|
/* Here is an overlapped added file we don't want to nuke. */
|
2001-11-16 08:26:30 +08:00
|
|
|
if (otherFi->actions[otherFileNum] != FA_ERASE) {
|
1999-08-17 06:10:27 +08:00
|
|
|
/* On updates, don't remove files. */
|
1999-08-15 21:41:06 +08:00
|
|
|
fi->actions[i] = FA_SKIP;
|
2001-10-14 06:01:38 +08:00
|
|
|
/*@switchbreak@*/ break;
|
1999-08-15 21:41:06 +08:00
|
|
|
}
|
1999-08-18 07:05:24 +08:00
|
|
|
/* Here is an overlapped removed file: skip in previous. */
|
2001-11-16 08:26:30 +08:00
|
|
|
otherFi->actions[otherFileNum] = FA_SKIP;
|
1999-08-15 04:01:38 +08:00
|
|
|
}
|
1999-08-16 03:11:40 +08:00
|
|
|
if (XFA_SKIPPING(fi->actions[i]))
|
2001-10-14 06:01:38 +08:00
|
|
|
/*@switchbreak@*/ break;
|
2002-07-28 08:41:15 +08:00
|
|
|
if (rpmfiFState(fi) != RPMFILE_STATE_NORMAL)
|
2001-10-14 06:01:38 +08:00
|
|
|
/*@switchbreak@*/ break;
|
2002-07-28 08:41:15 +08:00
|
|
|
if (!(S_ISREG(FMode) && (FFlags & RPMFILE_CONFIG))) {
|
2001-02-09 05:50:38 +08:00
|
|
|
fi->actions[i] = FA_ERASE;
|
2001-10-14 06:01:38 +08:00
|
|
|
/*@switchbreak@*/ break;
|
1999-08-15 04:01:38 +08:00
|
|
|
}
|
|
|
|
|
1999-08-18 07:05:24 +08:00
|
|
|
/* Here is a pre-existing modified config file that needs saving. */
|
2001-11-19 01:49:21 +08:00
|
|
|
{ char md5sum[50];
|
2002-07-28 08:41:15 +08:00
|
|
|
const unsigned char * MD5 = rpmfiMD5(fi);
|
2002-07-22 06:06:19 +08:00
|
|
|
if (!domd5(fn, md5sum, 0, NULL) && memcmp(MD5, md5sum, 16)) {
|
2002-05-20 02:42:25 +08:00
|
|
|
fi->actions[i] = FA_BACKUP;
|
|
|
|
/*@switchbreak@*/ break;
|
1999-07-14 22:36:10 +08:00
|
|
|
}
|
1999-01-19 11:01:52 +08:00
|
|
|
}
|
2001-02-09 05:50:38 +08:00
|
|
|
fi->actions[i] = FA_ERASE;
|
2001-10-14 06:01:38 +08:00
|
|
|
/*@switchbreak@*/ break;
|
1999-07-14 22:36:10 +08:00
|
|
|
}
|
2002-06-23 02:51:56 +08:00
|
|
|
/*@=boundswrite@*/
|
1998-12-19 03:09:38 +08:00
|
|
|
|
2002-05-20 02:42:25 +08:00
|
|
|
/* Update disk space info for a file. */
|
2003-01-02 01:26:46 +08:00
|
|
|
rpmtsUpdateDSI(ts, fiFps->entry->dev, rpmfiFSize(fi),
|
|
|
|
fi->replacedSizes[i], fixupSize, fi->actions[i]);
|
1998-12-19 03:09:38 +08:00
|
|
|
|
|
|
|
}
|
2002-05-20 02:42:25 +08:00
|
|
|
ps = rpmpsFree(ps);
|
1999-07-14 22:36:10 +08:00
|
|
|
}
|
1998-12-19 03:09:38 +08:00
|
|
|
|
2001-09-26 04:51:34 +08:00
|
|
|
/**
|
2001-11-11 03:24:19 +08:00
|
|
|
* Ensure that current package is newer than installed package.
|
|
|
|
* @param ts transaction set
|
|
|
|
* @param p current transaction element
|
|
|
|
* @param h installed header
|
|
|
|
* @return 0 if not newer, 1 if okay
|
2001-09-26 04:51:34 +08:00
|
|
|
*/
|
2002-05-20 02:42:25 +08:00
|
|
|
static int ensureOlder(rpmts ts,
|
|
|
|
const rpmte p, const Header h)
|
2001-11-11 03:24:19 +08:00
|
|
|
/*@modifies ts @*/
|
|
|
|
{
|
|
|
|
int_32 reqFlags = (RPMSENSE_LESS | RPMSENSE_EQUAL);
|
2001-11-11 08:11:33 +08:00
|
|
|
const char * reqEVR;
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmds req;
|
2001-11-11 03:24:19 +08:00
|
|
|
char * t;
|
2001-11-17 03:26:33 +08:00
|
|
|
int nb;
|
2001-11-11 03:24:19 +08:00
|
|
|
int rc;
|
|
|
|
|
|
|
|
if (p == NULL || h == NULL)
|
|
|
|
return 1;
|
|
|
|
|
2002-06-23 02:51:56 +08:00
|
|
|
/*@-boundswrite@*/
|
2002-05-20 02:42:25 +08:00
|
|
|
nb = strlen(rpmteNEVR(p)) + (rpmteE(p) != NULL ? strlen(rpmteE(p)) : 0) + 1;
|
2001-11-17 03:26:33 +08:00
|
|
|
t = alloca(nb);
|
2001-11-11 03:24:19 +08:00
|
|
|
*t = '\0';
|
|
|
|
reqEVR = t;
|
2002-05-20 02:42:25 +08:00
|
|
|
if (rpmteE(p) != NULL) t = stpcpy( stpcpy(t, rpmteE(p)), ":");
|
|
|
|
if (rpmteV(p) != NULL) t = stpcpy(t, rpmteV(p));
|
2001-11-11 03:24:19 +08:00
|
|
|
*t++ = '-';
|
2002-05-20 02:42:25 +08:00
|
|
|
if (rpmteR(p) != NULL) t = stpcpy(t, rpmteR(p));
|
2002-06-23 02:51:56 +08:00
|
|
|
/*@=boundswrite@*/
|
2001-11-11 03:24:19 +08:00
|
|
|
|
2002-05-20 02:42:25 +08:00
|
|
|
req = rpmdsSingle(RPMTAG_REQUIRENAME, rpmteN(p), reqEVR, reqFlags);
|
2002-07-30 07:06:06 +08:00
|
|
|
rc = rpmdsNVRMatchesDep(h, req, _rpmds_nopromote);
|
2002-05-20 02:42:25 +08:00
|
|
|
req = rpmdsFree(req);
|
2001-11-11 03:24:19 +08:00
|
|
|
|
|
|
|
if (rc == 0) {
|
2002-05-28 05:40:08 +08:00
|
|
|
rpmps ps = rpmtsProblems(ts);
|
2001-11-11 03:24:19 +08:00
|
|
|
const char * altNEVR = hGetNEVR(h, NULL);
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmpsAppend(ps, RPMPROB_OLDPACKAGE,
|
|
|
|
rpmteNEVR(p), rpmteKey(p),
|
2001-11-11 03:24:19 +08:00
|
|
|
NULL, NULL,
|
|
|
|
altNEVR,
|
|
|
|
0);
|
|
|
|
altNEVR = _free(altNEVR);
|
2002-05-20 02:42:25 +08:00
|
|
|
ps = rpmpsFree(ps);
|
2001-11-11 03:24:19 +08:00
|
|
|
rc = 1;
|
|
|
|
} else
|
|
|
|
rc = 0;
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
1999-01-01 03:16:31 +08:00
|
|
|
|
2001-09-26 04:51:34 +08:00
|
|
|
/**
|
2002-12-25 01:06:35 +08:00
|
|
|
* Skip any files that do not match install policies.
|
|
|
|
* @param ts transaction set
|
|
|
|
* @param fi file info set
|
2001-09-26 04:51:34 +08:00
|
|
|
*/
|
2001-11-16 08:26:30 +08:00
|
|
|
/*@-mustmod@*/ /* FIX: fi->actions is modified. */
|
2002-06-20 02:52:46 +08:00
|
|
|
/*@-bounds@*/
|
2002-05-20 02:42:25 +08:00
|
|
|
static void skipFiles(const rpmts ts, rpmfi fi)
|
2001-10-15 11:22:10 +08:00
|
|
|
/*@globals rpmGlobalMacroContext @*/
|
2001-10-18 00:43:36 +08:00
|
|
|
/*@modifies fi, rpmGlobalMacroContext @*/
|
1999-07-14 22:36:10 +08:00
|
|
|
{
|
2002-12-31 09:23:03 +08:00
|
|
|
uint_32 tscolor = rpmtsColor(ts);
|
|
|
|
uint_32 ficolor;
|
2002-12-25 01:06:35 +08:00
|
|
|
int noConfigs = (rpmtsFlags(ts) & RPMTRANS_FLAG_NOCONFIGS);
|
2002-05-20 07:37:24 +08:00
|
|
|
int noDocs = (rpmtsFlags(ts) & RPMTRANS_FLAG_NODOCS);
|
1999-08-07 08:07:51 +08:00
|
|
|
char ** netsharedPaths = NULL;
|
|
|
|
const char ** languages;
|
2001-04-04 04:41:09 +08:00
|
|
|
const char * dn, * bn;
|
|
|
|
int dnlen, bnlen, ix;
|
2000-07-08 04:06:41 +08:00
|
|
|
const char * s;
|
2001-04-03 21:41:56 +08:00
|
|
|
int * drc;
|
|
|
|
char * dff;
|
2001-11-16 08:26:30 +08:00
|
|
|
int dc;
|
2001-04-03 21:41:56 +08:00
|
|
|
int i, j;
|
1999-01-01 03:16:31 +08:00
|
|
|
|
1999-07-14 22:36:10 +08:00
|
|
|
if (!noDocs)
|
|
|
|
noDocs = rpmExpandNumeric("%{_excludedocs}");
|
1999-01-01 03:16:31 +08:00
|
|
|
|
1999-07-14 22:36:10 +08:00
|
|
|
{ const char *tmpPath = rpmExpand("%{_netsharedpath}", NULL);
|
2001-10-16 03:27:13 +08:00
|
|
|
/*@-branchstate@*/
|
1999-07-14 22:36:10 +08:00
|
|
|
if (tmpPath && *tmpPath != '%')
|
|
|
|
netsharedPaths = splitString(tmpPath, strlen(tmpPath), ':');
|
2001-10-16 03:27:13 +08:00
|
|
|
/*@=branchstate@*/
|
2001-04-04 04:41:09 +08:00
|
|
|
tmpPath = _free(tmpPath);
|
1999-07-14 22:36:10 +08:00
|
|
|
}
|
1999-01-01 03:16:31 +08:00
|
|
|
|
1999-08-22 12:17:12 +08:00
|
|
|
s = rpmExpand("%{_install_langs}", NULL);
|
2001-10-16 03:27:13 +08:00
|
|
|
/*@-branchstate@*/
|
2001-04-04 04:41:09 +08:00
|
|
|
if (!(s && *s != '%'))
|
|
|
|
s = _free(s);
|
1999-08-22 12:17:12 +08:00
|
|
|
if (s) {
|
|
|
|
languages = (const char **) splitString(s, strlen(s), ':');
|
2001-04-04 04:41:09 +08:00
|
|
|
s = _free(s);
|
1999-09-08 07:04:24 +08:00
|
|
|
} else
|
|
|
|
languages = NULL;
|
2001-10-16 03:27:13 +08:00
|
|
|
/*@=branchstate@*/
|
1999-01-01 03:16:31 +08:00
|
|
|
|
2001-04-03 21:41:56 +08:00
|
|
|
/* Compute directory refcount, skip directory if now empty. */
|
2002-05-20 02:42:25 +08:00
|
|
|
dc = rpmfiDC(fi);
|
2001-11-16 08:26:30 +08:00
|
|
|
drc = alloca(dc * sizeof(*drc));
|
|
|
|
memset(drc, 0, dc * sizeof(*drc));
|
|
|
|
dff = alloca(dc * sizeof(*dff));
|
|
|
|
memset(dff, 0, dc * sizeof(*dff));
|
|
|
|
|
2002-05-20 02:42:25 +08:00
|
|
|
fi = rpmfiInit(fi, 0);
|
2002-03-13 00:56:17 +08:00
|
|
|
if (fi != NULL) /* XXX lclint */
|
2002-05-20 02:42:25 +08:00
|
|
|
while ((i = rpmfiNext(fi)) >= 0)
|
2001-11-16 08:26:30 +08:00
|
|
|
{
|
2002-12-31 09:23:03 +08:00
|
|
|
char ** nsp;
|
1999-08-07 08:07:51 +08:00
|
|
|
|
2002-05-20 02:42:25 +08:00
|
|
|
bn = rpmfiBN(fi);
|
2001-11-16 08:26:30 +08:00
|
|
|
bnlen = strlen(bn);
|
2002-05-20 02:42:25 +08:00
|
|
|
ix = rpmfiDX(fi);
|
|
|
|
dn = rpmfiDN(fi);
|
2001-11-16 08:26:30 +08:00
|
|
|
dnlen = strlen(dn);
|
|
|
|
if (dn == NULL)
|
|
|
|
continue; /* XXX can't happen */
|
2001-04-04 04:41:09 +08:00
|
|
|
|
|
|
|
drc[ix]++;
|
2001-04-03 21:41:56 +08:00
|
|
|
|
1999-08-07 08:07:51 +08:00
|
|
|
/* Don't bother with skipped files */
|
2001-04-03 21:41:56 +08:00
|
|
|
if (XFA_SKIPPING(fi->actions[i])) {
|
2003-01-02 01:26:46 +08:00
|
|
|
drc[ix]--; dff[ix] = 1;
|
1999-07-14 22:36:10 +08:00
|
|
|
continue;
|
2001-04-03 21:41:56 +08:00
|
|
|
}
|
1999-01-01 03:16:31 +08:00
|
|
|
|
2002-12-31 09:23:03 +08:00
|
|
|
/* Ignore colored files not in our rainbow. */
|
|
|
|
ficolor = rpmfiFColor(fi);
|
2003-01-02 01:26:46 +08:00
|
|
|
if (tscolor && ficolor && !(tscolor & ficolor)) {
|
2002-12-31 09:23:03 +08:00
|
|
|
drc[ix]--; dff[ix] = 1;
|
|
|
|
fi->actions[i] = FA_SKIPCOLOR;
|
2003-01-02 01:26:46 +08:00
|
|
|
continue;
|
2002-12-31 09:23:03 +08:00
|
|
|
}
|
|
|
|
|
1999-08-07 08:07:51 +08:00
|
|
|
/*
|
|
|
|
* Skip net shared paths.
|
|
|
|
* Net shared paths are not relative to the current root (though
|
|
|
|
* they do need to take package relocations into account).
|
|
|
|
*/
|
1999-07-14 22:36:10 +08:00
|
|
|
for (nsp = netsharedPaths; nsp && *nsp; nsp++) {
|
2001-04-03 21:41:56 +08:00
|
|
|
int len;
|
1999-10-20 18:22:46 +08:00
|
|
|
|
1999-08-07 08:07:51 +08:00
|
|
|
len = strlen(*nsp);
|
2001-04-04 04:41:09 +08:00
|
|
|
if (dnlen >= len) {
|
2001-10-14 06:01:38 +08:00
|
|
|
if (strncmp(dn, *nsp, len))
|
|
|
|
/*@innercontinue@*/ continue;
|
2001-04-04 04:41:09 +08:00
|
|
|
/* Only directories or complete file paths can be net shared */
|
2001-10-14 06:01:38 +08:00
|
|
|
if (!(dn[len] == '/' || dn[len] == '\0'))
|
|
|
|
/*@innercontinue@*/ continue;
|
2001-04-04 04:41:09 +08:00
|
|
|
} else {
|
2001-10-14 06:01:38 +08:00
|
|
|
if (len < (dnlen + bnlen))
|
|
|
|
/*@innercontinue@*/ continue;
|
|
|
|
if (strncmp(dn, *nsp, dnlen))
|
|
|
|
/*@innercontinue@*/ continue;
|
|
|
|
if (strncmp(bn, (*nsp) + dnlen, bnlen))
|
|
|
|
/*@innercontinue@*/ continue;
|
2001-04-04 04:41:09 +08:00
|
|
|
len = dnlen + bnlen;
|
|
|
|
/* Only directories or complete file paths can be net shared */
|
2001-10-14 06:01:38 +08:00
|
|
|
if (!((*nsp)[len] == '/' || (*nsp)[len] == '\0'))
|
|
|
|
/*@innercontinue@*/ continue;
|
2001-04-04 04:41:09 +08:00
|
|
|
}
|
1999-08-07 08:07:51 +08:00
|
|
|
|
2001-06-06 03:26:22 +08:00
|
|
|
/*@innerbreak@*/ break;
|
1999-01-01 03:16:31 +08:00
|
|
|
}
|
1999-07-14 22:36:10 +08:00
|
|
|
|
|
|
|
if (nsp && *nsp) {
|
2001-04-04 04:41:09 +08:00
|
|
|
drc[ix]--; dff[ix] = 1;
|
1999-08-16 03:11:40 +08:00
|
|
|
fi->actions[i] = FA_SKIPNETSHARED;
|
1999-07-14 22:36:10 +08:00
|
|
|
continue;
|
1999-01-01 03:16:31 +08:00
|
|
|
}
|
|
|
|
|
1999-08-07 08:07:51 +08:00
|
|
|
/*
|
|
|
|
* Skip i18n language specific files.
|
|
|
|
*/
|
2003-04-03 05:16:26 +08:00
|
|
|
if (languages != NULL && fi->flangs != NULL && *fi->flangs[i]) {
|
1999-08-07 08:07:51 +08:00
|
|
|
const char **lang, *l, *le;
|
2001-10-17 01:42:18 +08:00
|
|
|
for (lang = languages; *lang != NULL; lang++) {
|
1999-08-22 12:17:12 +08:00
|
|
|
if (!strcmp(*lang, "all"))
|
2001-06-06 03:26:22 +08:00
|
|
|
/*@innerbreak@*/ break;
|
2001-04-29 09:05:43 +08:00
|
|
|
for (l = fi->flangs[i]; *l != '\0'; l = le) {
|
|
|
|
for (le = l; *le != '\0' && *le != '|'; le++)
|
2001-06-06 03:26:22 +08:00
|
|
|
{};
|
1999-07-14 22:36:10 +08:00
|
|
|
if ((le-l) > 0 && !strncmp(*lang, l, (le-l)))
|
2001-06-06 03:26:22 +08:00
|
|
|
/*@innerbreak@*/ break;
|
1999-07-14 22:36:10 +08:00
|
|
|
if (*le == '|') le++; /* skip over | */
|
|
|
|
}
|
2001-06-06 03:26:22 +08:00
|
|
|
if (*l != '\0')
|
|
|
|
/*@innerbreak@*/ break;
|
1999-07-14 22:36:10 +08:00
|
|
|
}
|
1999-08-07 08:07:51 +08:00
|
|
|
if (*lang == NULL) {
|
2001-04-04 04:41:09 +08:00
|
|
|
drc[ix]--; dff[ix] = 1;
|
1999-07-14 22:36:10 +08:00
|
|
|
fi->actions[i] = FA_SKIPNSTATE;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
1999-01-01 03:16:31 +08:00
|
|
|
|
2002-12-25 01:06:35 +08:00
|
|
|
/*
|
|
|
|
* Skip config files if requested.
|
|
|
|
*/
|
|
|
|
if (noConfigs && (rpmfiFFlags(fi) & RPMFILE_CONFIG)) {
|
|
|
|
drc[ix]--; dff[ix] = 1;
|
|
|
|
fi->actions[i] = FA_SKIPNSTATE;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
1999-08-07 08:07:51 +08:00
|
|
|
/*
|
|
|
|
* Skip documentation if requested.
|
|
|
|
*/
|
2002-05-20 02:42:25 +08:00
|
|
|
if (noDocs && (rpmfiFFlags(fi) & RPMFILE_DOC)) {
|
2001-04-04 04:41:09 +08:00
|
|
|
drc[ix]--; dff[ix] = 1;
|
1999-07-14 22:36:10 +08:00
|
|
|
fi->actions[i] = FA_SKIPNSTATE;
|
2001-04-21 14:02:09 +08:00
|
|
|
continue;
|
2001-04-03 21:41:56 +08:00
|
|
|
}
|
1999-01-01 03:16:31 +08:00
|
|
|
}
|
|
|
|
|
2001-04-03 21:41:56 +08:00
|
|
|
/* Skip (now empty) directories that had skipped files. */
|
2001-11-16 08:26:30 +08:00
|
|
|
#ifndef NOTYET
|
|
|
|
if (fi != NULL) /* XXX can't happen */
|
|
|
|
for (j = 0; j < dc; j++)
|
|
|
|
#else
|
2002-05-20 02:42:25 +08:00
|
|
|
if ((fi = rpmfiInitD(fi)) != NULL)
|
|
|
|
while (j = rpmfiNextD(fi) >= 0)
|
2001-11-16 08:26:30 +08:00
|
|
|
#endif
|
|
|
|
{
|
2001-04-03 21:41:56 +08:00
|
|
|
|
|
|
|
if (drc[j]) continue; /* dir still has files. */
|
|
|
|
if (!dff[j]) continue; /* dir was not emptied here. */
|
|
|
|
|
|
|
|
/* Find parent directory and basename. */
|
|
|
|
dn = fi->dnl[j]; dnlen = strlen(dn) - 1;
|
|
|
|
bn = dn + dnlen; bnlen = 0;
|
|
|
|
while (bn > dn && bn[-1] != '/') {
|
|
|
|
bnlen++;
|
|
|
|
dnlen--;
|
|
|
|
bn--;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If explicitly included in the package, skip the directory. */
|
2002-05-20 02:42:25 +08:00
|
|
|
fi = rpmfiInit(fi, 0);
|
2002-03-13 00:56:17 +08:00
|
|
|
if (fi != NULL) /* XXX lclint */
|
2002-05-20 02:42:25 +08:00
|
|
|
while ((i = rpmfiNext(fi)) >= 0) {
|
2002-07-28 08:41:15 +08:00
|
|
|
const char * fdn, * fbn;
|
|
|
|
int_16 fFMode;
|
2001-04-03 21:41:56 +08:00
|
|
|
|
|
|
|
if (XFA_SKIPPING(fi->actions[i]))
|
2001-10-14 06:01:38 +08:00
|
|
|
/*@innercontinue@*/ continue;
|
2002-07-28 08:41:15 +08:00
|
|
|
|
|
|
|
fFMode = rpmfiFMode(fi);
|
|
|
|
|
|
|
|
if (whatis(fFMode) != XDIR)
|
2001-10-14 06:01:38 +08:00
|
|
|
/*@innercontinue@*/ continue;
|
2002-07-28 08:41:15 +08:00
|
|
|
fdn = rpmfiDN(fi);
|
|
|
|
if (strlen(fdn) != dnlen)
|
2001-10-14 06:01:38 +08:00
|
|
|
/*@innercontinue@*/ continue;
|
2002-07-28 08:41:15 +08:00
|
|
|
if (strncmp(fdn, dn, dnlen))
|
2001-10-14 06:01:38 +08:00
|
|
|
/*@innercontinue@*/ continue;
|
2002-07-28 08:41:15 +08:00
|
|
|
fbn = rpmfiBN(fi);
|
|
|
|
if (strlen(fbn) != bnlen)
|
2001-10-14 06:01:38 +08:00
|
|
|
/*@innercontinue@*/ continue;
|
2002-07-28 08:41:15 +08:00
|
|
|
if (strncmp(fbn, bn, bnlen))
|
2001-10-14 06:01:38 +08:00
|
|
|
/*@innercontinue@*/ continue;
|
2001-04-03 21:41:56 +08:00
|
|
|
rpmMessage(RPMMESS_DEBUG, _("excluding directory %s\n"), dn);
|
|
|
|
fi->actions[i] = FA_SKIPNSTATE;
|
2001-06-06 03:26:22 +08:00
|
|
|
/*@innerbreak@*/ break;
|
2001-04-03 21:41:56 +08:00
|
|
|
}
|
2001-01-24 00:07:28 +08:00
|
|
|
}
|
2001-04-03 21:41:56 +08:00
|
|
|
|
2003-04-03 05:16:26 +08:00
|
|
|
/*@-dependenttrans@*/
|
2001-04-03 21:41:56 +08:00
|
|
|
if (netsharedPaths) freeSplitString(netsharedPaths);
|
2001-05-04 05:00:18 +08:00
|
|
|
#ifdef DYING /* XXX freeFi will deal with this later. */
|
2001-04-03 21:41:56 +08:00
|
|
|
fi->flangs = _free(fi->flangs);
|
2001-05-04 05:00:18 +08:00
|
|
|
#endif
|
1999-08-22 12:17:12 +08:00
|
|
|
if (languages) freeSplitString((char **)languages);
|
2003-04-03 05:16:26 +08:00
|
|
|
/*@=dependenttrans@*/
|
1999-07-14 22:36:10 +08:00
|
|
|
}
|
2002-06-20 02:52:46 +08:00
|
|
|
/*@=bounds@*/
|
2001-11-16 08:26:30 +08:00
|
|
|
/*@=mustmod@*/
|
1999-01-01 03:16:31 +08:00
|
|
|
|
2001-11-14 08:14:01 +08:00
|
|
|
/**
|
|
|
|
* Return transaction element's file info.
|
2002-05-20 02:42:25 +08:00
|
|
|
* @todo Take a rpmfi refcount here.
|
2002-05-28 05:40:08 +08:00
|
|
|
* @param tsi transaction element iterator
|
2001-11-14 08:14:01 +08:00
|
|
|
* @return transaction element file info
|
|
|
|
*/
|
|
|
|
static /*@null@*/
|
2002-05-28 05:40:08 +08:00
|
|
|
rpmfi rpmtsiFi(const rpmtsi tsi)
|
2001-11-17 03:26:33 +08:00
|
|
|
/*@*/
|
2001-11-14 08:14:01 +08:00
|
|
|
{
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmfi fi = NULL;
|
2001-11-14 08:14:01 +08:00
|
|
|
|
2002-05-28 05:40:08 +08:00
|
|
|
if (tsi != NULL && tsi->ocsave != -1) {
|
2002-05-20 02:42:25 +08:00
|
|
|
/*@-type -abstract@*/ /* FIX: rpmte not opaque */
|
2002-05-28 05:40:08 +08:00
|
|
|
rpmte te = rpmtsElement(tsi->ts, tsi->ocsave);
|
2001-11-17 06:42:19 +08:00
|
|
|
/*@-assignexpose@*/
|
2002-05-20 07:37:24 +08:00
|
|
|
if (te != NULL && (fi = te->fi) != NULL)
|
2001-11-14 08:14:01 +08:00
|
|
|
fi->te = te;
|
2001-11-17 06:42:19 +08:00
|
|
|
/*@=assignexpose@*/
|
2001-11-17 03:26:33 +08:00
|
|
|
/*@=type =abstract@*/
|
2001-11-14 08:14:01 +08:00
|
|
|
}
|
|
|
|
/*@-compdef -refcounttrans -usereleased @*/
|
|
|
|
return fi;
|
|
|
|
/*@=compdef =refcounttrans =usereleased @*/
|
|
|
|
}
|
|
|
|
|
2002-05-20 02:42:25 +08:00
|
|
|
#define NOTIFY(_ts, _al) /*@i@*/ if ((_ts)->notify) (void) (_ts)->notify _al
|
1999-01-01 03:16:31 +08:00
|
|
|
|
2002-05-20 02:42:25 +08:00
|
|
|
int rpmtsRun(rpmts ts, rpmps okProbs, rpmprobFilterFlags ignoreSet)
|
1999-07-14 22:36:10 +08:00
|
|
|
{
|
2002-12-31 09:23:03 +08:00
|
|
|
uint_32 tscolor = rpmtsColor(ts);
|
1999-07-14 22:36:10 +08:00
|
|
|
int i, j;
|
2001-02-18 01:53:21 +08:00
|
|
|
int ourrc = 0;
|
1999-07-14 22:36:10 +08:00
|
|
|
int totalFileCount = 0;
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmfi fi;
|
2001-11-11 20:47:08 +08:00
|
|
|
sharedFileInfo shared, sharedList;
|
1999-07-14 22:36:10 +08:00
|
|
|
int numShared;
|
1999-08-14 04:05:57 +08:00
|
|
|
int nexti;
|
2002-08-20 06:27:44 +08:00
|
|
|
alKey lastFailKey;
|
1999-10-20 18:22:46 +08:00
|
|
|
fingerPrintCache fpc;
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmps ps;
|
2002-08-20 06:27:44 +08:00
|
|
|
rpmpsm psm;
|
2002-05-28 05:40:08 +08:00
|
|
|
rpmtsi pi; rpmte p;
|
|
|
|
rpmtsi qi; rpmte q;
|
2002-08-05 00:55:55 +08:00
|
|
|
int numAdded;
|
|
|
|
int numRemoved;
|
2001-10-16 22:58:57 +08:00
|
|
|
int xx;
|
2001-11-05 11:44:05 +08:00
|
|
|
|
2003-01-02 01:26:46 +08:00
|
|
|
/* XXX programmer error segfault avoidance. */
|
|
|
|
if (rpmtsNElements(ts) <= 0)
|
|
|
|
return -1;
|
1999-01-01 03:16:31 +08:00
|
|
|
|
2002-05-20 07:37:24 +08:00
|
|
|
if (rpmtsFlags(ts) & RPMTRANS_FLAG_NOSCRIPTS)
|
|
|
|
(void) rpmtsSetFlags(ts, (rpmtsFlags(ts) | _noTransScripts | _noTransTriggers));
|
|
|
|
if (rpmtsFlags(ts) & RPMTRANS_FLAG_NOTRIGGERS)
|
|
|
|
(void) rpmtsSetFlags(ts, (rpmtsFlags(ts) | _noTransTriggers));
|
2001-01-25 05:35:52 +08:00
|
|
|
|
2002-12-31 10:12:02 +08:00
|
|
|
if (rpmtsFlags(ts) & RPMTRANS_FLAG_JUSTDB)
|
2002-05-20 07:37:24 +08:00
|
|
|
(void) rpmtsSetFlags(ts, (rpmtsFlags(ts) | _noTransScripts | _noTransTriggers));
|
2001-01-25 05:35:52 +08:00
|
|
|
|
2002-05-20 02:42:25 +08:00
|
|
|
ts->probs = rpmpsFree(ts->probs);
|
|
|
|
ts->probs = rpmpsCreate();
|
2002-05-18 05:08:39 +08:00
|
|
|
|
2002-06-29 11:16:34 +08:00
|
|
|
/* XXX Make sure the database is open RDWR for package install/erase. */
|
|
|
|
{ int dbmode = (rpmtsFlags(ts) & RPMTRANS_FLAG_TEST)
|
|
|
|
? O_RDONLY : (O_RDWR|O_CREAT);
|
|
|
|
|
|
|
|
/* Open database RDWR for installing packages. */
|
|
|
|
if (rpmtsOpenDB(ts, dbmode))
|
|
|
|
return -1; /* XXX W2DO? */
|
|
|
|
}
|
|
|
|
|
2000-10-21 06:04:27 +08:00
|
|
|
ts->ignoreSet = ignoreSet;
|
2002-05-18 05:08:39 +08:00
|
|
|
{ const char * currDir = currentDirectory();
|
|
|
|
rpmtsSetCurrDir(ts, currDir);
|
|
|
|
currDir = _free(currDir);
|
|
|
|
}
|
|
|
|
|
|
|
|
(void) rpmtsSetChrootDone(ts, 0);
|
|
|
|
|
|
|
|
{ int_32 tid = (int_32) time(NULL);
|
|
|
|
(void) rpmtsSetTid(ts, tid);
|
|
|
|
}
|
2000-07-09 23:17:11 +08:00
|
|
|
|
2000-10-21 00:47:00 +08:00
|
|
|
/* Get available space on mounted file systems. */
|
2002-05-20 02:42:25 +08:00
|
|
|
xx = rpmtsInitDSI(ts);
|
1999-01-05 00:44:20 +08:00
|
|
|
|
1999-08-07 07:44:25 +08:00
|
|
|
/* ===============================================
|
|
|
|
* For packages being installed:
|
|
|
|
* - verify package arch/os.
|
|
|
|
* - verify package epoch:version-release is newer.
|
|
|
|
* - count files.
|
|
|
|
* For packages being removed:
|
|
|
|
* - count files.
|
|
|
|
*/
|
2002-07-19 05:42:18 +08:00
|
|
|
|
2002-10-26 22:43:43 +08:00
|
|
|
rpmMessage(RPMMESS_DEBUG, _("sanity checking %d elements\n"), rpmtsNElements(ts));
|
2002-05-28 05:40:08 +08:00
|
|
|
ps = rpmtsProblems(ts);
|
1999-07-14 22:36:10 +08:00
|
|
|
/* The ordering doesn't matter here */
|
2002-05-28 05:40:08 +08:00
|
|
|
pi = rpmtsiInit(ts);
|
|
|
|
while ((p = rpmtsiNext(pi, TR_ADDED)) != NULL) {
|
2001-10-31 02:00:21 +08:00
|
|
|
rpmdbMatchIterator mi;
|
2001-11-16 08:26:30 +08:00
|
|
|
int fc;
|
|
|
|
|
2002-05-28 05:40:08 +08:00
|
|
|
if ((fi = rpmtsiFi(pi)) == NULL)
|
2001-11-16 08:26:30 +08:00
|
|
|
continue; /* XXX can't happen */
|
2002-05-20 02:42:25 +08:00
|
|
|
fc = rpmfiFC(fi);
|
2001-10-31 02:00:21 +08:00
|
|
|
|
2002-12-31 09:23:03 +08:00
|
|
|
if (!(rpmtsFilterFlags(ts) & RPMPROB_FILTER_IGNOREARCH) && !tscolor)
|
2002-05-20 02:42:25 +08:00
|
|
|
if (!archOkay(rpmteA(p)))
|
|
|
|
rpmpsAppend(ps, RPMPROB_BADARCH,
|
|
|
|
rpmteNEVR(p), rpmteKey(p),
|
|
|
|
rpmteA(p), NULL,
|
2001-11-10 01:22:08 +08:00
|
|
|
NULL, 0);
|
1999-01-08 01:06:24 +08:00
|
|
|
|
2002-05-20 07:37:24 +08:00
|
|
|
if (!(rpmtsFilterFlags(ts) & RPMPROB_FILTER_IGNOREOS))
|
2002-05-20 02:42:25 +08:00
|
|
|
if (!osOkay(rpmteO(p)))
|
|
|
|
rpmpsAppend(ps, RPMPROB_BADOS,
|
|
|
|
rpmteNEVR(p), rpmteKey(p),
|
|
|
|
rpmteO(p), NULL,
|
2001-11-10 01:22:08 +08:00
|
|
|
NULL, 0);
|
1999-01-05 00:44:20 +08:00
|
|
|
|
2002-05-20 07:37:24 +08:00
|
|
|
if (!(rpmtsFilterFlags(ts) & RPMPROB_FILTER_OLDPACKAGE)) {
|
2001-11-11 03:24:19 +08:00
|
|
|
Header h;
|
2002-05-20 02:42:25 +08:00
|
|
|
mi = rpmtsInitIterator(ts, RPMTAG_NAME, rpmteN(p), 0);
|
2001-11-11 03:24:19 +08:00
|
|
|
while ((h = rpmdbNextIterator(mi)) != NULL)
|
|
|
|
xx = ensureOlder(ts, p, h);
|
2001-04-30 06:43:01 +08:00
|
|
|
mi = rpmdbFreeIterator(mi);
|
1999-07-14 22:36:10 +08:00
|
|
|
}
|
1999-03-19 11:39:17 +08:00
|
|
|
|
2003-01-02 00:54:04 +08:00
|
|
|
if (!(rpmtsFilterFlags(ts) & RPMPROB_FILTER_REPLACEPKG)) {
|
2002-05-20 02:42:25 +08:00
|
|
|
mi = rpmtsInitIterator(ts, RPMTAG_NAME, rpmteN(p), 0);
|
2002-08-20 22:56:37 +08:00
|
|
|
xx = rpmdbSetIteratorRE(mi, RPMTAG_EPOCH, RPMMIRE_DEFAULT,
|
|
|
|
rpmteE(p));
|
2001-11-11 03:24:19 +08:00
|
|
|
xx = rpmdbSetIteratorRE(mi, RPMTAG_VERSION, RPMMIRE_DEFAULT,
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmteV(p));
|
2001-11-11 03:24:19 +08:00
|
|
|
xx = rpmdbSetIteratorRE(mi, RPMTAG_RELEASE, RPMMIRE_DEFAULT,
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmteR(p));
|
2003-01-18 01:43:04 +08:00
|
|
|
if (tscolor) {
|
|
|
|
xx = rpmdbSetIteratorRE(mi, RPMTAG_ARCH, RPMMIRE_DEFAULT,
|
|
|
|
rpmteA(p));
|
|
|
|
xx = rpmdbSetIteratorRE(mi, RPMTAG_OS, RPMMIRE_DEFAULT,
|
|
|
|
rpmteO(p));
|
|
|
|
}
|
2001-06-15 12:56:33 +08:00
|
|
|
|
2000-04-27 08:10:28 +08:00
|
|
|
while (rpmdbNextIterator(mi) != NULL) {
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmpsAppend(ps, RPMPROB_PKG_INSTALLED,
|
|
|
|
rpmteNEVR(p), rpmteKey(p),
|
2001-11-10 01:22:08 +08:00
|
|
|
NULL, NULL,
|
|
|
|
NULL, 0);
|
2001-06-06 03:26:22 +08:00
|
|
|
/*@innerbreak@*/ break;
|
2000-04-27 08:10:28 +08:00
|
|
|
}
|
2001-04-30 06:43:01 +08:00
|
|
|
mi = rpmdbFreeIterator(mi);
|
2000-04-13 18:11:32 +08:00
|
|
|
}
|
1999-01-05 00:44:20 +08:00
|
|
|
|
2001-11-10 07:13:50 +08:00
|
|
|
/* Count no. of files (if any). */
|
2001-11-16 08:26:30 +08:00
|
|
|
totalFileCount += fc;
|
2001-10-31 02:00:21 +08:00
|
|
|
|
1999-07-14 22:36:10 +08:00
|
|
|
}
|
2002-05-28 05:40:08 +08:00
|
|
|
pi = rpmtsiFree(pi);
|
2002-05-20 02:42:25 +08:00
|
|
|
ps = rpmpsFree(ps);
|
1999-01-05 00:44:20 +08:00
|
|
|
|
2001-11-11 11:15:47 +08:00
|
|
|
/* The ordering doesn't matter here */
|
2002-05-28 05:40:08 +08:00
|
|
|
pi = rpmtsiInit(ts);
|
|
|
|
while ((p = rpmtsiNext(pi, TR_REMOVED)) != NULL) {
|
2001-11-16 08:26:30 +08:00
|
|
|
int fc;
|
|
|
|
|
2002-05-28 05:40:08 +08:00
|
|
|
if ((fi = rpmtsiFi(pi)) == NULL)
|
2001-11-11 11:15:47 +08:00
|
|
|
continue; /* XXX can't happen */
|
2002-05-20 02:42:25 +08:00
|
|
|
fc = rpmfiFC(fi);
|
2001-11-16 08:26:30 +08:00
|
|
|
|
|
|
|
totalFileCount += fc;
|
2001-11-11 11:15:47 +08:00
|
|
|
}
|
2002-05-28 05:40:08 +08:00
|
|
|
pi = rpmtsiFree(pi);
|
1999-01-05 00:44:20 +08:00
|
|
|
|
1999-08-07 07:44:25 +08:00
|
|
|
/* ===============================================
|
2001-10-31 02:00:21 +08:00
|
|
|
* Initialize transaction element file info for package:
|
1999-08-07 07:44:25 +08:00
|
|
|
*/
|
1999-01-05 00:44:20 +08:00
|
|
|
|
2000-10-21 00:47:00 +08:00
|
|
|
/*
|
|
|
|
* FIXME?: we'd be better off assembling one very large file list and
|
|
|
|
* calling fpLookupList only once. I'm not sure that the speedup is
|
|
|
|
* worth the trouble though.
|
|
|
|
*/
|
2002-07-19 05:42:18 +08:00
|
|
|
rpmMessage(RPMMESS_DEBUG, _("computing %d file fingerprints\n"), totalFileCount);
|
2003-03-26 07:51:24 +08:00
|
|
|
|
2002-08-05 00:55:55 +08:00
|
|
|
numAdded = numRemoved = 0;
|
2002-05-28 05:40:08 +08:00
|
|
|
pi = rpmtsiInit(ts);
|
|
|
|
while ((p = rpmtsiNext(pi, 0)) != NULL) {
|
2001-11-16 08:26:30 +08:00
|
|
|
int fc;
|
2001-11-05 06:00:11 +08:00
|
|
|
|
2002-05-28 05:40:08 +08:00
|
|
|
if ((fi = rpmtsiFi(pi)) == NULL)
|
2001-11-12 06:51:00 +08:00
|
|
|
continue; /* XXX can't happen */
|
2002-05-20 02:42:25 +08:00
|
|
|
fc = rpmfiFC(fi);
|
2001-11-12 06:51:00 +08:00
|
|
|
|
2001-10-16 03:27:13 +08:00
|
|
|
/*@-branchstate@*/
|
2002-05-20 02:42:25 +08:00
|
|
|
switch (rpmteType(p)) {
|
1999-08-14 04:05:57 +08:00
|
|
|
case TR_ADDED:
|
2002-08-05 00:55:55 +08:00
|
|
|
numAdded++;
|
2001-01-24 00:07:28 +08:00
|
|
|
fi->record = 0;
|
|
|
|
/* Skip netshared paths, not our i18n files, and excluded docs */
|
2001-11-16 08:26:30 +08:00
|
|
|
if (fc > 0)
|
2001-11-12 06:51:00 +08:00
|
|
|
skipFiles(ts, fi);
|
2001-10-14 06:01:38 +08:00
|
|
|
/*@switchbreak@*/ break;
|
1999-08-14 04:05:57 +08:00
|
|
|
case TR_REMOVED:
|
2002-08-05 00:55:55 +08:00
|
|
|
numRemoved++;
|
2002-05-20 02:42:25 +08:00
|
|
|
fi->record = rpmteDBOffset(p);
|
2001-10-14 06:01:38 +08:00
|
|
|
/*@switchbreak@*/ break;
|
1999-07-14 22:36:10 +08:00
|
|
|
}
|
2001-10-16 03:27:13 +08:00
|
|
|
/*@=branchstate@*/
|
1999-02-21 11:34:52 +08:00
|
|
|
|
2001-11-16 08:26:30 +08:00
|
|
|
fi->fps = (fc > 0 ? xmalloc(fc * sizeof(*fi->fps)) : NULL);
|
1999-07-14 22:36:10 +08:00
|
|
|
}
|
2002-05-28 05:40:08 +08:00
|
|
|
pi = rpmtsiFree(pi);
|
1999-01-05 00:44:20 +08:00
|
|
|
|
2002-05-24 03:42:23 +08:00
|
|
|
if (!rpmtsChrootDone(ts)) {
|
2002-05-20 07:37:24 +08:00
|
|
|
const char * rootDir = rpmtsRootDir(ts);
|
2001-10-16 22:58:57 +08:00
|
|
|
xx = chdir("/");
|
2001-10-14 03:35:58 +08:00
|
|
|
/*@-superuser -noeffect @*/
|
2002-05-18 05:08:39 +08:00
|
|
|
if (rootDir != NULL)
|
|
|
|
xx = chroot(rootDir);
|
2001-10-14 03:35:58 +08:00
|
|
|
/*@=superuser =noeffect @*/
|
2002-05-18 05:08:39 +08:00
|
|
|
(void) rpmtsSetChrootDone(ts, 1);
|
2001-01-27 01:06:09 +08:00
|
|
|
}
|
1999-07-14 22:36:10 +08:00
|
|
|
|
2001-10-19 00:39:54 +08:00
|
|
|
ts->ht = htCreate(totalFileCount * 2, 0, 0, fpHashFunction, fpEqual);
|
1999-10-20 18:22:46 +08:00
|
|
|
fpc = fpCacheCreate(totalFileCount);
|
1999-10-09 04:30:49 +08:00
|
|
|
|
1999-08-07 07:44:25 +08:00
|
|
|
/* ===============================================
|
|
|
|
* Add fingerprint for each file not skipped.
|
|
|
|
*/
|
2002-05-28 05:40:08 +08:00
|
|
|
pi = rpmtsiInit(ts);
|
|
|
|
while ((p = rpmtsiNext(pi, 0)) != NULL) {
|
2001-11-16 08:26:30 +08:00
|
|
|
int fc;
|
2001-11-12 00:17:57 +08:00
|
|
|
|
2002-09-01 06:39:34 +08:00
|
|
|
(void) rpmdbCheckSignals();
|
|
|
|
|
2002-05-28 05:40:08 +08:00
|
|
|
if ((fi = rpmtsiFi(pi)) == NULL)
|
2001-11-12 06:51:00 +08:00
|
|
|
continue; /* XXX can't happen */
|
2002-05-20 02:42:25 +08:00
|
|
|
fc = rpmfiFC(fi);
|
2001-11-12 00:17:57 +08:00
|
|
|
|
2003-04-09 05:42:55 +08:00
|
|
|
(void) rpmswEnter(rpmtsOp(ts, RPMTS_OP_FINGERPRINT), 0);
|
2001-11-16 08:26:30 +08:00
|
|
|
fpLookupList(fpc, fi->dnl, fi->bnl, fi->dil, fc, fi->fps);
|
2001-11-12 00:17:57 +08:00
|
|
|
/*@-branchstate@*/
|
2002-05-20 02:42:25 +08:00
|
|
|
fi = rpmfiInit(fi, 0);
|
2002-03-13 00:56:17 +08:00
|
|
|
if (fi != NULL) /* XXX lclint */
|
2002-05-20 02:42:25 +08:00
|
|
|
while ((i = rpmfiNext(fi)) >= 0) {
|
1999-08-16 03:11:40 +08:00
|
|
|
if (XFA_SKIPPING(fi->actions[i]))
|
2001-10-14 06:01:38 +08:00
|
|
|
/*@innercontinue@*/ continue;
|
2001-04-30 06:43:01 +08:00
|
|
|
/*@-dependenttrans@*/
|
2001-11-16 08:26:30 +08:00
|
|
|
htAddEntry(ts->ht, fi->fps + i, (void *) fi);
|
2001-04-30 06:43:01 +08:00
|
|
|
/*@=dependenttrans@*/
|
1999-07-14 22:36:10 +08:00
|
|
|
}
|
2001-11-12 00:17:57 +08:00
|
|
|
/*@=branchstate@*/
|
2003-04-09 05:42:55 +08:00
|
|
|
(void) rpmswExit(rpmtsOp(ts, RPMTS_OP_FINGERPRINT), fc);
|
2003-04-07 20:05:35 +08:00
|
|
|
|
1999-07-14 22:36:10 +08:00
|
|
|
}
|
2002-05-28 05:40:08 +08:00
|
|
|
pi = rpmtsiFree(pi);
|
1999-07-14 22:36:10 +08:00
|
|
|
|
2001-11-12 06:51:00 +08:00
|
|
|
NOTIFY(ts, (NULL, RPMCALLBACK_TRANS_START, 6, ts->orderCount,
|
2000-10-21 06:04:27 +08:00
|
|
|
NULL, ts->notifyData));
|
1999-07-14 22:36:10 +08:00
|
|
|
|
1999-08-07 07:44:25 +08:00
|
|
|
/* ===============================================
|
1999-08-15 04:01:38 +08:00
|
|
|
* Compute file disposition for each package in transaction set.
|
1999-08-07 07:44:25 +08:00
|
|
|
*/
|
2002-07-19 05:42:18 +08:00
|
|
|
rpmMessage(RPMMESS_DEBUG, _("computing file dispositions\n"));
|
2002-05-28 05:40:08 +08:00
|
|
|
ps = rpmtsProblems(ts);
|
|
|
|
pi = rpmtsiInit(ts);
|
|
|
|
while ((p = rpmtsiNext(pi, 0)) != NULL) {
|
2000-03-23 23:49:50 +08:00
|
|
|
dbiIndexSet * matches;
|
1999-07-14 22:36:10 +08:00
|
|
|
int knownBad;
|
2001-11-16 08:26:30 +08:00
|
|
|
int fc;
|
1999-07-14 22:36:10 +08:00
|
|
|
|
2002-09-01 06:39:34 +08:00
|
|
|
(void) rpmdbCheckSignals();
|
|
|
|
|
2002-05-28 05:40:08 +08:00
|
|
|
if ((fi = rpmtsiFi(pi)) == NULL)
|
2001-11-12 06:51:00 +08:00
|
|
|
continue; /* XXX can't happen */
|
2002-05-20 02:42:25 +08:00
|
|
|
fc = rpmfiFC(fi);
|
2001-11-12 00:17:57 +08:00
|
|
|
|
2002-05-28 05:40:08 +08:00
|
|
|
NOTIFY(ts, (NULL, RPMCALLBACK_TRANS_PROGRESS, rpmtsiOc(pi),
|
2001-11-12 06:51:00 +08:00
|
|
|
ts->orderCount, NULL, ts->notifyData));
|
1999-07-14 22:36:10 +08:00
|
|
|
|
2001-11-16 08:26:30 +08:00
|
|
|
if (fc == 0) continue;
|
2000-12-13 04:03:45 +08:00
|
|
|
|
2003-04-09 05:42:55 +08:00
|
|
|
(void) rpmswEnter(rpmtsOp(ts, RPMTS_OP_FINGERPRINT), 0);
|
1999-08-15 04:01:38 +08:00
|
|
|
/* Extract file info for all files in this package from the database. */
|
2001-11-16 08:26:30 +08:00
|
|
|
matches = xcalloc(fc, sizeof(*matches));
|
2002-05-18 05:08:39 +08:00
|
|
|
if (rpmdbFindFpList(rpmtsGetRdb(ts), fi->fps, matches, fc)) {
|
2002-05-20 02:42:25 +08:00
|
|
|
ps = rpmpsFree(ps);
|
2001-04-30 06:43:01 +08:00
|
|
|
return 1; /* XXX WTFO? */
|
2001-10-28 06:31:10 +08:00
|
|
|
}
|
1999-07-14 22:36:10 +08:00
|
|
|
|
|
|
|
numShared = 0;
|
2002-05-20 02:42:25 +08:00
|
|
|
fi = rpmfiInit(fi, 0);
|
|
|
|
while ((i = rpmfiNext(fi)) >= 0)
|
1999-09-13 04:43:23 +08:00
|
|
|
numShared += dbiIndexSetCount(matches[i]);
|
1999-03-19 11:39:17 +08:00
|
|
|
|
1999-08-15 04:01:38 +08:00
|
|
|
/* Build sorted file info list for this package. */
|
2001-09-25 05:53:14 +08:00
|
|
|
shared = sharedList = xcalloc((numShared + 1), sizeof(*sharedList));
|
2001-11-16 08:26:30 +08:00
|
|
|
|
2002-05-20 02:42:25 +08:00
|
|
|
fi = rpmfiInit(fi, 0);
|
|
|
|
while ((i = rpmfiNext(fi)) >= 0) {
|
1999-08-15 04:01:38 +08:00
|
|
|
/*
|
|
|
|
* Take care not to mark files as replaced in packages that will
|
|
|
|
* have been removed before we will get here.
|
|
|
|
*/
|
1999-09-13 04:43:23 +08:00
|
|
|
for (j = 0; j < dbiIndexSetCount(matches[i]); j++) {
|
2001-11-12 00:17:57 +08:00
|
|
|
int ro;
|
1999-09-13 04:43:23 +08:00
|
|
|
ro = dbiIndexRecordOffset(matches[i], j);
|
1999-08-15 04:01:38 +08:00
|
|
|
knownBad = 0;
|
2002-05-28 05:40:08 +08:00
|
|
|
qi = rpmtsiInit(ts);
|
|
|
|
while ((q = rpmtsiNext(qi, TR_REMOVED)) != NULL) {
|
2001-11-12 00:17:57 +08:00
|
|
|
if (ro == knownBad)
|
|
|
|
/*@innerbreak@*/ break;
|
2002-05-20 02:42:25 +08:00
|
|
|
if (rpmteDBOffset(q) == ro)
|
2001-11-12 00:17:57 +08:00
|
|
|
knownBad = ro;
|
1999-01-05 00:44:20 +08:00
|
|
|
}
|
2002-05-28 05:40:08 +08:00
|
|
|
qi = rpmtsiFree(qi);
|
1999-07-14 22:36:10 +08:00
|
|
|
|
|
|
|
shared->pkgFileNum = i;
|
1999-09-13 04:43:23 +08:00
|
|
|
shared->otherPkg = dbiIndexRecordOffset(matches[i], j);
|
|
|
|
shared->otherFileNum = dbiIndexRecordFileNumber(matches[i], j);
|
1999-07-14 22:36:10 +08:00
|
|
|
shared->isRemoved = (knownBad == ro);
|
|
|
|
shared++;
|
1999-01-05 00:44:20 +08:00
|
|
|
}
|
2001-06-06 20:36:31 +08:00
|
|
|
matches[i] = dbiFreeIndexSet(matches[i]);
|
1999-01-05 00:44:20 +08:00
|
|
|
}
|
1999-07-14 22:36:10 +08:00
|
|
|
numShared = shared - sharedList;
|
|
|
|
shared->otherPkg = -1;
|
2001-04-04 04:41:09 +08:00
|
|
|
matches = _free(matches);
|
1999-03-19 11:39:17 +08:00
|
|
|
|
1999-08-15 04:01:38 +08:00
|
|
|
/* Sort file info by other package index (otherPkg) */
|
1999-07-14 22:36:10 +08:00
|
|
|
qsort(sharedList, numShared, sizeof(*shared), sharedCmp);
|
1999-03-19 11:39:17 +08:00
|
|
|
|
1999-08-15 04:01:38 +08:00
|
|
|
/* For all files from this package that are in the database ... */
|
2002-01-19 06:51:30 +08:00
|
|
|
/*@-branchstate@*/
|
1999-08-14 04:05:57 +08:00
|
|
|
for (i = 0; i < numShared; i = nexti) {
|
|
|
|
int beingRemoved;
|
1999-03-19 11:39:17 +08:00
|
|
|
|
1999-08-15 04:01:38 +08:00
|
|
|
shared = sharedList + i;
|
|
|
|
|
|
|
|
/* Find the end of the files in the other package. */
|
1999-08-14 04:05:57 +08:00
|
|
|
for (nexti = i + 1; nexti < numShared; nexti++) {
|
1999-08-15 04:01:38 +08:00
|
|
|
if (sharedList[nexti].otherPkg != shared->otherPkg)
|
2001-06-06 03:26:22 +08:00
|
|
|
/*@innerbreak@*/ break;
|
1999-08-14 04:05:57 +08:00
|
|
|
}
|
|
|
|
|
1999-08-15 04:01:38 +08:00
|
|
|
/* Is this file from a package being removed? */
|
|
|
|
beingRemoved = 0;
|
2001-11-12 04:45:20 +08:00
|
|
|
if (ts->removedPackages != NULL)
|
1999-07-14 22:36:10 +08:00
|
|
|
for (j = 0; j < ts->numRemovedPackages; j++) {
|
1999-08-15 04:01:38 +08:00
|
|
|
if (ts->removedPackages[j] != shared->otherPkg)
|
2001-10-14 06:01:38 +08:00
|
|
|
/*@innercontinue@*/ continue;
|
1999-08-15 04:01:38 +08:00
|
|
|
beingRemoved = 1;
|
2001-06-06 03:26:22 +08:00
|
|
|
/*@innerbreak@*/ break;
|
1999-03-19 11:39:17 +08:00
|
|
|
}
|
|
|
|
|
1999-08-15 04:01:38 +08:00
|
|
|
/* Determine the fate of each file. */
|
2002-05-20 02:42:25 +08:00
|
|
|
switch (rpmteType(p)) {
|
1999-08-14 04:05:57 +08:00
|
|
|
case TR_ADDED:
|
2001-11-12 00:17:57 +08:00
|
|
|
xx = handleInstInstalledFiles(ts, p, fi, shared, nexti - i,
|
2002-05-20 07:37:24 +08:00
|
|
|
!(beingRemoved || (rpmtsFilterFlags(ts) & RPMPROB_FILTER_REPLACEOLDFILES)));
|
2001-10-14 06:01:38 +08:00
|
|
|
/*@switchbreak@*/ break;
|
1999-08-14 04:05:57 +08:00
|
|
|
case TR_REMOVED:
|
|
|
|
if (!beingRemoved)
|
2001-10-19 00:39:54 +08:00
|
|
|
xx = handleRmvdInstalledFiles(ts, fi, shared, nexti - i);
|
2001-10-14 06:01:38 +08:00
|
|
|
/*@switchbreak@*/ break;
|
1999-08-14 04:05:57 +08:00
|
|
|
}
|
1999-03-19 11:39:17 +08:00
|
|
|
}
|
2002-01-19 06:51:30 +08:00
|
|
|
/*@=branchstate@*/
|
1999-02-17 12:32:55 +08:00
|
|
|
|
1999-07-14 22:36:10 +08:00
|
|
|
free(sharedList);
|
1999-02-17 12:32:55 +08:00
|
|
|
|
1999-08-14 04:05:57 +08:00
|
|
|
/* Update disk space needs on each partition for this package. */
|
2001-11-12 00:17:57 +08:00
|
|
|
handleOverlappedFiles(ts, p, fi);
|
1999-02-17 12:32:55 +08:00
|
|
|
|
1999-08-14 04:05:57 +08:00
|
|
|
/* Check added package has sufficient space on each partition used. */
|
2002-05-20 02:42:25 +08:00
|
|
|
switch (rpmteType(p)) {
|
1999-08-14 04:05:57 +08:00
|
|
|
case TR_ADDED:
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmtsCheckDSIProblems(ts, p);
|
2001-10-14 06:01:38 +08:00
|
|
|
/*@switchbreak@*/ break;
|
1999-08-14 04:05:57 +08:00
|
|
|
case TR_REMOVED:
|
2001-10-14 06:01:38 +08:00
|
|
|
/*@switchbreak@*/ break;
|
1999-07-14 22:36:10 +08:00
|
|
|
}
|
2003-04-09 05:42:55 +08:00
|
|
|
(void) rpmswExit(rpmtsOp(ts, RPMTS_OP_FINGERPRINT), fc);
|
1999-02-17 12:32:55 +08:00
|
|
|
}
|
2002-05-28 05:40:08 +08:00
|
|
|
pi = rpmtsiFree(pi);
|
2002-05-20 02:42:25 +08:00
|
|
|
ps = rpmpsFree(ps);
|
1999-02-21 11:34:52 +08:00
|
|
|
|
2002-05-24 03:42:23 +08:00
|
|
|
if (rpmtsChrootDone(ts)) {
|
|
|
|
const char * currDir = rpmtsCurrDir(ts);
|
2001-10-14 03:35:58 +08:00
|
|
|
/*@-superuser -noeffect @*/
|
2001-10-16 22:58:57 +08:00
|
|
|
xx = chroot(".");
|
2001-10-14 03:35:58 +08:00
|
|
|
/*@=superuser =noeffect @*/
|
2002-05-18 05:08:39 +08:00
|
|
|
(void) rpmtsSetChrootDone(ts, 0);
|
|
|
|
if (currDir != NULL)
|
|
|
|
xx = chdir(currDir);
|
2001-01-27 01:06:09 +08:00
|
|
|
}
|
1999-02-21 11:34:52 +08:00
|
|
|
|
2001-11-12 06:51:00 +08:00
|
|
|
NOTIFY(ts, (NULL, RPMCALLBACK_TRANS_STOP, 6, ts->orderCount,
|
2001-04-30 06:43:01 +08:00
|
|
|
NULL, ts->notifyData));
|
|
|
|
|
1999-08-07 07:44:25 +08:00
|
|
|
/* ===============================================
|
1999-08-14 04:05:57 +08:00
|
|
|
* Free unused memory as soon as possible.
|
1999-08-07 07:44:25 +08:00
|
|
|
*/
|
2002-05-28 05:40:08 +08:00
|
|
|
pi = rpmtsiInit(ts);
|
|
|
|
while ((p = rpmtsiNext(pi, 0)) != NULL) {
|
|
|
|
if ((fi = rpmtsiFi(pi)) == NULL)
|
2001-11-12 06:51:00 +08:00
|
|
|
continue; /* XXX can't happen */
|
2002-05-20 02:42:25 +08:00
|
|
|
if (rpmfiFC(fi) == 0)
|
1999-08-14 04:05:57 +08:00
|
|
|
continue;
|
2001-02-20 01:12:21 +08:00
|
|
|
fi->fps = _free(fi->fps);
|
1999-03-21 05:09:47 +08:00
|
|
|
}
|
2002-05-28 05:40:08 +08:00
|
|
|
pi = rpmtsiFree(pi);
|
1999-02-21 11:34:52 +08:00
|
|
|
|
2002-05-18 05:08:39 +08:00
|
|
|
fpc = fpCacheFree(fpc);
|
|
|
|
ts->ht = htFree(ts->ht);
|
1999-10-20 18:22:46 +08:00
|
|
|
|
1999-08-14 04:05:57 +08:00
|
|
|
/* ===============================================
|
|
|
|
* If unfiltered problems exist, free memory and return.
|
|
|
|
*/
|
2002-05-20 07:37:24 +08:00
|
|
|
if ((rpmtsFlags(ts) & RPMTRANS_FLAG_BUILD_PROBS)
|
2001-10-30 00:35:01 +08:00
|
|
|
|| (ts->probs->numProblems &&
|
2002-05-20 02:42:25 +08:00
|
|
|
(okProbs != NULL || rpmpsTrim(ts->probs, okProbs)))
|
2001-10-30 00:35:01 +08:00
|
|
|
)
|
2001-05-23 22:25:19 +08:00
|
|
|
{
|
1999-07-14 22:36:10 +08:00
|
|
|
return ts->orderCount;
|
|
|
|
}
|
1999-02-21 11:34:52 +08:00
|
|
|
|
2001-02-12 06:02:29 +08:00
|
|
|
/* ===============================================
|
|
|
|
* Save removed files before erasing.
|
|
|
|
*/
|
2002-05-20 07:37:24 +08:00
|
|
|
if (rpmtsFlags(ts) & (RPMTRANS_FLAG_DIRSTASH | RPMTRANS_FLAG_REPACKAGE)) {
|
2002-08-05 00:55:55 +08:00
|
|
|
int progress;
|
2003-03-26 07:51:24 +08:00
|
|
|
|
2002-08-05 00:55:55 +08:00
|
|
|
progress = 0;
|
2002-05-28 05:40:08 +08:00
|
|
|
pi = rpmtsiInit(ts);
|
|
|
|
while ((p = rpmtsiNext(pi, 0)) != NULL) {
|
2002-09-01 06:39:34 +08:00
|
|
|
|
|
|
|
(void) rpmdbCheckSignals();
|
|
|
|
|
2002-08-20 06:27:44 +08:00
|
|
|
if ((fi = rpmtsiFi(pi)) == NULL)
|
|
|
|
continue; /* XXX can't happen */
|
2002-05-20 02:42:25 +08:00
|
|
|
switch (rpmteType(p)) {
|
2001-02-12 06:02:29 +08:00
|
|
|
case TR_ADDED:
|
2001-10-14 06:01:38 +08:00
|
|
|
/*@switchbreak@*/ break;
|
2001-02-12 06:02:29 +08:00
|
|
|
case TR_REMOVED:
|
2002-05-20 07:37:24 +08:00
|
|
|
if (!(rpmtsFlags(ts) & RPMTRANS_FLAG_REPACKAGE))
|
2001-11-12 00:17:57 +08:00
|
|
|
/*@switchbreak@*/ break;
|
2002-08-05 00:55:55 +08:00
|
|
|
if (!progress)
|
|
|
|
NOTIFY(ts, (NULL, RPMCALLBACK_REPACKAGE_START,
|
|
|
|
7, numRemoved, NULL, ts->notifyData));
|
|
|
|
|
|
|
|
NOTIFY(ts, (NULL, RPMCALLBACK_REPACKAGE_PROGRESS, progress,
|
2003-01-02 01:26:46 +08:00
|
|
|
numRemoved, NULL, ts->notifyData));
|
2002-08-05 00:55:55 +08:00
|
|
|
progress++;
|
|
|
|
|
2003-04-09 05:42:55 +08:00
|
|
|
(void) rpmswEnter(rpmtsOp(ts, RPMTS_OP_REPACKAGE), 0);
|
2003-03-26 07:51:24 +08:00
|
|
|
|
2002-07-26 07:36:32 +08:00
|
|
|
/* XXX TR_REMOVED needs CPIO_MAP_{ABSOLUTE,ADDDOT} CPIO_ALL_HARDLINKS */
|
2002-08-20 06:27:44 +08:00
|
|
|
fi->mapflags |= CPIO_MAP_ABSOLUTE;
|
|
|
|
fi->mapflags |= CPIO_MAP_ADDDOT;
|
|
|
|
fi->mapflags |= CPIO_ALL_HARDLINKS;
|
|
|
|
psm = rpmpsmNew(ts, p, fi);
|
|
|
|
xx = rpmpsmStage(psm, PSM_PKGSAVE);
|
|
|
|
psm = rpmpsmFree(psm);
|
|
|
|
fi->mapflags &= ~CPIO_MAP_ABSOLUTE;
|
|
|
|
fi->mapflags &= ~CPIO_MAP_ADDDOT;
|
|
|
|
fi->mapflags &= ~CPIO_ALL_HARDLINKS;
|
|
|
|
|
2003-04-09 05:42:55 +08:00
|
|
|
(void) rpmswExit(rpmtsOp(ts, RPMTS_OP_REPACKAGE), 0);
|
2003-03-26 07:51:24 +08:00
|
|
|
|
2001-10-14 06:01:38 +08:00
|
|
|
/*@switchbreak@*/ break;
|
2001-02-12 06:02:29 +08:00
|
|
|
}
|
|
|
|
}
|
2002-05-28 05:40:08 +08:00
|
|
|
pi = rpmtsiFree(pi);
|
2002-08-05 00:55:55 +08:00
|
|
|
if (progress) {
|
|
|
|
NOTIFY(ts, (NULL, RPMCALLBACK_REPACKAGE_STOP, 7, numRemoved,
|
|
|
|
NULL, ts->notifyData));
|
|
|
|
}
|
2001-02-12 06:02:29 +08:00
|
|
|
}
|
|
|
|
|
1999-08-07 07:44:25 +08:00
|
|
|
/* ===============================================
|
|
|
|
* Install and remove packages.
|
|
|
|
*/
|
2002-08-20 06:27:44 +08:00
|
|
|
lastFailKey = (alKey)-2; /* erased packages have -1 */
|
2002-05-28 05:40:08 +08:00
|
|
|
pi = rpmtsiInit(ts);
|
2001-10-29 06:17:47 +08:00
|
|
|
/*@-branchstate@*/ /* FIX: fi reload needs work */
|
2002-05-28 05:40:08 +08:00
|
|
|
while ((p = rpmtsiNext(pi, 0)) != NULL) {
|
2001-11-12 00:17:57 +08:00
|
|
|
alKey pkgKey;
|
2001-01-21 23:43:32 +08:00
|
|
|
int gotfd;
|
|
|
|
|
2002-09-01 06:39:34 +08:00
|
|
|
(void) rpmdbCheckSignals();
|
|
|
|
|
2001-01-21 23:43:32 +08:00
|
|
|
gotfd = 0;
|
2002-05-28 05:40:08 +08:00
|
|
|
if ((fi = rpmtsiFi(pi)) == NULL)
|
2001-11-12 06:51:00 +08:00
|
|
|
continue; /* XXX can't happen */
|
2001-11-12 00:17:57 +08:00
|
|
|
|
2002-08-20 06:27:44 +08:00
|
|
|
psm = rpmpsmNew(ts, p, fi);
|
2003-04-03 05:16:26 +08:00
|
|
|
assert(psm != NULL);
|
2002-08-20 06:27:44 +08:00
|
|
|
psm->unorderedSuccessor =
|
|
|
|
(rpmtsiOc(pi) >= rpmtsUnorderedSuccessors(ts, -1) ? 1 : 0);
|
|
|
|
|
2002-05-20 02:42:25 +08:00
|
|
|
switch (rpmteType(p)) {
|
1999-08-14 04:05:57 +08:00
|
|
|
case TR_ADDED:
|
2003-04-09 05:42:55 +08:00
|
|
|
(void) rpmswEnter(rpmtsOp(ts, RPMTS_OP_INSTALL), 0);
|
2001-10-31 02:00:21 +08:00
|
|
|
|
2002-05-20 02:42:25 +08:00
|
|
|
pkgKey = rpmteAddedKey(p);
|
1999-02-21 11:34:52 +08:00
|
|
|
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmMessage(RPMMESS_DEBUG, "========== +++ %s\n", rpmteNEVR(p));
|
2002-05-20 07:37:24 +08:00
|
|
|
p->h = NULL;
|
2002-05-20 02:42:25 +08:00
|
|
|
/*@-type@*/ /* FIX: rpmte not opaque */
|
2001-11-12 04:45:20 +08:00
|
|
|
{
|
2001-11-17 03:26:33 +08:00
|
|
|
/*@-noeffectuncon@*/ /* FIX: notify annotations */
|
2002-08-21 06:05:18 +08:00
|
|
|
p->fd = ts->notify(p->h, RPMCALLBACK_INST_OPEN_FILE, 0, 0,
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmteKey(p), ts->notifyData);
|
2001-11-17 03:26:33 +08:00
|
|
|
/*@=noeffectuncon@*/
|
2002-05-20 02:42:25 +08:00
|
|
|
if (rpmteFd(p) != NULL) {
|
2002-08-06 09:41:44 +08:00
|
|
|
rpmVSFlags ovsflags = rpmtsVSFlags(ts);
|
|
|
|
rpmVSFlags vsflags = ovsflags | RPMVSF_NEEDPAYLOAD;
|
2001-02-13 03:02:15 +08:00
|
|
|
rpmRC rpmrc;
|
1999-02-21 11:34:52 +08:00
|
|
|
|
2002-08-06 09:41:44 +08:00
|
|
|
ovsflags = rpmtsSetVSFlags(ts, vsflags);
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmrc = rpmReadPackageFile(ts, rpmteFd(p),
|
2002-08-03 05:52:01 +08:00
|
|
|
rpmteNEVR(p), &p->h);
|
2002-08-06 09:41:44 +08:00
|
|
|
vsflags = rpmtsSetVSFlags(ts, ovsflags);
|
2001-10-28 04:09:20 +08:00
|
|
|
|
2002-08-24 05:01:59 +08:00
|
|
|
switch (rpmrc) {
|
|
|
|
default:
|
2001-11-17 03:26:33 +08:00
|
|
|
/*@-noeffectuncon@*/ /* FIX: notify annotations */
|
2002-08-21 06:05:18 +08:00
|
|
|
p->fd = ts->notify(p->h, RPMCALLBACK_INST_CLOSE_FILE,
|
2001-10-31 02:00:21 +08:00
|
|
|
0, 0,
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmteKey(p), ts->notifyData);
|
2001-11-17 03:26:33 +08:00
|
|
|
/*@=noeffectuncon@*/
|
2001-11-12 00:17:57 +08:00
|
|
|
p->fd = NULL;
|
1999-07-14 22:36:10 +08:00
|
|
|
ourrc++;
|
2002-08-24 05:01:59 +08:00
|
|
|
/*@innerbreak@*/ 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:
|
|
|
|
/*@innerbreak@*/ break;
|
2001-11-12 04:45:20 +08:00
|
|
|
}
|
2002-05-20 02:42:25 +08:00
|
|
|
if (rpmteFd(p) != NULL) gotfd = 1;
|
1999-05-18 02:44:14 +08:00
|
|
|
}
|
|
|
|
}
|
2001-11-17 03:26:33 +08:00
|
|
|
/*@=type@*/
|
1999-07-14 22:36:10 +08:00
|
|
|
|
2002-05-20 02:42:25 +08:00
|
|
|
if (rpmteFd(p) != NULL) {
|
2002-08-20 06:27:44 +08:00
|
|
|
/*
|
|
|
|
* XXX Sludge necessary to tranfer existing fstates/actions
|
|
|
|
* XXX around a recreated file info set.
|
|
|
|
*/
|
|
|
|
psm->fi = rpmfiFree(psm->fi);
|
2001-11-12 04:45:20 +08:00
|
|
|
{
|
2002-08-20 06:27:44 +08:00
|
|
|
char * fstates = fi->fstates;
|
|
|
|
fileAction * actions = fi->actions;
|
2002-12-28 08:24:14 +08:00
|
|
|
rpmte savep;
|
2002-08-20 06:27:44 +08:00
|
|
|
|
|
|
|
fi->fstates = NULL;
|
|
|
|
fi->actions = NULL;
|
2003-04-03 05:16:26 +08:00
|
|
|
/*@-nullstate@*/ /* FIX: fi->actions is NULL */
|
2002-08-20 06:27:44 +08:00
|
|
|
fi = rpmfiFree(fi);
|
2003-04-03 05:16:26 +08:00
|
|
|
/*@=nullstate@*/
|
2002-12-28 08:24:14 +08:00
|
|
|
|
|
|
|
savep = rpmtsSetRelocateElement(ts, p);
|
2002-08-20 06:27:44 +08:00
|
|
|
fi = rpmfiNew(ts, p->h, RPMTAG_BASENAMES, 1);
|
2002-12-28 08:24:14 +08:00
|
|
|
(void) rpmtsSetRelocateElement(ts, savep);
|
|
|
|
|
2002-08-21 06:05:18 +08:00
|
|
|
if (fi != NULL) { /* XXX can't happen */
|
|
|
|
fi->te = p;
|
|
|
|
fi->fstates = _free(fi->fstates);
|
|
|
|
fi->fstates = fstates;
|
|
|
|
fi->actions = _free(fi->actions);
|
|
|
|
fi->actions = actions;
|
|
|
|
p->fi = fi;
|
|
|
|
}
|
2001-01-25 05:35:52 +08:00
|
|
|
}
|
2002-08-20 06:27:44 +08:00
|
|
|
psm->fi = rpmfiLink(p->fi, NULL);
|
|
|
|
|
|
|
|
/*@-nullstate@*/ /* FIX: psm->fi may be NULL */
|
|
|
|
if (rpmpsmStage(psm, PSM_PKGINSTALL)) {
|
1999-07-14 22:36:10 +08:00
|
|
|
ourrc++;
|
2002-08-20 06:27:44 +08:00
|
|
|
lastFailKey = pkgKey;
|
1999-07-14 22:36:10 +08:00
|
|
|
}
|
2002-08-20 06:27:44 +08:00
|
|
|
/*@=nullstate@*/
|
1999-07-14 22:36:10 +08:00
|
|
|
} else {
|
|
|
|
ourrc++;
|
2002-08-20 06:27:44 +08:00
|
|
|
lastFailKey = pkgKey;
|
1999-02-21 11:34:52 +08:00
|
|
|
}
|
|
|
|
|
2001-01-21 23:43:32 +08:00
|
|
|
if (gotfd) {
|
2001-10-16 22:58:57 +08:00
|
|
|
/*@-noeffectuncon @*/ /* FIX: check rc */
|
2002-08-21 06:05:18 +08:00
|
|
|
(void) ts->notify(p->h, RPMCALLBACK_INST_CLOSE_FILE, 0, 0,
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmteKey(p), ts->notifyData);
|
2001-10-16 22:58:57 +08:00
|
|
|
/*@=noeffectuncon @*/
|
2001-11-17 03:26:33 +08:00
|
|
|
/*@-type@*/
|
2001-11-12 00:17:57 +08:00
|
|
|
p->fd = NULL;
|
2001-11-17 03:26:33 +08:00
|
|
|
/*@=type@*/
|
2001-01-21 23:43:32 +08:00
|
|
|
}
|
2002-08-21 06:05:18 +08:00
|
|
|
|
|
|
|
p->h = headerFree(p->h);
|
|
|
|
|
2003-04-09 05:42:55 +08:00
|
|
|
(void) rpmswExit(rpmtsOp(ts, RPMTS_OP_INSTALL), 0);
|
2003-03-26 07:51:24 +08:00
|
|
|
|
2001-10-14 06:01:38 +08:00
|
|
|
/*@switchbreak@*/ break;
|
2003-03-26 07:51:24 +08:00
|
|
|
|
1999-08-14 04:05:57 +08:00
|
|
|
case TR_REMOVED:
|
2003-04-09 05:42:55 +08:00
|
|
|
(void) rpmswEnter(rpmtsOp(ts, RPMTS_OP_ERASE), 0);
|
2003-03-26 07:51:24 +08:00
|
|
|
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmMessage(RPMMESS_DEBUG, "========== --- %s\n", rpmteNEVR(p));
|
2002-08-20 06:27:44 +08:00
|
|
|
/*
|
|
|
|
* XXX This has always been a hack, now mostly broken.
|
|
|
|
* If install failed, then we shouldn't erase.
|
|
|
|
*/
|
|
|
|
if (rpmteDependsOnKey(p) != lastFailKey) {
|
|
|
|
if (rpmpsmStage(psm, PSM_PKGERASE))
|
2001-10-19 00:39:54 +08:00
|
|
|
ourrc++;
|
|
|
|
}
|
2003-03-26 07:51:24 +08:00
|
|
|
|
2003-04-09 05:42:55 +08:00
|
|
|
(void) rpmswExit(rpmtsOp(ts, RPMTS_OP_ERASE), 0);
|
2003-03-26 07:51:24 +08:00
|
|
|
|
2001-10-14 06:01:38 +08:00
|
|
|
/*@switchbreak@*/ break;
|
1999-07-14 22:36:10 +08:00
|
|
|
}
|
2002-05-18 05:08:39 +08:00
|
|
|
xx = rpmdbSync(rpmtsGetRdb(ts));
|
2002-08-20 06:27:44 +08:00
|
|
|
|
|
|
|
/*@-nullstate@*/ /* FIX: psm->fi may be NULL */
|
|
|
|
psm = rpmpsmFree(psm);
|
|
|
|
/*@=nullstate@*/
|
|
|
|
|
2002-05-17 00:55:21 +08:00
|
|
|
/*@-type@*/ /* FIX: p is almost opaque */
|
2002-08-21 06:05:18 +08:00
|
|
|
p->fi = rpmfiFree(p->fi);
|
2002-05-17 00:55:21 +08:00
|
|
|
/*@=type@*/
|
2002-08-20 06:27:44 +08:00
|
|
|
|
1999-02-21 11:34:52 +08:00
|
|
|
}
|
2001-10-29 06:17:47 +08:00
|
|
|
/*@=branchstate@*/
|
2002-05-28 05:40:08 +08:00
|
|
|
pi = rpmtsiFree(pi);
|
1999-02-21 11:34:52 +08:00
|
|
|
|
2001-10-31 02:00:21 +08:00
|
|
|
/*@-nullstate@*/ /* FIX: ts->flList may be NULL */
|
1999-08-07 05:35:15 +08:00
|
|
|
if (ourrc)
|
1999-07-14 22:36:10 +08:00
|
|
|
return -1;
|
|
|
|
else
|
|
|
|
return 0;
|
2001-05-04 05:00:18 +08:00
|
|
|
/*@=nullstate@*/
|
1999-02-21 11:34:52 +08:00
|
|
|
}
|