2002-05-17 00:55:21 +08:00
|
|
|
/** \ingroup rpmts
|
2000-08-28 03:40:35 +08:00
|
|
|
* \file lib/transaction.c
|
|
|
|
*/
|
|
|
|
|
1998-12-19 03:09:38 +08:00
|
|
|
#include "system.h"
|
2002-04-13 09:28:20 +08:00
|
|
|
#include <rpmlib.h>
|
1998-12-19 03:09:38 +08:00
|
|
|
|
2001-11-11 09:46:43 +08:00
|
|
|
#include <rpmmacro.h> /* XXX for rpmExpand */
|
|
|
|
|
2002-07-28 08:41:15 +08:00
|
|
|
#include "fsm.h"
|
2001-09-26 04:51:34 +08:00
|
|
|
#include "psm.h"
|
2001-11-04 23:43:26 +08:00
|
|
|
|
2002-07-14 03:08:51 +08:00
|
|
|
#include "rpmdb.h"
|
2007-09-17 18:17:07 +08:00
|
|
|
#include "rpmdb_internal.h" /* XXX for dbiIndexSetCount */
|
2002-05-20 02:42:25 +08:00
|
|
|
|
2002-04-12 00:55:19 +08:00
|
|
|
#include "rpmds.h"
|
2002-05-20 07:37:24 +08:00
|
|
|
|
2004-02-26 03:54:58 +08:00
|
|
|
#include "rpmlock.h"
|
|
|
|
|
2002-05-20 07:37:24 +08:00
|
|
|
#define _RPMFI_INTERNAL
|
2002-04-12 00:55:19 +08:00
|
|
|
#include "rpmfi.h"
|
2002-05-20 07:37:24 +08:00
|
|
|
|
|
|
|
#define _RPMTE_INTERNAL
|
2002-04-12 00:55:19 +08:00
|
|
|
#include "rpmte.h"
|
2002-05-20 07:37:24 +08:00
|
|
|
|
|
|
|
#define _RPMTS_INTERNAL
|
2002-04-12 00:55:19 +08:00
|
|
|
#include "rpmts.h"
|
|
|
|
|
2002-07-26 07:36:32 +08:00
|
|
|
#include "cpio.h"
|
1998-12-27 02:32:08 +08:00
|
|
|
#include "fprint.h"
|
2001-11-19 01:49:21 +08:00
|
|
|
#include "legacy.h" /* XXX domd5 */
|
2001-06-18 06:18:03 +08:00
|
|
|
#include "misc.h" /* XXX stripTrailingChar, splitString, currentDirectory */
|
1998-12-19 03:09:38 +08:00
|
|
|
|
2000-12-13 04:03:45 +08:00
|
|
|
#include "debug.h"
|
|
|
|
|
2007-08-30 20:49:31 +08:00
|
|
|
#include "idtx.h"
|
2004-03-06 02:22:25 +08:00
|
|
|
|
|
|
|
|
|
|
|
/* XXX: This is a hack. I needed a to setup a notify callback
|
|
|
|
* for the rollback transaction, but I did not want to create
|
|
|
|
* a header for rpminstall.c.
|
|
|
|
*/
|
2007-09-12 01:07:39 +08:00
|
|
|
extern void * rpmShowProgress(const void * arg,
|
2004-03-06 02:22:25 +08:00
|
|
|
const rpmCallbackType what,
|
|
|
|
const unsigned long amount,
|
|
|
|
const unsigned long total,
|
2007-09-12 01:07:39 +08:00
|
|
|
fnpyKey key,
|
|
|
|
void * data)
|
|
|
|
;
|
2004-03-06 02:22:25 +08:00
|
|
|
|
2001-09-26 04:51:34 +08:00
|
|
|
/**
|
|
|
|
*/
|
2007-09-12 01:07:39 +08:00
|
|
|
static int archOkay(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
|
|
|
/**
|
|
|
|
*/
|
2007-09-12 01:07:39 +08:00
|
|
|
static int osOkay(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-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
|
|
|
/**
|
2007-10-06 10:41:49 +08:00
|
|
|
* handleInstInstalledFiles.
|
2003-07-10 04:18:54 +08:00
|
|
|
* @param ts transaction set
|
2007-10-06 10:41:49 +08:00
|
|
|
* @param p current transaction element
|
2003-07-10 04:18:54 +08:00
|
|
|
* @param fi file info set
|
2007-10-06 10:41:49 +08:00
|
|
|
* @param shared shared file info
|
|
|
|
* @param sharedCount no. of shared elements
|
2003-07-10 04:18:54 +08:00
|
|
|
* @param reportConflicts
|
2001-09-26 04:51:34 +08:00
|
|
|
*/
|
2001-10-19 09:24:21 +08:00
|
|
|
/* XXX only ts->{probs,rpmdb} modified */
|
2002-05-20 02:42:25 +08:00
|
|
|
static int handleInstInstalledFiles(const rpmts ts,
|
|
|
|
rpmte p, rpmfi fi,
|
2001-11-11 20:47:08 +08:00
|
|
|
sharedFileInfo shared,
|
2001-10-19 00:39:54 +08:00
|
|
|
int sharedCount, int reportConflicts)
|
1999-07-14 22:36:10 +08:00
|
|
|
{
|
2003-01-18 01:43:04 +08:00
|
|
|
uint_32 tscolor = rpmtsColor(ts);
|
2007-05-01 12:55:14 +08:00
|
|
|
uint_32 prefcolor = rpmtsPrefColor(ts);
|
2003-01-18 01:43:04 +08:00
|
|
|
uint_32 otecolor, tecolor;
|
2003-07-10 04:18:54 +08:00
|
|
|
uint_32 oFColor, FColor;
|
2001-11-19 01:49:21 +08:00
|
|
|
const char * altNEVR = NULL;
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmfi otherFi = NULL;
|
1999-07-14 22:36:10 +08:00
|
|
|
int numReplaced = 0;
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmps ps;
|
2001-11-19 01:49:21 +08:00
|
|
|
int i;
|
1998-12-19 03:09:38 +08:00
|
|
|
|
2001-11-19 01:49:21 +08:00
|
|
|
{ rpmdbMatchIterator mi;
|
|
|
|
Header h;
|
|
|
|
int scareMem = 0;
|
2000-04-27 08:10:28 +08:00
|
|
|
|
2001-11-19 01:49:21 +08:00
|
|
|
mi = rpmtsInitIterator(ts, RPMDBI_PACKAGES,
|
2001-11-10 01:22:08 +08:00
|
|
|
&shared->otherPkg, sizeof(shared->otherPkg));
|
2001-11-19 01:49:21 +08:00
|
|
|
while ((h = rpmdbNextIterator(mi)) != NULL) {
|
|
|
|
altNEVR = hGetNEVR(h, NULL);
|
2002-08-20 06:27:44 +08:00
|
|
|
otherFi = rpmfiNew(ts, h, RPMTAG_BASENAMES, scareMem);
|
2001-11-19 01:49:21 +08:00
|
|
|
break;
|
|
|
|
}
|
2001-04-30 06:43:01 +08:00
|
|
|
mi = rpmdbFreeIterator(mi);
|
2000-04-27 08:10:28 +08:00
|
|
|
}
|
1999-01-06 11:16:35 +08:00
|
|
|
|
2003-01-18 01:43:04 +08:00
|
|
|
/* Compute package color. */
|
|
|
|
tecolor = rpmteColor(p);
|
|
|
|
tecolor &= tscolor;
|
|
|
|
|
|
|
|
/* Compute other pkg color. */
|
|
|
|
otecolor = 0;
|
|
|
|
otherFi = rpmfiInit(otherFi, 0);
|
|
|
|
if (otherFi != NULL)
|
|
|
|
while (rpmfiNext(otherFi) >= 0)
|
|
|
|
otecolor |= rpmfiFColor(otherFi);
|
|
|
|
otecolor &= tscolor;
|
|
|
|
|
2003-01-21 07:52:04 +08:00
|
|
|
if (otherFi == NULL)
|
|
|
|
return 1;
|
|
|
|
|
2001-11-14 08:14:01 +08:00
|
|
|
fi->replaced = xcalloc(sharedCount, sizeof(*fi->replaced));
|
1998-12-19 03:09:38 +08:00
|
|
|
|
2002-05-28 05:40:08 +08:00
|
|
|
ps = rpmtsProblems(ts);
|
1999-07-14 22:36:10 +08:00
|
|
|
for (i = 0; i < sharedCount; i++, shared++) {
|
1999-08-14 04:05:57 +08:00
|
|
|
int otherFileNum, fileNum;
|
2002-07-28 08:41:15 +08:00
|
|
|
int isCfgFile;
|
2001-11-14 08:14:01 +08:00
|
|
|
|
1999-07-14 22:36:10 +08:00
|
|
|
otherFileNum = shared->otherFileNum;
|
2002-05-20 02:42:25 +08:00
|
|
|
(void) rpmfiSetFX(otherFi, otherFileNum);
|
2003-07-10 04:18:54 +08:00
|
|
|
oFColor = rpmfiFColor(otherFi);
|
|
|
|
oFColor &= tscolor;
|
1999-08-14 04:05:57 +08:00
|
|
|
|
2001-11-19 01:49:21 +08:00
|
|
|
fileNum = shared->pkgFileNum;
|
2002-05-20 02:42:25 +08:00
|
|
|
(void) rpmfiSetFX(fi, fileNum);
|
2003-07-10 04:18:54 +08:00
|
|
|
FColor = rpmfiFColor(fi);
|
|
|
|
FColor &= tscolor;
|
2001-11-14 08:14:01 +08:00
|
|
|
|
2002-07-28 08:41:15 +08:00
|
|
|
isCfgFile = ((rpmfiFFlags(otherFi) | rpmfiFFlags(fi)) & RPMFILE_CONFIG);
|
|
|
|
|
2001-11-19 01:49:21 +08:00
|
|
|
#ifdef DYING
|
2000-12-14 06:00:33 +08:00
|
|
|
/* XXX another tedious segfault, assume file state normal. */
|
|
|
|
if (otherStates && otherStates[otherFileNum] != RPMFILE_STATE_NORMAL)
|
1999-08-14 04:05:57 +08:00
|
|
|
continue;
|
2001-11-19 01:49:21 +08:00
|
|
|
#endif
|
1999-08-14 04:05:57 +08:00
|
|
|
|
2001-01-09 12:07:49 +08:00
|
|
|
if (XFA_SKIPPING(fi->actions[fileNum]))
|
2000-07-06 04:39:15 +08:00
|
|
|
continue;
|
|
|
|
|
2007-04-16 20:26:12 +08:00
|
|
|
if (!(fi->mapflags & CPIO_SBIT_CHECK)) {
|
|
|
|
int_16 omode = rpmfiFMode(otherFi);
|
|
|
|
if (S_ISREG(omode) && (omode & 06000) != 0) {
|
|
|
|
fi->mapflags |= CPIO_SBIT_CHECK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-07-10 04:18:54 +08:00
|
|
|
if (rpmfiCompare(otherFi, fi)) {
|
2004-07-05 23:24:17 +08:00
|
|
|
int rConflicts;
|
2003-07-10 04:18:54 +08:00
|
|
|
|
2004-07-05 23:24:17 +08:00
|
|
|
rConflicts = reportConflicts;
|
2003-07-10 04:18:54 +08:00
|
|
|
/* Resolve file conflicts to prefer Elf64 (if not forced). */
|
2004-07-05 23:24:17 +08:00
|
|
|
if (tscolor != 0 && FColor != 0 && FColor != oFColor)
|
2003-07-10 04:18:54 +08:00
|
|
|
{
|
2007-05-01 12:55:14 +08:00
|
|
|
if (oFColor & prefcolor) {
|
2004-10-10 03:40:09 +08:00
|
|
|
fi->actions[fileNum] = FA_SKIPCOLOR;
|
2004-07-05 23:24:17 +08:00
|
|
|
rConflicts = 0;
|
2003-07-10 04:18:54 +08:00
|
|
|
} else
|
2007-05-01 12:55:14 +08:00
|
|
|
if (FColor & prefcolor) {
|
2003-07-10 04:18:54 +08:00
|
|
|
fi->actions[fileNum] = FA_CREATE;
|
2004-07-05 23:24:17 +08:00
|
|
|
rConflicts = 0;
|
2003-07-10 04:18:54 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-07-05 23:24:17 +08:00
|
|
|
if (rConflicts) {
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmpsAppend(ps, RPMPROB_FILE_CONFLICT,
|
|
|
|
rpmteNEVR(p), rpmteKey(p),
|
|
|
|
rpmfiDN(fi), rpmfiBN(fi),
|
2001-11-10 01:22:08 +08:00
|
|
|
altNEVR,
|
2001-10-31 02:00:21 +08:00
|
|
|
0);
|
2001-11-10 01:22:08 +08:00
|
|
|
}
|
2003-07-10 04:18:54 +08:00
|
|
|
/* Save file identifier to mark as state REPLACED. */
|
|
|
|
if ( !(isCfgFile || XFA_SKIPPING(fi->actions[fileNum])) ) {
|
2007-09-12 01:07:39 +08:00
|
|
|
/* FIX: p->replaced, not fi */
|
1999-08-14 04:05:57 +08:00
|
|
|
if (!shared->isRemoved)
|
|
|
|
fi->replaced[numReplaced++] = *shared;
|
1999-07-14 22:36:10 +08:00
|
|
|
}
|
1999-08-14 04:05:57 +08:00
|
|
|
}
|
1998-12-19 03:09:38 +08:00
|
|
|
|
2003-07-10 04:18:54 +08:00
|
|
|
/* Determine config file dispostion, skipping missing files (if any). */
|
2002-07-28 08:41:15 +08:00
|
|
|
if (isCfgFile) {
|
2003-07-10 04:18:54 +08:00
|
|
|
int skipMissing =
|
|
|
|
((rpmtsFlags(ts) & RPMTRANS_FLAG_ALLFILES) ? 0 : 1);
|
2007-09-20 21:19:25 +08:00
|
|
|
rpmFileAction action = rpmfiDecideFate(otherFi, fi, skipMissing);
|
2001-11-19 01:49:21 +08:00
|
|
|
fi->actions[fileNum] = action;
|
1998-12-19 03:09:38 +08:00
|
|
|
}
|
2002-07-28 08:41:15 +08:00
|
|
|
fi->replacedSizes[fileNum] = rpmfiFSize(otherFi);
|
1998-12-19 03:09:38 +08:00
|
|
|
}
|
2002-05-20 02:42:25 +08:00
|
|
|
ps = rpmpsFree(ps);
|
1998-12-19 03:09:38 +08:00
|
|
|
|
2001-11-19 01:49:21 +08:00
|
|
|
altNEVR = _free(altNEVR);
|
2002-08-20 06:27:44 +08:00
|
|
|
otherFi = rpmfiFree(otherFi);
|
1998-12-19 03:09:38 +08:00
|
|
|
|
1999-09-22 01:21:57 +08:00
|
|
|
fi->replaced = xrealloc(fi->replaced, /* XXX memory leak */
|
1999-07-14 22:36:10 +08:00
|
|
|
sizeof(*fi->replaced) * (numReplaced + 1));
|
|
|
|
fi->replaced[numReplaced].otherPkg = 0;
|
1998-12-19 03:09:38 +08:00
|
|
|
|
1999-07-14 22:36:10 +08:00
|
|
|
return 0;
|
1998-12-19 03:09:38 +08:00
|
|
|
}
|
|
|
|
|
2001-09-26 04:51:34 +08:00
|
|
|
/**
|
|
|
|
*/
|
2001-10-19 09:24:21 +08:00
|
|
|
/* XXX only ts->rpmdb modified */
|
2002-05-20 02:42:25 +08:00
|
|
|
static int handleRmvdInstalledFiles(const rpmts ts, rpmfi fi,
|
2001-11-11 20:47:08 +08:00
|
|
|
sharedFileInfo shared, int sharedCount)
|
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;
|
2004-03-27 01:27:57 +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))
|
|
|
|
|
2002-07-28 22:52:33 +08:00
|
|
|
int _fps_debug = 0;
|
2001-11-16 02:22:33 +08:00
|
|
|
|
|
|
|
static int fpsCompare (const void * one, const void * two)
|
|
|
|
{
|
|
|
|
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);
|
|
|
|
if (_fps_debug)
|
|
|
|
fprintf(stderr, "\trc(%d) = strcmp(\"%s\", \"%s\")\n", rc, afn, bfn);
|
|
|
|
|
|
|
|
if (_fps_debug)
|
|
|
|
fprintf(stderr, "\t%s/%s%s\trc %d\n",
|
|
|
|
ISROOT(b->entry->dirName),
|
|
|
|
(b->subDir ? b->subDir : ""),
|
|
|
|
b->baseName,
|
|
|
|
rc
|
|
|
|
);
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int _linear_fps_search = 0;
|
|
|
|
|
|
|
|
static int findFps(const struct fingerPrint_s * fiFps,
|
|
|
|
const struct fingerPrint_s * otherFps,
|
|
|
|
int otherFc)
|
|
|
|
{
|
|
|
|
int otherFileNum;
|
|
|
|
|
|
|
|
if (_fps_debug)
|
|
|
|
fprintf(stderr, "==> %s/%s%s\n",
|
|
|
|
ISROOT(fiFps->entry->dirName),
|
|
|
|
(fiFps->subDir ? fiFps->subDir : ""),
|
|
|
|
fiFps->baseName);
|
|
|
|
|
|
|
|
if (_linear_fps_search) {
|
|
|
|
|
|
|
|
linear:
|
|
|
|
for (otherFileNum = 0; otherFileNum < otherFc; otherFileNum++, otherFps++) {
|
|
|
|
|
|
|
|
if (_fps_debug)
|
|
|
|
fprintf(stderr, "\t%4d %s/%s%s\n", otherFileNum,
|
|
|
|
ISROOT(otherFps->entry->dirName),
|
|
|
|
(otherFps->subDir ? otherFps->subDir : ""),
|
|
|
|
otherFps->baseName);
|
|
|
|
|
|
|
|
/* If the addresses are the same, so are the values. */
|
|
|
|
if (fiFps == otherFps)
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* Otherwise, compare fingerprints by value. */
|
|
|
|
if (FP_EQUAL((*fiFps), (*otherFps)))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (otherFileNum == otherFc) {
|
|
|
|
if (_fps_debug)
|
2002-07-28 08:41:15 +08:00
|
|
|
fprintf(stderr, "*** FP_EQUAL NULL %s/%s%s\n",
|
2001-11-16 02:22:33 +08:00
|
|
|
ISROOT(fiFps->entry->dirName),
|
|
|
|
(fiFps->subDir ? fiFps->subDir : ""),
|
|
|
|
fiFps->baseName);
|
|
|
|
}
|
|
|
|
|
|
|
|
return otherFileNum;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
const struct fingerPrint_s * bingoFps;
|
|
|
|
|
|
|
|
bingoFps = bsearch(fiFps, otherFps, otherFc, sizeof(*otherFps), fpsCompare);
|
|
|
|
if (bingoFps == NULL) {
|
2002-07-28 08:41:15 +08:00
|
|
|
if (_fps_debug)
|
|
|
|
fprintf(stderr, "*** bingoFps NULL %s/%s%s\n",
|
2001-11-16 02:22:33 +08:00
|
|
|
ISROOT(fiFps->entry->dirName),
|
|
|
|
(fiFps->subDir ? fiFps->subDir : ""),
|
|
|
|
fiFps->baseName);
|
|
|
|
goto linear;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If the addresses are the same, so are the values. */
|
2007-09-12 01:07:39 +08:00
|
|
|
/* LCL: looks good to me */
|
2001-11-16 02:22:33 +08:00
|
|
|
if (!(fiFps == bingoFps || FP_EQUAL((*fiFps), (*bingoFps)))) {
|
2002-07-28 08:41:15 +08:00
|
|
|
if (_fps_debug)
|
2001-11-16 02:22:33 +08:00
|
|
|
fprintf(stderr, "*** BAD %s/%s%s\n",
|
|
|
|
ISROOT(bingoFps->entry->dirName),
|
|
|
|
(bingoFps->subDir ? bingoFps->subDir : ""),
|
|
|
|
bingoFps->baseName);
|
|
|
|
goto linear;
|
|
|
|
}
|
|
|
|
|
|
|
|
otherFileNum = (bingoFps != NULL ? (bingoFps - otherFps) : 0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return otherFileNum;
|
|
|
|
}
|
|
|
|
|
2000-10-21 00:47:00 +08:00
|
|
|
/**
|
2002-05-20 02:42:25 +08:00
|
|
|
* Update disk space needs on each partition for this package's files.
|
2000-10-21 00:47:00 +08:00
|
|
|
*/
|
2001-10-19 09:24:21 +08:00
|
|
|
/* XXX only ts->{probs,di} modified */
|
2002-05-20 02:42:25 +08:00
|
|
|
static void handleOverlappedFiles(const rpmts ts,
|
|
|
|
const rpmte p, rpmfi fi)
|
1999-07-14 22:36:10 +08:00
|
|
|
{
|
|
|
|
uint_32 fixupSize = 0;
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmps ps;
|
2001-11-14 08:14:01 +08:00
|
|
|
const char * fn;
|
2001-10-19 00:39:54 +08:00
|
|
|
int i, j;
|
2004-03-27 01:27:57 +08:00
|
|
|
|
2002-05-28 05:40:08 +08:00
|
|
|
ps = rpmtsProblems(ts);
|
2002-05-20 02:42:25 +08:00
|
|
|
fi = rpmfiInit(fi, 0);
|
|
|
|
if (fi != NULL)
|
|
|
|
while ((i = rpmfiNext(fi)) >= 0) {
|
2003-07-10 04:18:54 +08:00
|
|
|
uint_32 tscolor = rpmtsColor(ts);
|
2007-05-01 12:55:14 +08:00
|
|
|
uint_32 prefcolor = rpmtsPrefColor(ts);
|
2003-07-10 04:18:54 +08:00
|
|
|
uint_32 oFColor, FColor;
|
2001-11-16 02:22:33 +08:00
|
|
|
struct fingerPrint_s * fiFps;
|
1999-08-15 04:01:38 +08:00
|
|
|
int otherPkgNum, otherFileNum;
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmfi otherFi;
|
2002-07-28 08:41:15 +08:00
|
|
|
int_32 FFlags;
|
|
|
|
int_16 FMode;
|
2002-05-20 02:42:25 +08:00
|
|
|
const rpmfi * recs;
|
1999-08-15 04:01:38 +08:00
|
|
|
int numRecs;
|
|
|
|
|
1999-08-16 03:11:40 +08:00
|
|
|
if (XFA_SKIPPING(fi->actions[i]))
|
1999-07-14 22:36:10 +08:00
|
|
|
continue;
|
1998-12-19 03:09:38 +08:00
|
|
|
|
2002-05-20 02:42:25 +08:00
|
|
|
fn = rpmfiFN(fi);
|
2001-11-16 02:22:33 +08:00
|
|
|
fiFps = fi->fps + i;
|
2002-07-28 08:41:15 +08:00
|
|
|
FFlags = rpmfiFFlags(fi);
|
|
|
|
FMode = rpmfiFMode(fi);
|
2003-07-10 04:18:54 +08:00
|
|
|
FColor = rpmfiFColor(fi);
|
|
|
|
FColor &= tscolor;
|
1999-10-20 18:22:46 +08:00
|
|
|
|
2002-05-20 02:42:25 +08:00
|
|
|
fixupSize = 0;
|
1998-12-19 03:09:38 +08:00
|
|
|
|
1999-08-18 07:05:24 +08:00
|
|
|
/*
|
|
|
|
* Retrieve all records that apply to this file. Note that the
|
|
|
|
* file info records were built in the same order as the packages
|
|
|
|
* will be installed and removed so the records for an overlapped
|
|
|
|
* files will be sorted in exactly the same order.
|
|
|
|
*/
|
2001-11-16 02:22:33 +08:00
|
|
|
(void) htGetEntry(ts->ht, fiFps,
|
2001-10-30 00:35:01 +08:00
|
|
|
(const void ***) &recs, &numRecs, NULL);
|
1999-08-18 07:05:24 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* If this package is being added, look only at other packages
|
|
|
|
* being added -- removed packages dance to a different tune.
|
2002-05-20 02:42:25 +08:00
|
|
|
*
|
1999-08-18 07:05:24 +08:00
|
|
|
* If both this and the other package are being added, overlapped
|
|
|
|
* files must be identical (or marked as a conflict). The
|
|
|
|
* disposition of already installed config files leads to
|
|
|
|
* a small amount of extra complexity.
|
|
|
|
*
|
|
|
|
* If this package is being removed, then there are two cases that
|
|
|
|
* need to be worried about:
|
|
|
|
* If the other package is being added, then skip any overlapped files
|
|
|
|
* so that this package removal doesn't nuke the overlapped files
|
|
|
|
* that were just installed.
|
|
|
|
* If both this and the other package are being removed, then each
|
|
|
|
* file removal from preceding packages needs to be skipped so that
|
|
|
|
* the file removal occurs only on the last occurence of an overlapped
|
|
|
|
* file in the transaction set.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Locate this overlapped file in the set of added/removed packages. */
|
2001-01-09 12:07:49 +08:00
|
|
|
for (j = 0; j < numRecs && recs[j] != fi; j++)
|
2001-06-06 03:26:22 +08:00
|
|
|
{};
|
1999-07-14 22:36:10 +08:00
|
|
|
|
1999-08-18 07:05:24 +08:00
|
|
|
/* Find what the previous disposition of this file was. */
|
1999-07-14 22:36:10 +08:00
|
|
|
otherFileNum = -1; /* keep gcc quiet */
|
2001-11-17 03:26:33 +08:00
|
|
|
otherFi = NULL;
|
1999-08-14 04:05:57 +08:00
|
|
|
for (otherPkgNum = j - 1; otherPkgNum >= 0; otherPkgNum--) {
|
2001-11-16 02:22:33 +08:00
|
|
|
struct fingerPrint_s * otherFps;
|
|
|
|
int otherFc;
|
|
|
|
|
|
|
|
otherFi = recs[otherPkgNum];
|
|
|
|
|
1999-08-18 07:05:24 +08:00
|
|
|
/* Added packages need only look at other added packages. */
|
2002-05-20 02:42:25 +08:00
|
|
|
if (rpmteType(p) == TR_ADDED && rpmteType(otherFi->te) != TR_ADDED)
|
2007-09-12 01:07:39 +08:00
|
|
|
continue;
|
1999-08-14 04:05:57 +08:00
|
|
|
|
2001-11-16 02:22:33 +08:00
|
|
|
otherFps = otherFi->fps;
|
2002-05-20 02:42:25 +08:00
|
|
|
otherFc = rpmfiFC(otherFi);
|
2000-06-17 03:12:09 +08:00
|
|
|
|
2001-11-16 02:22:33 +08:00
|
|
|
otherFileNum = findFps(fiFps, otherFps, otherFc);
|
2002-05-20 02:42:25 +08:00
|
|
|
(void) rpmfiSetFX(otherFi, otherFileNum);
|
2000-06-17 03:12:09 +08:00
|
|
|
|
2002-06-22 02:00:50 +08:00
|
|
|
/* XXX Happens iff fingerprint for incomplete package install. */
|
2001-11-16 02:22:33 +08:00
|
|
|
if (otherFi->actions[otherFileNum] != FA_UNKNOWN)
|
2007-09-12 01:07:39 +08:00
|
|
|
break;
|
1998-12-19 03:09:38 +08:00
|
|
|
}
|
|
|
|
|
2003-07-10 04:18:54 +08:00
|
|
|
oFColor = rpmfiFColor(otherFi);
|
|
|
|
oFColor &= tscolor;
|
|
|
|
|
2002-05-20 02:42:25 +08:00
|
|
|
switch (rpmteType(p)) {
|
1999-08-14 04:05:57 +08:00
|
|
|
case TR_ADDED:
|
2007-08-09 20:15:24 +08:00
|
|
|
{
|
2003-07-10 04:18:54 +08:00
|
|
|
int reportConflicts =
|
|
|
|
!(rpmtsFilterFlags(ts) & RPMPROB_FILTER_REPLACENEWFILES);
|
|
|
|
int done = 0;
|
|
|
|
|
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)
|
2007-09-12 01:07:39 +08:00
|
|
|
break;
|
2007-08-09 20:15:24 +08:00
|
|
|
if (rpmfiConfigConflict(fi)) {
|
1999-08-18 07:05:24 +08:00
|
|
|
/* Here is a non-overlapped pre-existing config file. */
|
2002-07-28 08:41:15 +08:00
|
|
|
fi->actions[i] = (FFlags & RPMFILE_NOREPLACE)
|
1999-07-14 22:36:10 +08:00
|
|
|
? FA_ALTNAME : FA_BACKUP;
|
1999-08-17 06:10:27 +08:00
|
|
|
} else {
|
1999-07-14 22:36:10 +08:00
|
|
|
fi->actions[i] = FA_CREATE;
|
1999-08-17 06:10:27 +08:00
|
|
|
}
|
2007-09-12 01:07:39 +08:00
|
|
|
break;
|
1999-07-14 22:36:10 +08:00
|
|
|
}
|
1999-08-17 06:10:27 +08:00
|
|
|
|
2001-11-16 08:26:30 +08:00
|
|
|
assert(otherFi != NULL);
|
2000-10-21 00:47:00 +08:00
|
|
|
/* Mark added overlapped non-identical files as a conflict. */
|
2003-07-10 04:18:54 +08:00
|
|
|
if (rpmfiCompare(otherFi, fi)) {
|
2004-07-05 23:24:17 +08:00
|
|
|
int rConflicts;
|
2003-07-10 04:18:54 +08:00
|
|
|
|
2004-07-05 23:24:17 +08:00
|
|
|
rConflicts = reportConflicts;
|
2003-07-10 04:18:54 +08:00
|
|
|
/* Resolve file conflicts to prefer Elf64 (if not forced) ... */
|
2004-07-05 23:24:17 +08:00
|
|
|
if (tscolor != 0) {
|
2007-05-01 12:55:14 +08:00
|
|
|
if (FColor & prefcolor) {
|
|
|
|
/* ... last file of preferred colour is installed ... */
|
2004-10-10 03:40:09 +08:00
|
|
|
if (!XFA_SKIPPING(fi->actions[i])) {
|
|
|
|
/* XXX static helpers are order dependent. Ick. */
|
|
|
|
if (strcmp(fn, "/usr/sbin/libgcc_post_upgrade")
|
|
|
|
&& strcmp(fn, "/usr/sbin/glibc_post_upgrade"))
|
2007-05-01 12:55:14 +08:00
|
|
|
otherFi->actions[otherFileNum] = FA_SKIPCOLOR;
|
2004-10-10 03:40:09 +08:00
|
|
|
}
|
2003-07-10 04:18:54 +08:00
|
|
|
fi->actions[i] = FA_CREATE;
|
2004-07-05 23:24:17 +08:00
|
|
|
rConflicts = 0;
|
2003-07-10 04:18:54 +08:00
|
|
|
} else
|
2007-05-01 12:55:14 +08:00
|
|
|
if (oFColor & prefcolor) {
|
|
|
|
/* ... first file of preferred colour is installed ... */
|
2003-07-10 04:18:54 +08:00
|
|
|
if (XFA_SKIPPING(fi->actions[i]))
|
|
|
|
otherFi->actions[otherFileNum] = FA_CREATE;
|
2004-10-10 03:40:09 +08:00
|
|
|
fi->actions[i] = FA_SKIPCOLOR;
|
2004-07-05 23:24:17 +08:00
|
|
|
rConflicts = 0;
|
2003-07-10 04:18:54 +08:00
|
|
|
} else
|
|
|
|
if (FColor == 0 && oFColor == 0) {
|
|
|
|
/* ... otherwise, do both, last in wins. */
|
|
|
|
otherFi->actions[otherFileNum] = FA_CREATE;
|
|
|
|
fi->actions[i] = FA_CREATE;
|
2004-07-05 23:24:17 +08:00
|
|
|
rConflicts = 0;
|
2003-07-10 04:18:54 +08:00
|
|
|
}
|
|
|
|
done = 1;
|
|
|
|
}
|
|
|
|
|
2004-07-05 23:24:17 +08:00
|
|
|
if (rConflicts) {
|
2003-07-10 04:18:54 +08:00
|
|
|
rpmpsAppend(ps, RPMPROB_NEW_FILE_CONFLICT,
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmteNEVR(p), rpmteKey(p),
|
2001-11-14 08:14:01 +08:00
|
|
|
fn, NULL,
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmteNEVR(otherFi->te),
|
2001-10-31 02:00:21 +08:00
|
|
|
0);
|
2003-07-10 04:18:54 +08:00
|
|
|
}
|
1999-07-14 22:36:10 +08:00
|
|
|
}
|
1998-12-19 03:09:38 +08:00
|
|
|
|
1999-08-18 07:05:24 +08:00
|
|
|
/* Try to get the disk accounting correct even if a conflict. */
|
2002-07-28 08:41:15 +08:00
|
|
|
fixupSize = rpmfiFSize(otherFi);
|
1998-12-19 03:09:38 +08:00
|
|
|
|
2007-08-09 20:15:24 +08:00
|
|
|
if (rpmfiConfigConflict(fi)) {
|
1999-08-18 07:05:24 +08:00
|
|
|
/* Here is an overlapped pre-existing config file. */
|
2002-07-28 08:41:15 +08:00
|
|
|
fi->actions[i] = (FFlags & RPMFILE_NOREPLACE)
|
1999-08-17 06:10:27 +08:00
|
|
|
? FA_ALTNAME : FA_SKIP;
|
|
|
|
} else {
|
2003-07-10 04:18:54 +08:00
|
|
|
if (!done)
|
|
|
|
fi->actions[i] = FA_CREATE;
|
1999-08-17 06:10:27 +08:00
|
|
|
}
|
2007-09-12 01:07:39 +08:00
|
|
|
} 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;
|
2007-09-12 01:07:39 +08:00
|
|
|
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]))
|
2007-09-12 01:07:39 +08:00
|
|
|
break;
|
2002-07-28 08:41:15 +08:00
|
|
|
if (rpmfiFState(fi) != RPMFILE_STATE_NORMAL)
|
2007-09-12 01:07:39 +08:00
|
|
|
break;
|
2002-07-28 08:41:15 +08:00
|
|
|
if (!(S_ISREG(FMode) && (FFlags & RPMFILE_CONFIG))) {
|
2001-02-09 05:50:38 +08:00
|
|
|
fi->actions[i] = FA_ERASE;
|
2007-09-12 01:07:39 +08:00
|
|
|
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. */
|
2007-07-11 18:48:43 +08:00
|
|
|
{ unsigned char md5sum[50];
|
2002-07-28 08:41:15 +08:00
|
|
|
const unsigned char * MD5 = rpmfiMD5(fi);
|
2002-07-22 06:06:19 +08:00
|
|
|
if (!domd5(fn, md5sum, 0, NULL) && memcmp(MD5, md5sum, 16)) {
|
2002-05-20 02:42:25 +08:00
|
|
|
fi->actions[i] = FA_BACKUP;
|
2007-09-12 01:07:39 +08:00
|
|
|
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;
|
2007-09-12 01:07:39 +08:00
|
|
|
break;
|
1999-07-14 22:36:10 +08:00
|
|
|
}
|
1998-12-19 03:09:38 +08:00
|
|
|
|
2002-05-20 02:42:25 +08:00
|
|
|
/* Update disk space info for a file. */
|
2003-01-02 01:26:46 +08:00
|
|
|
rpmtsUpdateDSI(ts, fiFps->entry->dev, rpmfiFSize(fi),
|
|
|
|
fi->replacedSizes[i], fixupSize, fi->actions[i]);
|
1998-12-19 03:09:38 +08:00
|
|
|
|
|
|
|
}
|
2002-05-20 02:42:25 +08:00
|
|
|
ps = rpmpsFree(ps);
|
1999-07-14 22:36:10 +08:00
|
|
|
}
|
1998-12-19 03:09:38 +08:00
|
|
|
|
2001-09-26 04:51:34 +08:00
|
|
|
/**
|
2001-11-11 03:24:19 +08:00
|
|
|
* Ensure that current package is newer than installed package.
|
|
|
|
* @param ts transaction set
|
|
|
|
* @param p current transaction element
|
|
|
|
* @param h installed header
|
|
|
|
* @return 0 if not newer, 1 if okay
|
2001-09-26 04:51:34 +08:00
|
|
|
*/
|
2002-05-20 02:42:25 +08:00
|
|
|
static int ensureOlder(rpmts ts,
|
|
|
|
const rpmte p, const Header h)
|
2001-11-11 03:24:19 +08:00
|
|
|
{
|
|
|
|
int_32 reqFlags = (RPMSENSE_LESS | RPMSENSE_EQUAL);
|
2001-11-11 08:11:33 +08:00
|
|
|
const char * reqEVR;
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmds req;
|
2001-11-11 03:24:19 +08:00
|
|
|
char * t;
|
2001-11-17 03:26:33 +08:00
|
|
|
int nb;
|
2001-11-11 03:24:19 +08:00
|
|
|
int rc;
|
|
|
|
|
|
|
|
if (p == NULL || h == NULL)
|
|
|
|
return 1;
|
|
|
|
|
2002-05-20 02:42:25 +08:00
|
|
|
nb = strlen(rpmteNEVR(p)) + (rpmteE(p) != NULL ? strlen(rpmteE(p)) : 0) + 1;
|
2001-11-17 03:26:33 +08:00
|
|
|
t = alloca(nb);
|
2001-11-11 03:24:19 +08:00
|
|
|
*t = '\0';
|
|
|
|
reqEVR = t;
|
2002-05-20 02:42:25 +08:00
|
|
|
if (rpmteE(p) != NULL) t = stpcpy( stpcpy(t, rpmteE(p)), ":");
|
|
|
|
if (rpmteV(p) != NULL) t = stpcpy(t, rpmteV(p));
|
2001-11-11 03:24:19 +08:00
|
|
|
*t++ = '-';
|
2002-05-20 02:42:25 +08:00
|
|
|
if (rpmteR(p) != NULL) t = stpcpy(t, rpmteR(p));
|
2004-03-27 01:27:57 +08:00
|
|
|
|
2002-05-20 02:42:25 +08:00
|
|
|
req = rpmdsSingle(RPMTAG_REQUIRENAME, rpmteN(p), reqEVR, reqFlags);
|
2002-07-30 07:06:06 +08:00
|
|
|
rc = rpmdsNVRMatchesDep(h, req, _rpmds_nopromote);
|
2002-05-20 02:42:25 +08:00
|
|
|
req = rpmdsFree(req);
|
2001-11-11 03:24:19 +08:00
|
|
|
|
|
|
|
if (rc == 0) {
|
2002-05-28 05:40:08 +08:00
|
|
|
rpmps ps = rpmtsProblems(ts);
|
2001-11-11 03:24:19 +08:00
|
|
|
const char * altNEVR = hGetNEVR(h, NULL);
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmpsAppend(ps, RPMPROB_OLDPACKAGE,
|
|
|
|
rpmteNEVR(p), rpmteKey(p),
|
2001-11-11 03:24:19 +08:00
|
|
|
NULL, NULL,
|
|
|
|
altNEVR,
|
|
|
|
0);
|
|
|
|
altNEVR = _free(altNEVR);
|
2002-05-20 02:42:25 +08:00
|
|
|
ps = rpmpsFree(ps);
|
2001-11-11 03:24:19 +08:00
|
|
|
rc = 1;
|
|
|
|
} else
|
|
|
|
rc = 0;
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
1999-01-01 03:16:31 +08:00
|
|
|
|
2001-09-26 04:51:34 +08:00
|
|
|
/**
|
2002-12-25 01:06:35 +08:00
|
|
|
* Skip any files that do not match install policies.
|
|
|
|
* @param ts transaction set
|
|
|
|
* @param fi file info set
|
2001-09-26 04:51:34 +08:00
|
|
|
*/
|
2007-09-12 01:07:39 +08:00
|
|
|
/* FIX: fi->actions is modified. */
|
2002-05-20 02:42:25 +08:00
|
|
|
static void skipFiles(const rpmts ts, rpmfi fi)
|
1999-07-14 22:36:10 +08:00
|
|
|
{
|
2002-12-31 09:23:03 +08:00
|
|
|
uint_32 tscolor = rpmtsColor(ts);
|
2003-07-10 04:18:54 +08:00
|
|
|
uint_32 FColor;
|
2002-12-25 01:06:35 +08:00
|
|
|
int noConfigs = (rpmtsFlags(ts) & RPMTRANS_FLAG_NOCONFIGS);
|
2002-05-20 07:37:24 +08:00
|
|
|
int noDocs = (rpmtsFlags(ts) & RPMTRANS_FLAG_NODOCS);
|
1999-08-07 08:07:51 +08:00
|
|
|
char ** netsharedPaths = NULL;
|
|
|
|
const char ** languages;
|
2001-04-04 04:41:09 +08:00
|
|
|
const char * dn, * bn;
|
|
|
|
int dnlen, bnlen, ix;
|
2000-07-08 04:06:41 +08:00
|
|
|
const char * s;
|
2001-04-03 21:41:56 +08:00
|
|
|
int * drc;
|
|
|
|
char * dff;
|
2001-11-16 08:26:30 +08:00
|
|
|
int dc;
|
2001-04-03 21:41:56 +08:00
|
|
|
int i, j;
|
1999-01-01 03:16:31 +08:00
|
|
|
|
1999-07-14 22:36:10 +08:00
|
|
|
if (!noDocs)
|
|
|
|
noDocs = rpmExpandNumeric("%{_excludedocs}");
|
1999-01-01 03:16:31 +08:00
|
|
|
|
1999-07-14 22:36:10 +08:00
|
|
|
{ const char *tmpPath = rpmExpand("%{_netsharedpath}", NULL);
|
|
|
|
if (tmpPath && *tmpPath != '%')
|
|
|
|
netsharedPaths = splitString(tmpPath, strlen(tmpPath), ':');
|
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-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;
|
1999-01-01 03:16:31 +08:00
|
|
|
|
2001-04-03 21:41:56 +08:00
|
|
|
/* Compute directory refcount, skip directory if now empty. */
|
2002-05-20 02:42:25 +08:00
|
|
|
dc = rpmfiDC(fi);
|
2001-11-16 08:26:30 +08:00
|
|
|
drc = alloca(dc * sizeof(*drc));
|
|
|
|
memset(drc, 0, dc * sizeof(*drc));
|
|
|
|
dff = alloca(dc * sizeof(*dff));
|
|
|
|
memset(dff, 0, dc * sizeof(*dff));
|
|
|
|
|
2002-05-20 02:42:25 +08:00
|
|
|
fi = rpmfiInit(fi, 0);
|
2002-03-13 00:56:17 +08:00
|
|
|
if (fi != NULL) /* XXX lclint */
|
2002-05-20 02:42:25 +08:00
|
|
|
while ((i = rpmfiNext(fi)) >= 0)
|
2001-11-16 08:26:30 +08:00
|
|
|
{
|
2002-12-31 09:23:03 +08:00
|
|
|
char ** nsp;
|
1999-08-07 08:07:51 +08:00
|
|
|
|
2002-05-20 02:42:25 +08:00
|
|
|
bn = rpmfiBN(fi);
|
2001-11-16 08:26:30 +08:00
|
|
|
bnlen = strlen(bn);
|
2002-05-20 02:42:25 +08:00
|
|
|
ix = rpmfiDX(fi);
|
|
|
|
dn = rpmfiDN(fi);
|
2001-11-16 08:26:30 +08:00
|
|
|
dnlen = strlen(dn);
|
|
|
|
if (dn == NULL)
|
|
|
|
continue; /* XXX can't happen */
|
2001-04-04 04:41:09 +08:00
|
|
|
|
|
|
|
drc[ix]++;
|
2001-04-03 21:41:56 +08:00
|
|
|
|
1999-08-07 08:07:51 +08:00
|
|
|
/* Don't bother with skipped files */
|
2001-04-03 21:41:56 +08:00
|
|
|
if (XFA_SKIPPING(fi->actions[i])) {
|
2003-01-02 01:26:46 +08:00
|
|
|
drc[ix]--; dff[ix] = 1;
|
1999-07-14 22:36:10 +08:00
|
|
|
continue;
|
2001-04-03 21:41:56 +08:00
|
|
|
}
|
1999-01-01 03:16:31 +08:00
|
|
|
|
2002-12-31 09:23:03 +08:00
|
|
|
/* Ignore colored files not in our rainbow. */
|
2003-07-10 04:18:54 +08:00
|
|
|
FColor = rpmfiFColor(fi);
|
|
|
|
if (tscolor && FColor && !(tscolor & FColor)) {
|
2002-12-31 09:23:03 +08:00
|
|
|
drc[ix]--; dff[ix] = 1;
|
|
|
|
fi->actions[i] = FA_SKIPCOLOR;
|
2003-01-02 01:26:46 +08:00
|
|
|
continue;
|
2002-12-31 09:23:03 +08:00
|
|
|
}
|
|
|
|
|
1999-08-07 08:07:51 +08:00
|
|
|
/*
|
|
|
|
* Skip net shared paths.
|
|
|
|
* Net shared paths are not relative to the current root (though
|
|
|
|
* they do need to take package relocations into account).
|
|
|
|
*/
|
1999-07-14 22:36:10 +08:00
|
|
|
for (nsp = netsharedPaths; nsp && *nsp; nsp++) {
|
2001-04-03 21:41:56 +08:00
|
|
|
int len;
|
1999-10-20 18:22:46 +08:00
|
|
|
|
1999-08-07 08:07:51 +08:00
|
|
|
len = strlen(*nsp);
|
2001-04-04 04:41:09 +08:00
|
|
|
if (dnlen >= len) {
|
2001-10-14 06:01:38 +08:00
|
|
|
if (strncmp(dn, *nsp, len))
|
2007-09-12 01:07:39 +08:00
|
|
|
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'))
|
2007-09-12 01:07:39 +08:00
|
|
|
continue;
|
2001-04-04 04:41:09 +08:00
|
|
|
} else {
|
2001-10-14 06:01:38 +08:00
|
|
|
if (len < (dnlen + bnlen))
|
2007-09-12 01:07:39 +08:00
|
|
|
continue;
|
2001-10-14 06:01:38 +08:00
|
|
|
if (strncmp(dn, *nsp, dnlen))
|
2007-09-12 01:07:39 +08:00
|
|
|
continue;
|
2007-02-22 20:27:42 +08:00
|
|
|
/* Insure that only the netsharedpath basename is compared. */
|
|
|
|
if ((s = strchr((*nsp) + dnlen, '/')) != NULL && s[1] != '\0')
|
2007-09-12 01:07:39 +08:00
|
|
|
continue;
|
2001-10-14 06:01:38 +08:00
|
|
|
if (strncmp(bn, (*nsp) + dnlen, bnlen))
|
2007-09-12 01:07:39 +08:00
|
|
|
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'))
|
2007-09-12 01:07:39 +08:00
|
|
|
continue;
|
2001-04-04 04:41:09 +08:00
|
|
|
}
|
1999-08-07 08:07:51 +08:00
|
|
|
|
2007-09-12 01:07:39 +08:00
|
|
|
break;
|
1999-01-01 03:16:31 +08:00
|
|
|
}
|
1999-07-14 22:36:10 +08:00
|
|
|
|
|
|
|
if (nsp && *nsp) {
|
2001-04-04 04:41:09 +08:00
|
|
|
drc[ix]--; dff[ix] = 1;
|
1999-08-16 03:11:40 +08:00
|
|
|
fi->actions[i] = FA_SKIPNETSHARED;
|
1999-07-14 22:36:10 +08:00
|
|
|
continue;
|
1999-01-01 03:16:31 +08:00
|
|
|
}
|
|
|
|
|
1999-08-07 08:07:51 +08:00
|
|
|
/*
|
|
|
|
* Skip i18n language specific files.
|
|
|
|
*/
|
2003-04-03 05:16:26 +08:00
|
|
|
if (languages != NULL && fi->flangs != NULL && *fi->flangs[i]) {
|
1999-08-07 08:07:51 +08:00
|
|
|
const char **lang, *l, *le;
|
2001-10-17 01:42:18 +08:00
|
|
|
for (lang = languages; *lang != NULL; lang++) {
|
1999-08-22 12:17:12 +08:00
|
|
|
if (!strcmp(*lang, "all"))
|
2007-09-12 01:07:39 +08:00
|
|
|
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)))
|
2007-09-12 01:07:39 +08:00
|
|
|
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')
|
2007-09-12 01:07:39 +08:00
|
|
|
break;
|
1999-07-14 22:36:10 +08:00
|
|
|
}
|
1999-08-07 08:07:51 +08:00
|
|
|
if (*lang == NULL) {
|
2001-04-04 04:41:09 +08:00
|
|
|
drc[ix]--; dff[ix] = 1;
|
1999-07-14 22:36:10 +08:00
|
|
|
fi->actions[i] = FA_SKIPNSTATE;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
1999-01-01 03:16:31 +08:00
|
|
|
|
2002-12-25 01:06:35 +08:00
|
|
|
/*
|
|
|
|
* Skip config files if requested.
|
|
|
|
*/
|
|
|
|
if (noConfigs && (rpmfiFFlags(fi) & RPMFILE_CONFIG)) {
|
|
|
|
drc[ix]--; dff[ix] = 1;
|
|
|
|
fi->actions[i] = FA_SKIPNSTATE;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
1999-08-07 08:07:51 +08:00
|
|
|
/*
|
|
|
|
* Skip documentation if requested.
|
|
|
|
*/
|
2002-05-20 02:42:25 +08:00
|
|
|
if (noDocs && (rpmfiFFlags(fi) & RPMFILE_DOC)) {
|
2001-04-04 04:41:09 +08:00
|
|
|
drc[ix]--; dff[ix] = 1;
|
1999-07-14 22:36:10 +08:00
|
|
|
fi->actions[i] = FA_SKIPNSTATE;
|
2001-04-21 14:02:09 +08:00
|
|
|
continue;
|
2001-04-03 21:41:56 +08:00
|
|
|
}
|
1999-01-01 03:16:31 +08:00
|
|
|
}
|
|
|
|
|
2001-04-03 21:41:56 +08:00
|
|
|
/* Skip (now empty) directories that had skipped files. */
|
2001-11-16 08:26:30 +08:00
|
|
|
#ifndef NOTYET
|
|
|
|
if (fi != NULL) /* XXX can't happen */
|
|
|
|
for (j = 0; j < dc; j++)
|
|
|
|
#else
|
2002-05-20 02:42:25 +08:00
|
|
|
if ((fi = rpmfiInitD(fi)) != NULL)
|
|
|
|
while (j = rpmfiNextD(fi) >= 0)
|
2001-11-16 08:26:30 +08:00
|
|
|
#endif
|
|
|
|
{
|
2001-04-03 21:41:56 +08:00
|
|
|
|
|
|
|
if (drc[j]) continue; /* dir still has files. */
|
|
|
|
if (!dff[j]) continue; /* dir was not emptied here. */
|
|
|
|
|
|
|
|
/* Find parent directory and basename. */
|
|
|
|
dn = fi->dnl[j]; dnlen = strlen(dn) - 1;
|
|
|
|
bn = dn + dnlen; bnlen = 0;
|
|
|
|
while (bn > dn && bn[-1] != '/') {
|
|
|
|
bnlen++;
|
|
|
|
dnlen--;
|
|
|
|
bn--;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If explicitly included in the package, skip the directory. */
|
2002-05-20 02:42:25 +08:00
|
|
|
fi = rpmfiInit(fi, 0);
|
2002-03-13 00:56:17 +08:00
|
|
|
if (fi != NULL) /* XXX lclint */
|
2002-05-20 02:42:25 +08:00
|
|
|
while ((i = rpmfiNext(fi)) >= 0) {
|
2002-07-28 08:41:15 +08:00
|
|
|
const char * fdn, * fbn;
|
|
|
|
int_16 fFMode;
|
2001-04-03 21:41:56 +08:00
|
|
|
|
|
|
|
if (XFA_SKIPPING(fi->actions[i]))
|
2007-09-12 01:07:39 +08:00
|
|
|
continue;
|
2002-07-28 08:41:15 +08:00
|
|
|
|
|
|
|
fFMode = rpmfiFMode(fi);
|
|
|
|
|
2007-09-26 14:57:26 +08:00
|
|
|
if (rpmfiWhatis(fFMode) != XDIR)
|
2007-09-12 01:07:39 +08:00
|
|
|
continue;
|
2002-07-28 08:41:15 +08:00
|
|
|
fdn = rpmfiDN(fi);
|
|
|
|
if (strlen(fdn) != dnlen)
|
2007-09-12 01:07:39 +08:00
|
|
|
continue;
|
2002-07-28 08:41:15 +08:00
|
|
|
if (strncmp(fdn, dn, dnlen))
|
2007-09-12 01:07:39 +08:00
|
|
|
continue;
|
2002-07-28 08:41:15 +08:00
|
|
|
fbn = rpmfiBN(fi);
|
|
|
|
if (strlen(fbn) != bnlen)
|
2007-09-12 01:07:39 +08:00
|
|
|
continue;
|
2002-07-28 08:41:15 +08:00
|
|
|
if (strncmp(fbn, bn, bnlen))
|
2007-09-12 01:07:39 +08:00
|
|
|
continue;
|
2007-10-09 19:48:04 +08:00
|
|
|
rpmlog(RPMLOG_DEBUG, _("excluding directory %s\n"), dn);
|
2001-04-03 21:41:56 +08:00
|
|
|
fi->actions[i] = FA_SKIPNSTATE;
|
2007-09-12 01:07:39 +08:00
|
|
|
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-11-14 08:14:01 +08:00
|
|
|
/**
|
|
|
|
* Return transaction element's file info.
|
2002-05-20 02:42:25 +08:00
|
|
|
* @todo Take a rpmfi refcount here.
|
2002-05-28 05:40:08 +08:00
|
|
|
* @param tsi transaction element iterator
|
2001-11-14 08:14:01 +08:00
|
|
|
* @return transaction element file info
|
|
|
|
*/
|
2007-09-12 01:07:39 +08:00
|
|
|
static
|
2002-05-28 05:40:08 +08:00
|
|
|
rpmfi rpmtsiFi(const rpmtsi tsi)
|
2001-11-14 08:14:01 +08:00
|
|
|
{
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmfi fi = NULL;
|
2001-11-14 08:14:01 +08:00
|
|
|
|
2002-05-28 05:40:08 +08:00
|
|
|
if (tsi != NULL && tsi->ocsave != -1) {
|
2007-09-12 01:07:39 +08:00
|
|
|
/* FIX: rpmte not opaque */
|
2002-05-28 05:40:08 +08:00
|
|
|
rpmte te = rpmtsElement(tsi->ts, tsi->ocsave);
|
2002-05-20 07:37:24 +08:00
|
|
|
if (te != NULL && (fi = te->fi) != NULL)
|
2001-11-14 08:14:01 +08:00
|
|
|
fi->te = te;
|
|
|
|
}
|
|
|
|
return fi;
|
|
|
|
}
|
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
/**
|
|
|
|
* This is not a generalized function to be called from outside
|
|
|
|
* librpm. It is called internally by rpmtsRun() to rollback
|
|
|
|
* a failed transaction.
|
|
|
|
* @param rollbackTransaction rollback transaction
|
|
|
|
* @return RPMRC_OK, or RPMRC_FAIL
|
|
|
|
*/
|
|
|
|
static rpmRC _rpmtsRollback(rpmts rollbackTransaction)
|
1999-07-14 22:36:10 +08:00
|
|
|
{
|
2004-03-27 01:27:57 +08:00
|
|
|
int rc = 0;
|
|
|
|
int numAdded = 0;
|
|
|
|
int numRemoved = 0;
|
|
|
|
int_32 tid;
|
|
|
|
rpmtsi tsi;
|
|
|
|
rpmte te;
|
|
|
|
rpmps ps;
|
1999-01-01 03:16:31 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
/*
|
|
|
|
* Gather information about this rollback transaction for reporting.
|
|
|
|
* 1) Get tid
|
2004-03-06 02:22:25 +08:00
|
|
|
*/
|
2004-03-27 01:27:57 +08:00
|
|
|
tid = rpmtsGetTid(rollbackTransaction);
|
2001-01-25 05:35:52 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
/*
|
|
|
|
* 2) Get number of install elments and erase elements
|
|
|
|
*/
|
|
|
|
tsi = rpmtsiInit(rollbackTransaction);
|
|
|
|
while((te = rpmtsiNext(tsi, 0)) != NULL) {
|
|
|
|
switch (rpmteType(te)) {
|
|
|
|
case TR_ADDED:
|
|
|
|
numAdded++;
|
2007-09-12 01:07:39 +08:00
|
|
|
break;
|
2004-03-27 01:27:57 +08:00
|
|
|
case TR_REMOVED:
|
|
|
|
numRemoved++;
|
2007-09-12 01:07:39 +08:00
|
|
|
break;
|
2004-03-27 01:27:57 +08:00
|
|
|
default:
|
2007-09-12 01:07:39 +08:00
|
|
|
break;
|
2004-03-27 01:27:57 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
tsi = rpmtsiFree(tsi);
|
2002-05-18 05:08:39 +08:00
|
|
|
|
2007-10-09 19:14:30 +08:00
|
|
|
rpmlog(RPMMESS_NORMAL, _("Transaction failed...rolling back\n"));
|
|
|
|
rpmlog(RPMMESS_NORMAL,
|
2004-03-27 01:27:57 +08:00
|
|
|
_("Rollback packages (+%d/-%d) to %-24.24s (0x%08x):\n"),
|
2007-07-10 18:32:45 +08:00
|
|
|
numAdded, numRemoved, ctime((time_t*) &tid), tid);
|
2002-06-29 11:16:34 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
/* Check the transaction to see if it is doable */
|
|
|
|
rc = rpmtsCheck(rollbackTransaction);
|
|
|
|
ps = rpmtsProblems(rollbackTransaction);
|
|
|
|
if (rc != 0 && rpmpsNumProblems(ps) > 0) {
|
2007-10-09 19:14:30 +08:00
|
|
|
rpmlog(RPMMESS_ERROR, _("Failed dependencies:\n"));
|
2004-03-27 01:27:57 +08:00
|
|
|
rpmpsPrint(NULL, ps);
|
|
|
|
ps = rpmpsFree(ps);
|
|
|
|
return -1;
|
2002-06-29 11:16:34 +08:00
|
|
|
}
|
2004-03-27 01:27:57 +08:00
|
|
|
ps = rpmpsFree(ps);
|
2002-06-29 11:16:34 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
/* Order the transaction */
|
|
|
|
rc = rpmtsOrder(rollbackTransaction);
|
|
|
|
if (rc != 0) {
|
2007-10-09 19:14:30 +08:00
|
|
|
rpmlog(RPMMESS_ERROR,
|
2004-03-27 01:27:57 +08:00
|
|
|
_("Could not order auto-rollback transaction!\n"));
|
|
|
|
return -1;
|
2002-05-18 05:08:39 +08:00
|
|
|
}
|
|
|
|
|
2000-07-09 23:17:11 +08:00
|
|
|
|
1999-01-05 00:44:20 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
/* Run the transaction and print any problems
|
|
|
|
* We want to stay with the original transactions flags except
|
|
|
|
* that we want to add what is essentially a force.
|
|
|
|
* This handles two things in particular:
|
|
|
|
*
|
|
|
|
* 1. We we want to upgrade over a newer package.
|
|
|
|
* 2. If a header for the old package is there we
|
|
|
|
* we want to replace it. No questions asked.
|
1999-08-07 07:44:25 +08:00
|
|
|
*/
|
2004-03-27 01:27:57 +08:00
|
|
|
rc = rpmtsRun(rollbackTransaction, NULL,
|
|
|
|
RPMPROB_FILTER_REPLACEPKG
|
|
|
|
| RPMPROB_FILTER_REPLACEOLDFILES
|
|
|
|
| RPMPROB_FILTER_REPLACENEWFILES
|
|
|
|
| RPMPROB_FILTER_OLDPACKAGE
|
|
|
|
);
|
|
|
|
ps = rpmtsProblems(rollbackTransaction);
|
|
|
|
if (rc > 0 && rpmpsNumProblems(ps) > 0)
|
|
|
|
rpmpsPrint(stderr, ps);
|
|
|
|
ps = rpmpsFree(ps);
|
2004-05-04 01:29:16 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* After we have ran through the transaction we need to
|
|
|
|
* remove any repackaged packages we just installed/upgraded
|
|
|
|
* from the rp repository.
|
|
|
|
*/
|
|
|
|
tsi = rpmtsiInit(rollbackTransaction);
|
|
|
|
while((te = rpmtsiNext(tsi, 0)) != NULL) {
|
2007-10-09 19:14:30 +08:00
|
|
|
rpmlog(RPMMESS_NORMAL, _("Cleaning up repackaged packages:\n"));
|
2004-05-04 01:29:16 +08:00
|
|
|
switch (rpmteType(te)) {
|
|
|
|
/* The install elements are repackaged packages */
|
|
|
|
case TR_ADDED:
|
|
|
|
/* Make sure the filename is still there. XXX: Can't happen */
|
|
|
|
if(te->key) {
|
2007-10-09 19:14:30 +08:00
|
|
|
rpmlog(RPMMESS_NORMAL, _("\tRemoving %s:\n"), te->key);
|
2004-05-04 01:29:16 +08:00
|
|
|
(void) unlink(te->key); /* XXX: Should check for an error? */
|
|
|
|
}
|
2007-09-12 01:07:39 +08:00
|
|
|
break;
|
2004-05-04 01:29:16 +08:00
|
|
|
|
|
|
|
/* Ignore erase elements...nothing to do */
|
|
|
|
default:
|
2007-09-12 01:07:39 +08:00
|
|
|
break;
|
2004-05-04 01:29:16 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
tsi = rpmtsiFree(tsi);
|
|
|
|
|
|
|
|
/* Free the rollback transaction */
|
2004-03-27 01:27:57 +08:00
|
|
|
rollbackTransaction = rpmtsFree(rollbackTransaction);
|
2002-07-19 05:42:18 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
return rc;
|
|
|
|
}
|
1999-01-08 01:06:24 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
/**
|
|
|
|
* Get the repackaged header and filename from the repackage directory.
|
|
|
|
* @todo Find a suitable home for this function.
|
|
|
|
* @todo This function creates an IDTX everytime it is called. Needs to
|
|
|
|
* be made more efficient (only create on per running transaction).
|
|
|
|
* @param ts rpm transaction
|
|
|
|
* @param te transaction element
|
2004-10-20 18:19:34 +08:00
|
|
|
* @retval hdrp Repackaged header
|
|
|
|
* @retval fnp Repackaged package's path (transaction key)
|
2004-03-27 01:27:57 +08:00
|
|
|
* @return RPMRC_NOTFOUND or RPMRC_OK
|
|
|
|
*/
|
|
|
|
static rpmRC getRepackageHeaderFromTE(rpmts ts, rpmte te,
|
2007-09-12 01:07:39 +08:00
|
|
|
Header *hdrp,
|
|
|
|
const char **fnp)
|
2004-03-27 01:27:57 +08:00
|
|
|
{
|
|
|
|
int_32 tid;
|
|
|
|
const char * name;
|
|
|
|
const char * rpname = NULL;
|
|
|
|
const char * _repackage_dir = NULL;
|
|
|
|
const char * globStr = "-*.rpm";
|
|
|
|
char * rp = NULL; /* Rollback package name */
|
|
|
|
IDTX rtids = NULL;
|
|
|
|
IDT rpIDT;
|
|
|
|
int nrids = 0;
|
|
|
|
int nb; /* Number of bytes */
|
|
|
|
Header h = NULL;
|
|
|
|
int rc = RPMRC_NOTFOUND; /* Assume we do not find it*/
|
|
|
|
int xx;
|
1999-01-05 00:44:20 +08:00
|
|
|
|
2007-10-09 19:48:04 +08:00
|
|
|
rpmlog(RPMLOG_DEBUG,
|
2004-03-27 01:27:57 +08:00
|
|
|
_("Getting repackaged header from transaction element\n"));
|
1999-03-19 11:39:17 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
/* Set header pointer to null if its not already */
|
|
|
|
if (hdrp)
|
|
|
|
*hdrp = NULL;
|
2004-10-20 18:19:34 +08:00
|
|
|
if (fnp)
|
|
|
|
*fnp = NULL;
|
2001-06-15 12:56:33 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
/* Get the TID of the current transaction */
|
|
|
|
tid = rpmtsGetTid(ts);
|
|
|
|
/* Need the repackage dir if the user want to
|
|
|
|
* rollback on a failure.
|
|
|
|
*/
|
|
|
|
_repackage_dir = rpmExpand("%{?_repackage_dir}", NULL);
|
|
|
|
if (_repackage_dir == NULL) goto exit;
|
1999-01-05 00:44:20 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
/* Build the glob string to find the possible repackaged
|
|
|
|
* packages for this package.
|
|
|
|
*/
|
|
|
|
name = rpmteN(te);
|
|
|
|
nb = strlen(_repackage_dir) + strlen(name) + strlen(globStr) + 2;
|
|
|
|
rp = memset((char *) malloc(nb), 0, nb);
|
|
|
|
xx = snprintf(rp, nb, "%s/%s%s.rpm", _repackage_dir, name, globStr);
|
2001-10-31 02:00:21 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
/* Get the index of possible repackaged packages */
|
2007-10-09 19:48:04 +08:00
|
|
|
rpmlog(RPMLOG_DEBUG, _("\tLooking for %s...\n"), rp);
|
2004-03-27 01:27:57 +08:00
|
|
|
rtids = IDTXglob(ts, rp, RPMTAG_REMOVETID);
|
|
|
|
rp = _free(rp);
|
|
|
|
if (rtids != NULL) {
|
2007-10-09 19:48:04 +08:00
|
|
|
rpmlog(RPMLOG_DEBUG, _("\tMatches found.\n"));
|
2004-03-27 01:27:57 +08:00
|
|
|
rpIDT = rtids->idt;
|
|
|
|
nrids = rtids->nidt;
|
|
|
|
} else {
|
2007-10-09 19:48:04 +08:00
|
|
|
rpmlog(RPMLOG_DEBUG, _("\tNo matches found.\n"));
|
2004-03-27 01:27:57 +08:00
|
|
|
goto exit;
|
1999-07-14 22:36:10 +08:00
|
|
|
}
|
1999-01-05 00:44:20 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
/* Now walk through index until we find the package (or we have
|
|
|
|
* exhausted the index.
|
|
|
|
*/
|
|
|
|
do {
|
|
|
|
/* If index is null we have exhausted the list and need to
|
|
|
|
* get out of here...the repackaged package was not found.
|
|
|
|
*/
|
|
|
|
if (rpIDT == NULL) {
|
2007-10-09 19:48:04 +08:00
|
|
|
rpmlog(RPMLOG_DEBUG, _("\tRepackaged package not found!.\n"));
|
2004-03-27 01:27:57 +08:00
|
|
|
break;
|
|
|
|
}
|
2001-11-16 08:26:30 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
/* Is this the same tid. If not decrement the list and continue */
|
|
|
|
if (rpIDT->val.u32 != tid) {
|
|
|
|
nrids--;
|
|
|
|
if (nrids > 0)
|
|
|
|
rpIDT++;
|
|
|
|
else
|
|
|
|
rpIDT = NULL;
|
|
|
|
continue;
|
|
|
|
}
|
2001-11-16 08:26:30 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
/* OK, the tid matches. Now lets see if the name is the same.
|
|
|
|
* If I could not get the name from the package, I will go onto
|
|
|
|
* the next one. Perhaps I should return an error at this
|
|
|
|
* point, but if this was not the correct one, at least the correct one
|
|
|
|
* would be found.
|
2004-05-04 01:29:16 +08:00
|
|
|
* XXX: Should Match NAC!
|
2004-03-27 01:27:57 +08:00
|
|
|
*/
|
2007-10-09 19:48:04 +08:00
|
|
|
rpmlog(RPMLOG_DEBUG, _("\tREMOVETID matched INSTALLTID.\n"));
|
2004-03-27 01:27:57 +08:00
|
|
|
if (headerGetEntry(rpIDT->h, RPMTAG_NAME, NULL, (void **) &rpname, NULL)) {
|
2007-10-09 19:48:04 +08:00
|
|
|
rpmlog(RPMLOG_DEBUG, _("\t\tName: %s.\n"), rpname);
|
2004-03-27 01:27:57 +08:00
|
|
|
if (!strcmp(name,rpname)) {
|
|
|
|
/* It matched we have a canidate */
|
|
|
|
h = headerLink(rpIDT->h);
|
|
|
|
nb = strlen(rpIDT->key) + 1;
|
|
|
|
rp = memset((char *) malloc(nb), 0, nb);
|
|
|
|
rp = strncat(rp, rpIDT->key, nb);
|
|
|
|
rc = RPMRC_OK;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Decrement list */
|
|
|
|
nrids--;
|
|
|
|
if (nrids > 0)
|
|
|
|
rpIDT++;
|
|
|
|
else
|
|
|
|
rpIDT = NULL;
|
|
|
|
} while (1);
|
|
|
|
|
|
|
|
exit:
|
|
|
|
if (rc != RPMRC_NOTFOUND && h != NULL && hdrp != NULL) {
|
2007-10-09 19:48:04 +08:00
|
|
|
rpmlog(RPMLOG_DEBUG, _("\tRepackaged Package was %s...\n"), rp);
|
2004-03-27 01:27:57 +08:00
|
|
|
if (hdrp != NULL)
|
|
|
|
*hdrp = headerLink(h);
|
2004-10-20 18:19:34 +08:00
|
|
|
if (fnp != NULL)
|
|
|
|
*fnp = rp;
|
2004-03-27 01:27:57 +08:00
|
|
|
else
|
|
|
|
rp = _free(rp);
|
2001-11-11 11:15:47 +08:00
|
|
|
}
|
2004-03-27 01:27:57 +08:00
|
|
|
if (h != NULL)
|
|
|
|
h = headerFree(h);
|
|
|
|
rtids = IDTXfree(rtids);
|
|
|
|
return rc;
|
|
|
|
}
|
1999-01-05 00:44:20 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
/**
|
|
|
|
* This is not a generalized function to be called from outside
|
|
|
|
* librpm. It is called internally by rpmtsRun() to add elements
|
2004-05-04 01:29:16 +08:00
|
|
|
* to its autorollback transaction.
|
2004-03-27 01:27:57 +08:00
|
|
|
* @param rollbackTransaction rollback transaction
|
|
|
|
* @param runningTransaction running transaction (the one you want to rollback)
|
|
|
|
* @param te Transaction element.
|
|
|
|
* @return RPMRC_OK, or RPMRC_FAIL
|
|
|
|
*/
|
|
|
|
static rpmRC _rpmtsAddRollbackElement(rpmts rollbackTransaction,
|
|
|
|
rpmts runningTransaction, rpmte te)
|
|
|
|
{
|
|
|
|
Header h = NULL;
|
|
|
|
Header rph = NULL;
|
2007-07-11 19:23:07 +08:00
|
|
|
const char * rpn;
|
2004-03-27 01:27:57 +08:00
|
|
|
unsigned int db_instance = 0;
|
|
|
|
rpmtsi pi;
|
|
|
|
rpmte p;
|
|
|
|
int rc = RPMRC_FAIL; /* Assume Failure */
|
2004-03-17 05:58:25 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
switch(rpmteType(te)) {
|
|
|
|
case TR_ADDED:
|
|
|
|
{ rpmdbMatchIterator mi;
|
2004-03-17 05:58:25 +08:00
|
|
|
|
2007-10-09 19:48:04 +08:00
|
|
|
rpmlog(RPMLOG_DEBUG,
|
2004-03-27 01:27:57 +08:00
|
|
|
_("Adding install element to auto-rollback transaction.\n"));
|
2004-03-17 05:58:25 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
/* Get the header for this package from the database
|
|
|
|
* First get the database instance (the key).
|
|
|
|
*/
|
|
|
|
db_instance = rpmteDBInstance(te);
|
|
|
|
if (db_instance == 0) {
|
|
|
|
/* Could not get the db instance: WTD! */
|
2007-10-09 19:14:30 +08:00
|
|
|
rpmlog(RPMMESS_FATALERROR,
|
2004-03-27 01:27:57 +08:00
|
|
|
_("Could not get install element database instance!\n"));
|
|
|
|
break;
|
|
|
|
}
|
2004-03-17 05:58:25 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
/* Now suck the header out of the database */
|
|
|
|
mi = rpmtsInitIterator(rollbackTransaction,
|
|
|
|
RPMDBI_PACKAGES, &db_instance, sizeof(db_instance));
|
|
|
|
h = rpmdbNextIterator(mi);
|
|
|
|
if (h != NULL) h = headerLink(h);
|
|
|
|
mi = rpmdbFreeIterator(mi);
|
|
|
|
if (h == NULL) {
|
|
|
|
/* Header was not there??? */
|
2007-10-09 19:14:30 +08:00
|
|
|
rpmlog(RPMMESS_FATALERROR,
|
2004-03-27 01:27:57 +08:00
|
|
|
_("Could not get header for auto-rollback transaction!\n"));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Now see if there is a repackaged package for this */
|
|
|
|
rc = getRepackageHeaderFromTE(runningTransaction, te, &rph, &rpn);
|
|
|
|
switch(rc) {
|
|
|
|
case RPMRC_OK:
|
|
|
|
/* Add the install element, as we had a repackaged package */
|
2007-10-09 19:48:04 +08:00
|
|
|
rpmlog(RPMLOG_DEBUG,
|
2004-03-27 01:27:57 +08:00
|
|
|
_("\tAdded repackaged package header: %s.\n"), rpn);
|
2007-10-09 19:48:04 +08:00
|
|
|
rpmlog(RPMLOG_DEBUG,
|
2004-05-04 01:29:16 +08:00
|
|
|
_("\tAdded from install element %s.\n"), rpmteNEVRA(te));
|
2004-03-27 01:27:57 +08:00
|
|
|
rc = rpmtsAddInstallElement(rollbackTransaction, headerLink(rph),
|
|
|
|
(fnpyKey) rpn, 1, te->relocs);
|
2007-09-12 01:07:39 +08:00
|
|
|
break;
|
2004-03-27 01:27:57 +08:00
|
|
|
|
|
|
|
case RPMRC_NOTFOUND:
|
|
|
|
/* Add the header as an erase element, we did not
|
|
|
|
* have a repackaged package
|
|
|
|
*/
|
2007-10-09 19:48:04 +08:00
|
|
|
rpmlog(RPMLOG_DEBUG, _("\tAdded erase element.\n"));
|
|
|
|
rpmlog(RPMLOG_DEBUG,
|
2004-05-04 01:29:16 +08:00
|
|
|
_("\tAdded from install element %s.\n"), rpmteNEVRA(te));
|
2004-03-27 01:27:57 +08:00
|
|
|
rc = rpmtsAddEraseElement(rollbackTransaction, h, db_instance);
|
2007-09-12 01:07:39 +08:00
|
|
|
break;
|
2004-03-27 01:27:57 +08:00
|
|
|
|
|
|
|
default:
|
|
|
|
/* Not sure what to do on failure...just give up */
|
2007-10-09 19:14:30 +08:00
|
|
|
rpmlog(RPMMESS_FATALERROR,
|
2004-03-27 01:27:57 +08:00
|
|
|
_("Could not get repackaged header for auto-rollback transaction!\n"));
|
2007-09-12 01:07:39 +08:00
|
|
|
break;
|
2004-03-27 01:27:57 +08:00
|
|
|
}
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case TR_REMOVED:
|
2007-10-09 19:48:04 +08:00
|
|
|
rpmlog(RPMLOG_DEBUG,
|
2004-03-27 01:27:57 +08:00
|
|
|
_("Add erase element to auto-rollback transaction.\n"));
|
2004-05-04 01:29:16 +08:00
|
|
|
/* See if this element has already been added.
|
|
|
|
* If so we want to do nothing. Compare N's for match.
|
|
|
|
* XXX: Really should compare NAC's.
|
2004-03-27 01:27:57 +08:00
|
|
|
*/
|
|
|
|
pi = rpmtsiInit(rollbackTransaction);
|
2004-05-04 01:29:16 +08:00
|
|
|
while ((p = rpmtsiNext(pi, 0)) != NULL) {
|
2004-03-27 01:27:57 +08:00
|
|
|
if (!strcmp(rpmteN(p), rpmteN(te))) {
|
2007-10-09 19:48:04 +08:00
|
|
|
rpmlog(RPMLOG_DEBUG, _("\tFound existing upgrade element.\n"));
|
|
|
|
rpmlog(RPMLOG_DEBUG, _("\tNot adding erase element for %s.\n"),
|
2004-03-27 01:27:57 +08:00
|
|
|
rpmteN(te));
|
|
|
|
rc = RPMRC_OK;
|
|
|
|
pi = rpmtsiFree(pi);
|
2004-05-04 01:29:16 +08:00
|
|
|
goto cleanup;
|
2004-03-17 05:58:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
pi = rpmtsiFree(pi);
|
1999-01-05 00:44:20 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
/* Get the repackage header from the current transaction
|
|
|
|
* element.
|
|
|
|
*/
|
|
|
|
rc = getRepackageHeaderFromTE(runningTransaction, te, &rph, &rpn);
|
|
|
|
switch(rc) {
|
|
|
|
case RPMRC_OK:
|
|
|
|
/* Add the install element */
|
2007-10-09 19:48:04 +08:00
|
|
|
rpmlog(RPMLOG_DEBUG,
|
2004-03-27 01:27:57 +08:00
|
|
|
_("\tAdded repackaged package %s.\n"), rpn);
|
2007-10-09 19:48:04 +08:00
|
|
|
rpmlog(RPMLOG_DEBUG,
|
2004-05-04 01:29:16 +08:00
|
|
|
_("\tAdded from erase element %s.\n"), rpmteNEVRA(te));
|
2004-03-27 01:27:57 +08:00
|
|
|
rc = rpmtsAddInstallElement(rollbackTransaction, rph,
|
|
|
|
(fnpyKey) rpn, 1, te->relocs);
|
|
|
|
if (rc != RPMRC_OK)
|
2007-10-09 19:14:30 +08:00
|
|
|
rpmlog(RPMMESS_FATALERROR,
|
2004-03-27 01:27:57 +08:00
|
|
|
_("Could not add erase element to auto-rollback transaction.\n"));
|
2007-09-12 01:07:39 +08:00
|
|
|
break;
|
2001-11-05 06:00:11 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
case RPMRC_NOTFOUND:
|
|
|
|
/* Just did not have a repackaged package */
|
2007-10-09 19:48:04 +08:00
|
|
|
rpmlog(RPMLOG_DEBUG,
|
2004-03-27 01:27:57 +08:00
|
|
|
_("\tNo repackaged package...nothing to do.\n"));
|
|
|
|
rc = RPMRC_OK;
|
2007-09-12 01:07:39 +08:00
|
|
|
break;
|
2001-11-12 06:51:00 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
default:
|
2007-10-09 19:14:30 +08:00
|
|
|
rpmlog(RPMMESS_FATALERROR,
|
2004-03-27 01:27:57 +08:00
|
|
|
_("Failure reading repackaged package!\n"));
|
2007-09-12 01:07:39 +08:00
|
|
|
break;
|
1999-07-14 22:36:10 +08:00
|
|
|
}
|
2004-03-27 01:27:57 +08:00
|
|
|
break;
|
1999-02-21 11:34:52 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
default:
|
|
|
|
break;
|
1999-07-14 22:36:10 +08:00
|
|
|
}
|
1999-01-05 00:44:20 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
/* XXX: I want to free this, but if I do then the consumers of
|
|
|
|
* are hosed. Just leaving you a little note Jeff, so you
|
|
|
|
* know that this does introduce a memory leak. I wanted
|
|
|
|
* keep the patch as simple as possible so I am not fixxing
|
|
|
|
* the leak.
|
|
|
|
* if (rpn != NULL)
|
|
|
|
* free(rpn);
|
|
|
|
*/
|
1999-07-14 22:36:10 +08:00
|
|
|
|
2004-05-04 01:29:16 +08:00
|
|
|
cleanup:
|
2004-03-27 01:27:57 +08:00
|
|
|
/* Clean up */
|
|
|
|
if (h != NULL)
|
|
|
|
h = headerFree(h);
|
|
|
|
if (rph != NULL)
|
|
|
|
rph = headerFree(rph);
|
|
|
|
return rc;
|
|
|
|
}
|
2004-05-04 01:29:16 +08:00
|
|
|
|
2007-09-12 01:07:39 +08:00
|
|
|
#define NOTIFY(_ts, _al) if ((_ts)->notify) (void) (_ts)->notify _al
|
1999-10-09 04:30:49 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
int rpmtsRun(rpmts ts, rpmps okProbs, rpmprobFilterFlags ignoreSet)
|
|
|
|
{
|
|
|
|
uint_32 tscolor = rpmtsColor(ts);
|
|
|
|
int i, j;
|
|
|
|
int ourrc = 0;
|
|
|
|
int totalFileCount = 0;
|
|
|
|
rpmfi fi;
|
|
|
|
sharedFileInfo shared, sharedList;
|
|
|
|
int numShared;
|
|
|
|
int nexti;
|
2007-09-21 20:17:08 +08:00
|
|
|
rpmalKey lastFailKey;
|
2004-03-27 01:27:57 +08:00
|
|
|
fingerPrintCache fpc;
|
|
|
|
rpmps ps;
|
|
|
|
rpmpsm psm;
|
|
|
|
rpmtsi pi; rpmte p;
|
|
|
|
rpmtsi qi; rpmte q;
|
|
|
|
int numAdded;
|
|
|
|
int numRemoved;
|
|
|
|
rpmts rollbackTransaction = NULL;
|
|
|
|
int rollbackOnFailure = 0;
|
2004-04-08 07:50:35 +08:00
|
|
|
void * lock = NULL;
|
2004-03-27 01:27:57 +08:00
|
|
|
int xx;
|
2001-11-12 00:17:57 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
/* XXX programmer error segfault avoidance. */
|
|
|
|
if (rpmtsNElements(ts) <= 0)
|
|
|
|
return -1;
|
2001-11-12 00:17:57 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
/* See if we need to rollback on failure */
|
|
|
|
rollbackOnFailure = rpmExpandNumeric(
|
|
|
|
"%{?_rollback_transaction_on_failure}");
|
|
|
|
if (rpmtsGetType(ts) & (RPMTRANS_TYPE_ROLLBACK
|
|
|
|
| RPMTRANS_TYPE_AUTOROLLBACK)) {
|
|
|
|
rollbackOnFailure = 0;
|
|
|
|
}
|
|
|
|
/* If we are in test mode, there is no need to rollback on
|
2004-04-08 07:50:35 +08:00
|
|
|
* failure, nor acquire the transaction lock.
|
2004-03-27 01:27:57 +08:00
|
|
|
*/
|
2004-10-10 03:40:09 +08:00
|
|
|
/* If we are in test mode, then there's no need for transaction lock. */
|
2004-04-08 07:50:35 +08:00
|
|
|
if (rpmtsFlags(ts) & RPMTRANS_FLAG_TEST) {
|
|
|
|
rollbackOnFailure = 0;
|
|
|
|
} else {
|
|
|
|
lock = rpmtsAcquireLock(ts);
|
|
|
|
if (lock == NULL)
|
|
|
|
return -1; /* XXX W2DO? */
|
|
|
|
}
|
2004-03-27 01:27:57 +08:00
|
|
|
|
|
|
|
if (rpmtsFlags(ts) & RPMTRANS_FLAG_NOSCRIPTS)
|
|
|
|
(void) rpmtsSetFlags(ts, (rpmtsFlags(ts) | _noTransScripts | _noTransTriggers));
|
|
|
|
if (rpmtsFlags(ts) & RPMTRANS_FLAG_NOTRIGGERS)
|
|
|
|
(void) rpmtsSetFlags(ts, (rpmtsFlags(ts) | _noTransTriggers));
|
|
|
|
|
|
|
|
if (rpmtsFlags(ts) & RPMTRANS_FLAG_JUSTDB)
|
|
|
|
(void) rpmtsSetFlags(ts, (rpmtsFlags(ts) | _noTransScripts | _noTransTriggers));
|
|
|
|
|
2007-09-03 17:23:42 +08:00
|
|
|
/* if SELinux isn't enabled or init fails, don't bother... */
|
|
|
|
if (!rpmtsSELinuxEnabled(ts)) {
|
|
|
|
rpmtsSetFlags(ts, (rpmtsFlags(ts) | RPMTRANS_FLAG_NOCONTEXTS));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!rpmtsFlags(ts) & RPMTRANS_FLAG_NOCONTEXTS) {
|
2007-09-03 19:42:42 +08:00
|
|
|
const char *fn = rpmGetPath("%{?_install_file_context_path}", NULL);
|
|
|
|
if (matchpathcon_init(fn) == -1) {
|
|
|
|
rpmtsSetFlags(ts, (rpmtsFlags(ts) | RPMTRANS_FLAG_NOCONTEXTS));
|
|
|
|
}
|
|
|
|
_free(fn);
|
2007-09-03 17:23:42 +08:00
|
|
|
}
|
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
ts->probs = rpmpsFree(ts->probs);
|
|
|
|
ts->probs = rpmpsCreate();
|
|
|
|
|
|
|
|
/* XXX Make sure the database is open RDWR for package install/erase. */
|
|
|
|
{ int dbmode = (rpmtsFlags(ts) & RPMTRANS_FLAG_TEST)
|
|
|
|
? O_RDONLY : (O_RDWR|O_CREAT);
|
|
|
|
|
|
|
|
/* Open database RDWR for installing packages. */
|
|
|
|
if (rpmtsOpenDB(ts, dbmode)) {
|
|
|
|
rpmtsFreeLock(lock);
|
|
|
|
return -1; /* XXX W2DO? */
|
1999-07-14 22:36:10 +08:00
|
|
|
}
|
2004-03-27 01:27:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ts->ignoreSet = ignoreSet;
|
|
|
|
{ const char * currDir = currentDirectory();
|
|
|
|
rpmtsSetCurrDir(ts, currDir);
|
|
|
|
currDir = _free(currDir);
|
|
|
|
}
|
|
|
|
|
|
|
|
(void) rpmtsSetChrootDone(ts, 0);
|
2003-04-07 20:05:35 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
{ int_32 tid = (int_32) time(NULL);
|
|
|
|
(void) rpmtsSetTid(ts, tid);
|
1999-07-14 22:36:10 +08:00
|
|
|
}
|
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
/* Get available space on mounted file systems. */
|
|
|
|
xx = rpmtsInitDSI(ts);
|
1999-07-14 22:36:10 +08:00
|
|
|
|
1999-08-07 07:44:25 +08:00
|
|
|
/* ===============================================
|
2004-03-27 01:27:57 +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-08-07 07:44:25 +08:00
|
|
|
*/
|
2004-03-27 01:27:57 +08:00
|
|
|
|
2007-10-09 19:48:04 +08:00
|
|
|
rpmlog(RPMLOG_DEBUG, _("sanity checking %d elements\n"), rpmtsNElements(ts));
|
2002-05-28 05:40:08 +08:00
|
|
|
ps = rpmtsProblems(ts);
|
2004-03-27 01:27:57 +08:00
|
|
|
/* The ordering doesn't matter here */
|
2002-05-28 05:40:08 +08:00
|
|
|
pi = rpmtsiInit(ts);
|
2004-10-26 02:10:48 +08:00
|
|
|
/* XXX Only added packages need be checked. */
|
2004-03-27 01:27:57 +08:00
|
|
|
while ((p = rpmtsiNext(pi, TR_ADDED)) != NULL) {
|
|
|
|
rpmdbMatchIterator mi;
|
2001-11-16 08:26:30 +08:00
|
|
|
int fc;
|
1999-07-14 22:36:10 +08:00
|
|
|
|
2002-05-28 05:40:08 +08:00
|
|
|
if ((fi = rpmtsiFi(pi)) == NULL)
|
2001-11-12 06:51:00 +08:00
|
|
|
continue; /* XXX can't happen */
|
2002-05-20 02:42:25 +08:00
|
|
|
fc = rpmfiFC(fi);
|
2001-11-12 00:17:57 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
if (!(rpmtsFilterFlags(ts) & RPMPROB_FILTER_IGNOREARCH) && !tscolor)
|
|
|
|
if (!archOkay(rpmteA(p)))
|
|
|
|
rpmpsAppend(ps, RPMPROB_BADARCH,
|
|
|
|
rpmteNEVR(p), rpmteKey(p),
|
|
|
|
rpmteA(p), NULL,
|
|
|
|
NULL, 0);
|
2001-11-16 08:26:30 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
if (!(rpmtsFilterFlags(ts) & RPMPROB_FILTER_IGNOREOS))
|
|
|
|
if (!osOkay(rpmteO(p)))
|
|
|
|
rpmpsAppend(ps, RPMPROB_BADOS,
|
|
|
|
rpmteNEVR(p), rpmteKey(p),
|
|
|
|
rpmteO(p), NULL,
|
|
|
|
NULL, 0);
|
1999-07-14 22:36:10 +08:00
|
|
|
|
2004-10-10 03:40:09 +08:00
|
|
|
if (!(rpmtsFilterFlags(ts) & RPMPROB_FILTER_OLDPACKAGE)) {
|
2004-03-27 01:27:57 +08:00
|
|
|
Header h;
|
|
|
|
mi = rpmtsInitIterator(ts, RPMTAG_NAME, rpmteN(p), 0);
|
|
|
|
while ((h = rpmdbNextIterator(mi)) != NULL)
|
|
|
|
xx = ensureOlder(ts, p, h);
|
|
|
|
mi = rpmdbFreeIterator(mi);
|
1999-01-05 00:44:20 +08:00
|
|
|
}
|
1999-08-15 04:01:38 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
if (!(rpmtsFilterFlags(ts) & RPMPROB_FILTER_REPLACEPKG)) {
|
|
|
|
mi = rpmtsInitIterator(ts, RPMTAG_NAME, rpmteN(p), 0);
|
|
|
|
xx = rpmdbSetIteratorRE(mi, RPMTAG_EPOCH, RPMMIRE_STRCMP,
|
|
|
|
rpmteE(p));
|
|
|
|
xx = rpmdbSetIteratorRE(mi, RPMTAG_VERSION, RPMMIRE_STRCMP,
|
|
|
|
rpmteV(p));
|
|
|
|
xx = rpmdbSetIteratorRE(mi, RPMTAG_RELEASE, RPMMIRE_STRCMP,
|
|
|
|
rpmteR(p));
|
|
|
|
if (tscolor) {
|
|
|
|
xx = rpmdbSetIteratorRE(mi, RPMTAG_ARCH, RPMMIRE_STRCMP,
|
|
|
|
rpmteA(p));
|
|
|
|
xx = rpmdbSetIteratorRE(mi, RPMTAG_OS, RPMMIRE_STRCMP,
|
|
|
|
rpmteO(p));
|
1999-08-14 04:05:57 +08:00
|
|
|
}
|
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
while (rpmdbNextIterator(mi) != NULL) {
|
|
|
|
rpmpsAppend(ps, RPMPROB_PKG_INSTALLED,
|
|
|
|
rpmteNEVR(p), rpmteKey(p),
|
|
|
|
NULL, NULL,
|
|
|
|
NULL, 0);
|
2007-09-12 01:07:39 +08:00
|
|
|
break;
|
1999-03-19 11:39:17 +08:00
|
|
|
}
|
2004-03-27 01:27:57 +08:00
|
|
|
mi = rpmdbFreeIterator(mi);
|
1999-03-19 11:39:17 +08:00
|
|
|
}
|
1999-02-17 12:32:55 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
/* Count no. of files (if any). */
|
|
|
|
totalFileCount += fc;
|
1999-02-17 12:32:55 +08:00
|
|
|
|
|
|
|
}
|
2002-05-28 05:40:08 +08:00
|
|
|
pi = rpmtsiFree(pi);
|
2002-05-20 02:42:25 +08:00
|
|
|
ps = rpmpsFree(ps);
|
1999-02-21 11:34:52 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
/* The ordering doesn't matter here */
|
2002-05-28 05:40:08 +08:00
|
|
|
pi = rpmtsiInit(ts);
|
2004-03-27 01:27:57 +08:00
|
|
|
while ((p = rpmtsiNext(pi, TR_REMOVED)) != NULL) {
|
|
|
|
int fc;
|
|
|
|
|
2002-05-28 05:40:08 +08:00
|
|
|
if ((fi = rpmtsiFi(pi)) == NULL)
|
2001-11-12 06:51:00 +08:00
|
|
|
continue; /* XXX can't happen */
|
2004-03-27 01:27:57 +08:00
|
|
|
fc = rpmfiFC(fi);
|
|
|
|
|
|
|
|
totalFileCount += fc;
|
1999-03-21 05:09:47 +08:00
|
|
|
}
|
2002-05-28 05:40:08 +08:00
|
|
|
pi = rpmtsiFree(pi);
|
1999-02-21 11:34:52 +08:00
|
|
|
|
1999-10-20 18:22:46 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
/* Run pre-transaction scripts, but only if there are no known
|
|
|
|
* problems up to this point. */
|
2007-05-16 21:22:01 +08:00
|
|
|
if (!((rpmtsFlags(ts) & (RPMTRANS_FLAG_BUILD_PROBS|RPMTRANS_FLAG_TEST))
|
2007-09-26 15:40:02 +08:00
|
|
|
|| (rpmpsNumProblems(ts->probs) &&
|
2004-03-27 01:27:57 +08:00
|
|
|
(okProbs == NULL || rpmpsTrim(ts->probs, okProbs))))) {
|
2007-10-09 19:48:04 +08:00
|
|
|
rpmlog(RPMLOG_DEBUG, _("running pre-transaction scripts\n"));
|
2004-03-27 01:27:57 +08:00
|
|
|
pi = rpmtsiInit(ts);
|
|
|
|
while ((p = rpmtsiNext(pi, TR_ADDED)) != NULL) {
|
|
|
|
if ((fi = rpmtsiFi(pi)) == NULL)
|
|
|
|
continue; /* XXX can't happen */
|
|
|
|
|
2005-02-10 17:04:05 +08:00
|
|
|
/* If no pre-transaction script, then don't bother. */
|
|
|
|
if (fi->pretrans == NULL)
|
|
|
|
continue;
|
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
p->fd = ts->notify(p->h, RPMCALLBACK_INST_OPEN_FILE, 0, 0,
|
|
|
|
rpmteKey(p), ts->notifyData);
|
|
|
|
p->h = NULL;
|
|
|
|
if (rpmteFd(p) != NULL) {
|
|
|
|
rpmVSFlags ovsflags = rpmtsVSFlags(ts);
|
|
|
|
rpmVSFlags vsflags = ovsflags | RPMVSF_NEEDPAYLOAD;
|
|
|
|
rpmRC rpmrc;
|
|
|
|
ovsflags = rpmtsSetVSFlags(ts, vsflags);
|
|
|
|
rpmrc = rpmReadPackageFile(ts, rpmteFd(p),
|
|
|
|
rpmteNEVR(p), &p->h);
|
|
|
|
vsflags = rpmtsSetVSFlags(ts, ovsflags);
|
|
|
|
switch (rpmrc) {
|
|
|
|
default:
|
2007-09-12 01:07:39 +08:00
|
|
|
/* FIX: notify annotations */
|
2004-03-27 01:27:57 +08:00
|
|
|
p->fd = ts->notify(p->h, RPMCALLBACK_INST_CLOSE_FILE,
|
|
|
|
0, 0,
|
|
|
|
rpmteKey(p), ts->notifyData);
|
|
|
|
p->fd = NULL;
|
2007-09-12 01:07:39 +08:00
|
|
|
break;
|
2004-03-27 01:27:57 +08:00
|
|
|
case RPMRC_NOTTRUSTED:
|
|
|
|
case RPMRC_NOKEY:
|
|
|
|
case RPMRC_OK:
|
2007-09-12 01:07:39 +08:00
|
|
|
break;
|
2004-03-27 01:27:57 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rpmteFd(p) != NULL) {
|
|
|
|
fi = rpmfiNew(ts, p->h, RPMTAG_BASENAMES, 1);
|
|
|
|
if (fi != NULL) { /* XXX can't happen */
|
|
|
|
fi->te = p;
|
|
|
|
p->fi = fi;
|
|
|
|
}
|
|
|
|
psm = rpmpsmNew(ts, p, p->fi);
|
|
|
|
assert(psm != NULL);
|
|
|
|
psm->scriptTag = RPMTAG_PRETRANS;
|
|
|
|
psm->progTag = RPMTAG_PRETRANSPROG;
|
|
|
|
xx = rpmpsmStage(psm, PSM_SCRIPT);
|
|
|
|
psm = rpmpsmFree(psm);
|
|
|
|
|
|
|
|
(void) ts->notify(p->h, RPMCALLBACK_INST_CLOSE_FILE, 0, 0,
|
|
|
|
rpmteKey(p), ts->notifyData);
|
|
|
|
p->fd = NULL;
|
|
|
|
p->h = headerFree(p->h);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pi = rpmtsiFree(pi);
|
1999-07-14 22:36:10 +08:00
|
|
|
}
|
1999-02-21 11:34:52 +08:00
|
|
|
|
2004-03-06 02:22:25 +08:00
|
|
|
/* ===============================================
|
2004-03-27 01:27:57 +08:00
|
|
|
* Initialize transaction element file info for package:
|
2004-03-06 02:22:25 +08:00
|
|
|
*/
|
|
|
|
|
2004-03-27 01:27:57 +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.
|
|
|
|
*/
|
2007-10-09 19:48:04 +08:00
|
|
|
rpmlog(RPMLOG_DEBUG, _("computing %d file fingerprints\n"), totalFileCount);
|
2004-03-06 02:22:25 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
numAdded = numRemoved = 0;
|
|
|
|
pi = rpmtsiInit(ts);
|
|
|
|
while ((p = rpmtsiNext(pi, 0)) != NULL) {
|
|
|
|
int fc;
|
2004-03-06 02:22:25 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
if ((fi = rpmtsiFi(pi)) == NULL)
|
|
|
|
continue; /* XXX can't happen */
|
|
|
|
fc = rpmfiFC(fi);
|
2004-03-06 02:22:25 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
switch (rpmteType(p)) {
|
|
|
|
case TR_ADDED:
|
|
|
|
numAdded++;
|
|
|
|
fi->record = 0;
|
|
|
|
/* Skip netshared paths, not our i18n files, and excluded docs */
|
|
|
|
if (fc > 0)
|
|
|
|
skipFiles(ts, fi);
|
2007-09-12 01:07:39 +08:00
|
|
|
break;
|
2004-03-27 01:27:57 +08:00
|
|
|
case TR_REMOVED:
|
|
|
|
numRemoved++;
|
|
|
|
fi->record = rpmteDBOffset(p);
|
2007-09-12 01:07:39 +08:00
|
|
|
break;
|
2004-03-27 01:27:57 +08:00
|
|
|
}
|
2004-03-06 02:22:25 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
fi->fps = (fc > 0 ? xmalloc(fc * sizeof(*fi->fps)) : NULL);
|
|
|
|
}
|
|
|
|
pi = rpmtsiFree(pi);
|
2004-03-06 02:22:25 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
if (!rpmtsChrootDone(ts)) {
|
|
|
|
const char * rootDir = rpmtsRootDir(ts);
|
|
|
|
xx = chdir("/");
|
2007-06-19 18:33:50 +08:00
|
|
|
if (rootDir != NULL && strcmp(rootDir, "/") && *rootDir == '/') {
|
|
|
|
/* opening db before chroot not optimal, see rhbz#103852 c#3 */
|
|
|
|
xx = rpmdbOpenAll(ts->rdb);
|
2004-03-27 01:27:57 +08:00
|
|
|
xx = chroot(rootDir);
|
2007-06-19 18:33:50 +08:00
|
|
|
}
|
2004-03-27 01:27:57 +08:00
|
|
|
(void) rpmtsSetChrootDone(ts, 1);
|
|
|
|
}
|
2004-03-06 02:22:25 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
ts->ht = htCreate(totalFileCount * 2, 0, 0, fpHashFunction, fpEqual);
|
|
|
|
fpc = fpCacheCreate(totalFileCount);
|
2004-03-06 02:22:25 +08:00
|
|
|
|
2001-02-12 06:02:29 +08:00
|
|
|
/* ===============================================
|
2004-03-27 01:27:57 +08:00
|
|
|
* Add fingerprint for each file not skipped.
|
2001-02-12 06:02:29 +08:00
|
|
|
*/
|
2004-03-27 01:27:57 +08:00
|
|
|
pi = rpmtsiInit(ts);
|
|
|
|
while ((p = rpmtsiNext(pi, 0)) != NULL) {
|
|
|
|
int fc;
|
2003-03-26 07:51:24 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
(void) rpmdbCheckSignals();
|
2002-08-20 06:27:44 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
if ((fi = rpmtsiFi(pi)) == NULL)
|
|
|
|
continue; /* XXX can't happen */
|
|
|
|
fc = rpmfiFC(fi);
|
2003-03-26 07:51:24 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
(void) rpmswEnter(rpmtsOp(ts, RPMTS_OP_FINGERPRINT), 0);
|
|
|
|
fpLookupList(fpc, fi->dnl, fi->bnl, fi->dil, fc, fi->fps);
|
|
|
|
fi = rpmfiInit(fi, 0);
|
|
|
|
if (fi != NULL) /* XXX lclint */
|
|
|
|
while ((i = rpmfiNext(fi)) >= 0) {
|
|
|
|
if (XFA_SKIPPING(fi->actions[i]))
|
2007-09-12 01:07:39 +08:00
|
|
|
continue;
|
2004-03-27 01:27:57 +08:00
|
|
|
htAddEntry(ts->ht, fi->fps + i, (void *) fi);
|
2002-08-05 00:55:55 +08:00
|
|
|
}
|
2004-03-27 01:27:57 +08:00
|
|
|
(void) rpmswExit(rpmtsOp(ts, RPMTS_OP_FINGERPRINT), fc);
|
|
|
|
|
2001-02-12 06:02:29 +08:00
|
|
|
}
|
2004-03-27 01:27:57 +08:00
|
|
|
pi = rpmtsiFree(pi);
|
|
|
|
|
|
|
|
NOTIFY(ts, (NULL, RPMCALLBACK_TRANS_START, 6, ts->orderCount,
|
|
|
|
NULL, ts->notifyData));
|
2001-02-12 06:02:29 +08:00
|
|
|
|
1999-08-07 07:44:25 +08:00
|
|
|
/* ===============================================
|
2004-03-27 01:27:57 +08:00
|
|
|
* Compute file disposition for each package in transaction set.
|
1999-08-07 07:44:25 +08:00
|
|
|
*/
|
2007-10-09 19:48:04 +08:00
|
|
|
rpmlog(RPMLOG_DEBUG, _("computing file dispositions\n"));
|
2004-03-27 01:27:57 +08:00
|
|
|
ps = rpmtsProblems(ts);
|
2002-05-28 05:40:08 +08:00
|
|
|
pi = rpmtsiInit(ts);
|
|
|
|
while ((p = rpmtsiNext(pi, 0)) != NULL) {
|
2004-03-27 01:27:57 +08:00
|
|
|
dbiIndexSet * matches;
|
|
|
|
int knownBad;
|
|
|
|
int fc;
|
2001-01-21 23:43:32 +08:00
|
|
|
|
2002-09-01 06:39:34 +08:00
|
|
|
(void) rpmdbCheckSignals();
|
|
|
|
|
2002-05-28 05:40:08 +08:00
|
|
|
if ((fi = rpmtsiFi(pi)) == NULL)
|
2001-11-12 06:51:00 +08:00
|
|
|
continue; /* XXX can't happen */
|
2004-03-27 01:27:57 +08:00
|
|
|
fc = rpmfiFC(fi);
|
2002-08-20 06:27:44 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
NOTIFY(ts, (NULL, RPMCALLBACK_TRANS_PROGRESS, rpmtsiOc(pi),
|
|
|
|
ts->orderCount, NULL, ts->notifyData));
|
2001-10-31 02:00:21 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
if (fc == 0) continue;
|
1999-02-21 11:34:52 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
(void) rpmswEnter(rpmtsOp(ts, RPMTS_OP_FINGERPRINT), 0);
|
|
|
|
/* Extract file info for all files in this package from the database. */
|
|
|
|
matches = xcalloc(fc, sizeof(*matches));
|
|
|
|
if (rpmdbFindFpList(rpmtsGetRdb(ts), fi->fps, matches, fc)) {
|
|
|
|
ps = rpmpsFree(ps);
|
|
|
|
rpmtsFreeLock(lock);
|
|
|
|
return 1; /* XXX WTFO? */
|
|
|
|
}
|
2001-10-28 04:09:20 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
numShared = 0;
|
|
|
|
fi = rpmfiInit(fi, 0);
|
|
|
|
while ((i = rpmfiNext(fi)) >= 0)
|
|
|
|
numShared += dbiIndexSetCount(matches[i]);
|
2004-03-06 02:22:25 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
/* Build sorted file info list for this package. */
|
|
|
|
shared = sharedList = xcalloc((numShared + 1), sizeof(*sharedList));
|
2004-03-06 02:22:25 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
fi = rpmfiInit(fi, 0);
|
|
|
|
while ((i = rpmfiNext(fi)) >= 0) {
|
|
|
|
/*
|
|
|
|
* Take care not to mark files as replaced in packages that will
|
|
|
|
* have been removed before we will get here.
|
|
|
|
*/
|
|
|
|
for (j = 0; j < dbiIndexSetCount(matches[i]); j++) {
|
|
|
|
int ro;
|
|
|
|
ro = dbiIndexRecordOffset(matches[i], j);
|
|
|
|
knownBad = 0;
|
|
|
|
qi = rpmtsiInit(ts);
|
|
|
|
while ((q = rpmtsiNext(qi, TR_REMOVED)) != NULL) {
|
|
|
|
if (ro == knownBad)
|
2007-09-12 01:07:39 +08:00
|
|
|
break;
|
2004-03-27 01:27:57 +08:00
|
|
|
if (rpmteDBOffset(q) == ro)
|
|
|
|
knownBad = ro;
|
1999-05-18 02:44:14 +08:00
|
|
|
}
|
2004-03-27 01:27:57 +08:00
|
|
|
qi = rpmtsiFree(qi);
|
2002-08-20 06:27:44 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
shared->pkgFileNum = i;
|
|
|
|
shared->otherPkg = dbiIndexRecordOffset(matches[i], j);
|
|
|
|
shared->otherFileNum = dbiIndexRecordFileNumber(matches[i], j);
|
|
|
|
shared->isRemoved = (knownBad == ro);
|
|
|
|
shared++;
|
|
|
|
}
|
|
|
|
matches[i] = dbiFreeIndexSet(matches[i]);
|
|
|
|
}
|
|
|
|
numShared = shared - sharedList;
|
|
|
|
shared->otherPkg = -1;
|
|
|
|
matches = _free(matches);
|
2002-12-28 08:24:14 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
/* Sort file info by other package index (otherPkg) */
|
|
|
|
qsort(sharedList, numShared, sizeof(*shared), sharedCmp);
|
2002-12-28 08:24:14 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
/* For all files from this package that are in the database ... */
|
|
|
|
for (i = 0; i < numShared; i = nexti) {
|
|
|
|
int beingRemoved;
|
2002-08-20 06:27:44 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
shared = sharedList + i;
|
2004-03-06 02:22:25 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
/* Find the end of the files in the other package. */
|
|
|
|
for (nexti = i + 1; nexti < numShared; nexti++) {
|
|
|
|
if (sharedList[nexti].otherPkg != shared->otherPkg)
|
2007-09-12 01:07:39 +08:00
|
|
|
break;
|
2004-03-27 01:27:57 +08:00
|
|
|
}
|
2004-03-06 02:22:25 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
/* Is this file from a package being removed? */
|
|
|
|
beingRemoved = 0;
|
|
|
|
if (ts->removedPackages != NULL)
|
|
|
|
for (j = 0; j < ts->numRemovedPackages; j++) {
|
|
|
|
if (ts->removedPackages[j] != shared->otherPkg)
|
2007-09-12 01:07:39 +08:00
|
|
|
continue;
|
2004-03-27 01:27:57 +08:00
|
|
|
beingRemoved = 1;
|
2007-09-12 01:07:39 +08:00
|
|
|
break;
|
1999-02-21 11:34:52 +08:00
|
|
|
}
|
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
/* Determine the fate of each file. */
|
|
|
|
switch (rpmteType(p)) {
|
|
|
|
case TR_ADDED:
|
|
|
|
xx = handleInstInstalledFiles(ts, p, fi, shared, nexti - i,
|
|
|
|
!(beingRemoved || (rpmtsFilterFlags(ts) & RPMPROB_FILTER_REPLACEOLDFILES)));
|
2007-09-12 01:07:39 +08:00
|
|
|
break;
|
2004-03-27 01:27:57 +08:00
|
|
|
case TR_REMOVED:
|
|
|
|
if (!beingRemoved)
|
|
|
|
xx = handleRmvdInstalledFiles(ts, fi, shared, nexti - i);
|
2007-09-12 01:07:39 +08:00
|
|
|
break;
|
2001-01-21 23:43:32 +08:00
|
|
|
}
|
2004-03-27 01:27:57 +08:00
|
|
|
}
|
2002-08-21 06:05:18 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
free(sharedList);
|
2002-08-21 06:05:18 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
/* Update disk space needs on each partition for this package. */
|
|
|
|
handleOverlappedFiles(ts, p, fi);
|
2003-03-26 07:51:24 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
/* Check added package has sufficient space on each partition used. */
|
|
|
|
switch (rpmteType(p)) {
|
|
|
|
case TR_ADDED:
|
|
|
|
rpmtsCheckDSIProblems(ts, p);
|
2007-09-12 01:07:39 +08:00
|
|
|
break;
|
1999-08-14 04:05:57 +08:00
|
|
|
case TR_REMOVED:
|
2007-09-12 01:07:39 +08:00
|
|
|
break;
|
2004-03-27 01:27:57 +08:00
|
|
|
}
|
2007-04-16 20:26:12 +08:00
|
|
|
/* check for s-bit files to be removed */
|
|
|
|
if (rpmteType(p) == TR_REMOVED) {
|
|
|
|
fi = rpmfiInit(fi, 0);
|
|
|
|
while ((i = rpmfiNext(fi)) >= 0) {
|
|
|
|
int_16 mode;
|
|
|
|
if (XFA_SKIPPING(fi->actions[i]))
|
|
|
|
continue;
|
|
|
|
(void) rpmfiSetFX(fi, i);
|
|
|
|
mode = rpmfiFMode(fi);
|
|
|
|
if (S_ISREG(mode) && (mode & 06000) != 0) {
|
|
|
|
fi->mapflags |= CPIO_SBIT_CHECK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-03-27 01:27:57 +08:00
|
|
|
(void) rpmswExit(rpmtsOp(ts, RPMTS_OP_FINGERPRINT), fc);
|
|
|
|
}
|
|
|
|
pi = rpmtsiFree(pi);
|
|
|
|
ps = rpmpsFree(ps);
|
2003-03-26 07:51:24 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
if (rpmtsChrootDone(ts)) {
|
2004-11-11 11:58:46 +08:00
|
|
|
const char * rootDir = rpmtsRootDir(ts);
|
2004-03-27 01:27:57 +08:00
|
|
|
const char * currDir = rpmtsCurrDir(ts);
|
2004-11-11 11:58:46 +08:00
|
|
|
if (rootDir != NULL && strcmp(rootDir, "/") && *rootDir == '/')
|
|
|
|
xx = chroot(".");
|
2004-03-27 01:27:57 +08:00
|
|
|
(void) rpmtsSetChrootDone(ts, 0);
|
|
|
|
if (currDir != NULL)
|
|
|
|
xx = chdir(currDir);
|
|
|
|
}
|
2003-11-24 03:50:52 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
NOTIFY(ts, (NULL, RPMCALLBACK_TRANS_STOP, 6, ts->orderCount,
|
|
|
|
NULL, ts->notifyData));
|
2004-03-06 02:22:25 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
/* ===============================================
|
|
|
|
* Free unused memory as soon as possible.
|
|
|
|
*/
|
|
|
|
pi = rpmtsiInit(ts);
|
|
|
|
while ((p = rpmtsiNext(pi, 0)) != NULL) {
|
|
|
|
if ((fi = rpmtsiFi(pi)) == NULL)
|
|
|
|
continue; /* XXX can't happen */
|
|
|
|
if (rpmfiFC(fi) == 0)
|
|
|
|
continue;
|
|
|
|
fi->fps = _free(fi->fps);
|
|
|
|
}
|
|
|
|
pi = rpmtsiFree(pi);
|
2004-03-06 02:22:25 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
fpc = fpCacheFree(fpc);
|
|
|
|
ts->ht = htFree(ts->ht);
|
2004-03-06 02:22:25 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
/* ===============================================
|
|
|
|
* If unfiltered problems exist, free memory and return.
|
|
|
|
*/
|
|
|
|
if ((rpmtsFlags(ts) & RPMTRANS_FLAG_BUILD_PROBS)
|
2007-09-26 15:40:02 +08:00
|
|
|
|| (rpmpsNumProblems(ts->probs) &&
|
2004-03-27 01:27:57 +08:00
|
|
|
(okProbs == NULL || rpmpsTrim(ts->probs, okProbs)))
|
|
|
|
)
|
|
|
|
{
|
|
|
|
rpmtsFreeLock(lock);
|
|
|
|
return ts->orderCount;
|
|
|
|
}
|
2004-03-06 02:22:25 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
/* ===============================================
|
|
|
|
* If we were requested to rollback this transaction
|
|
|
|
* if an error occurs, then we need to create a
|
|
|
|
* a rollback transaction.
|
|
|
|
*/
|
|
|
|
if (rollbackOnFailure) {
|
|
|
|
rpmtransFlags tsFlags;
|
|
|
|
rpmVSFlags ovsflags;
|
|
|
|
rpmVSFlags vsflags;
|
2003-03-26 07:51:24 +08:00
|
|
|
|
2007-10-09 19:48:04 +08:00
|
|
|
rpmlog(RPMLOG_DEBUG,
|
2004-03-27 01:27:57 +08:00
|
|
|
_("Creating auto-rollback transaction\n"));
|
2003-03-26 07:51:24 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
rollbackTransaction = rpmtsCreate();
|
2002-08-20 06:27:44 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
/* Set the verify signature flags:
|
|
|
|
* - can't verify digests on repackaged packages. Other than
|
|
|
|
* they are wrong, this will cause segfaults down stream.
|
|
|
|
* - signatures are out too.
|
|
|
|
* - header check are out.
|
|
|
|
*/
|
|
|
|
vsflags = rpmExpandNumeric("%{?_vsflags_erase}");
|
|
|
|
vsflags |= _RPMVSF_NODIGESTS;
|
|
|
|
vsflags |= _RPMVSF_NOSIGNATURES;
|
|
|
|
vsflags |= RPMVSF_NOHDRCHK;
|
|
|
|
vsflags |= RPMVSF_NEEDPAYLOAD; /* XXX no legacy signatures */
|
|
|
|
ovsflags = rpmtsSetVSFlags(ts, vsflags);
|
2002-08-20 06:27:44 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
/*
|
|
|
|
* If we run this thing its imperitive that it be known that it
|
|
|
|
* is an autorollback transaction. This will affect the instance
|
|
|
|
* counts passed to the scriptlets in the psm.
|
|
|
|
*/
|
|
|
|
rpmtsSetType(rollbackTransaction, RPMTRANS_TYPE_AUTOROLLBACK);
|
2002-08-20 06:27:44 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
/* Set transaction flags to be the same as the running transaction */
|
|
|
|
tsFlags = rpmtsSetFlags(rollbackTransaction, rpmtsFlags(ts));
|
1999-02-21 11:34:52 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
/* Set root dir to be the same as the running transaction */
|
|
|
|
rpmtsSetRootDir(rollbackTransaction, rpmtsRootDir(ts));
|
2004-03-06 02:22:25 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
/* Setup the notify of the call back to be the same as the running
|
|
|
|
* transaction
|
|
|
|
*/
|
|
|
|
xx = rpmtsSetNotifyCallback(rollbackTransaction, ts->notify, ts->notifyData);
|
2004-03-17 05:58:25 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
/* Create rpmtsScore for running transaction and rollback transaction */
|
|
|
|
xx = rpmtsScoreInit(ts, rollbackTransaction);
|
|
|
|
}
|
2004-03-17 05:58:25 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
/* ===============================================
|
|
|
|
* Save removed files before erasing.
|
|
|
|
*/
|
|
|
|
if (rpmtsFlags(ts) & (RPMTRANS_FLAG_DIRSTASH | RPMTRANS_FLAG_REPACKAGE)) {
|
|
|
|
int progress;
|
2004-03-17 05:58:25 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
progress = 0;
|
|
|
|
pi = rpmtsiInit(ts);
|
|
|
|
while ((p = rpmtsiNext(pi, 0)) != NULL) {
|
2004-02-26 03:54:58 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
if ((fi = rpmtsiFi(pi)) == NULL)
|
|
|
|
continue; /* XXX can't happen */
|
|
|
|
switch (rpmteType(p)) {
|
|
|
|
case TR_ADDED:
|
2007-09-12 01:07:39 +08:00
|
|
|
break;
|
2004-03-27 01:27:57 +08:00
|
|
|
case TR_REMOVED:
|
|
|
|
if (!(rpmtsFlags(ts) & RPMTRANS_FLAG_REPACKAGE))
|
2007-09-12 01:07:39 +08:00
|
|
|
break;
|
2004-03-27 01:27:57 +08:00
|
|
|
if (!progress)
|
|
|
|
NOTIFY(ts, (NULL, RPMCALLBACK_REPACKAGE_START,
|
|
|
|
7, numRemoved, NULL, ts->notifyData));
|
2004-03-06 02:22:25 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
NOTIFY(ts, (NULL, RPMCALLBACK_REPACKAGE_PROGRESS, progress,
|
|
|
|
numRemoved, NULL, ts->notifyData));
|
|
|
|
progress++;
|
2004-03-06 02:22:25 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
(void) rpmswEnter(rpmtsOp(ts, RPMTS_OP_REPACKAGE), 0);
|
2004-03-06 02:22:25 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
/* XXX TR_REMOVED needs CPIO_MAP_{ABSOLUTE,ADDDOT} CPIO_ALL_HARDLINKS */
|
|
|
|
fi->mapflags |= CPIO_MAP_ABSOLUTE;
|
|
|
|
fi->mapflags |= CPIO_MAP_ADDDOT;
|
|
|
|
fi->mapflags |= CPIO_ALL_HARDLINKS;
|
|
|
|
psm = rpmpsmNew(ts, p, fi);
|
|
|
|
assert(psm != NULL);
|
|
|
|
xx = rpmpsmStage(psm, PSM_PKGSAVE);
|
|
|
|
psm = rpmpsmFree(psm);
|
|
|
|
fi->mapflags &= ~CPIO_MAP_ABSOLUTE;
|
|
|
|
fi->mapflags &= ~CPIO_MAP_ADDDOT;
|
|
|
|
fi->mapflags &= ~CPIO_ALL_HARDLINKS;
|
2004-03-06 02:22:25 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
(void) rpmswExit(rpmtsOp(ts, RPMTS_OP_REPACKAGE), 0);
|
2004-03-06 02:22:25 +08:00
|
|
|
|
2007-09-12 01:07:39 +08:00
|
|
|
break;
|
2004-03-27 01:27:57 +08:00
|
|
|
}
|
2004-03-06 02:22:25 +08:00
|
|
|
}
|
2004-03-27 01:27:57 +08:00
|
|
|
pi = rpmtsiFree(pi);
|
|
|
|
if (progress) {
|
|
|
|
NOTIFY(ts, (NULL, RPMCALLBACK_REPACKAGE_STOP, 7, numRemoved,
|
|
|
|
NULL, ts->notifyData));
|
2004-03-06 02:22:25 +08:00
|
|
|
}
|
2004-03-27 01:27:57 +08:00
|
|
|
}
|
2004-03-06 02:22:25 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
/* ===============================================
|
|
|
|
* Install and remove packages.
|
|
|
|
*/
|
2007-09-21 20:17:08 +08:00
|
|
|
lastFailKey = (rpmalKey)-2; /* erased packages have -1 */
|
2004-03-27 01:27:57 +08:00
|
|
|
pi = rpmtsiInit(ts);
|
2007-09-12 01:07:39 +08:00
|
|
|
/* FIX: fi reload needs work */
|
2004-03-27 01:27:57 +08:00
|
|
|
while ((p = rpmtsiNext(pi, 0)) != NULL) {
|
2007-09-21 20:17:08 +08:00
|
|
|
rpmalKey pkgKey;
|
2004-03-27 01:27:57 +08:00
|
|
|
int gotfd;
|
|
|
|
|
|
|
|
gotfd = 0;
|
|
|
|
if ((fi = rpmtsiFi(pi)) == NULL)
|
|
|
|
continue; /* XXX can't happen */
|
|
|
|
|
|
|
|
psm = rpmpsmNew(ts, p, fi);
|
|
|
|
assert(psm != NULL);
|
|
|
|
psm->unorderedSuccessor =
|
|
|
|
(rpmtsiOc(pi) >= rpmtsUnorderedSuccessors(ts, -1) ? 1 : 0);
|
|
|
|
|
|
|
|
switch (rpmteType(p)) {
|
|
|
|
case TR_ADDED:
|
|
|
|
(void) rpmswEnter(rpmtsOp(ts, RPMTS_OP_INSTALL), 0);
|
|
|
|
|
|
|
|
pkgKey = rpmteAddedKey(p);
|
|
|
|
|
2007-10-09 19:48:04 +08:00
|
|
|
rpmlog(RPMLOG_DEBUG, "========== +++ %s %s-%s 0x%x\n",
|
2004-03-27 01:27:57 +08:00
|
|
|
rpmteNEVR(p), rpmteA(p), rpmteO(p), rpmteColor(p));
|
|
|
|
|
|
|
|
p->h = NULL;
|
2007-09-12 01:07:39 +08:00
|
|
|
/* FIX: rpmte not opaque */
|
2004-03-27 01:27:57 +08:00
|
|
|
{
|
2007-09-12 01:07:39 +08:00
|
|
|
/* FIX: notify annotations */
|
2004-03-27 01:27:57 +08:00
|
|
|
p->fd = ts->notify(p->h, RPMCALLBACK_INST_OPEN_FILE, 0, 0,
|
|
|
|
rpmteKey(p), ts->notifyData);
|
|
|
|
if (rpmteFd(p) != NULL) {
|
|
|
|
rpmVSFlags ovsflags = rpmtsVSFlags(ts);
|
|
|
|
rpmVSFlags vsflags = ovsflags | RPMVSF_NEEDPAYLOAD;
|
|
|
|
rpmRC rpmrc;
|
|
|
|
|
|
|
|
ovsflags = rpmtsSetVSFlags(ts, vsflags);
|
|
|
|
rpmrc = rpmReadPackageFile(ts, rpmteFd(p),
|
|
|
|
rpmteNEVR(p), &p->h);
|
|
|
|
vsflags = rpmtsSetVSFlags(ts, ovsflags);
|
|
|
|
|
|
|
|
switch (rpmrc) {
|
|
|
|
default:
|
2007-09-12 01:07:39 +08:00
|
|
|
/* FIX: notify annotations */
|
2004-03-27 01:27:57 +08:00
|
|
|
p->fd = ts->notify(p->h, RPMCALLBACK_INST_CLOSE_FILE,
|
|
|
|
0, 0,
|
|
|
|
rpmteKey(p), ts->notifyData);
|
|
|
|
p->fd = NULL;
|
|
|
|
ourrc++;
|
|
|
|
|
|
|
|
/* If we should rollback this transaction
|
|
|
|
on failure, lets do it. */
|
|
|
|
if (rollbackOnFailure) {
|
2007-10-09 19:14:30 +08:00
|
|
|
rpmlog(RPMMESS_ERROR,
|
2004-03-27 01:27:57 +08:00
|
|
|
_("Add failed. Could not read package header.\n"));
|
|
|
|
/* Clean up the current transaction */
|
|
|
|
p->h = headerFree(p->h);
|
|
|
|
xx = rpmdbSync(rpmtsGetRdb(ts));
|
|
|
|
psm = rpmpsmFree(psm);
|
|
|
|
p->fi = rpmfiFree(p->fi);
|
|
|
|
pi = rpmtsiFree(pi);
|
|
|
|
|
|
|
|
/* Run the rollback transaction */
|
|
|
|
xx = _rpmtsRollback(rollbackTransaction);
|
|
|
|
return -1;
|
|
|
|
}
|
2007-09-12 01:07:39 +08:00
|
|
|
break;
|
2004-03-27 01:27:57 +08:00
|
|
|
case RPMRC_NOTTRUSTED:
|
|
|
|
case RPMRC_NOKEY:
|
|
|
|
case RPMRC_OK:
|
2007-09-12 01:07:39 +08:00
|
|
|
break;
|
2004-03-27 01:27:57 +08:00
|
|
|
}
|
|
|
|
if (rpmteFd(p) != NULL) gotfd = 1;
|
|
|
|
}
|
2004-03-06 02:22:25 +08:00
|
|
|
}
|
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
if (rpmteFd(p) != NULL) {
|
|
|
|
/*
|
|
|
|
* XXX Sludge necessary to tranfer existing fstates/actions
|
|
|
|
* XXX around a recreated file info set.
|
|
|
|
*/
|
|
|
|
psm->fi = rpmfiFree(psm->fi);
|
|
|
|
{
|
|
|
|
char * fstates = fi->fstates;
|
2007-09-20 21:19:25 +08:00
|
|
|
rpmFileAction * actions = fi->actions;
|
2007-06-18 21:31:13 +08:00
|
|
|
sharedFileInfo replaced = fi->replaced;
|
2007-04-16 20:26:12 +08:00
|
|
|
int mapflags = fi->mapflags;
|
2004-03-27 01:27:57 +08:00
|
|
|
rpmte savep;
|
2007-06-21 15:09:24 +08:00
|
|
|
int numShared = 0;
|
2007-06-18 21:31:13 +08:00
|
|
|
|
|
|
|
if (replaced != NULL) {
|
2007-07-10 18:52:49 +08:00
|
|
|
for (; replaced->otherPkg; replaced++) {
|
2007-06-18 21:31:13 +08:00
|
|
|
numShared++;
|
|
|
|
}
|
|
|
|
if (numShared > 0) {
|
|
|
|
replaced = xcalloc(numShared + 1,
|
|
|
|
sizeof(*fi->replaced));
|
|
|
|
memcpy(replaced, fi->replaced,
|
|
|
|
sizeof(*fi->replaced) * (numShared + 1));
|
|
|
|
}
|
|
|
|
}
|
2004-03-06 02:22:25 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
fi->fstates = NULL;
|
|
|
|
fi->actions = NULL;
|
2007-06-21 19:28:13 +08:00
|
|
|
fi->replaced = NULL;
|
2007-09-12 01:07:39 +08:00
|
|
|
/* FIX: fi->actions is NULL */
|
2004-03-27 01:27:57 +08:00
|
|
|
fi = rpmfiFree(fi);
|
2004-03-06 02:22:25 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
savep = rpmtsSetRelocateElement(ts, p);
|
|
|
|
fi = rpmfiNew(ts, p->h, RPMTAG_BASENAMES, 1);
|
|
|
|
(void) rpmtsSetRelocateElement(ts, savep);
|
2004-03-06 02:22:25 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
if (fi != NULL) { /* XXX can't happen */
|
|
|
|
fi->te = p;
|
|
|
|
fi->fstates = _free(fi->fstates);
|
|
|
|
fi->fstates = fstates;
|
|
|
|
fi->actions = _free(fi->actions);
|
|
|
|
fi->actions = actions;
|
2007-06-18 21:31:13 +08:00
|
|
|
if (replaced != NULL)
|
|
|
|
fi->replaced = replaced;
|
2007-04-16 20:26:12 +08:00
|
|
|
if (mapflags & CPIO_SBIT_CHECK)
|
|
|
|
fi->mapflags |= CPIO_SBIT_CHECK;
|
2004-03-27 01:27:57 +08:00
|
|
|
p->fi = fi;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
psm->fi = rpmfiLink(p->fi, NULL);
|
|
|
|
|
2007-09-12 01:07:39 +08:00
|
|
|
/* FIX: psm->fi may be NULL */
|
2004-03-27 01:27:57 +08:00
|
|
|
if (rpmpsmStage(psm, PSM_PKGINSTALL)) {
|
|
|
|
ourrc++;
|
|
|
|
lastFailKey = pkgKey;
|
|
|
|
|
|
|
|
/* If we should rollback this transaction
|
|
|
|
on failure, lets do it. */
|
|
|
|
if (rollbackOnFailure) {
|
2007-10-09 19:14:30 +08:00
|
|
|
rpmlog(RPMMESS_ERROR,
|
2004-03-27 01:27:57 +08:00
|
|
|
_("Add failed in rpmpsmStage().\n"));
|
|
|
|
/* Clean up the current transaction */
|
|
|
|
p->h = headerFree(p->h);
|
|
|
|
xx = rpmdbSync(rpmtsGetRdb(ts));
|
|
|
|
psm = rpmpsmFree(psm);
|
|
|
|
p->fi = rpmfiFree(p->fi);
|
|
|
|
pi = rpmtsiFree(pi);
|
|
|
|
|
|
|
|
/* Run the rollback transaction */
|
|
|
|
xx = _rpmtsRollback(rollbackTransaction);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If we should rollback on failure lets add
|
|
|
|
* this element to the rollback transaction
|
|
|
|
* as an erase element as it has installed succesfully.
|
|
|
|
*/
|
|
|
|
if (rollbackOnFailure) {
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
rc = _rpmtsAddRollbackElement(rollbackTransaction, ts, p);
|
|
|
|
if (rc != RPMRC_OK) {
|
|
|
|
/* Clean up the current transaction */
|
|
|
|
p->h = headerFree(p->h);
|
|
|
|
xx = rpmdbSync(rpmtsGetRdb(ts));
|
|
|
|
psm = rpmpsmFree(psm);
|
|
|
|
p->fi = rpmfiFree(p->fi);
|
|
|
|
pi = rpmtsiFree(pi);
|
2004-03-06 02:22:25 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
/* Clean up rollback transaction */
|
|
|
|
rollbackTransaction = rpmtsFree(rollbackTransaction);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
ourrc++;
|
|
|
|
lastFailKey = pkgKey;
|
|
|
|
|
|
|
|
/* If we should rollback this transaction
|
|
|
|
* on failure, lets do it.
|
|
|
|
*/
|
|
|
|
if (rollbackOnFailure) {
|
2007-10-09 19:14:30 +08:00
|
|
|
rpmlog(RPMMESS_ERROR, _("Add failed. Could not get file list.\n"));
|
2004-03-27 01:27:57 +08:00
|
|
|
/* Clean up the current transaction */
|
|
|
|
p->h = headerFree(p->h);
|
|
|
|
xx = rpmdbSync(rpmtsGetRdb(ts));
|
|
|
|
psm = rpmpsmFree(psm);
|
|
|
|
p->fi = rpmfiFree(p->fi);
|
|
|
|
pi = rpmtsiFree(pi);
|
2004-03-06 02:22:25 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
/* Run the rollback transaction */
|
|
|
|
xx = _rpmtsRollback(rollbackTransaction);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
2004-03-06 02:22:25 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
if (gotfd) {
|
2007-09-12 01:07:39 +08:00
|
|
|
/* FIX: check rc */
|
2004-03-27 01:27:57 +08:00
|
|
|
(void) ts->notify(p->h, RPMCALLBACK_INST_CLOSE_FILE, 0, 0,
|
|
|
|
rpmteKey(p), ts->notifyData);
|
|
|
|
p->fd = NULL;
|
2004-03-06 02:22:25 +08:00
|
|
|
}
|
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
p->h = headerFree(p->h);
|
2004-03-06 02:22:25 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
(void) rpmswExit(rpmtsOp(ts, RPMTS_OP_INSTALL), 0);
|
2004-03-06 02:22:25 +08:00
|
|
|
|
2007-09-12 01:07:39 +08:00
|
|
|
break;
|
2004-03-06 02:22:25 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
case TR_REMOVED:
|
|
|
|
(void) rpmswEnter(rpmtsOp(ts, RPMTS_OP_ERASE), 0);
|
2004-03-06 02:22:25 +08:00
|
|
|
|
2007-10-09 19:48:04 +08:00
|
|
|
rpmlog(RPMLOG_DEBUG, "========== --- %s %s-%s 0x%x\n",
|
2004-03-27 01:27:57 +08:00
|
|
|
rpmteNEVR(p), rpmteA(p), rpmteO(p), rpmteColor(p));
|
2004-03-06 02:22:25 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
/*
|
|
|
|
* XXX This has always been a hack, now mostly broken.
|
|
|
|
* If install failed, then we shouldn't erase.
|
|
|
|
*/
|
|
|
|
if (rpmteDependsOnKey(p) != lastFailKey) {
|
|
|
|
if (rpmpsmStage(psm, PSM_PKGERASE)) {
|
|
|
|
ourrc++;
|
2004-03-06 02:22:25 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
/* If we should rollback this transaction
|
|
|
|
* on failure, lets do it.
|
|
|
|
*/
|
|
|
|
if (rollbackOnFailure) {
|
2007-10-09 19:14:30 +08:00
|
|
|
rpmlog(RPMMESS_ERROR,
|
2004-03-27 01:27:57 +08:00
|
|
|
_("Erase failed failed in rpmpsmStage().\n"));
|
|
|
|
/* Clean up the current transaction */
|
|
|
|
xx = rpmdbSync(rpmtsGetRdb(ts));
|
|
|
|
psm = rpmpsmFree(psm);
|
|
|
|
p->fi = rpmfiFree(p->fi);
|
|
|
|
pi = rpmtsiFree(pi);
|
2004-03-06 02:22:25 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
/* Run the rollback transaction */
|
|
|
|
xx = _rpmtsRollback(rollbackTransaction);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
2004-03-06 02:22:25 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
/* If we should rollback on failure lets add
|
|
|
|
* this element to the rollback transaction
|
|
|
|
* as an install element as it has erased succesfully.
|
|
|
|
*/
|
|
|
|
if (rollbackOnFailure) {
|
|
|
|
int rc;
|
2004-03-06 02:22:25 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
rc = _rpmtsAddRollbackElement(rollbackTransaction, ts, p);
|
2004-03-06 02:22:25 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
if (rc != RPMRC_OK) {
|
|
|
|
/* Clean up the current transaction */
|
|
|
|
xx = rpmdbSync(rpmtsGetRdb(ts));
|
|
|
|
psm = rpmpsmFree(psm);
|
|
|
|
p->fi = rpmfiFree(p->fi);
|
|
|
|
pi = rpmtsiFree(pi);
|
|
|
|
|
|
|
|
/* Clean up rollback transaction */
|
|
|
|
rollbackTransaction = rpmtsFree(rollbackTransaction);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
(void) rpmswExit(rpmtsOp(ts, RPMTS_OP_ERASE), 0);
|
|
|
|
|
2007-09-12 01:07:39 +08:00
|
|
|
break;
|
2004-03-27 01:27:57 +08:00
|
|
|
}
|
|
|
|
xx = rpmdbSync(rpmtsGetRdb(ts));
|
|
|
|
|
2007-09-12 01:07:39 +08:00
|
|
|
/* FIX: psm->fi may be NULL */
|
2004-03-27 01:27:57 +08:00
|
|
|
psm = rpmpsmFree(psm);
|
|
|
|
|
2005-02-10 17:04:05 +08:00
|
|
|
#ifdef DYING
|
2007-09-12 01:07:39 +08:00
|
|
|
/* FIX: p is almost opaque */
|
2004-03-27 01:27:57 +08:00
|
|
|
p->fi = rpmfiFree(p->fi);
|
2005-02-10 17:04:05 +08:00
|
|
|
#endif
|
2004-03-06 02:22:25 +08:00
|
|
|
|
|
|
|
}
|
2004-03-27 01:27:57 +08:00
|
|
|
pi = rpmtsiFree(pi);
|
2004-03-06 02:22:25 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
/* If we created a rollback transaction lets get rid of it */
|
|
|
|
if (rollbackOnFailure && rollbackTransaction != NULL)
|
|
|
|
rollbackTransaction = rpmtsFree(rollbackTransaction);
|
2004-03-06 02:22:25 +08:00
|
|
|
|
2007-05-16 21:22:01 +08:00
|
|
|
if (!(rpmtsFlags(ts) & RPMTRANS_FLAG_TEST)) {
|
2007-10-09 19:48:04 +08:00
|
|
|
rpmlog(RPMLOG_DEBUG, _("running post-transaction scripts\n"));
|
2007-05-16 21:22:01 +08:00
|
|
|
pi = rpmtsiInit(ts);
|
|
|
|
while ((p = rpmtsiNext(pi, TR_ADDED)) != NULL) {
|
|
|
|
int haspostscript;
|
2005-02-10 17:04:05 +08:00
|
|
|
|
2007-05-16 21:22:01 +08:00
|
|
|
if ((fi = rpmtsiFi(pi)) == NULL)
|
|
|
|
continue; /* XXX can't happen */
|
2005-02-10 17:04:05 +08:00
|
|
|
|
2007-05-16 21:22:01 +08:00
|
|
|
haspostscript = (fi->posttrans != NULL ? 1 : 0);
|
|
|
|
p->fi = rpmfiFree(p->fi);
|
2005-02-10 17:04:05 +08:00
|
|
|
|
2007-05-16 21:22:01 +08:00
|
|
|
/* If no post-transaction script, then don't bother. */
|
|
|
|
if (!haspostscript)
|
|
|
|
continue;
|
2005-02-10 17:04:05 +08:00
|
|
|
|
2007-05-16 21:22:01 +08:00
|
|
|
p->fd = ts->notify(p->h, RPMCALLBACK_INST_OPEN_FILE, 0, 0,
|
|
|
|
rpmteKey(p), ts->notifyData);
|
|
|
|
p->h = NULL;
|
|
|
|
if (rpmteFd(p) != NULL) {
|
|
|
|
rpmVSFlags ovsflags = rpmtsVSFlags(ts);
|
|
|
|
rpmVSFlags vsflags = ovsflags | RPMVSF_NEEDPAYLOAD;
|
|
|
|
rpmRC rpmrc;
|
|
|
|
ovsflags = rpmtsSetVSFlags(ts, vsflags);
|
|
|
|
rpmrc = rpmReadPackageFile(ts, rpmteFd(p),
|
|
|
|
rpmteNEVR(p), &p->h);
|
|
|
|
vsflags = rpmtsSetVSFlags(ts, ovsflags);
|
|
|
|
switch (rpmrc) {
|
|
|
|
default:
|
|
|
|
p->fd = ts->notify(p->h, RPMCALLBACK_INST_CLOSE_FILE,
|
|
|
|
0, 0, rpmteKey(p), ts->notifyData);
|
|
|
|
p->fd = NULL;
|
2007-09-12 01:07:39 +08:00
|
|
|
break;
|
2007-05-16 21:22:01 +08:00
|
|
|
case RPMRC_NOTTRUSTED:
|
|
|
|
case RPMRC_NOKEY:
|
|
|
|
case RPMRC_OK:
|
2007-09-12 01:07:39 +08:00
|
|
|
break;
|
2007-05-16 21:22:01 +08:00
|
|
|
}
|
2004-03-27 01:27:57 +08:00
|
|
|
}
|
2004-03-06 02:22:25 +08:00
|
|
|
|
2007-05-16 21:22:01 +08:00
|
|
|
if (rpmteFd(p) != NULL) {
|
|
|
|
p->fi = rpmfiNew(ts, p->h, RPMTAG_BASENAMES, 1);
|
|
|
|
if (p->fi != NULL) /* XXX can't happen */
|
|
|
|
p->fi->te = p;
|
|
|
|
psm = rpmpsmNew(ts, p, p->fi);
|
2004-03-27 01:27:57 +08:00
|
|
|
assert(psm != NULL);
|
2007-05-16 21:22:01 +08:00
|
|
|
psm->scriptTag = RPMTAG_POSTTRANS;
|
|
|
|
psm->progTag = RPMTAG_POSTTRANSPROG;
|
|
|
|
xx = rpmpsmStage(psm, PSM_SCRIPT);
|
|
|
|
psm = rpmpsmFree(psm);
|
2004-03-27 01:27:57 +08:00
|
|
|
|
2007-05-16 21:22:01 +08:00
|
|
|
(void) ts->notify(p->h, RPMCALLBACK_INST_CLOSE_FILE, 0, 0,
|
|
|
|
rpmteKey(p), ts->notifyData);
|
|
|
|
p->fd = NULL;
|
|
|
|
p->fi = rpmfiFree(p->fi);
|
|
|
|
p->h = headerFree(p->h);
|
|
|
|
}
|
2004-03-27 01:27:57 +08:00
|
|
|
}
|
2007-05-16 21:22:01 +08:00
|
|
|
pi = rpmtsiFree(pi);
|
2004-03-27 01:27:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
rpmtsFreeLock(lock);
|
|
|
|
|
2007-09-12 01:07:39 +08:00
|
|
|
/* FIX: ts->flList may be NULL */
|
2004-03-27 01:27:57 +08:00
|
|
|
if (ourrc)
|
|
|
|
return -1;
|
|
|
|
else
|
|
|
|
return 0;
|
2004-03-06 02:22:25 +08:00
|
|
|
}
|