2000-08-28 03:40:35 +08:00
|
|
|
/** \ingroup rpmtrans
|
|
|
|
* \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 */
|
|
|
|
|
2001-09-26 04:51:34 +08:00
|
|
|
#include "psm.h"
|
2001-11-04 23:43:26 +08:00
|
|
|
|
2002-04-12 00:55:19 +08:00
|
|
|
#include "rpmds.h"
|
|
|
|
#include "rpmfi.h"
|
|
|
|
#include "rpmte.h"
|
|
|
|
#include "rpmts.h"
|
|
|
|
|
2002-02-01 23:19:44 +08:00
|
|
|
#include "rpmdb.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
|
|
|
|
1999-03-23 02:36:23 +08:00
|
|
|
/* XXX FIXME: merge with existing (broken?) tests in system.h */
|
1999-04-04 01:13:35 +08:00
|
|
|
/* portability fiddles */
|
1999-04-17 07:05:00 +08:00
|
|
|
#if STATFS_IN_SYS_STATVFS
|
2001-10-15 11:22:10 +08:00
|
|
|
/*@-incondefs@*/
|
1999-04-17 07:05:00 +08:00
|
|
|
# include <sys/statvfs.h>
|
2001-10-14 03:35:58 +08:00
|
|
|
#if defined(__LCLINT__)
|
2001-10-16 01:53:34 +08:00
|
|
|
/*@-declundef -exportheader -protoparammatch @*/ /* LCL: missing annotation */
|
2001-10-14 03:35:58 +08:00
|
|
|
extern int statvfs (const char * file, /*@out@*/ struct statvfs * buf)
|
2001-10-19 00:39:54 +08:00
|
|
|
/*@globals fileSystem @*/
|
2001-10-14 03:35:58 +08:00
|
|
|
/*@modifies *buf, fileSystem @*/;
|
2001-10-16 01:53:34 +08:00
|
|
|
/*@=declundef =exportheader =protoparammatch @*/
|
2001-10-15 11:22:10 +08:00
|
|
|
/*@=incondefs@*/
|
2001-10-14 03:35:58 +08:00
|
|
|
#endif
|
1999-03-23 02:36:23 +08:00
|
|
|
#else
|
1999-04-17 07:05:00 +08:00
|
|
|
# if STATFS_IN_SYS_VFS
|
|
|
|
# include <sys/vfs.h>
|
1999-03-23 02:36:23 +08:00
|
|
|
# else
|
1999-04-17 07:05:00 +08:00
|
|
|
# if STATFS_IN_SYS_MOUNT
|
|
|
|
# include <sys/mount.h>
|
|
|
|
# else
|
|
|
|
# if STATFS_IN_SYS_STATFS
|
|
|
|
# include <sys/statfs.h>
|
|
|
|
# endif
|
1999-03-23 02:36:23 +08:00
|
|
|
# endif
|
|
|
|
# endif
|
|
|
|
#endif
|
1999-03-19 11:39:17 +08:00
|
|
|
|
2000-12-13 04:03:45 +08:00
|
|
|
#include "debug.h"
|
|
|
|
|
2001-11-10 04:41:18 +08:00
|
|
|
/*@access FD_t @*/ /* XXX compared with NULL */
|
|
|
|
/*@access Header @*/ /* XXX compared with NULL */
|
|
|
|
/*@access rpmProblemSet @*/ /* XXX need rpmProblemSetOK() */
|
|
|
|
/*@access dbiIndexSet @*/
|
|
|
|
/*@access rpmdb @*/
|
1999-09-18 04:52:46 +08:00
|
|
|
|
2001-11-10 04:41:18 +08:00
|
|
|
/*@access PSM_t @*/
|
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
|
|
|
|
2001-11-10 04:41:18 +08:00
|
|
|
/*@access TFI_t @*/
|
|
|
|
|
|
|
|
/*@access teIterator @*/
|
|
|
|
/*@access rpmTransactionSet @*/
|
2001-10-29 06:17:47 +08:00
|
|
|
|
2001-09-26 04:51:34 +08:00
|
|
|
/**
|
|
|
|
*/
|
1999-03-19 11:39:17 +08:00
|
|
|
struct diskspaceInfo {
|
2001-11-11 03:24:19 +08:00
|
|
|
dev_t dev; /*!< File system device number. */
|
|
|
|
signed long bneeded; /*!< No. of blocks needed. */
|
|
|
|
signed long ineeded; /*!< No. of inodes needed. */
|
|
|
|
int bsize; /*!< File system block size. */
|
|
|
|
signed long bavail; /*!< No. of blocks available. */
|
|
|
|
signed long iavail; /*!< No. of inodes available. */
|
1999-03-19 11:39:17 +08:00
|
|
|
};
|
|
|
|
|
2001-09-26 04:51:34 +08:00
|
|
|
/**
|
|
|
|
* Adjust for root only reserved space. On linux e2fs, this is 5%.
|
|
|
|
*/
|
1999-04-19 04:56:19 +08:00
|
|
|
#define adj_fs_blocks(_nb) (((_nb) * 21) / 20)
|
|
|
|
|
1999-08-07 05:35:15 +08:00
|
|
|
/* argon thought a shift optimization here was a waste of time... he's
|
1999-03-19 11:39:17 +08:00
|
|
|
probably right :-( */
|
|
|
|
#define BLOCK_ROUND(size, block) (((size) + (block) - 1) / (block))
|
|
|
|
|
1999-07-14 22:36:10 +08:00
|
|
|
void rpmtransSetScriptFd(rpmTransactionSet ts, FD_t fd)
|
|
|
|
{
|
1999-12-08 05:14:51 +08:00
|
|
|
ts->scriptFd = (fd ? fdLink(fd, "rpmtransSetScriptFd") : NULL);
|
1999-07-14 22:36:10 +08:00
|
|
|
}
|
1999-02-23 08:56:32 +08:00
|
|
|
|
2001-11-08 08:12:49 +08:00
|
|
|
int rpmtransGetKeys(const rpmTransactionSet ts, fnpyKey ** ep, int * nep)
|
2000-12-13 04:03:45 +08:00
|
|
|
{
|
|
|
|
int rc = 0;
|
|
|
|
|
|
|
|
if (nep) *nep = ts->orderCount;
|
|
|
|
if (ep) {
|
2001-11-12 00:17:57 +08:00
|
|
|
teIterator pi; transactionElement p;
|
2001-11-08 08:12:49 +08:00
|
|
|
fnpyKey * e;
|
2000-12-13 04:03:45 +08:00
|
|
|
|
|
|
|
*ep = e = xmalloc(ts->orderCount * sizeof(*e));
|
2001-11-12 00:17:57 +08:00
|
|
|
pi = teInitIterator(ts);
|
|
|
|
while ((p = teNextIterator(pi)) != NULL) {
|
2001-11-17 03:26:33 +08:00
|
|
|
switch (teGetType(p)) {
|
2000-12-13 04:03:45 +08:00
|
|
|
case TR_ADDED:
|
2001-11-13 04:51:05 +08:00
|
|
|
/*@-dependenttrans@*/
|
2001-11-17 03:26:33 +08:00
|
|
|
*e = teGetKey(p);
|
2001-11-13 04:51:05 +08:00
|
|
|
/*@=dependenttrans@*/
|
2001-10-30 07:39:51 +08:00
|
|
|
/*@switchbreak@*/ break;
|
2000-12-13 04:03:45 +08:00
|
|
|
case TR_REMOVED:
|
2001-11-12 00:17:57 +08:00
|
|
|
default:
|
2000-12-13 04:03:45 +08:00
|
|
|
*e = NULL;
|
2001-10-14 06:01:38 +08:00
|
|
|
/*@switchbreak@*/ break;
|
2000-12-13 04:03:45 +08:00
|
|
|
}
|
2001-11-12 00:17:57 +08:00
|
|
|
e++;
|
2000-12-13 04:03:45 +08:00
|
|
|
}
|
2001-11-12 00:17:57 +08:00
|
|
|
pi = teFreeIterator(pi);
|
2000-12-13 04:03:45 +08:00
|
|
|
}
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
/**
|
|
|
|
*/
|
2001-11-19 01:49:21 +08:00
|
|
|
static fileAction decideFileFate(const rpmTransactionSet ts,
|
|
|
|
const TFI_t ofi, TFI_t nfi)
|
2001-10-19 00:39:54 +08:00
|
|
|
/*@globals fileSystem @*/
|
2001-11-19 01:49:21 +08:00
|
|
|
/*@modifies nfi, fileSystem @*/
|
1999-07-14 22:36:10 +08:00
|
|
|
{
|
2001-11-19 01:49:21 +08:00
|
|
|
const char * fn = tfiGetFN(nfi);
|
|
|
|
int newFlags = tfiGetFFlags(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.
|
|
|
|
*/
|
2001-11-19 01:49:21 +08:00
|
|
|
if (!(ts->transFlags & RPMTRANS_FLAG_ALLFILES)
|
|
|
|
&& (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
|
|
|
|
1999-07-14 22:36:10 +08:00
|
|
|
diskWhat = whatis(sb.st_mode);
|
2001-11-19 01:49:21 +08:00
|
|
|
dbWhat = whatis(ofi->fmodes[ofi->i]);
|
|
|
|
newWhat = whatis(nfi->fmodes[nfi->i]);
|
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-04-15 05:48:44 +08:00
|
|
|
#ifdef DYING
|
2001-11-19 01:49:21 +08:00
|
|
|
if (ofi->md5s != NULL && nfi->md5s != NULL) {
|
2002-04-15 05:48:44 +08:00
|
|
|
#endif
|
2001-11-19 01:49:21 +08:00
|
|
|
const unsigned char * omd5 = ofi->md5s + (16 * ofi->i);
|
|
|
|
const unsigned char * nmd5 = nfi->md5s + (16 * nfi->i);
|
|
|
|
if (domd5(fn, buffer, 0))
|
|
|
|
return FA_CREATE; /* assume file has been removed */
|
|
|
|
if (!memcmp(omd5, buffer, 16))
|
|
|
|
return FA_CREATE; /* unmodified config file, replace. */
|
|
|
|
if (!memcmp(omd5, nmd5, 16))
|
|
|
|
return FA_SKIP; /* identical file, don't bother. */
|
2002-04-15 05:48:44 +08:00
|
|
|
#ifdef DYING
|
2001-11-19 01:49:21 +08:00
|
|
|
} else {
|
|
|
|
const char * omd5 = ofi->fmd5s[ofi->i];
|
|
|
|
const char * nmd5 = nfi->fmd5s[nfi->i];
|
|
|
|
if (domd5(fn, buffer, 1))
|
|
|
|
return FA_CREATE; /* assume file has been removed */
|
|
|
|
if (!strcmp(omd5, buffer))
|
|
|
|
return FA_CREATE; /* unmodified config file, replace. */
|
|
|
|
if (!strcmp(omd5, nmd5))
|
|
|
|
return FA_SKIP; /* identical file, don't bother. */
|
1999-07-14 22:36:10 +08:00
|
|
|
}
|
2002-04-15 05:48:44 +08:00
|
|
|
#endif
|
1999-07-14 22:36:10 +08:00
|
|
|
} else /* dbWhat == LINK */ {
|
|
|
|
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 */
|
|
|
|
if (!strcmp(ofi->flinks[ofi->i], buffer))
|
|
|
|
return FA_CREATE; /* unmodified config file, replace. */
|
|
|
|
if (!strcmp(ofi->flinks[ofi->i], nfi->flinks[nfi->i]))
|
|
|
|
return FA_SKIP; /* identical file, don't bother. */
|
1999-07-14 22:36:10 +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
|
|
|
}
|
|
|
|
|
2001-09-26 04:51:34 +08:00
|
|
|
/**
|
|
|
|
*/
|
2001-11-19 01:49:21 +08:00
|
|
|
static int filecmp(TFI_t afi, TFI_t bfi)
|
2001-06-06 03:26:22 +08:00
|
|
|
/*@*/
|
1999-07-14 22:36:10 +08:00
|
|
|
{
|
2001-11-19 01:49:21 +08:00
|
|
|
fileTypes awhat = whatis(afi->fmodes[afi->i]);
|
|
|
|
fileTypes bwhat = whatis(bfi->fmodes[bfi->i]);
|
|
|
|
|
|
|
|
if (awhat != bwhat) return 1;
|
|
|
|
|
|
|
|
if (awhat == LINK) {
|
|
|
|
const char * alink = afi->flinks[afi->i];
|
|
|
|
const char * blink = bfi->flinks[bfi->i];
|
|
|
|
return strcmp(alink, blink);
|
|
|
|
} else if (awhat == REG) {
|
2002-04-15 05:48:44 +08:00
|
|
|
#ifdef DYING
|
2001-11-19 01:49:21 +08:00
|
|
|
if (afi->md5s != NULL && bfi->md5s != NULL) {
|
2002-04-15 05:48:44 +08:00
|
|
|
#endif
|
2001-11-19 01:49:21 +08:00
|
|
|
const unsigned char * amd5 = afi->md5s + (16 * afi->i);
|
|
|
|
const unsigned char * bmd5 = bfi->md5s + (16 * bfi->i);
|
|
|
|
return memcmp(amd5, bmd5, 16);
|
2002-04-15 05:48:44 +08:00
|
|
|
#ifdef DYING
|
2001-11-19 01:49:21 +08:00
|
|
|
} else {
|
|
|
|
const char * amd5 = afi->fmd5s[afi->i];
|
|
|
|
const char * bmd5 = bfi->fmd5s[bfi->i];
|
|
|
|
return strcmp(amd5, bmd5);
|
|
|
|
}
|
2002-04-15 05:48:44 +08:00
|
|
|
#endif
|
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
|
|
|
}
|
|
|
|
|
2001-09-26 04:51:34 +08:00
|
|
|
/**
|
|
|
|
*/
|
2001-10-19 09:24:21 +08:00
|
|
|
/* XXX only ts->{probs,rpmdb} modified */
|
2001-11-12 00:17:57 +08:00
|
|
|
static int handleInstInstalledFiles(const rpmTransactionSet ts,
|
|
|
|
transactionElement p, TFI_t fi,
|
2001-11-11 20:47:08 +08:00
|
|
|
sharedFileInfo shared,
|
2001-10-19 00:39:54 +08:00
|
|
|
int sharedCount, int reportConflicts)
|
|
|
|
/*@globals fileSystem @*/
|
|
|
|
/*@modifies ts, fi, fileSystem @*/
|
1999-07-14 22:36:10 +08:00
|
|
|
{
|
2001-11-19 01:49:21 +08:00
|
|
|
const char * altNEVR = NULL;
|
|
|
|
TFI_t otherFi = NULL;
|
1999-07-14 22:36:10 +08:00
|
|
|
int numReplaced = 0;
|
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);
|
|
|
|
otherFi = fiNew(ts, NULL, h, RPMTAG_BASENAMES, scareMem);
|
|
|
|
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
|
|
|
|
2001-11-19 01:49:21 +08:00
|
|
|
if (otherFi == NULL)
|
|
|
|
return 1;
|
1999-01-06 11:16:35 +08:00
|
|
|
|
2001-11-14 08:14:01 +08:00
|
|
|
fi->replaced = xcalloc(sharedCount, sizeof(*fi->replaced));
|
1998-12-19 03:09:38 +08:00
|
|
|
|
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;
|
2001-11-14 08:14:01 +08:00
|
|
|
|
1999-07-14 22:36:10 +08:00
|
|
|
otherFileNum = shared->otherFileNum;
|
2001-11-19 01:49:21 +08:00
|
|
|
(void) tfiSetFX(otherFi, otherFileNum);
|
1999-08-14 04:05:57 +08:00
|
|
|
|
2001-11-19 01:49:21 +08:00
|
|
|
fileNum = shared->pkgFileNum;
|
2001-11-14 08:14:01 +08:00
|
|
|
(void) tfiSetFX(fi, fileNum);
|
|
|
|
|
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)) {
|
2001-11-10 01:22:08 +08:00
|
|
|
if (reportConflicts) {
|
2001-10-31 02:00:21 +08:00
|
|
|
rpmProblemSetAppend(ts->probs, RPMPROB_FILE_CONFLICT,
|
2001-11-17 03:26:33 +08:00
|
|
|
teGetNEVR(p), teGetKey(p),
|
2001-11-14 08:14:01 +08:00
|
|
|
tfiGetDN(fi), tfiGetBN(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
|
|
|
}
|
2001-11-19 01:49:21 +08:00
|
|
|
if (!(tfiGetFFlags(otherFi) | tfiGetFFlags(fi)) & RPMFILE_CONFIG) {
|
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
|
|
|
|
2001-11-19 01:49:21 +08:00
|
|
|
if ((tfiGetFFlags(otherFi) | tfiGetFFlags(fi)) & RPMFILE_CONFIG) {
|
|
|
|
fileAction action;
|
|
|
|
action = decideFileFate(ts, otherFi, fi);
|
|
|
|
fi->actions[fileNum] = action;
|
1998-12-19 03:09:38 +08:00
|
|
|
}
|
2001-11-19 01:49:21 +08:00
|
|
|
fi->replacedSizes[fileNum] = otherFi->fsizes[otherFi->i];
|
1999-08-14 04:05:57 +08:00
|
|
|
|
1998-12-19 03:09:38 +08:00
|
|
|
}
|
|
|
|
|
2001-11-19 01:49:21 +08:00
|
|
|
altNEVR = _free(altNEVR);
|
|
|
|
otherFi = fiFree(otherFi, 1);
|
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
|
|
|
}
|
|
|
|
|
2001-09-26 04:51:34 +08:00
|
|
|
/**
|
|
|
|
*/
|
2001-10-19 09:24:21 +08:00
|
|
|
/* XXX only ts->rpmdb modified */
|
2001-10-19 00:39:54 +08:00
|
|
|
static int handleRmvdInstalledFiles(const rpmTransactionSet ts, TFI_t fi,
|
2001-11-11 20:47:08 +08:00
|
|
|
sharedFileInfo shared, int sharedCount)
|
2001-10-19 00:39:54 +08:00
|
|
|
/*@globals fileSystem @*/
|
2001-11-13 04:51:05 +08:00
|
|
|
/*@modifies ts, fi, fileSystem @*/
|
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
|
|
|
|
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
|
|
|
}
|
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@*/
|
|
|
|
static int _fps_debug = 0;
|
|
|
|
|
|
|
|
static int fpsCompare (const void * one, const void * two)
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
|
|
|
|
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++;
|
|
|
|
|
|
|
|
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)
|
|
|
|
fprintf(stderr, "*** NULL %s/%s%s\n",
|
|
|
|
ISROOT(fiFps->entry->dirName),
|
|
|
|
(fiFps->subDir ? fiFps->subDir : ""),
|
|
|
|
fiFps->baseName);
|
|
|
|
/*@=modfilesys@*/
|
|
|
|
}
|
|
|
|
|
|
|
|
return otherFileNum;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
const struct fingerPrint_s * bingoFps;
|
|
|
|
|
|
|
|
bingoFps = bsearch(fiFps, otherFps, otherFc, sizeof(*otherFps), fpsCompare);
|
|
|
|
if (bingoFps == NULL) {
|
|
|
|
/*@-modfilesys@*/
|
|
|
|
fprintf(stderr, "*** NULL %s/%s%s\n",
|
|
|
|
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@*/
|
|
|
|
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
|
|
|
/**
|
|
|
|
* Update disk space needs on each partition for this package.
|
|
|
|
*/
|
2001-10-19 09:24:21 +08:00
|
|
|
/* XXX only ts->{probs,di} modified */
|
2001-11-12 00:17:57 +08:00
|
|
|
static void handleOverlappedFiles(const rpmTransactionSet ts,
|
|
|
|
const transactionElement p, TFI_t fi)
|
2001-10-19 00:39:54 +08:00
|
|
|
/*@globals fileSystem @*/
|
|
|
|
/*@modifies ts, fi, fileSystem @*/
|
1999-07-14 22:36:10 +08:00
|
|
|
{
|
|
|
|
struct diskspaceInfo * ds = NULL;
|
|
|
|
uint_32 fixupSize = 0;
|
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
|
|
|
|
2001-11-14 08:14:01 +08:00
|
|
|
fi = tfiInit(fi, 0);
|
2002-03-13 00:56:17 +08:00
|
|
|
if (fi != NULL) /* XXX lclint */
|
2001-11-14 08:14:01 +08:00
|
|
|
while ((i = tfiNext(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;
|
2001-11-16 08:26:30 +08:00
|
|
|
TFI_t otherFi;
|
2001-01-21 23:43:32 +08:00
|
|
|
const TFI_t * 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
|
|
|
|
2001-11-14 08:14:01 +08:00
|
|
|
fn = tfiGetFN(fi);
|
2001-11-16 02:22:33 +08:00
|
|
|
fiFps = fi->fps + i;
|
1999-10-20 18:22:46 +08:00
|
|
|
|
2001-10-30 00:35:01 +08:00
|
|
|
if (ts->di) {
|
|
|
|
ds = ts->di;
|
2000-10-21 00:47:00 +08:00
|
|
|
while (ds->bsize && ds->dev != fi->fps[i].entry->dev) ds++;
|
|
|
|
if (!ds->bsize) ds = NULL;
|
1999-07-14 22:36:10 +08:00
|
|
|
fixupSize = 0;
|
1999-08-07 05:35:15 +08:00
|
|
|
}
|
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.
|
|
|
|
* 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. */
|
2001-11-17 03:26:33 +08:00
|
|
|
if (teGetType(p) == TR_ADDED && teGetType(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;
|
2001-11-16 08:26:30 +08:00
|
|
|
otherFc = tfiGetFC(otherFi);
|
2000-06-17 03:12:09 +08:00
|
|
|
|
2001-11-16 02:22:33 +08:00
|
|
|
otherFileNum = findFps(fiFps, otherFps, otherFc);
|
2001-11-19 01:49:21 +08:00
|
|
|
(void) tfiSetFX(otherFi, otherFileNum);
|
2000-06-17 03:12:09 +08:00
|
|
|
|
1999-08-18 07:05:24 +08:00
|
|
|
/* XXX is this test still necessary? */
|
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
|
|
|
}
|
|
|
|
|
2001-11-17 03:26:33 +08:00
|
|
|
switch (teGetType(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;
|
2001-11-19 01:49:21 +08:00
|
|
|
if ((tfiGetFFlags(fi) & RPMFILE_CONFIG) &&
|
2001-11-14 08:14:01 +08:00
|
|
|
!lstat(fn, &sb)) {
|
1999-08-18 07:05:24 +08:00
|
|
|
/* Here is a non-overlapped pre-existing config file. */
|
2001-11-19 01:49:21 +08:00
|
|
|
fi->actions[i] = (tfiGetFFlags(fi) & 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. */
|
2001-10-30 00:35:01 +08:00
|
|
|
if ((ts->ignoreSet & RPMPROB_FILTER_REPLACENEWFILES)
|
2001-11-19 01:49:21 +08:00
|
|
|
&& filecmp(otherFi, fi))
|
2001-10-31 02:00:21 +08:00
|
|
|
{
|
|
|
|
rpmProblemSetAppend(ts->probs, RPMPROB_NEW_FILE_CONFLICT,
|
2001-11-17 03:26:33 +08:00
|
|
|
teGetNEVR(p), teGetKey(p),
|
2001-11-14 08:14:01 +08:00
|
|
|
fn, NULL,
|
2001-11-17 03:26:33 +08:00
|
|
|
teGetNEVR(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. */
|
2001-11-16 08:26:30 +08:00
|
|
|
fixupSize = otherFi->fsizes[otherFileNum];
|
1998-12-19 03:09:38 +08:00
|
|
|
|
2001-11-19 01:49:21 +08:00
|
|
|
if ((tfiGetFFlags(fi) & RPMFILE_CONFIG) && !lstat(fn, &sb)) {
|
1999-08-18 07:05:24 +08:00
|
|
|
/* Here is an overlapped pre-existing config file. */
|
2001-11-19 01:49:21 +08:00
|
|
|
fi->actions[i] = (tfiGetFFlags(fi) & 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;
|
2001-05-06 03:28:32 +08:00
|
|
|
if (fi->fstates && fi->fstates[i] != RPMFILE_STATE_NORMAL)
|
2001-10-14 06:01:38 +08:00
|
|
|
/*@switchbreak@*/ break;
|
2001-11-19 01:49:21 +08:00
|
|
|
if (!(S_ISREG(fi->fmodes[i]) && (tfiGetFFlags(fi) & 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-04-15 05:48:44 +08:00
|
|
|
#ifdef DYING
|
2001-11-19 01:49:21 +08:00
|
|
|
if (fi->md5s != NULL) {
|
2002-04-15 05:48:44 +08:00
|
|
|
#endif
|
|
|
|
const unsigned char * md5 = fi->md5s + (16 * i);
|
|
|
|
if (!domd5(fn, md5sum, 0) && memcmp(md5, md5sum, 16)) {
|
2001-11-19 01:49:21 +08:00
|
|
|
fi->actions[i] = FA_BACKUP;
|
|
|
|
/*@switchbreak@*/ break;
|
|
|
|
}
|
2002-04-15 05:48:44 +08:00
|
|
|
#ifdef DYING
|
2001-11-19 01:49:21 +08:00
|
|
|
} else {
|
|
|
|
const char * fmd5 = fi->fmd5s[i];
|
|
|
|
if (!domd5(fn, md5sum, 1) && strcmp(fmd5, md5sum)) {
|
|
|
|
fi->actions[i] = FA_BACKUP;
|
|
|
|
/*@switchbreak@*/ break;
|
|
|
|
}
|
1999-07-14 22:36:10 +08:00
|
|
|
}
|
2002-04-15 05:48:44 +08:00
|
|
|
#endif
|
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
|
|
|
}
|
1998-12-19 03:09:38 +08:00
|
|
|
|
1999-07-14 22:36:10 +08:00
|
|
|
if (ds) {
|
2000-10-21 00:47:00 +08:00
|
|
|
uint_32 s = BLOCK_ROUND(fi->fsizes[i], ds->bsize);
|
1998-12-19 03:09:38 +08:00
|
|
|
|
1999-07-14 22:36:10 +08:00
|
|
|
switch (fi->actions[i]) {
|
|
|
|
case FA_BACKUP:
|
|
|
|
case FA_SAVE:
|
|
|
|
case FA_ALTNAME:
|
2000-10-21 00:47:00 +08:00
|
|
|
ds->ineeded++;
|
|
|
|
ds->bneeded += s;
|
2001-10-14 06:01:38 +08:00
|
|
|
/*@switchbreak@*/ break;
|
1998-12-19 03:09:38 +08:00
|
|
|
|
2001-02-12 06:02:29 +08:00
|
|
|
/*
|
2001-04-03 21:41:56 +08:00
|
|
|
* FIXME: If two packages share a file (same md5sum), and
|
2000-10-21 00:47:00 +08:00
|
|
|
* that file is being replaced on disk, will ds->bneeded get
|
|
|
|
* decremented twice? Quite probably!
|
|
|
|
*/
|
1999-07-14 22:36:10 +08:00
|
|
|
case FA_CREATE:
|
2000-10-21 00:47:00 +08:00
|
|
|
ds->bneeded += s;
|
|
|
|
ds->bneeded -= BLOCK_ROUND(fi->replacedSizes[i], ds->bsize);
|
2001-10-14 06:01:38 +08:00
|
|
|
/*@switchbreak@*/ break;
|
1998-12-19 03:09:38 +08:00
|
|
|
|
2001-02-09 05:50:38 +08:00
|
|
|
case FA_ERASE:
|
2000-10-21 00:47:00 +08:00
|
|
|
ds->ineeded--;
|
|
|
|
ds->bneeded -= s;
|
2001-10-14 06:01:38 +08:00
|
|
|
/*@switchbreak@*/ break;
|
1998-12-19 03:09:38 +08:00
|
|
|
|
1999-07-14 22:36:10 +08:00
|
|
|
default:
|
2001-10-14 06:01:38 +08:00
|
|
|
/*@switchbreak@*/ break;
|
1999-07-14 22:36:10 +08:00
|
|
|
}
|
1998-12-19 03:09:38 +08:00
|
|
|
|
2000-10-21 00:47:00 +08:00
|
|
|
ds->bneeded -= BLOCK_ROUND(fixupSize, ds->bsize);
|
1998-12-19 03:09:38 +08:00
|
|
|
}
|
|
|
|
}
|
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
|
|
|
*/
|
2001-10-31 02:00:21 +08:00
|
|
|
static int ensureOlder(rpmTransactionSet ts,
|
2001-11-11 09:46:43 +08:00
|
|
|
const transactionElement 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;
|
|
|
|
rpmDepSet 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;
|
|
|
|
|
2001-11-17 03:26:33 +08:00
|
|
|
nb = strlen(teGetNEVR(p)) + (teGetE(p) != NULL ? strlen(teGetE(p)) : 0) + 1;
|
|
|
|
t = alloca(nb);
|
2001-11-11 03:24:19 +08:00
|
|
|
*t = '\0';
|
|
|
|
reqEVR = t;
|
2001-11-17 03:26:33 +08:00
|
|
|
if (teGetE(p) != NULL) t = stpcpy( stpcpy(t, teGetE(p)), ":");
|
|
|
|
if (teGetV(p) != NULL) t = stpcpy(t, teGetV(p));
|
2001-11-11 03:24:19 +08:00
|
|
|
*t++ = '-';
|
2001-11-17 03:26:33 +08:00
|
|
|
if (teGetR(p) != NULL) t = stpcpy(t, teGetR(p));
|
2001-11-11 03:24:19 +08:00
|
|
|
|
2001-11-17 03:26:33 +08:00
|
|
|
req = dsSingle(RPMTAG_REQUIRENAME, teGetN(p), reqEVR, reqFlags);
|
2001-11-11 03:24:19 +08:00
|
|
|
rc = headerMatchesDepFlags(h, req);
|
2001-11-11 08:11:33 +08:00
|
|
|
req = dsFree(req);
|
2001-11-11 03:24:19 +08:00
|
|
|
|
|
|
|
if (rc == 0) {
|
|
|
|
const char * altNEVR = hGetNEVR(h, NULL);
|
|
|
|
rpmProblemSetAppend(ts->probs, RPMPROB_OLDPACKAGE,
|
2001-11-17 03:26:33 +08:00
|
|
|
teGetNEVR(p), teGetKey(p),
|
2001-11-11 03:24:19 +08:00
|
|
|
NULL, NULL,
|
|
|
|
altNEVR,
|
|
|
|
0);
|
|
|
|
altNEVR = _free(altNEVR);
|
|
|
|
rc = 1;
|
|
|
|
} else
|
|
|
|
rc = 0;
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
1999-01-01 03:16:31 +08:00
|
|
|
|
2001-09-26 04:51:34 +08:00
|
|
|
/**
|
|
|
|
*/
|
2001-11-16 08:26:30 +08:00
|
|
|
/*@-mustmod@*/ /* FIX: fi->actions is modified. */
|
2001-01-24 00:07:28 +08:00
|
|
|
static void skipFiles(const rpmTransactionSet ts, TFI_t 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
|
|
|
{
|
2001-01-24 00:07:28 +08:00
|
|
|
int noDocs = (ts->transFlags & 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. */
|
2001-11-16 08:26:30 +08:00
|
|
|
dc = tfiGetDC(fi);
|
|
|
|
drc = alloca(dc * sizeof(*drc));
|
|
|
|
memset(drc, 0, dc * sizeof(*drc));
|
|
|
|
dff = alloca(dc * sizeof(*dff));
|
|
|
|
memset(dff, 0, dc * sizeof(*dff));
|
|
|
|
|
2002-03-13 00:56:17 +08:00
|
|
|
fi = tfiInit(fi, 0);
|
|
|
|
if (fi != NULL) /* XXX lclint */
|
2001-11-16 08:26:30 +08:00
|
|
|
while ((i = tfiNext(fi)) >= 0)
|
|
|
|
{
|
1999-08-07 08:07:51 +08:00
|
|
|
char **nsp;
|
|
|
|
|
2001-11-16 08:26:30 +08:00
|
|
|
bn = tfiGetBN(fi);
|
|
|
|
bnlen = strlen(bn);
|
|
|
|
ix = tfiGetDX(fi);
|
|
|
|
dn = tfiGetDN(fi);
|
|
|
|
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])) {
|
2001-04-04 04:41:09 +08:00
|
|
|
drc[ix]--;
|
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
|
|
|
|
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.
|
|
|
|
*/
|
2001-01-24 00:07:28 +08:00
|
|
|
if (fi->flangs && languages && *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
|
|
|
|
1999-08-07 08:07:51 +08:00
|
|
|
/*
|
|
|
|
* Skip documentation if requested.
|
|
|
|
*/
|
2001-11-19 01:49:21 +08:00
|
|
|
if (noDocs && (tfiGetFFlags(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
|
|
|
|
if ((fi = tdiInit(fi)) != NULL)
|
|
|
|
while (j = tdiNext(fi) >= 0)
|
|
|
|
#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-03-13 00:56:17 +08:00
|
|
|
fi = tfiInit(fi, 0);
|
|
|
|
if (fi != NULL) /* XXX lclint */
|
2001-11-16 21:58:21 +08:00
|
|
|
while ((i = tfiNext(fi)) >= 0) {
|
2001-04-03 21:41:56 +08:00
|
|
|
const char * dir;
|
|
|
|
|
|
|
|
if (XFA_SKIPPING(fi->actions[i]))
|
2001-10-14 06:01:38 +08:00
|
|
|
/*@innercontinue@*/ continue;
|
2001-04-03 21:41:56 +08:00
|
|
|
if (whatis(fi->fmodes[i]) != XDIR)
|
2001-10-14 06:01:38 +08:00
|
|
|
/*@innercontinue@*/ continue;
|
2001-04-03 21:41:56 +08:00
|
|
|
dir = fi->dnl[fi->dil[i]];
|
|
|
|
if (strlen(dir) != dnlen)
|
2001-10-14 06:01:38 +08:00
|
|
|
/*@innercontinue@*/ continue;
|
2001-04-03 21:41:56 +08:00
|
|
|
if (strncmp(dir, dn, dnlen))
|
2001-10-14 06:01:38 +08:00
|
|
|
/*@innercontinue@*/ continue;
|
2001-04-03 21:41:56 +08:00
|
|
|
if (strlen(fi->bnl[i]) != bnlen)
|
2001-10-14 06:01:38 +08:00
|
|
|
/*@innercontinue@*/ continue;
|
2001-04-03 21:41:56 +08:00
|
|
|
if (strncmp(fi->bnl[i], 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
|
|
|
|
|
|
|
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);
|
1999-07-14 22:36:10 +08:00
|
|
|
}
|
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.
|
|
|
|
* @todo Take a TFI_t refcount here.
|
|
|
|
* @param tei transaction element iterator
|
|
|
|
* @return transaction element file info
|
|
|
|
*/
|
|
|
|
static /*@null@*/
|
2001-11-17 03:26:33 +08:00
|
|
|
TFI_t teiGetFi(const teIterator tei)
|
|
|
|
/*@*/
|
2001-11-14 08:14:01 +08:00
|
|
|
{
|
|
|
|
TFI_t fi = NULL;
|
|
|
|
|
|
|
|
if (tei != NULL && tei->ocsave != -1) {
|
2001-11-17 03:26:33 +08:00
|
|
|
/*@-type -abstract@*/ /* FIX: transactionElement not opaque */
|
2001-11-17 06:42:19 +08:00
|
|
|
transactionElement te = tei->ts->order[tei->ocsave];
|
|
|
|
/*@-assignexpose@*/
|
2001-11-14 08:14:01 +08:00
|
|
|
if ((fi = te->fi) != NULL)
|
|
|
|
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 @*/
|
|
|
|
}
|
|
|
|
|
2000-10-21 06:04:27 +08:00
|
|
|
#define NOTIFY(_ts, _al) if ((_ts)->notify) (void) (_ts)->notify _al
|
1999-01-01 03:16:31 +08:00
|
|
|
|
2000-08-30 06:04:33 +08:00
|
|
|
int rpmRunTransactions( rpmTransactionSet ts,
|
2002-04-14 02:52:18 +08:00
|
|
|
rpmProblemSet okProbs,
|
2002-03-17 23:49:09 +08:00
|
|
|
rpmprobFilterFlags ignoreSet)
|
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;
|
2001-02-18 01:53:21 +08:00
|
|
|
TFI_t fi;
|
2001-01-27 01:06:09 +08:00
|
|
|
struct diskspaceInfo * dip;
|
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;
|
2001-11-12 00:17:57 +08:00
|
|
|
alKey lastKey;
|
1999-10-20 18:22:46 +08:00
|
|
|
fingerPrintCache fpc;
|
2001-11-12 00:17:57 +08:00
|
|
|
PSM_t psm = memset(alloca(sizeof(*psm)), 0, sizeof(*psm));
|
|
|
|
teIterator pi; transactionElement p;
|
|
|
|
teIterator qi; transactionElement q;
|
2001-10-16 22:58:57 +08:00
|
|
|
int xx;
|
2001-11-05 11:44:05 +08:00
|
|
|
|
1999-07-14 22:36:10 +08:00
|
|
|
/* FIXME: what if the same package is included in ts twice? */
|
1999-01-01 03:16:31 +08:00
|
|
|
|
2001-03-04 23:34:53 +08:00
|
|
|
if (ts->transFlags & RPMTRANS_FLAG_NOSCRIPTS)
|
|
|
|
ts->transFlags |= (_noTransScripts | _noTransTriggers);
|
|
|
|
if (ts->transFlags & RPMTRANS_FLAG_NOTRIGGERS)
|
|
|
|
ts->transFlags |= _noTransTriggers;
|
2001-01-25 05:35:52 +08:00
|
|
|
|
|
|
|
/* XXX MULTILIB is broken, as packages can and do execute /sbin/ldconfig. */
|
|
|
|
if (ts->transFlags & (RPMTRANS_FLAG_JUSTDB | RPMTRANS_FLAG_MULTILIB))
|
2001-03-04 23:34:53 +08:00
|
|
|
ts->transFlags |= (_noTransScripts | _noTransTriggers);
|
2001-01-25 05:35:52 +08:00
|
|
|
|
2001-11-13 06:54:39 +08:00
|
|
|
ts->probs = rpmProblemSetFree(ts->probs);
|
|
|
|
ts->probs = rpmProblemSetCreate();
|
2000-10-21 06:04:27 +08:00
|
|
|
ts->ignoreSet = ignoreSet;
|
2001-04-04 04:41:09 +08:00
|
|
|
ts->currDir = _free(ts->currDir);
|
2000-07-09 23:17:11 +08:00
|
|
|
ts->currDir = currentDirectory();
|
2000-12-20 01:43:56 +08:00
|
|
|
ts->chrootDone = 0;
|
2001-07-28 08:33:07 +08:00
|
|
|
if (ts->rpmdb) ts->rpmdb->db_chrootDone = 0;
|
2001-08-03 13:04:13 +08:00
|
|
|
ts->id = (int_32) time(NULL);
|
2000-07-09 23:17:11 +08:00
|
|
|
|
2001-02-28 06:08:53 +08:00
|
|
|
memset(psm, 0, sizeof(*psm));
|
2001-10-29 06:17:47 +08:00
|
|
|
psm->ts = rpmtsLink(ts, "tsRun");
|
2001-02-28 06:08:53 +08:00
|
|
|
|
2000-10-21 00:47:00 +08:00
|
|
|
/* Get available space on mounted file systems. */
|
2000-10-21 06:04:27 +08:00
|
|
|
if (!(ts->ignoreSet & RPMPROB_FILTER_DISKSPACE) &&
|
2001-11-13 04:51:05 +08:00
|
|
|
!rpmGetFilesystemList(&ts->filesystems, &ts->filesystemCount))
|
|
|
|
{
|
1999-07-14 22:36:10 +08:00
|
|
|
struct stat sb;
|
1999-01-01 03:16:31 +08:00
|
|
|
|
2001-11-13 04:51:05 +08:00
|
|
|
rpmMessage(RPMMESS_DEBUG, _("getting list of mounted filesystems\n"));
|
|
|
|
|
2001-04-04 04:41:09 +08:00
|
|
|
ts->di = _free(ts->di);
|
2001-09-25 05:53:14 +08:00
|
|
|
dip = ts->di = xcalloc((ts->filesystemCount + 1), sizeof(*ts->di));
|
1999-01-01 03:16:31 +08:00
|
|
|
|
2001-01-27 01:06:09 +08:00
|
|
|
for (i = 0; (i < ts->filesystemCount) && dip; i++) {
|
1999-07-14 22:36:10 +08:00
|
|
|
#if STATFS_IN_SYS_STATVFS
|
|
|
|
struct statvfs sfb;
|
2000-07-08 04:06:41 +08:00
|
|
|
memset(&sfb, 0, sizeof(sfb));
|
2001-01-27 01:06:09 +08:00
|
|
|
if (statvfs(ts->filesystems[i], &sfb))
|
1999-07-14 22:36:10 +08:00
|
|
|
#else
|
|
|
|
struct statfs sfb;
|
|
|
|
# if STAT_STATFS4
|
2001-06-04 21:55:58 +08:00
|
|
|
/* This platform has the 4-argument version of the statfs call. The last two
|
1999-07-14 22:36:10 +08:00
|
|
|
* should be the size of struct statfs and 0, respectively. The 0 is the
|
|
|
|
* filesystem type, and is always 0 when statfs is called on a mounted
|
|
|
|
* filesystem, as we're doing.
|
|
|
|
*/
|
2000-07-08 04:06:41 +08:00
|
|
|
memset(&sfb, 0, sizeof(sfb));
|
2001-01-27 01:06:09 +08:00
|
|
|
if (statfs(ts->filesystems[i], &sfb, sizeof(sfb), 0))
|
1999-07-14 22:36:10 +08:00
|
|
|
# else
|
2000-07-08 04:06:41 +08:00
|
|
|
memset(&sfb, 0, sizeof(sfb));
|
2001-01-27 01:06:09 +08:00
|
|
|
if (statfs(ts->filesystems[i], &sfb))
|
1999-07-14 22:36:10 +08:00
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
{
|
2001-01-27 01:06:09 +08:00
|
|
|
dip = NULL;
|
1999-07-14 22:36:10 +08:00
|
|
|
} else {
|
2001-01-27 01:06:09 +08:00
|
|
|
ts->di[i].bsize = sfb.f_bsize;
|
|
|
|
ts->di[i].bneeded = 0;
|
|
|
|
ts->di[i].ineeded = 0;
|
1999-07-14 22:36:10 +08:00
|
|
|
#ifdef STATFS_HAS_F_BAVAIL
|
2001-01-27 01:06:09 +08:00
|
|
|
ts->di[i].bavail = sfb.f_bavail;
|
1999-07-14 22:36:10 +08:00
|
|
|
#else
|
|
|
|
/* FIXME: the statfs struct doesn't have a member to tell how many blocks are
|
|
|
|
* available for non-superusers. f_blocks - f_bfree is probably too big, but
|
|
|
|
* it's about all we can do.
|
|
|
|
*/
|
2001-01-27 01:06:09 +08:00
|
|
|
ts->di[i].bavail = sfb.f_blocks - sfb.f_bfree;
|
1999-07-14 22:36:10 +08:00
|
|
|
#endif
|
2000-12-30 05:44:37 +08:00
|
|
|
/* XXX Avoid FAT and other file systems that have not inodes. */
|
2001-01-27 01:06:09 +08:00
|
|
|
ts->di[i].iavail = !(sfb.f_ffree == 0 && sfb.f_files == 0)
|
2000-12-30 05:44:37 +08:00
|
|
|
? sfb.f_ffree : -1;
|
1999-01-01 03:16:31 +08:00
|
|
|
|
2001-10-16 22:58:57 +08:00
|
|
|
xx = stat(ts->filesystems[i], &sb);
|
2001-01-27 01:06:09 +08:00
|
|
|
ts->di[i].dev = sb.st_dev;
|
1999-07-14 22:36:10 +08:00
|
|
|
}
|
|
|
|
}
|
1999-01-05 00:44:20 +08:00
|
|
|
|
2001-01-27 01:06:09 +08:00
|
|
|
if (dip) ts->di[i].bsize = 0;
|
1999-07-14 22:36:10 +08:00
|
|
|
}
|
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.
|
|
|
|
*/
|
1999-07-14 22:36:10 +08:00
|
|
|
/* The ordering doesn't matter here */
|
2001-11-12 00:17:57 +08:00
|
|
|
pi = teInitIterator(ts);
|
|
|
|
while ((p = teNext(pi, TR_ADDED)) != NULL) {
|
2001-10-31 02:00:21 +08:00
|
|
|
rpmdbMatchIterator mi;
|
2001-11-16 08:26:30 +08:00
|
|
|
int fc;
|
|
|
|
|
2001-11-17 03:26:33 +08:00
|
|
|
if ((fi = teiGetFi(pi)) == NULL)
|
2001-11-16 08:26:30 +08:00
|
|
|
continue; /* XXX can't happen */
|
|
|
|
fc = tfiGetFC(fi);
|
2001-10-31 02:00:21 +08:00
|
|
|
|
2001-11-13 06:54:39 +08:00
|
|
|
if (!(ts->ignoreSet & RPMPROB_FILTER_IGNOREARCH))
|
2001-11-17 03:26:33 +08:00
|
|
|
if (!archOkay(teGetA(p)))
|
2001-11-13 06:54:39 +08:00
|
|
|
rpmProblemSetAppend(ts->probs, RPMPROB_BADARCH,
|
2001-11-17 03:26:33 +08:00
|
|
|
teGetNEVR(p), teGetKey(p),
|
|
|
|
teGetA(p), NULL,
|
2001-11-10 01:22:08 +08:00
|
|
|
NULL, 0);
|
1999-01-08 01:06:24 +08:00
|
|
|
|
2001-11-13 06:54:39 +08:00
|
|
|
if (!(ts->ignoreSet & RPMPROB_FILTER_IGNOREOS))
|
2001-11-17 03:26:33 +08:00
|
|
|
if (!osOkay(teGetO(p)))
|
2001-11-13 06:54:39 +08:00
|
|
|
rpmProblemSetAppend(ts->probs, RPMPROB_BADOS,
|
2001-11-17 03:26:33 +08:00
|
|
|
teGetNEVR(p), teGetKey(p),
|
|
|
|
teGetO(p), NULL,
|
2001-11-10 01:22:08 +08:00
|
|
|
NULL, 0);
|
1999-01-05 00:44:20 +08:00
|
|
|
|
2000-10-21 06:04:27 +08:00
|
|
|
if (!(ts->ignoreSet & RPMPROB_FILTER_OLDPACKAGE)) {
|
2001-11-11 03:24:19 +08:00
|
|
|
Header h;
|
2001-11-17 03:26:33 +08:00
|
|
|
mi = rpmtsInitIterator(ts, RPMTAG_NAME, teGetN(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
|
|
|
|
2000-07-09 12:42:12 +08:00
|
|
|
/* XXX multilib should not display "already installed" problems */
|
2001-11-17 03:26:33 +08:00
|
|
|
if (!(ts->ignoreSet & RPMPROB_FILTER_REPLACEPKG) && !teGetMultiLib(p)) {
|
|
|
|
mi = rpmtsInitIterator(ts, RPMTAG_NAME, teGetN(p), 0);
|
2001-11-11 03:24:19 +08:00
|
|
|
xx = rpmdbSetIteratorRE(mi, RPMTAG_VERSION, RPMMIRE_DEFAULT,
|
2001-11-17 03:26:33 +08:00
|
|
|
teGetV(p));
|
2001-11-11 03:24:19 +08:00
|
|
|
xx = rpmdbSetIteratorRE(mi, RPMTAG_RELEASE, RPMMIRE_DEFAULT,
|
2001-11-17 03:26:33 +08:00
|
|
|
teGetR(p));
|
2001-06-15 12:56:33 +08:00
|
|
|
|
2000-04-27 08:10:28 +08:00
|
|
|
while (rpmdbNextIterator(mi) != NULL) {
|
2001-10-31 02:00:21 +08:00
|
|
|
rpmProblemSetAppend(ts->probs, RPMPROB_PKG_INSTALLED,
|
2001-11-17 03:26:33 +08:00
|
|
|
teGetNEVR(p), teGetKey(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
|
|
|
}
|
2001-11-12 00:17:57 +08:00
|
|
|
pi = teFreeIterator(pi);
|
1999-01-05 00:44:20 +08:00
|
|
|
|
2001-11-11 11:15:47 +08:00
|
|
|
/* The ordering doesn't matter here */
|
2001-11-12 00:17:57 +08:00
|
|
|
pi = teInitIterator(ts);
|
|
|
|
while ((p = teNext(pi, TR_REMOVED)) != NULL) {
|
2001-11-16 08:26:30 +08:00
|
|
|
int fc;
|
|
|
|
|
2001-11-17 03:26:33 +08:00
|
|
|
if ((fi = teiGetFi(pi)) == NULL)
|
2001-11-11 11:15:47 +08:00
|
|
|
continue; /* XXX can't happen */
|
2001-11-16 08:26:30 +08:00
|
|
|
fc = tfiGetFC(fi);
|
|
|
|
|
|
|
|
totalFileCount += fc;
|
2001-11-11 11:15:47 +08:00
|
|
|
}
|
2001-11-12 00:17:57 +08:00
|
|
|
pi = teFreeIterator(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.
|
|
|
|
*/
|
2001-11-12 00:17:57 +08:00
|
|
|
pi = teInitIterator(ts);
|
|
|
|
while ((p = teNextIterator(pi)) != NULL) {
|
2001-11-16 08:26:30 +08:00
|
|
|
int fc;
|
2001-11-05 06:00:11 +08:00
|
|
|
|
2001-11-17 03:26:33 +08:00
|
|
|
if ((fi = teiGetFi(pi)) == NULL)
|
2001-11-12 06:51:00 +08:00
|
|
|
continue; /* XXX can't happen */
|
2001-11-16 08:26:30 +08:00
|
|
|
fc = tfiGetFC(fi);
|
2001-11-12 06:51:00 +08:00
|
|
|
|
2002-03-13 00:56:17 +08:00
|
|
|
#ifdef DYING /* XXX W2DO? this is now done in teiGetFi, okay ??? */
|
2001-01-23 03:11:19 +08:00
|
|
|
fi->magic = TFIMAGIC;
|
2001-11-12 00:17:57 +08:00
|
|
|
fi->te = p;
|
2001-11-12 06:51:00 +08:00
|
|
|
#endif
|
2001-10-31 02:00:21 +08:00
|
|
|
|
2001-10-16 03:27:13 +08:00
|
|
|
/*@-branchstate@*/
|
2001-11-17 03:26:33 +08:00
|
|
|
switch (teGetType(p)) {
|
1999-08-14 04:05:57 +08:00
|
|
|
case TR_ADDED:
|
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:
|
2001-11-17 03:26:33 +08:00
|
|
|
fi->record = teGetDBOffset(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
|
|
|
}
|
2001-11-12 00:17:57 +08:00
|
|
|
pi = teFreeIterator(pi);
|
1999-01-05 00:44:20 +08:00
|
|
|
|
2001-01-27 01:06:09 +08:00
|
|
|
if (!ts->chrootDone) {
|
2001-10-16 22:58:57 +08:00
|
|
|
xx = chdir("/");
|
2001-10-14 03:35:58 +08:00
|
|
|
/*@-superuser -noeffect @*/
|
2001-10-16 22:58:57 +08:00
|
|
|
xx = chroot(ts->rootDir);
|
2001-10-14 03:35:58 +08:00
|
|
|
/*@=superuser =noeffect @*/
|
2001-01-27 01:06:09 +08:00
|
|
|
ts->chrootDone = 1;
|
2001-07-28 08:33:07 +08:00
|
|
|
if (ts->rpmdb) ts->rpmdb->db_chrootDone = 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.
|
|
|
|
*/
|
2001-11-12 00:17:57 +08:00
|
|
|
pi = teInitIterator(ts);
|
|
|
|
while ((p = teNextIterator(pi)) != NULL) {
|
2001-11-16 08:26:30 +08:00
|
|
|
int fc;
|
2001-11-12 00:17:57 +08:00
|
|
|
|
2001-11-17 03:26:33 +08:00
|
|
|
if ((fi = teiGetFi(pi)) == NULL)
|
2001-11-12 06:51:00 +08:00
|
|
|
continue; /* XXX can't happen */
|
2001-11-16 08:26:30 +08:00
|
|
|
fc = tfiGetFC(fi);
|
2001-11-12 00:17:57 +08:00
|
|
|
|
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-03-13 00:56:17 +08:00
|
|
|
fi = tfiInit(fi, 0);
|
|
|
|
if (fi != NULL) /* XXX lclint */
|
2001-11-16 21:58:21 +08:00
|
|
|
while ((i = tfiNext(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@*/
|
1999-07-14 22:36:10 +08:00
|
|
|
}
|
2001-11-12 00:17:57 +08:00
|
|
|
pi = teFreeIterator(pi);
|
1999-07-14 22:36:10 +08:00
|
|
|
|
2001-10-16 22:58:57 +08:00
|
|
|
/*@-noeffectuncon @*/ /* FIX: check rc */
|
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));
|
2001-10-16 22:58:57 +08:00
|
|
|
/*@=noeffectuncon@*/
|
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
|
|
|
*/
|
2001-11-12 00:17:57 +08:00
|
|
|
pi = teInitIterator(ts);
|
|
|
|
while ((p = teNextIterator(pi)) != 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
|
|
|
|
2001-11-17 03:26:33 +08:00
|
|
|
if ((fi = teiGetFi(pi)) == NULL)
|
2001-11-12 06:51:00 +08:00
|
|
|
continue; /* XXX can't happen */
|
2001-11-16 08:26:30 +08:00
|
|
|
fc = tfiGetFC(fi);
|
2001-11-12 00:17:57 +08:00
|
|
|
|
2001-10-16 22:58:57 +08:00
|
|
|
/*@-noeffectuncon @*/ /* FIX: check rc */
|
2001-11-17 03:26:33 +08:00
|
|
|
NOTIFY(ts, (NULL, RPMCALLBACK_TRANS_PROGRESS, teiGetOc(pi),
|
2001-11-12 06:51:00 +08:00
|
|
|
ts->orderCount, NULL, ts->notifyData));
|
2001-10-16 22:58:57 +08:00
|
|
|
/*@=noeffectuncon@*/
|
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
|
|
|
|
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));
|
|
|
|
if (rpmdbFindFpList(ts->rpmdb, fi->fps, matches, fc)) {
|
2001-10-29 06:17:47 +08:00
|
|
|
psm->ts = rpmtsUnlink(ts, "tsRun (rpmFindFpList fail)");
|
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-03-13 00:56:17 +08:00
|
|
|
fi = tfiInit(fi, 0);
|
2001-11-16 08:26:30 +08:00
|
|
|
while ((i = tfiNext(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-03-13 00:56:17 +08:00
|
|
|
fi = tfiInit(fi, 0);
|
2001-11-16 21:58:21 +08:00
|
|
|
while ((i = tfiNext(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;
|
2001-11-12 00:17:57 +08:00
|
|
|
qi = teInitIterator(ts);
|
|
|
|
while ((q = teNext(qi, TR_REMOVED)) != NULL) {
|
|
|
|
if (ro == knownBad)
|
|
|
|
/*@innerbreak@*/ break;
|
2001-11-17 03:26:33 +08:00
|
|
|
if (teGetDBOffset(q) == ro)
|
2001-11-12 00:17:57 +08:00
|
|
|
knownBad = ro;
|
1999-01-05 00:44:20 +08:00
|
|
|
}
|
2001-11-12 00:17:57 +08:00
|
|
|
qi = teFreeIterator(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. */
|
2001-11-17 03:26:33 +08:00
|
|
|
switch (teGetType(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,
|
2001-10-19 00:39:54 +08:00
|
|
|
!(beingRemoved || (ts->ignoreSet & 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. */
|
2001-11-17 03:26:33 +08:00
|
|
|
switch (teGetType(p)) {
|
1999-08-14 04:05:57 +08:00
|
|
|
case TR_ADDED:
|
2001-11-16 08:26:30 +08:00
|
|
|
if (!(ts->di && tfiGetFC(fi) > 0))
|
2001-10-14 06:01:38 +08:00
|
|
|
/*@switchbreak@*/ break;
|
2001-01-27 01:06:09 +08:00
|
|
|
for (i = 0; i < ts->filesystemCount; i++) {
|
|
|
|
|
|
|
|
dip = ts->di + i;
|
2000-12-30 05:44:37 +08:00
|
|
|
|
|
|
|
/* XXX Avoid FAT and other file systems that have not inodes. */
|
|
|
|
if (dip->iavail <= 0)
|
2001-10-14 06:01:38 +08:00
|
|
|
/*@innercontinue@*/ continue;
|
2000-12-30 05:44:37 +08:00
|
|
|
|
2001-11-10 01:22:08 +08:00
|
|
|
if (adj_fs_blocks(dip->bneeded) > dip->bavail) {
|
2001-10-31 02:00:21 +08:00
|
|
|
rpmProblemSetAppend(ts->probs, RPMPROB_DISKSPACE,
|
2001-11-17 03:26:33 +08:00
|
|
|
teGetNEVR(p), teGetKey(p),
|
2001-01-27 01:06:09 +08:00
|
|
|
ts->filesystems[i], NULL, NULL,
|
2000-12-30 05:44:37 +08:00
|
|
|
(adj_fs_blocks(dip->bneeded) - dip->bavail) * dip->bsize);
|
2001-11-10 01:22:08 +08:00
|
|
|
}
|
2000-12-30 05:44:37 +08:00
|
|
|
|
2001-11-10 01:22:08 +08:00
|
|
|
if (adj_fs_blocks(dip->ineeded) > dip->iavail) {
|
2001-10-31 02:00:21 +08:00
|
|
|
rpmProblemSetAppend(ts->probs, RPMPROB_DISKNODES,
|
2001-11-17 03:26:33 +08:00
|
|
|
teGetNEVR(p), teGetKey(p),
|
2001-01-27 01:06:09 +08:00
|
|
|
ts->filesystems[i], NULL, NULL,
|
2000-12-30 05:44:37 +08:00
|
|
|
(adj_fs_blocks(dip->ineeded) - dip->iavail));
|
2001-11-10 01:22:08 +08:00
|
|
|
}
|
1999-07-14 22:36:10 +08:00
|
|
|
}
|
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
|
|
|
}
|
1999-02-17 12:32:55 +08:00
|
|
|
}
|
2001-11-12 00:17:57 +08:00
|
|
|
pi = teFreeIterator(pi);
|
1999-02-21 11:34:52 +08:00
|
|
|
|
2001-01-27 01:06:09 +08:00
|
|
|
if (ts->chrootDone) {
|
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 @*/
|
2001-01-27 01:06:09 +08:00
|
|
|
ts->chrootDone = 0;
|
2001-07-28 08:33:07 +08:00
|
|
|
if (ts->rpmdb) ts->rpmdb->db_chrootDone = 0;
|
2001-10-16 22:58:57 +08:00
|
|
|
xx = chdir(ts->currDir);
|
2001-01-27 01:06:09 +08:00
|
|
|
}
|
1999-02-21 11:34:52 +08:00
|
|
|
|
2001-10-16 22:58:57 +08:00
|
|
|
/*@-noeffectuncon @*/ /* FIX: check rc */
|
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));
|
2001-10-16 22:58:57 +08:00
|
|
|
/*@=noeffectuncon @*/
|
2001-04-30 06:43:01 +08:00
|
|
|
|
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
|
|
|
*/
|
2001-11-12 00:17:57 +08:00
|
|
|
pi = teInitIterator(ts);
|
|
|
|
while ((p = teNextIterator(pi)) != NULL) {
|
2001-11-17 03:26:33 +08:00
|
|
|
if ((fi = teiGetFi(pi)) == NULL)
|
2001-11-12 06:51:00 +08:00
|
|
|
continue; /* XXX can't happen */
|
2001-11-16 08:26:30 +08:00
|
|
|
if (tfiGetFC(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
|
|
|
}
|
2001-11-12 00:17:57 +08:00
|
|
|
pi = teFreeIterator(pi);
|
1999-02-21 11:34:52 +08:00
|
|
|
|
1999-10-20 18:22:46 +08:00
|
|
|
fpCacheFree(fpc);
|
2001-10-19 00:39:54 +08:00
|
|
|
htFree(ts->ht);
|
|
|
|
ts->ht = NULL;
|
1999-10-20 18:22:46 +08:00
|
|
|
|
1999-08-14 04:05:57 +08:00
|
|
|
/* ===============================================
|
|
|
|
* If unfiltered problems exist, free memory and return.
|
|
|
|
*/
|
2001-10-30 00:35:01 +08:00
|
|
|
if ((ts->transFlags & RPMTRANS_FLAG_BUILD_PROBS)
|
|
|
|
|| (ts->probs->numProblems &&
|
|
|
|
(okProbs != NULL || rpmProblemSetTrim(ts->probs, okProbs)))
|
|
|
|
)
|
2001-05-23 22:25:19 +08:00
|
|
|
{
|
2001-10-31 02:00:21 +08:00
|
|
|
if (psm->ts != NULL)
|
|
|
|
psm->ts = rpmtsUnlink(psm->ts, "tsRun (problems)");
|
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.
|
|
|
|
*/
|
|
|
|
if (ts->transFlags & (RPMTRANS_FLAG_DIRSTASH | RPMTRANS_FLAG_REPACKAGE)) {
|
2001-11-12 00:17:57 +08:00
|
|
|
pi = teInitIterator(ts);
|
|
|
|
while ((p = teNextIterator(pi)) != NULL) {
|
2001-11-17 03:26:33 +08:00
|
|
|
fi = teiGetFi(pi);
|
|
|
|
switch (teGetType(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:
|
2001-11-12 00:17:57 +08:00
|
|
|
if (!(ts->transFlags & RPMTRANS_FLAG_REPACKAGE))
|
|
|
|
/*@switchbreak@*/ break;
|
|
|
|
psm->te = p;
|
|
|
|
psm->fi = rpmfiLink(fi, "tsRepackage");
|
|
|
|
xx = psmStage(psm, PSM_PKGSAVE);
|
|
|
|
(void) rpmfiUnlink(fi, "tsRepackage");
|
|
|
|
psm->fi = NULL;
|
|
|
|
psm->te = NULL;
|
2001-10-14 06:01:38 +08:00
|
|
|
/*@switchbreak@*/ break;
|
2001-02-12 06:02:29 +08:00
|
|
|
}
|
|
|
|
}
|
2001-11-12 00:17:57 +08:00
|
|
|
pi = teFreeIterator(pi);
|
2001-02-12 06:02:29 +08:00
|
|
|
}
|
|
|
|
|
1999-08-07 07:44:25 +08:00
|
|
|
/* ===============================================
|
|
|
|
* Install and remove packages.
|
|
|
|
*/
|
2001-11-05 06:00:11 +08:00
|
|
|
lastKey = (alKey)-2; /* erased packages have -1 */
|
2001-11-12 00:17:57 +08:00
|
|
|
pi = teInitIterator(ts);
|
2001-10-29 06:17:47 +08:00
|
|
|
/*@-branchstate@*/ /* FIX: fi reload needs work */
|
2001-11-12 00:17:57 +08:00
|
|
|
while ((p = teNextIterator(pi)) != NULL) {
|
|
|
|
alKey pkgKey;
|
2001-06-20 04:03:13 +08:00
|
|
|
Header h;
|
2001-01-21 23:43:32 +08:00
|
|
|
int gotfd;
|
|
|
|
|
|
|
|
gotfd = 0;
|
2001-11-17 03:26:33 +08:00
|
|
|
if ((fi = teiGetFi(pi)) == NULL)
|
2001-11-12 06:51:00 +08:00
|
|
|
continue; /* XXX can't happen */
|
2001-11-12 00:17:57 +08:00
|
|
|
|
|
|
|
psm->te = p;
|
2001-10-29 06:17:47 +08:00
|
|
|
psm->fi = rpmfiLink(fi, "tsInstall");
|
2001-11-17 03:26:33 +08:00
|
|
|
switch (teGetType(p)) {
|
1999-08-14 04:05:57 +08:00
|
|
|
case TR_ADDED:
|
2001-10-31 02:00:21 +08:00
|
|
|
|
2001-11-17 03:26:33 +08:00
|
|
|
pkgKey = teGetAddedKey(p);
|
1999-02-21 11:34:52 +08:00
|
|
|
|
2001-11-17 03:26:33 +08:00
|
|
|
rpmMessage(RPMMESS_DEBUG, "========== +++ %s\n", teGetNEVR(p));
|
2001-11-12 04:45:20 +08:00
|
|
|
h = NULL;
|
2001-11-17 03:26:33 +08:00
|
|
|
/*@-type@*/ /* FIX: transactionElement not opaque */
|
2001-11-12 04:45:20 +08:00
|
|
|
{
|
2001-11-17 03:26:33 +08:00
|
|
|
/*@-noeffectuncon@*/ /* FIX: notify annotations */
|
2001-11-12 00:17:57 +08:00
|
|
|
p->fd = ts->notify(fi->h, RPMCALLBACK_INST_OPEN_FILE, 0, 0,
|
2001-11-17 03:26:33 +08:00
|
|
|
teGetKey(p), ts->notifyData);
|
|
|
|
/*@=noeffectuncon@*/
|
|
|
|
if (teGetFd(p) != NULL) {
|
2001-02-13 03:02:15 +08:00
|
|
|
rpmRC rpmrc;
|
1999-02-21 11:34:52 +08:00
|
|
|
|
2001-11-17 03:26:33 +08:00
|
|
|
rpmrc = rpmReadPackageFile(ts, teGetFd(p),
|
2001-10-28 04:09:20 +08:00
|
|
|
"rpmRunTransactions", &h);
|
|
|
|
|
2001-02-13 03:02:15 +08:00
|
|
|
if (!(rpmrc == RPMRC_OK || rpmrc == RPMRC_BADSIZE)) {
|
2001-11-17 03:26:33 +08:00
|
|
|
/*@-noeffectuncon@*/ /* FIX: notify annotations */
|
2001-11-13 06:54:39 +08:00
|
|
|
p->fd = ts->notify(fi->h, RPMCALLBACK_INST_CLOSE_FILE,
|
2001-10-31 02:00:21 +08:00
|
|
|
0, 0,
|
2001-11-17 03:26:33 +08:00
|
|
|
teGetKey(p), ts->notifyData);
|
|
|
|
/*@=noeffectuncon@*/
|
2001-11-12 00:17:57 +08:00
|
|
|
p->fd = NULL;
|
1999-07-14 22:36:10 +08:00
|
|
|
ourrc++;
|
2001-11-12 04:45:20 +08:00
|
|
|
}
|
2001-11-17 03:26:33 +08:00
|
|
|
if (teGetFd(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
|
|
|
|
2001-11-17 03:26:33 +08:00
|
|
|
if (teGetFd(p) != NULL) {
|
2001-11-12 04:45:20 +08:00
|
|
|
{
|
2001-10-19 00:39:54 +08:00
|
|
|
char * fstates = fi->fstates;
|
|
|
|
fileAction * actions = fi->actions;
|
2001-10-31 02:00:21 +08:00
|
|
|
|
2001-10-19 00:39:54 +08:00
|
|
|
fi->fstates = NULL;
|
|
|
|
fi->actions = NULL;
|
2002-05-07 09:07:41 +08:00
|
|
|
psm->fi = fiFree(psm->fi, 1);
|
2001-11-12 04:45:20 +08:00
|
|
|
(void) fiFree(fi, 0);
|
|
|
|
/*@-usereleased@*/
|
2001-10-19 00:39:54 +08:00
|
|
|
fi->magic = TFIMAGIC;
|
2001-11-12 00:17:57 +08:00
|
|
|
fi->te = p;
|
2001-10-19 00:39:54 +08:00
|
|
|
fi->record = 0;
|
2001-11-12 04:45:20 +08:00
|
|
|
(void) fiNew(ts, fi, h, RPMTAG_BASENAMES, 1);
|
2002-05-07 09:07:41 +08:00
|
|
|
psm->fi = rpmfiLink(fi, "tsInstall");
|
2001-10-19 00:39:54 +08:00
|
|
|
fi->fstates = _free(fi->fstates);
|
|
|
|
fi->fstates = fstates;
|
|
|
|
fi->actions = _free(fi->actions);
|
|
|
|
fi->actions = actions;
|
2001-11-12 04:45:20 +08:00
|
|
|
/*@=usereleased@*/
|
2001-10-31 02:00:21 +08:00
|
|
|
|
2001-01-25 05:35:52 +08:00
|
|
|
}
|
2001-11-17 03:26:33 +08:00
|
|
|
if (teGetMultiLib(p))
|
2000-10-21 06:04:27 +08:00
|
|
|
ts->transFlags |= RPMTRANS_FLAG_MULTILIB;
|
2002-03-17 23:49:09 +08:00
|
|
|
else
|
|
|
|
ts->transFlags &= ~RPMTRANS_FLAG_MULTILIB;
|
2000-07-06 04:39:15 +08:00
|
|
|
|
2001-03-03 03:47:45 +08:00
|
|
|
if (psmStage(psm, PSM_PKGINSTALL)) {
|
1999-07-14 22:36:10 +08:00
|
|
|
ourrc++;
|
2001-11-05 06:00:11 +08:00
|
|
|
lastKey = pkgKey;
|
1999-07-14 22:36:10 +08:00
|
|
|
}
|
2001-11-02 04:15:10 +08:00
|
|
|
fi->h = headerFree(fi->h, "TR_ADDED fi->h free");
|
1999-07-14 22:36:10 +08:00
|
|
|
} else {
|
|
|
|
ourrc++;
|
2001-11-05 06:00:11 +08:00
|
|
|
lastKey = pkgKey;
|
1999-02-21 11:34:52 +08:00
|
|
|
}
|
|
|
|
|
2001-11-02 04:15:10 +08:00
|
|
|
h = headerFree(h, "TR_ADDED h free");
|
1999-07-14 22:36:10 +08:00
|
|
|
|
2001-01-21 23:43:32 +08:00
|
|
|
if (gotfd) {
|
2001-10-16 22:58:57 +08:00
|
|
|
/*@-noeffectuncon @*/ /* FIX: check rc */
|
2001-11-17 03:26:33 +08:00
|
|
|
(void) ts->notify(fi->h, RPMCALLBACK_INST_CLOSE_FILE, 0, 0,
|
|
|
|
teGetKey(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
|
|
|
}
|
2001-10-14 06:01:38 +08:00
|
|
|
/*@switchbreak@*/ break;
|
1999-08-14 04:05:57 +08:00
|
|
|
case TR_REMOVED:
|
2001-11-17 03:26:33 +08:00
|
|
|
rpmMessage(RPMMESS_DEBUG, "========== --- %s\n", teGetNEVR(p));
|
2000-08-21 05:39:13 +08:00
|
|
|
/* If install failed, then we shouldn't erase. */
|
2001-11-17 03:26:33 +08:00
|
|
|
if (teGetDependsOnKey(p) != lastKey) {
|
2001-10-19 00:39:54 +08:00
|
|
|
if (psmStage(psm, PSM_PKGERASE))
|
|
|
|
ourrc++;
|
|
|
|
}
|
2001-10-14 06:01:38 +08:00
|
|
|
/*@switchbreak@*/ break;
|
1999-07-14 22:36:10 +08:00
|
|
|
}
|
2001-10-16 22:58:57 +08:00
|
|
|
xx = rpmdbSync(ts->rpmdb);
|
2001-11-12 04:45:20 +08:00
|
|
|
(void) rpmfiUnlink(psm->fi, "tsInstall");
|
2001-10-29 06:17:47 +08:00
|
|
|
psm->fi = NULL;
|
2001-11-12 00:17:57 +08:00
|
|
|
psm->te = NULL;
|
2002-05-07 09:07:41 +08:00
|
|
|
p->fi = fiFree(fi, 1);
|
1999-02-21 11:34:52 +08:00
|
|
|
}
|
2001-10-29 06:17:47 +08:00
|
|
|
/*@=branchstate@*/
|
2001-11-12 00:17:57 +08:00
|
|
|
pi = teFreeIterator(pi);
|
1999-02-21 11:34:52 +08:00
|
|
|
|
2001-10-29 06:17:47 +08:00
|
|
|
psm->ts = rpmtsUnlink(psm->ts, "tsRun");
|
2001-10-28 06:31:10 +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
|
|
|
}
|