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"
|
|
|
|
|
2001-11-11 09:46:43 +08:00
|
|
|
#include <rpmmacro.h> /* XXX for rpmExpand */
|
|
|
|
|
|
|
|
|
2001-11-04 23:43:26 +08:00
|
|
|
#define _NEED_TEITERATOR 1
|
2001-09-26 04:51:34 +08:00
|
|
|
#include "psm.h"
|
2001-11-04 23:43:26 +08:00
|
|
|
|
1998-12-27 02:32:08 +08:00
|
|
|
#include "fprint.h"
|
2001-10-22 05:43:32 +08:00
|
|
|
#include "legacy.h" /* XXX mdfile */
|
2001-06-18 06:18:03 +08:00
|
|
|
#include "misc.h" /* XXX stripTrailingChar, splitString, currentDirectory */
|
1998-12-31 07:03:43 +08:00
|
|
|
#include "rpmdb.h"
|
1998-12-19 03:09:38 +08:00
|
|
|
|
2001-08-03 23:17:55 +08:00
|
|
|
/*@-redecl -exportheadervar@*/
|
2001-10-15 11:22:10 +08:00
|
|
|
/*@unchecked@*/
|
2001-07-28 08:33:07 +08:00
|
|
|
extern const char * chroot_prefix;
|
2001-08-03 23:17:55 +08:00
|
|
|
/*@=redecl =exportheadervar@*/
|
2001-07-28 08:33:07 +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 rpmFNSet @*/
|
|
|
|
/*@access TFI_t @*/
|
|
|
|
|
|
|
|
/*@access teIterator @*/
|
|
|
|
/*@access transactionElement @*/
|
|
|
|
/*@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))
|
|
|
|
|
2001-09-26 04:51:34 +08:00
|
|
|
/**
|
|
|
|
*/
|
2001-06-06 03:26:22 +08:00
|
|
|
static /*@null@*/ void * freeFl(rpmTransactionSet ts,
|
|
|
|
/*@only@*/ /*@null@*/ TFI_t flList)
|
|
|
|
/*@*/
|
1999-03-01 02:36:19 +08:00
|
|
|
{
|
2001-04-30 06:43:01 +08:00
|
|
|
if (flList) {
|
|
|
|
TFI_t fi;
|
|
|
|
int oc;
|
1999-03-01 02:36:19 +08:00
|
|
|
|
2001-10-29 06:17:47 +08:00
|
|
|
/*@-usereleased -onlytrans @*/ /* FIX: fi needs to be only */
|
2001-04-30 06:43:01 +08:00
|
|
|
for (oc = 0, fi = flList; oc < ts->orderCount; oc++, fi++)
|
|
|
|
freeFi(fi);
|
|
|
|
flList = _free(flList);
|
2001-10-29 06:17:47 +08:00
|
|
|
/*@=usereleased =onlytrans @*/
|
1999-03-01 02:36:19 +08:00
|
|
|
}
|
2001-04-30 06:43:01 +08:00
|
|
|
return NULL;
|
1999-03-01 02:36:19 +08:00
|
|
|
}
|
|
|
|
|
1999-07-14 22:36:10 +08:00
|
|
|
void rpmtransSetScriptFd(rpmTransactionSet ts, FD_t fd)
|
|
|
|
{
|
2001-10-17 01:42:18 +08:00
|
|
|
/*@-type@*/ /* FIX: cast? */
|
1999-12-08 05:14:51 +08:00
|
|
|
ts->scriptFd = (fd ? fdLink(fd, "rpmtransSetScriptFd") : NULL);
|
2001-10-17 01:42:18 +08:00
|
|
|
/*@=type@*/
|
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-08 08:12:49 +08:00
|
|
|
fnpyKey * e;
|
2000-12-13 04:03:45 +08:00
|
|
|
int oc;
|
|
|
|
|
|
|
|
*ep = e = xmalloc(ts->orderCount * sizeof(*e));
|
|
|
|
for (oc = 0; oc < ts->orderCount; oc++, e++) {
|
|
|
|
switch (ts->order[oc].type) {
|
|
|
|
case TR_ADDED:
|
2001-11-05 11:44:05 +08:00
|
|
|
*e = ts->order[oc].key;
|
2001-10-30 07:39:51 +08:00
|
|
|
/*@switchbreak@*/ break;
|
2001-06-06 03:26:22 +08:00
|
|
|
default:
|
2000-12-13 04:03:45 +08:00
|
|
|
case TR_REMOVED:
|
2001-06-06 03:26:22 +08:00
|
|
|
/*@-mods@*/ /* FIX: double indirection. */
|
2000-12-13 04:03:45 +08:00
|
|
|
*e = NULL;
|
2001-06-06 03:26:22 +08:00
|
|
|
/*@=mods@*/
|
2001-10-14 06:01:38 +08:00
|
|
|
/*@switchbreak@*/ break;
|
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-01-28 01:42:24 +08:00
|
|
|
static fileAction decideFileFate(const char * dirName,
|
1999-10-20 18:22:46 +08:00
|
|
|
const char * baseName, short dbMode,
|
1999-08-14 04:05:57 +08:00
|
|
|
const char * dbMd5, const char * dbLink, short newMode,
|
|
|
|
const char * newMd5, const char * newLink, int newFlags,
|
2001-09-26 04:51:34 +08:00
|
|
|
rpmtransFlags transFlags)
|
2001-10-19 00:39:54 +08:00
|
|
|
/*@globals fileSystem @*/
|
|
|
|
/*@modifies fileSystem @*/
|
1999-07-14 22:36:10 +08:00
|
|
|
{
|
|
|
|
char buffer[1024];
|
1999-08-14 04:05:57 +08:00
|
|
|
const char * dbAttr, * newAttr;
|
2001-02-11 00:47:40 +08:00
|
|
|
fileTypes dbWhat, newWhat, diskWhat;
|
1999-07-14 22:36:10 +08:00
|
|
|
struct stat sb;
|
|
|
|
int i, rc;
|
|
|
|
int save = (newFlags & RPMFILE_NOREPLACE) ? FA_ALTNAME : FA_SAVE;
|
1999-10-21 10:40:57 +08:00
|
|
|
char * filespec = alloca(strlen(dirName) + strlen(baseName) + 1);
|
1999-10-20 18:22:46 +08:00
|
|
|
|
2000-10-21 00:47:00 +08:00
|
|
|
(void) stpcpy( stpcpy(filespec, dirName), baseName);
|
1998-12-27 02:32:08 +08:00
|
|
|
|
1999-07-14 22:36:10 +08:00
|
|
|
if (lstat(filespec, &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.
|
|
|
|
*/
|
|
|
|
if (!(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"),
|
|
|
|
filespec);
|
|
|
|
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);
|
|
|
|
dbWhat = whatis(dbMode);
|
|
|
|
newWhat = whatis(newMode);
|
1999-01-01 03:16:31 +08:00
|
|
|
|
1999-07-14 22:36:10 +08:00
|
|
|
/* RPM >= 2.3.10 shouldn't create config directories -- we'll ignore
|
|
|
|
them in older packages as well */
|
1999-08-17 06:10:27 +08:00
|
|
|
if (newWhat == XDIR) {
|
1999-07-14 22:36:10 +08:00
|
|
|
return FA_CREATE;
|
1999-08-17 06:10:27 +08:00
|
|
|
}
|
1999-01-01 03:16:31 +08:00
|
|
|
|
1999-07-14 22:36:10 +08:00
|
|
|
if (diskWhat != newWhat) {
|
|
|
|
return save;
|
|
|
|
} else if (newWhat != dbWhat && diskWhat != dbWhat) {
|
|
|
|
return save;
|
|
|
|
} else if (dbWhat != newWhat) {
|
|
|
|
return FA_CREATE;
|
|
|
|
} else if (dbWhat != LINK && dbWhat != REG) {
|
|
|
|
return FA_CREATE;
|
1998-12-19 03:09:38 +08:00
|
|
|
}
|
|
|
|
|
1999-07-14 22:36:10 +08:00
|
|
|
if (dbWhat == REG) {
|
2001-09-26 04:51:34 +08:00
|
|
|
rc = mdfile(filespec, buffer);
|
1999-01-12 11:11:25 +08:00
|
|
|
|
1999-07-14 22:36:10 +08:00
|
|
|
if (rc) {
|
|
|
|
/* assume the file has been removed, don't freak */
|
|
|
|
return FA_CREATE;
|
|
|
|
}
|
|
|
|
dbAttr = dbMd5;
|
|
|
|
newAttr = newMd5;
|
|
|
|
} else /* dbWhat == LINK */ {
|
|
|
|
memset(buffer, 0, sizeof(buffer));
|
|
|
|
i = readlink(filespec, buffer, sizeof(buffer) - 1);
|
|
|
|
if (i == -1) {
|
|
|
|
/* assume the file has been removed, don't freak */
|
|
|
|
return FA_CREATE;
|
|
|
|
}
|
|
|
|
dbAttr = dbLink;
|
|
|
|
newAttr = newLink;
|
|
|
|
}
|
1999-01-01 03:16:31 +08:00
|
|
|
|
1999-08-07 05:35:15 +08:00
|
|
|
/* this order matters - we'd prefer to CREATE the file if at all
|
1999-07-14 22:36:10 +08:00
|
|
|
possible in case something else (like the timestamp) has changed */
|
1999-02-23 06:15:19 +08:00
|
|
|
|
1999-07-14 22:36:10 +08:00
|
|
|
if (!strcmp(dbAttr, buffer)) {
|
1999-09-22 01:21:57 +08:00
|
|
|
/* this config file has never been modified, so just replace it */
|
1999-07-14 22:36:10 +08:00
|
|
|
return FA_CREATE;
|
1999-02-25 07:55:00 +08:00
|
|
|
}
|
1999-03-06 06:41:10 +08:00
|
|
|
|
1999-07-14 22:36:10 +08:00
|
|
|
if (!strcmp(dbAttr, newAttr)) {
|
|
|
|
/* this file is the same in all versions of this package */
|
|
|
|
return FA_SKIP;
|
|
|
|
}
|
1999-03-01 02:36:19 +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
|
|
|
/**
|
|
|
|
*/
|
1999-08-14 04:05:57 +08:00
|
|
|
static int filecmp(short mode1, const char * md51, const char * link1,
|
|
|
|
short mode2, const char * md52, const char * link2)
|
2001-06-06 03:26:22 +08:00
|
|
|
/*@*/
|
1999-07-14 22:36:10 +08:00
|
|
|
{
|
2001-02-11 00:47:40 +08:00
|
|
|
fileTypes what1 = whatis(mode1);
|
|
|
|
fileTypes what2 = whatis(mode2);
|
1998-12-19 03:09:38 +08:00
|
|
|
|
1999-07-14 22:36:10 +08:00
|
|
|
if (what1 != what2) return 1;
|
1998-12-19 03:09:38 +08:00
|
|
|
|
1999-07-14 22:36:10 +08:00
|
|
|
if (what1 == LINK)
|
|
|
|
return strcmp(link1, link2);
|
|
|
|
else if (what1 == REG)
|
|
|
|
return strcmp(md51, md52);
|
|
|
|
|
|
|
|
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-10-19 00:39:54 +08:00
|
|
|
static int handleInstInstalledFiles(const rpmTransactionSet ts, 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-02-05 06:15:30 +08:00
|
|
|
HGE_t hge = fi->hge;
|
2001-05-04 05:00:18 +08:00
|
|
|
HFD_t hfd = (fi->hfd ? fi->hfd : headerFreeData);
|
2001-10-19 00:39:54 +08:00
|
|
|
rpmtransFlags transFlags = ts->transFlags;
|
2001-06-12 12:10:21 +08:00
|
|
|
rpmTagType oltype, omtype;
|
1999-07-14 22:36:10 +08:00
|
|
|
Header h;
|
|
|
|
int i;
|
1999-08-14 04:05:57 +08:00
|
|
|
const char ** otherMd5s;
|
|
|
|
const char ** otherLinks;
|
|
|
|
const char * otherStates;
|
|
|
|
uint_32 * otherFlags;
|
|
|
|
uint_32 * otherSizes;
|
1999-07-14 22:36:10 +08:00
|
|
|
uint_16 * otherModes;
|
|
|
|
int numReplaced = 0;
|
2001-10-16 22:58:57 +08:00
|
|
|
int xx;
|
1998-12-19 03:09:38 +08:00
|
|
|
|
2000-04-27 08:10:28 +08:00
|
|
|
rpmdbMatchIterator mi;
|
|
|
|
|
2001-11-10 01:22:08 +08:00
|
|
|
mi = rpmtsInitIterator(ts, RPMDBI_PACKAGES,
|
|
|
|
&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;
|
|
|
|
}
|
1999-01-06 11:16:35 +08:00
|
|
|
|
2001-10-16 22:58:57 +08:00
|
|
|
xx = hge(h, RPMTAG_FILEMD5S, &omtype, (void **) &otherMd5s, NULL);
|
|
|
|
xx = hge(h, RPMTAG_FILELINKTOS, &oltype, (void **) &otherLinks, NULL);
|
|
|
|
xx = hge(h, RPMTAG_FILESTATES, NULL, (void **) &otherStates, NULL);
|
|
|
|
xx = hge(h, RPMTAG_FILEMODES, NULL, (void **) &otherModes, NULL);
|
|
|
|
xx = hge(h, RPMTAG_FILEFLAGS, NULL, (void **) &otherFlags, NULL);
|
|
|
|
xx = hge(h, RPMTAG_FILESIZES, NULL, (void **) &otherSizes, NULL);
|
1999-01-06 11:16:35 +08:00
|
|
|
|
2001-04-30 06:43:01 +08:00
|
|
|
fi->replaced = xmalloc(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;
|
1999-07-14 22:36:10 +08:00
|
|
|
otherFileNum = shared->otherFileNum;
|
|
|
|
fileNum = shared->pkgFileNum;
|
1999-08-14 04:05:57 +08:00
|
|
|
|
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-01-09 12:07:49 +08:00
|
|
|
if (XFA_SKIPPING(fi->actions[fileNum]))
|
2000-07-06 04:39:15 +08:00
|
|
|
continue;
|
|
|
|
|
1999-08-14 04:05:57 +08:00
|
|
|
if (filecmp(otherModes[otherFileNum],
|
1999-07-14 22:36:10 +08:00
|
|
|
otherMd5s[otherFileNum],
|
|
|
|
otherLinks[otherFileNum],
|
|
|
|
fi->fmodes[fileNum],
|
|
|
|
fi->fmd5s[fileNum],
|
|
|
|
fi->flinks[fileNum])) {
|
2001-10-31 02:00:21 +08:00
|
|
|
/*@-compdef@*/ /* FIX: *fi->replaced undefined */
|
2001-11-10 01:22:08 +08:00
|
|
|
if (reportConflicts) {
|
|
|
|
const char * pkgNEVR = fiGetNEVR(fi);
|
|
|
|
const char * altNEVR = hGetNEVR(h, NULL);
|
2001-10-31 02:00:21 +08:00
|
|
|
rpmProblemSetAppend(ts->probs, RPMPROB_FILE_CONFLICT,
|
2001-11-10 01:22:08 +08:00
|
|
|
pkgNEVR, fi->key,
|
2001-10-31 02:00:21 +08:00
|
|
|
fi->dnl[fi->dil[fileNum]], fi->bnl[fileNum],
|
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
|
|
|
pkgNEVR = _free(pkgNEVR);
|
|
|
|
altNEVR = _free(altNEVR);
|
|
|
|
}
|
2001-10-31 02:00:21 +08:00
|
|
|
/*@=compdef@*/
|
1999-08-14 04:05:57 +08:00
|
|
|
if (!(otherFlags[otherFileNum] | fi->fflags[fileNum])
|
|
|
|
& RPMFILE_CONFIG) {
|
2001-06-06 03:26:22 +08:00
|
|
|
/*@-assignexpose@*/
|
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
|
|
|
|
1999-08-14 04:05:57 +08:00
|
|
|
if ((otherFlags[otherFileNum] | fi->fflags[fileNum]) & RPMFILE_CONFIG) {
|
1999-10-20 18:22:46 +08:00
|
|
|
fi->actions[fileNum] = decideFileFate(
|
|
|
|
fi->dnl[fi->dil[fileNum]],
|
|
|
|
fi->bnl[fileNum],
|
1999-08-07 05:35:15 +08:00
|
|
|
otherModes[otherFileNum],
|
1999-07-14 22:36:10 +08:00
|
|
|
otherMd5s[otherFileNum],
|
|
|
|
otherLinks[otherFileNum],
|
|
|
|
fi->fmodes[fileNum],
|
|
|
|
fi->fmd5s[fileNum],
|
|
|
|
fi->flinks[fileNum],
|
1999-08-07 05:35:15 +08:00
|
|
|
fi->fflags[fileNum],
|
1999-09-22 01:21:57 +08:00
|
|
|
transFlags);
|
1998-12-19 03:09:38 +08:00
|
|
|
}
|
1999-08-14 04:05:57 +08:00
|
|
|
|
|
|
|
fi->replacedSizes[fileNum] = otherSizes[otherFileNum];
|
1998-12-19 03:09:38 +08:00
|
|
|
}
|
|
|
|
|
2001-02-05 06:15:30 +08:00
|
|
|
otherMd5s = hfd(otherMd5s, omtype);
|
|
|
|
otherLinks = hfd(otherLinks, oltype);
|
2001-04-30 06:43:01 +08:00
|
|
|
mi = rpmdbFreeIterator(mi);
|
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-10-28 04:09:20 +08:00
|
|
|
/*@modifies 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
|
|
|
|
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-10-19 00:39:54 +08:00
|
|
|
static void handleOverlappedFiles(const rpmTransactionSet ts, TFI_t fi)
|
|
|
|
/*@globals fileSystem @*/
|
|
|
|
/*@modifies ts, fi, fileSystem @*/
|
1999-07-14 22:36:10 +08:00
|
|
|
{
|
|
|
|
struct diskspaceInfo * ds = NULL;
|
|
|
|
uint_32 fixupSize = 0;
|
1999-10-20 18:22:46 +08:00
|
|
|
char * filespec = NULL;
|
|
|
|
int fileSpecAlloced = 0;
|
2001-10-19 00:39:54 +08:00
|
|
|
int i, j;
|
1999-08-07 05:35:15 +08:00
|
|
|
|
1999-07-14 22:36:10 +08:00
|
|
|
for (i = 0; i < fi->fc; i++) {
|
1999-08-15 04:01:38 +08:00
|
|
|
int otherPkgNum, otherFileNum;
|
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
|
|
|
|
1999-10-21 10:40:57 +08:00
|
|
|
j = strlen(fi->dnl[fi->dil[i]]) + strlen(fi->bnl[i]) + 1;
|
2001-10-16 03:27:13 +08:00
|
|
|
/*@-branchstate@*/
|
1999-10-20 18:22:46 +08:00
|
|
|
if (j > fileSpecAlloced) {
|
|
|
|
fileSpecAlloced = j * 2;
|
|
|
|
filespec = xrealloc(filespec, fileSpecAlloced);
|
|
|
|
}
|
2001-10-16 03:27:13 +08:00
|
|
|
/*@=branchstate@*/
|
1999-10-20 18:22:46 +08:00
|
|
|
|
2000-10-21 00:47:00 +08:00
|
|
|
(void) stpcpy( stpcpy( filespec, fi->dnl[fi->dil[i]]), fi->bnl[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-10-30 00:35:01 +08:00
|
|
|
(void) htGetEntry(ts->ht, &fi->fps[i],
|
|
|
|
(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 */
|
1999-08-14 04:05:57 +08:00
|
|
|
for (otherPkgNum = j - 1; otherPkgNum >= 0; otherPkgNum--) {
|
1999-08-18 07:05:24 +08:00
|
|
|
/* Added packages need only look at other added packages. */
|
|
|
|
if (fi->type == TR_ADDED && recs[otherPkgNum]->type != TR_ADDED)
|
2001-10-14 06:01:38 +08:00
|
|
|
/*@innercontinue@*/ continue;
|
1999-08-14 04:05:57 +08:00
|
|
|
|
|
|
|
/* TESTME: there are more efficient searches in the world... */
|
|
|
|
for (otherFileNum = 0; otherFileNum < recs[otherPkgNum]->fc;
|
|
|
|
otherFileNum++) {
|
2000-06-17 03:12:09 +08:00
|
|
|
|
|
|
|
/* If the addresses are the same, so are the values. */
|
|
|
|
if ((fi->fps + i) == (recs[otherPkgNum]->fps + otherFileNum))
|
2001-06-06 03:26:22 +08:00
|
|
|
/*@innerbreak@*/ break;
|
2000-06-17 03:12:09 +08:00
|
|
|
|
|
|
|
/* Otherwise, compare fingerprints by value. */
|
2001-05-04 05:00:18 +08:00
|
|
|
/*@-nullpass@*/ /* LCL: looks good to me */
|
1999-08-14 04:05:57 +08:00
|
|
|
if (FP_EQUAL(fi->fps[i], recs[otherPkgNum]->fps[otherFileNum]))
|
2001-06-06 03:26:22 +08:00
|
|
|
/*@innerbreak@*/ break;
|
2001-05-04 05:00:18 +08:00
|
|
|
/*@=nullpass@*/
|
2000-06-17 03:12:09 +08:00
|
|
|
|
1998-12-19 03:09:38 +08:00
|
|
|
}
|
1999-08-18 07:05:24 +08:00
|
|
|
/* XXX is this test still necessary? */
|
1999-08-14 04:05:57 +08:00
|
|
|
if (recs[otherPkgNum]->actions[otherFileNum] != FA_UNKNOWN)
|
2001-06-06 03:26:22 +08:00
|
|
|
/*@innerbreak@*/ break;
|
1998-12-19 03:09:38 +08:00
|
|
|
}
|
|
|
|
|
1999-08-14 04:05:57 +08:00
|
|
|
switch (fi->type) {
|
|
|
|
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;
|
1999-10-20 18:22:46 +08:00
|
|
|
if ((fi->fflags[i] & RPMFILE_CONFIG) &&
|
|
|
|
!lstat(filespec, &sb)) {
|
1999-08-18 07:05:24 +08:00
|
|
|
/* Here is a non-overlapped pre-existing config file. */
|
1999-07-14 22:36:10 +08:00
|
|
|
fi->actions[i] = (fi->fflags[i] & RPMFILE_NOREPLACE)
|
|
|
|
? 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
|
|
|
|
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)
|
|
|
|
&& filecmp(recs[otherPkgNum]->fmodes[otherFileNum],
|
1999-07-14 22:36:10 +08:00
|
|
|
recs[otherPkgNum]->fmd5s[otherFileNum],
|
|
|
|
recs[otherPkgNum]->flinks[otherFileNum],
|
|
|
|
fi->fmodes[i],
|
|
|
|
fi->fmd5s[i],
|
2001-10-31 02:00:21 +08:00
|
|
|
fi->flinks[i]))
|
|
|
|
{
|
2001-11-10 01:22:08 +08:00
|
|
|
const char * pkgNEVR = fiGetNEVR(fi);
|
|
|
|
const char * altNEVR = fiGetNEVR(recs[otherPkgNum]);
|
2001-10-31 02:00:21 +08:00
|
|
|
rpmProblemSetAppend(ts->probs, RPMPROB_NEW_FILE_CONFLICT,
|
2001-11-10 01:22:08 +08:00
|
|
|
pkgNEVR, fi->key,
|
2001-10-31 02:00:21 +08:00
|
|
|
filespec, NULL,
|
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
|
|
|
pkgNEVR = _free(pkgNEVR);
|
|
|
|
altNEVR = _free(altNEVR);
|
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. */
|
1999-07-14 22:36:10 +08:00
|
|
|
fixupSize = recs[otherPkgNum]->fsizes[otherFileNum];
|
1998-12-19 03:09:38 +08:00
|
|
|
|
1999-10-20 18:22:46 +08:00
|
|
|
if ((fi->fflags[i] & RPMFILE_CONFIG) && !lstat(filespec, &sb)) {
|
1999-08-18 07:05:24 +08:00
|
|
|
/* Here is an overlapped pre-existing config file. */
|
1999-08-17 06:10:27 +08:00
|
|
|
fi->actions[i] = (fi->fflags[i] & RPMFILE_NOREPLACE)
|
|
|
|
? FA_ALTNAME : FA_SKIP;
|
|
|
|
} else {
|
|
|
|
fi->actions[i] = FA_CREATE;
|
|
|
|
}
|
2001-10-14 06:01:38 +08:00
|
|
|
} /*@switchbreak@*/ break;
|
1999-08-14 04:05:57 +08:00
|
|
|
case TR_REMOVED:
|
1999-08-15 04:01:38 +08:00
|
|
|
if (otherPkgNum >= 0) {
|
2000-10-21 00:47:00 +08:00
|
|
|
/* Here is an overlapped added file we don't want to nuke. */
|
2001-02-09 05:50:38 +08:00
|
|
|
if (recs[otherPkgNum]->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. */
|
1999-08-15 04:01:38 +08:00
|
|
|
recs[otherPkgNum]->actions[otherFileNum] = FA_SKIP;
|
|
|
|
}
|
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;
|
1999-08-15 04:01:38 +08:00
|
|
|
if (!(S_ISREG(fi->fmodes[i]) && (fi->fflags[i] & 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. */
|
1999-08-15 04:01:38 +08:00
|
|
|
{ char mdsum[50];
|
1999-10-20 18:22:46 +08:00
|
|
|
if (!mdfile(filespec, mdsum) && strcmp(fi->fmd5s[i], mdsum)) {
|
1999-08-15 04:01:38 +08:00
|
|
|
fi->actions[i] = FA_BACKUP;
|
2001-10-14 06:01:38 +08:00
|
|
|
/*@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
|
|
|
}
|
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
|
|
|
}
|
|
|
|
}
|
2001-10-31 02:00:21 +08:00
|
|
|
filespec = _free(filespec);
|
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;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
if (p == NULL || h == NULL)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
t = alloca(strlen(p->NEVR) + (p->epoch != NULL ? strlen(p->epoch) : 0) + 1);
|
|
|
|
*t = '\0';
|
|
|
|
reqEVR = t;
|
|
|
|
if (p->epoch != NULL) t = stpcpy( stpcpy(t, p->epoch), ":");
|
|
|
|
if (p->version != NULL) t = stpcpy(t, p->version);
|
|
|
|
*t++ = '-';
|
|
|
|
if (p->release != NULL) t = stpcpy(t, p->release);
|
|
|
|
|
2001-11-11 08:11:33 +08:00
|
|
|
req = dsSingle(RPMTAG_REQUIRENAME, p->name, 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
|
|
|
|
|
|
|
/*@-branchstate@*/ /* FIX: p->key ??? */
|
|
|
|
if (rc == 0) {
|
|
|
|
const char * altNEVR = hGetNEVR(h, NULL);
|
|
|
|
rpmProblemSetAppend(ts->probs, RPMPROB_OLDPACKAGE,
|
|
|
|
p->NEVR, p->key,
|
|
|
|
NULL, NULL,
|
|
|
|
altNEVR,
|
|
|
|
0);
|
|
|
|
altNEVR = _free(altNEVR);
|
|
|
|
rc = 1;
|
|
|
|
} else
|
|
|
|
rc = 0;
|
|
|
|
/*@=branchstate@*/
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
1999-01-01 03:16:31 +08:00
|
|
|
|
2001-09-26 04:51:34 +08:00
|
|
|
/**
|
|
|
|
*/
|
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;
|
|
|
|
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. */
|
|
|
|
drc = alloca(fi->dc * sizeof(*drc));
|
|
|
|
memset(drc, 0, fi->dc * sizeof(*drc));
|
|
|
|
dff = alloca(fi->dc * sizeof(*dff));
|
|
|
|
memset(dff, 0, fi->dc * sizeof(*dff));
|
|
|
|
|
1999-07-14 22:36:10 +08:00
|
|
|
for (i = 0; i < fi->fc; i++) {
|
1999-08-07 08:07:51 +08:00
|
|
|
char **nsp;
|
|
|
|
|
2001-04-04 04:41:09 +08:00
|
|
|
bn = fi->bnl[i];
|
|
|
|
bnlen = strlen(bn);
|
|
|
|
ix = fi->dil[i];
|
|
|
|
dn = fi->dnl[ix];
|
|
|
|
dnlen = strlen(dn);
|
|
|
|
|
|
|
|
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-04-03 21:41:56 +08:00
|
|
|
if (noDocs && (fi->fflags[i] & 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. */
|
|
|
|
for (j = 0; j < fi->dc; j++) {
|
|
|
|
|
|
|
|
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. */
|
|
|
|
for (i = 0; i < fi->fc; i++) {
|
|
|
|
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
|
|
|
}
|
1999-01-01 03:16:31 +08:00
|
|
|
|
2001-02-18 01:53:21 +08:00
|
|
|
/**
|
|
|
|
* Return next transaction element's file info.
|
2001-11-02 11:13:35 +08:00
|
|
|
* @param tei transaction element iterator
|
|
|
|
* @return nest transaction element file info, NULL on termination
|
2001-02-18 01:53:21 +08:00
|
|
|
*/
|
2001-11-02 11:13:35 +08:00
|
|
|
/*@unused@*/ static inline
|
|
|
|
TFI_t teNextFi(teIterator tei)
|
|
|
|
/*@modifies tei @*/
|
2001-06-06 03:26:22 +08:00
|
|
|
{
|
2001-02-18 01:53:21 +08:00
|
|
|
TFI_t fi = NULL;
|
|
|
|
|
2001-11-02 11:13:35 +08:00
|
|
|
if (teNextIterator(tei) != NULL && tei->ocsave != -1)
|
|
|
|
fi = tei->ts->flList + tei->ocsave;
|
|
|
|
/*@-compdef -onlytrans -usereleased@*/ /* FIX: ts->flList may be released */
|
2001-02-18 01:53:21 +08:00
|
|
|
return fi;
|
2001-11-02 11:13:35 +08:00
|
|
|
/*@=compdef =onlytrans =usereleased@*/
|
2001-02-18 01:53:21 +08:00
|
|
|
}
|
|
|
|
|
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,
|
|
|
|
rpmCallbackFunction notify, rpmCallbackData notifyData,
|
|
|
|
rpmProblemSet okProbs, rpmProblemSet * newProbs,
|
|
|
|
rpmtransFlags transFlags, 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-05 06:00:11 +08:00
|
|
|
alKey pkgKey, lastKey;
|
1999-07-14 22:36:10 +08:00
|
|
|
int oc;
|
2001-11-05 11:44:05 +08:00
|
|
|
transactionElement p;
|
1999-10-20 18:22:46 +08:00
|
|
|
fingerPrintCache fpc;
|
2001-02-28 06:08:53 +08:00
|
|
|
struct psm_s psmbuf;
|
|
|
|
PSM_t psm = &psmbuf;
|
2001-11-02 11:13:35 +08:00
|
|
|
teIterator tei;
|
2001-10-16 22:58:57 +08:00
|
|
|
int xx;
|
2001-11-05 11:44:05 +08:00
|
|
|
|
2001-11-11 09:46:43 +08:00
|
|
|
int keep_header = 0;
|
1999-01-01 03:16:31 +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
|
|
|
|
2000-10-21 06:04:27 +08:00
|
|
|
ts->transFlags = transFlags;
|
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
|
|
|
|
2000-10-21 06:04:27 +08:00
|
|
|
ts->notify = notify;
|
|
|
|
ts->notifyData = notifyData;
|
2001-06-06 03:26:22 +08:00
|
|
|
/*@-assignexpose@*/
|
2001-10-30 00:35:01 +08:00
|
|
|
ts->probs = *newProbs = rpmProblemSetCreate();
|
2001-11-10 01:22:08 +08:00
|
|
|
*newProbs = rpmpsLink(ts->probs, "RunTransactions");
|
2001-06-06 03:26:22 +08:00
|
|
|
/*@=assignexpose@*/
|
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-06-06 03:26:22 +08:00
|
|
|
/*@-assignexpose@*/
|
2001-10-29 06:17:47 +08:00
|
|
|
psm->ts = rpmtsLink(ts, "tsRun");
|
2001-06-06 03:26:22 +08:00
|
|
|
/*@=assignexpose@*/
|
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-01-27 01:06:09 +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-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-05 11:44:05 +08:00
|
|
|
tei = teInitIterator(ts);
|
2001-11-09 00:28:35 +08:00
|
|
|
while ((p = teNext(tei, TR_ADDED)) != NULL) {
|
2001-10-31 02:00:21 +08:00
|
|
|
rpmdbMatchIterator mi;
|
|
|
|
|
2001-11-11 03:24:19 +08:00
|
|
|
/*@-branchstate@*/ /* FIX: p->key ??? */
|
|
|
|
if (!archOkay(p->arch) && !(ts->ignoreSet & RPMPROB_FILTER_IGNOREARCH))
|
2001-10-31 02:00:21 +08:00
|
|
|
rpmProblemSetAppend(ts->probs, RPMPROB_BADARCH,
|
2001-11-11 03:24:19 +08:00
|
|
|
p->NEVR, p->key,
|
|
|
|
p->arch, NULL,
|
2001-11-10 01:22:08 +08:00
|
|
|
NULL, 0);
|
1999-01-08 01:06:24 +08:00
|
|
|
|
2001-11-11 03:24:19 +08:00
|
|
|
if (!osOkay(p->os) && !(ts->ignoreSet & RPMPROB_FILTER_IGNOREOS))
|
2001-10-31 02:00:21 +08:00
|
|
|
rpmProblemSetAppend(ts->probs, RPMPROB_BADOS,
|
2001-11-11 03:24:19 +08:00
|
|
|
p->NEVR, p->key,
|
|
|
|
p->os, NULL,
|
2001-11-10 01:22:08 +08:00
|
|
|
NULL, 0);
|
2001-11-11 03:24:19 +08:00
|
|
|
/*@=branchstate@*/
|
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;
|
|
|
|
mi = rpmtsInitIterator(ts, RPMTAG_NAME, p->name, 0);
|
|
|
|
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-10-31 02:00:21 +08:00
|
|
|
if (!(ts->ignoreSet & RPMPROB_FILTER_REPLACEPKG)
|
2001-11-02 07:18:15 +08:00
|
|
|
#ifdef DYING /* XXX MULTILIB multiLib from transactionElement */
|
|
|
|
&& !alGetMultiLib(ts->addedPackages, i)
|
|
|
|
#endif
|
|
|
|
) {
|
2001-11-11 03:24:19 +08:00
|
|
|
mi = rpmtsInitIterator(ts, RPMTAG_NAME, p->name, 0);
|
|
|
|
xx = rpmdbSetIteratorRE(mi, RPMTAG_VERSION, RPMMIRE_DEFAULT,
|
|
|
|
p->version);
|
|
|
|
xx = rpmdbSetIteratorRE(mi, RPMTAG_RELEASE, RPMMIRE_DEFAULT,
|
|
|
|
p->release);
|
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-11 03:24:19 +08:00
|
|
|
p->NEVR, p->key,
|
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-10 04:41:18 +08:00
|
|
|
if (p->fns != NULL)
|
|
|
|
totalFileCount += p->fns->fc;
|
2001-10-31 02:00:21 +08:00
|
|
|
|
1999-07-14 22:36:10 +08:00
|
|
|
}
|
2001-11-05 11:44:05 +08:00
|
|
|
tei = teFreeIterator(tei);
|
1999-01-05 00:44:20 +08:00
|
|
|
|
2001-11-11 11:15:47 +08:00
|
|
|
#ifdef DYING
|
1999-07-14 22:36:10 +08:00
|
|
|
/* FIXME: it seems a bit silly to read in all of these headers twice */
|
|
|
|
/* The ordering doesn't matter here */
|
2000-06-14 22:21:06 +08:00
|
|
|
if (ts->numRemovedPackages > 0) {
|
|
|
|
rpmdbMatchIterator mi;
|
2000-04-27 08:10:28 +08:00
|
|
|
Header h;
|
2000-07-09 12:42:12 +08:00
|
|
|
int fileCount;
|
2000-04-27 08:10:28 +08:00
|
|
|
|
2001-10-28 04:09:20 +08:00
|
|
|
mi = rpmtsInitIterator(ts, RPMDBI_PACKAGES, NULL, 0);
|
2001-10-16 22:58:57 +08:00
|
|
|
xx = rpmdbAppendIterator(mi, ts->removedPackages, ts->numRemovedPackages);
|
2000-04-27 08:10:28 +08:00
|
|
|
while ((h = rpmdbNextIterator(mi)) != NULL) {
|
|
|
|
if (headerGetEntry(h, RPMTAG_BASENAMES, NULL, NULL, &fileCount))
|
|
|
|
totalFileCount += fileCount;
|
|
|
|
}
|
2001-04-30 06:43:01 +08:00
|
|
|
mi = rpmdbFreeIterator(mi);
|
2000-04-27 08:10:28 +08:00
|
|
|
}
|
2001-11-11 11:15:47 +08:00
|
|
|
#else
|
|
|
|
/* The ordering doesn't matter here */
|
|
|
|
tei = teInitIterator(ts);
|
|
|
|
while ((p = teNext(tei, TR_REMOVED)) != NULL) {
|
|
|
|
rpmFNSet fns;
|
|
|
|
|
|
|
|
fns = p->fns;
|
|
|
|
if (fns == NULL)
|
|
|
|
continue;
|
|
|
|
if (fns->bnl == NULL)
|
|
|
|
continue; /* XXX can't happen */
|
|
|
|
if (fns->dnl == NULL)
|
|
|
|
continue; /* XXX can't happen */
|
|
|
|
if (fns->dil == NULL)
|
|
|
|
continue; /* XXX can't happen */
|
|
|
|
totalFileCount += fns->fc;
|
|
|
|
}
|
|
|
|
tei = teFreeIterator(tei);
|
|
|
|
#endif
|
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
|
|
|
*/
|
2001-11-11 03:24:19 +08:00
|
|
|
ts->flEntries = ts->numAddedPackages + ts->numRemovedPackages;
|
2001-04-30 06:43:01 +08:00
|
|
|
ts->flList = xcalloc(ts->flEntries, sizeof(*ts->flList));
|
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-02 11:13:35 +08:00
|
|
|
tei = teInitIterator(ts);
|
|
|
|
while ((fi = teNextFi(tei)) != NULL) {
|
2001-11-05 06:00:11 +08:00
|
|
|
|
2001-11-02 11:13:35 +08:00
|
|
|
oc = teGetOc(tei);
|
2001-01-23 03:11:19 +08:00
|
|
|
fi->magic = TFIMAGIC;
|
1999-01-05 00:44:20 +08:00
|
|
|
|
2001-01-24 00:07:28 +08:00
|
|
|
fi->type = ts->order[oc].type;
|
2001-10-31 02:00:21 +08:00
|
|
|
|
2001-10-16 03:27:13 +08:00
|
|
|
/*@-branchstate@*/
|
2001-04-21 14:02:09 +08:00
|
|
|
switch (fi->type) {
|
1999-08-14 04:05:57 +08:00
|
|
|
case TR_ADDED:
|
2001-01-24 00:07:28 +08:00
|
|
|
fi->record = 0;
|
2001-10-31 02:00:21 +08:00
|
|
|
|
2001-11-11 09:46:43 +08:00
|
|
|
/*@i@*/ fi->h = headerLink(ts->order[oc].h, "xfer to fi->h");
|
|
|
|
ts->order[oc].h = headerFree(ts->order[oc].h, "xfer to fi->h");
|
2001-10-31 02:00:21 +08:00
|
|
|
|
2001-11-02 07:18:15 +08:00
|
|
|
#ifdef DYING /* XXX MULTILIB multiLib from transactionElement */
|
2001-10-31 02:00:21 +08:00
|
|
|
fi->multiLib = alGetMultiLib(ts->addedPackages, i);
|
2001-11-02 07:18:15 +08:00
|
|
|
#else
|
|
|
|
fi->multiLib = ts->order[oc].multiLib;
|
|
|
|
#endif
|
2001-11-05 11:44:05 +08:00
|
|
|
|
|
|
|
/*@i@*/ fi->key = ts->order[oc].key;
|
|
|
|
fi->relocs = ts->order[oc].relocs;
|
|
|
|
/*@i@*/ fi->fd = ts->order[oc].fd;
|
2001-10-31 02:00:21 +08:00
|
|
|
|
|
|
|
/* XXX availablePackage can be dumped here XXX */
|
|
|
|
|
|
|
|
/* XXX header arg unused. */
|
|
|
|
loadFi(ts, fi, fi->h, keep_header);
|
|
|
|
|
2001-09-26 04:51:34 +08:00
|
|
|
if (fi->fc == 0)
|
1999-07-14 22:36:10 +08:00
|
|
|
continue;
|
1999-03-05 07:26:51 +08:00
|
|
|
|
2001-01-24 00:07:28 +08:00
|
|
|
/* Skip netshared paths, not our i18n files, and excluded docs */
|
|
|
|
skipFiles(ts, fi);
|
2001-10-14 06:01:38 +08:00
|
|
|
/*@switchbreak@*/ break;
|
1999-08-14 04:05:57 +08:00
|
|
|
case TR_REMOVED:
|
1999-07-14 22:36:10 +08:00
|
|
|
fi->record = ts->order[oc].u.removed.dboffset;
|
2001-10-19 00:39:54 +08:00
|
|
|
/* Retrieve erased package header from the database. */
|
2000-04-27 08:10:28 +08:00
|
|
|
{ rpmdbMatchIterator mi;
|
|
|
|
|
2001-10-28 04:09:20 +08:00
|
|
|
mi = rpmtsInitIterator(ts, RPMDBI_PACKAGES,
|
2001-01-25 05:35:52 +08:00
|
|
|
&fi->record, sizeof(fi->record));
|
2000-04-27 08:10:28 +08:00
|
|
|
if ((fi->h = rpmdbNextIterator(mi)) != NULL)
|
2001-11-02 04:15:10 +08:00
|
|
|
fi->h = headerLink(fi->h, "TR_REMOVED loadFi");
|
2001-04-30 06:43:01 +08:00
|
|
|
mi = rpmdbFreeIterator(mi);
|
2000-04-27 08:10:28 +08:00
|
|
|
}
|
1999-09-13 04:43:23 +08:00
|
|
|
if (fi->h == NULL) {
|
1999-07-14 22:36:10 +08:00
|
|
|
/* ACK! */
|
|
|
|
continue;
|
|
|
|
}
|
2001-01-24 00:07:28 +08:00
|
|
|
/* XXX header arg unused. */
|
2001-10-19 00:39:54 +08:00
|
|
|
loadFi(ts, fi, fi->h, 0);
|
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-01-24 00:07:28 +08:00
|
|
|
if (fi->fc)
|
2001-04-30 06:43:01 +08:00
|
|
|
fi->fps = xmalloc(fi->fc * sizeof(*fi->fps));
|
1999-07-14 22:36:10 +08:00
|
|
|
}
|
2001-11-02 11:13:35 +08:00
|
|
|
tei = teFreeIterator(tei);
|
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-08-03 23:17:55 +08:00
|
|
|
/*@-onlytrans@*/
|
2001-10-18 00:43:36 +08:00
|
|
|
/*@-mods@*/
|
2001-07-28 08:33:07 +08:00
|
|
|
chroot_prefix = ts->rootDir;
|
2001-10-18 00:43:36 +08:00
|
|
|
/*@=mods@*/
|
2001-08-03 23:17:55 +08:00
|
|
|
/*@=onlytrans@*/
|
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-02 11:13:35 +08:00
|
|
|
tei = teInitIterator(ts);
|
|
|
|
while ((fi = teNextFi(tei)) != NULL) {
|
1999-10-21 10:40:57 +08:00
|
|
|
fpLookupList(fpc, fi->dnl, fi->bnl, fi->dil, fi->fc, fi->fps);
|
1999-07-14 22:36:10 +08:00
|
|
|
for (i = 0; i < fi->fc; i++) {
|
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-10-19 00:39:54 +08:00
|
|
|
htAddEntry(ts->ht, fi->fps + i, fi);
|
2001-04-30 06:43:01 +08:00
|
|
|
/*@=dependenttrans@*/
|
1999-07-14 22:36:10 +08:00
|
|
|
}
|
|
|
|
}
|
2001-11-02 11:13:35 +08:00
|
|
|
tei = teFreeIterator(tei);
|
1999-07-14 22:36:10 +08:00
|
|
|
|
2001-10-16 22:58:57 +08:00
|
|
|
/*@-noeffectuncon @*/ /* FIX: check rc */
|
2001-02-18 01:53:21 +08:00
|
|
|
NOTIFY(ts, (NULL, RPMCALLBACK_TRANS_START, 6, ts->flEntries,
|
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-02 11:13:35 +08:00
|
|
|
tei = teInitIterator(ts);
|
|
|
|
while ((fi = teNextFi(tei)) != NULL) {
|
2000-03-23 23:49:50 +08:00
|
|
|
dbiIndexSet * matches;
|
1999-07-14 22:36:10 +08:00
|
|
|
int knownBad;
|
|
|
|
|
2001-10-16 22:58:57 +08:00
|
|
|
/*@-noeffectuncon @*/ /* FIX: check rc */
|
2001-02-18 01:53:21 +08:00
|
|
|
NOTIFY(ts, (NULL, RPMCALLBACK_TRANS_PROGRESS, (fi - ts->flList),
|
|
|
|
ts->flEntries, NULL, ts->notifyData));
|
2001-10-16 22:58:57 +08:00
|
|
|
/*@=noeffectuncon@*/
|
1999-07-14 22:36:10 +08:00
|
|
|
|
2000-12-13 04:03:45 +08:00
|
|
|
if (fi->fc == 0) continue;
|
|
|
|
|
1999-08-15 04:01:38 +08:00
|
|
|
/* Extract file info for all files in this package from the database. */
|
2001-09-25 05:53:14 +08:00
|
|
|
matches = xcalloc(fi->fc, sizeof(*matches));
|
2001-10-28 06:31:10 +08:00
|
|
|
if (rpmdbFindFpList(ts->rpmdb, fi->fps, matches, fi->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;
|
|
|
|
for (i = 0; i < fi->fc; i++)
|
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));
|
1999-07-14 22:36:10 +08:00
|
|
|
for (i = 0; i < fi->fc; i++) {
|
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++) {
|
1999-08-14 04:05:57 +08:00
|
|
|
int k, ro;
|
1999-09-13 04:43:23 +08:00
|
|
|
ro = dbiIndexRecordOffset(matches[i], j);
|
1999-08-15 04:01:38 +08:00
|
|
|
knownBad = 0;
|
1999-08-14 04:05:57 +08:00
|
|
|
for (k = 0; ro != knownBad && k < ts->orderCount; k++) {
|
|
|
|
switch (ts->order[k].type) {
|
|
|
|
case TR_REMOVED:
|
|
|
|
if (ts->order[k].u.removed.dboffset == ro)
|
|
|
|
knownBad = ro;
|
2001-10-14 06:01:38 +08:00
|
|
|
/*@switchbreak@*/ break;
|
1999-08-14 04:05:57 +08:00
|
|
|
case TR_ADDED:
|
2001-10-14 06:01:38 +08:00
|
|
|
/*@switchbreak@*/ break;
|
1999-01-05 03:11:04 +08:00
|
|
|
}
|
1999-01-05 00:44:20 +08:00
|
|
|
}
|
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 ... */
|
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;
|
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. */
|
1999-08-14 04:05:57 +08:00
|
|
|
switch (fi->type) {
|
|
|
|
case TR_ADDED:
|
2001-10-19 00:39:54 +08:00
|
|
|
xx = handleInstInstalledFiles(ts, fi, shared, nexti - i,
|
|
|
|
!(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
|
|
|
}
|
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-10-19 00:39:54 +08:00
|
|
|
handleOverlappedFiles(ts, 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. */
|
|
|
|
switch (fi->type) {
|
|
|
|
case TR_ADDED:
|
2001-01-27 01:06:09 +08:00
|
|
|
if (!(ts->di && fi->fc))
|
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) {
|
|
|
|
const char * pkgNEVR = fiGetNEVR(fi);
|
2001-10-31 02:00:21 +08:00
|
|
|
rpmProblemSetAppend(ts->probs, RPMPROB_DISKSPACE,
|
2001-11-10 01:22:08 +08:00
|
|
|
pkgNEVR, fi->key,
|
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
|
|
|
pkgNEVR = _free(pkgNEVR);
|
|
|
|
}
|
2000-12-30 05:44:37 +08:00
|
|
|
|
2001-11-10 01:22:08 +08:00
|
|
|
if (adj_fs_blocks(dip->ineeded) > dip->iavail) {
|
|
|
|
const char * pkgNEVR = fiGetNEVR(fi);
|
2001-10-31 02:00:21 +08:00
|
|
|
rpmProblemSetAppend(ts->probs, RPMPROB_DISKNODES,
|
2001-11-10 01:22:08 +08:00
|
|
|
pkgNEVR, fi->key,
|
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
|
|
|
pkgNEVR = _free(pkgNEVR);
|
|
|
|
}
|
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-02 11:13:35 +08:00
|
|
|
tei = teFreeIterator(tei);
|
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-18 00:43:36 +08:00
|
|
|
/*@-mods@*/
|
2001-07-28 08:33:07 +08:00
|
|
|
chroot_prefix = NULL;
|
2001-10-18 00:43:36 +08:00
|
|
|
/*@=mods@*/
|
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-04-30 06:43:01 +08:00
|
|
|
NOTIFY(ts, (NULL, RPMCALLBACK_TRANS_STOP, 6, ts->flEntries,
|
|
|
|
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
|
|
|
*/
|
1999-02-21 11:34:52 +08:00
|
|
|
|
2001-11-02 11:13:35 +08:00
|
|
|
tei = teInitIterator(ts);
|
|
|
|
while ((fi = teNextFi(tei)) != NULL) {
|
1999-08-14 04:05:57 +08:00
|
|
|
if (fi->fc == 0)
|
|
|
|
continue;
|
2001-02-20 01:12:21 +08:00
|
|
|
fi->fps = _free(fi->fps);
|
1999-03-21 05:09:47 +08:00
|
|
|
}
|
2001-11-02 11:13:35 +08:00
|
|
|
tei = teFreeIterator(tei);
|
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-04-30 06:43:01 +08:00
|
|
|
ts->flList = freeFl(ts, ts->flList);
|
|
|
|
ts->flEntries = 0;
|
2001-10-31 02:00:21 +08:00
|
|
|
if (psm->ts != NULL)
|
|
|
|
psm->ts = rpmtsUnlink(psm->ts, "tsRun (problems)");
|
|
|
|
/*@-nullstate@*/ /* FIX: ts->flList may be NULL */
|
1999-07-14 22:36:10 +08:00
|
|
|
return ts->orderCount;
|
2001-05-04 05:00:18 +08:00
|
|
|
/*@=nullstate@*/
|
1999-07-14 22:36:10 +08:00
|
|
|
}
|
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-02 11:13:35 +08:00
|
|
|
tei = teInitIterator(ts);
|
|
|
|
while ((fi = teNextFi(tei)) != NULL) {
|
2001-02-20 01:12:21 +08:00
|
|
|
switch (fi->type) {
|
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-10-29 06:17:47 +08:00
|
|
|
if (ts->transFlags & RPMTRANS_FLAG_REPACKAGE) {
|
|
|
|
psm->fi = rpmfiLink(fi, "tsRepackage");
|
2001-10-16 22:58:57 +08:00
|
|
|
xx = psmStage(psm, PSM_PKGSAVE);
|
2001-10-29 06:17:47 +08:00
|
|
|
(void) rpmfiUnlink(fi, "tsRepackage");
|
|
|
|
psm->fi = NULL;
|
|
|
|
}
|
2001-10-14 06:01:38 +08:00
|
|
|
/*@switchbreak@*/ break;
|
2001-02-12 06:02:29 +08:00
|
|
|
}
|
|
|
|
}
|
2001-11-02 11:13:35 +08:00
|
|
|
tei = teFreeIterator(tei);
|
2001-02-12 06:02:29 +08:00
|
|
|
}
|
|
|
|
|
1999-08-07 07:44:25 +08:00
|
|
|
/* ===============================================
|
|
|
|
* Install and remove packages.
|
|
|
|
*/
|
2000-06-19 19:35:29 +08:00
|
|
|
|
2001-11-05 06:00:11 +08:00
|
|
|
lastKey = (alKey)-2; /* erased packages have -1 */
|
2001-11-02 11:13:35 +08:00
|
|
|
tei = teInitIterator(ts);
|
2001-10-29 06:17:47 +08:00
|
|
|
/*@-branchstate@*/ /* FIX: fi reload needs work */
|
2001-11-02 11:13:35 +08:00
|
|
|
while ((fi = teNextFi(tei)) != NULL) {
|
2001-06-20 04:03:13 +08:00
|
|
|
Header h;
|
2001-01-21 23:43:32 +08:00
|
|
|
int gotfd;
|
|
|
|
|
2001-11-02 11:13:35 +08:00
|
|
|
oc = teGetOc(tei);
|
2001-01-21 23:43:32 +08:00
|
|
|
gotfd = 0;
|
2001-10-29 06:17:47 +08:00
|
|
|
psm->fi = rpmfiLink(fi, "tsInstall");
|
2001-10-14 06:01:38 +08:00
|
|
|
switch (fi->type) {
|
1999-08-14 04:05:57 +08:00
|
|
|
case TR_ADDED:
|
2001-10-31 02:00:21 +08:00
|
|
|
|
2001-11-05 06:00:11 +08:00
|
|
|
pkgKey = ts->order[oc].u.addedKey;
|
1999-02-21 11:34:52 +08:00
|
|
|
|
2001-10-19 00:39:54 +08:00
|
|
|
rpmMessage(RPMMESS_DEBUG, "========== +++ %s-%s-%s\n",
|
|
|
|
fi->name, fi->version, fi->release);
|
2001-11-02 04:15:10 +08:00
|
|
|
h = (fi->h ? headerLink(fi->h, "TR_ADDED install") : NULL);
|
2001-10-16 03:27:13 +08:00
|
|
|
/*@-branchstate@*/
|
2001-10-31 02:00:21 +08:00
|
|
|
if (fi->fd == NULL) {
|
|
|
|
/*@-noeffectuncon @*/ /* FIX: ??? */
|
|
|
|
fi->fd = ts->notify(fi->h, RPMCALLBACK_INST_OPEN_FILE, 0, 0,
|
|
|
|
fi->key, ts->notifyData);
|
|
|
|
/*@=noeffectuncon @*/
|
|
|
|
if (fi->fd != NULL) {
|
2001-02-13 03:02:15 +08:00
|
|
|
rpmRC rpmrc;
|
1999-02-21 11:34:52 +08:00
|
|
|
|
2001-11-02 04:15:10 +08:00
|
|
|
h = headerFree(h, "TR_ADDED install");
|
2001-09-26 04:51:34 +08:00
|
|
|
|
2001-10-26 12:16:19 +08:00
|
|
|
/*@-mustmod@*/ /* LCL: segfault */
|
2001-10-31 02:00:21 +08:00
|
|
|
rpmrc = rpmReadPackageFile(ts, fi->fd,
|
2001-10-28 04:09:20 +08:00
|
|
|
"rpmRunTransactions", &h);
|
2001-10-26 12:16:19 +08:00
|
|
|
/*@=mustmod@*/
|
2001-10-28 04:09:20 +08:00
|
|
|
|
2001-02-13 03:02:15 +08:00
|
|
|
if (!(rpmrc == RPMRC_OK || rpmrc == RPMRC_BADSIZE)) {
|
2001-10-16 22:58:57 +08:00
|
|
|
/*@-noeffectuncon @*/ /* FIX: check rc */
|
2001-10-31 02:00:21 +08:00
|
|
|
(void) ts->notify(fi->h, RPMCALLBACK_INST_CLOSE_FILE,
|
|
|
|
0, 0,
|
|
|
|
fi->key, ts->notifyData);
|
2001-10-16 22:58:57 +08:00
|
|
|
/*@=noeffectuncon @*/
|
2001-10-31 02:00:21 +08:00
|
|
|
fi->fd = NULL;
|
1999-07-14 22:36:10 +08:00
|
|
|
ourrc++;
|
2001-10-19 00:39:54 +08:00
|
|
|
} else if (fi->h != NULL) {
|
2001-10-31 02:00:21 +08:00
|
|
|
Header foo = relocateFileList(ts, fi, h, NULL);
|
2001-11-02 04:15:10 +08:00
|
|
|
h = headerFree(h, "TR_ADDED read free");
|
|
|
|
h = headerLink(foo, "TR_ADDED relocate xfer");
|
|
|
|
foo = headerFree(foo, "TR_ADDED relocate");
|
1999-07-14 22:36:10 +08:00
|
|
|
}
|
2001-10-31 02:00:21 +08:00
|
|
|
if (fi->fd != NULL) gotfd = 1;
|
1999-05-18 02:44:14 +08:00
|
|
|
}
|
|
|
|
}
|
2001-10-16 03:27:13 +08:00
|
|
|
/*@=branchstate@*/
|
1999-07-14 22:36:10 +08:00
|
|
|
|
2001-10-31 02:00:21 +08:00
|
|
|
if (fi->fd != NULL) {
|
2001-01-25 05:35:52 +08:00
|
|
|
Header hsave = NULL;
|
2000-07-06 04:39:15 +08:00
|
|
|
|
2001-01-25 05:35:52 +08:00
|
|
|
if (fi->h) {
|
2001-11-02 04:15:10 +08:00
|
|
|
hsave = headerLink(fi->h, "TR_ADDED fi->h hsave");
|
|
|
|
fi->h = headerFree(fi->h, "TR_ADDED fi->h free");
|
|
|
|
fi->h = headerLink(h, "TR_ADDED fi->h link");
|
2001-10-19 00:39:54 +08:00
|
|
|
} else {
|
|
|
|
char * fstates = fi->fstates;
|
|
|
|
fileAction * actions = fi->actions;
|
2001-10-31 02:00:21 +08:00
|
|
|
uint_32 multiLib = fi->multiLib;
|
|
|
|
const void * key = fi->key;
|
|
|
|
rpmRelocation * relocs = fi->relocs;
|
|
|
|
FD_t fd = fi->fd;
|
|
|
|
|
2001-10-19 00:39:54 +08:00
|
|
|
fi->fstates = NULL;
|
|
|
|
fi->actions = NULL;
|
2001-10-31 02:00:21 +08:00
|
|
|
fi->key = NULL;
|
|
|
|
fi->relocs = NULL;
|
|
|
|
fi->fd = NULL;
|
2001-10-19 00:39:54 +08:00
|
|
|
freeFi(fi);
|
2001-11-02 11:13:35 +08:00
|
|
|
oc = teGetOc(tei);
|
2001-10-19 00:39:54 +08:00
|
|
|
fi->magic = TFIMAGIC;
|
|
|
|
fi->type = ts->order[oc].type;
|
|
|
|
fi->record = 0;
|
|
|
|
loadFi(ts, fi, h, 1);
|
|
|
|
fi->fstates = _free(fi->fstates);
|
|
|
|
fi->fstates = fstates;
|
|
|
|
fi->actions = _free(fi->actions);
|
|
|
|
fi->actions = actions;
|
2001-10-31 02:00:21 +08:00
|
|
|
fi->multiLib = multiLib;
|
|
|
|
fi->key = key;
|
|
|
|
fi->relocs = relocs;
|
|
|
|
/*@-newreftrans@*/
|
|
|
|
/*@i@*/ fi->fd = fd;
|
|
|
|
/*@=newreftrans@*/
|
|
|
|
|
2001-01-25 05:35:52 +08:00
|
|
|
}
|
2001-10-31 02:00:21 +08:00
|
|
|
if (fi->multiLib)
|
2000-10-21 06:04:27 +08:00
|
|
|
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");
|
2001-01-25 05:35:52 +08:00
|
|
|
if (hsave) {
|
2001-11-02 04:15:10 +08:00
|
|
|
fi->h = headerLink(hsave, "TR_ADDED fi->h restore");
|
|
|
|
hsave = headerFree(hsave, "TR_ADDED hsave free");
|
2001-01-25 05:35:52 +08:00
|
|
|
}
|
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 */
|
2000-10-21 06:04:27 +08:00
|
|
|
(void)ts->notify(fi->h, RPMCALLBACK_INST_CLOSE_FILE, 0, 0,
|
2001-10-31 02:00:21 +08:00
|
|
|
fi->key, ts->notifyData);
|
2001-10-16 22:58:57 +08:00
|
|
|
/*@=noeffectuncon @*/
|
2001-10-31 02:00:21 +08:00
|
|
|
fi->fd = NULL;
|
2001-01-21 23:43:32 +08:00
|
|
|
}
|
2001-11-11 09:46:43 +08:00
|
|
|
fi->h = headerFree(fi->h, "TR_ADDED fini");
|
2001-10-19 00:39:54 +08:00
|
|
|
freeFi(fi);
|
2001-10-14 06:01:38 +08:00
|
|
|
/*@switchbreak@*/ break;
|
1999-08-14 04:05:57 +08:00
|
|
|
case TR_REMOVED:
|
2001-10-19 00:39:54 +08:00
|
|
|
rpmMessage(RPMMESS_DEBUG, "========== --- %s-%s-%s\n",
|
|
|
|
fi->name, fi->version, fi->release);
|
2001-11-02 11:13:35 +08:00
|
|
|
oc = teGetOc(tei);
|
2000-08-21 05:39:13 +08:00
|
|
|
/* If install failed, then we shouldn't erase. */
|
2001-11-05 06:00:11 +08:00
|
|
|
if (ts->order[oc].u.removed.dependsOnKey != lastKey) {
|
2001-10-19 00:39:54 +08:00
|
|
|
if (psmStage(psm, PSM_PKGERASE))
|
|
|
|
ourrc++;
|
|
|
|
}
|
2001-11-11 09:46:43 +08:00
|
|
|
fi->h = headerFree(fi->h, "TR_REMOVED fini");
|
2001-10-19 00:39:54 +08:00
|
|
|
freeFi(fi);
|
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-10-29 06:17:47 +08:00
|
|
|
(void) rpmfiUnlink(fi, "tsInstall");
|
|
|
|
psm->fi = NULL;
|
1999-02-21 11:34:52 +08:00
|
|
|
}
|
2001-10-29 06:17:47 +08:00
|
|
|
/*@=branchstate@*/
|
2001-11-02 11:13:35 +08:00
|
|
|
tei = teFreeIterator(tei);
|
1999-02-21 11:34:52 +08:00
|
|
|
|
2001-04-30 06:43:01 +08:00
|
|
|
ts->flList = freeFl(ts, ts->flList);
|
|
|
|
ts->flEntries = 0;
|
1999-07-14 22:36:10 +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
|
|
|
}
|