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"
|
|
|
|
|
2008-01-30 19:53:51 +08:00
|
|
|
#include <rpm/rpmlib.h> /* rpmMachineScore, rpmReadPackageFile */
|
2007-12-08 20:02:32 +08:00
|
|
|
#include <rpm/rpmmacro.h> /* XXX for rpmExpand */
|
|
|
|
#include <rpm/rpmlog.h>
|
|
|
|
#include <rpm/rpmdb.h>
|
|
|
|
#include <rpm/rpmds.h>
|
2008-01-30 23:05:29 +08:00
|
|
|
#include <rpm/rpmfileutil.h>
|
|
|
|
#include <rpm/rpmstring.h>
|
2008-04-18 02:56:54 +08:00
|
|
|
#include <rpm/argv.h>
|
2002-05-20 07:37:24 +08:00
|
|
|
|
2008-05-12 17:28:12 +08:00
|
|
|
#include "lib/rpmdb_internal.h" /* XXX for dbiIndexSetCount */
|
|
|
|
#include "lib/fprint.h"
|
2008-01-30 23:05:29 +08:00
|
|
|
#include "lib/psm.h"
|
2007-11-23 18:39:29 +08:00
|
|
|
#include "lib/rpmlock.h"
|
2007-12-03 15:46:51 +08:00
|
|
|
#include "lib/rpmfi_internal.h" /* fi->replaced, fi->actions... */
|
2007-12-03 16:15:46 +08:00
|
|
|
#include "lib/rpmte_internal.h" /* XXX te->h, te->fd, te->h */
|
2007-11-23 18:39:29 +08:00
|
|
|
#include "lib/rpmts_internal.h"
|
|
|
|
#include "lib/cpio.h"
|
1998-12-19 03:09:38 +08:00
|
|
|
|
2000-12-13 04:03:45 +08:00
|
|
|
#include "debug.h"
|
|
|
|
|
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
|
|
|
{
|
2008-02-05 18:12:31 +08:00
|
|
|
rpm_color_t tscolor = rpmtsColor(ts);
|
|
|
|
rpm_color_t prefcolor = rpmtsPrefColor(ts);
|
|
|
|
rpm_color_t otecolor, tecolor;
|
|
|
|
rpm_color_t oFColor, FColor;
|
2007-12-15 01:52:11 +08:00
|
|
|
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) {
|
2007-12-01 16:29:44 +08:00
|
|
|
altNEVR = headerGetNEVRA(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)) {
|
2008-02-05 18:31:32 +08:00
|
|
|
rpm_mode_t omode = rpmfiFMode(otherFi);
|
2007-04-16 20:26:12 +08:00
|
|
|
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,
|
2007-10-24 15:31:42 +08:00
|
|
|
rpmteNEVRA(p), rpmteKey(p),
|
2002-05-20 02:42:25 +08:00
|
|
|
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
|
|
|
|
2007-12-19 18:05:56 +08:00
|
|
|
xx = hge(h, RPMTAG_FILESTATES, NULL, (rpm_data_t *) &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;
|
2008-01-02 19:55:16 +08:00
|
|
|
size_t adnlen = strlen(a->entry->dirName);
|
|
|
|
size_t asnlen = (a->subDir ? strlen(a->subDir) : 0);
|
|
|
|
size_t abnlen = strlen(a->baseName);
|
|
|
|
size_t bdnlen = strlen(b->entry->dirName);
|
|
|
|
size_t bsnlen = (b->subDir ? strlen(b->subDir) : 0);
|
|
|
|
size_t bbnlen = strlen(b->baseName);
|
2008-04-30 16:32:33 +08:00
|
|
|
char *afn = NULL, *bfn = NULL;
|
2001-11-16 02:22:33 +08:00
|
|
|
int rc = 0;
|
|
|
|
|
|
|
|
if (adnlen == 1 && asnlen != 0) adnlen = 0;
|
|
|
|
if (bdnlen == 1 && bsnlen != 0) bdnlen = 0;
|
|
|
|
|
2008-04-30 16:32:33 +08:00
|
|
|
if (adnlen) rstrcat(&afn, a->entry->dirName);
|
|
|
|
rstrcat(&afn, "/");
|
|
|
|
if (a->subDir && asnlen) rstrcat(&afn, a->subDir);
|
|
|
|
if (abnlen) rstrcat(&afn, a->baseName);
|
|
|
|
if (afn[0] == '/' && afn[1] == '/') {
|
|
|
|
memmove(afn, afn+1, strlen(afn+1)+1);
|
|
|
|
}
|
2001-11-16 02:22:33 +08:00
|
|
|
|
2008-04-30 16:32:33 +08:00
|
|
|
if (bdnlen) rstrcat(&bfn, b->entry->dirName);
|
|
|
|
rstrcat(&bfn, "/");
|
|
|
|
if (b->subDir && bsnlen) rstrcat(&bfn, b->subDir);
|
|
|
|
if (bbnlen) rstrcat(&bfn, b->baseName);
|
|
|
|
if (bfn[0] == '/' && bfn[1] == '/') {
|
|
|
|
memmove(bfn, bfn+1, strlen(bfn+1)+1);
|
|
|
|
}
|
2001-11-16 02:22:33 +08:00
|
|
|
|
|
|
|
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
|
|
|
|
);
|
2008-04-30 16:32:33 +08:00
|
|
|
free(afn);
|
|
|
|
free(bfn);
|
2001-11-16 02:22:33 +08:00
|
|
|
|
|
|
|
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
|
|
|
{
|
2007-10-26 19:24:14 +08:00
|
|
|
uint32_t 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) {
|
2008-02-05 18:12:31 +08:00
|
|
|
rpm_color_t tscolor = rpmtsColor(ts);
|
|
|
|
rpm_color_t prefcolor = rpmtsPrefColor(ts);
|
|
|
|
rpm_color_t 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;
|
2008-02-05 21:15:41 +08:00
|
|
|
rpmfileAttrs FFlags;
|
2008-02-05 18:31:32 +08:00
|
|
|
rpm_mode_t 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,
|
2007-10-24 15:31:42 +08:00
|
|
|
rpmteNEVRA(p), rpmteKey(p),
|
2001-11-14 08:14:01 +08:00
|
|
|
fn, NULL,
|
2007-10-24 15:31:42 +08:00
|
|
|
rpmteNEVRA(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. */
|
2008-05-29 20:48:40 +08:00
|
|
|
{ pgpHashAlgo algo = 0;
|
|
|
|
size_t diglen = 0;
|
|
|
|
const unsigned char *digest;
|
2008-05-30 17:06:40 +08:00
|
|
|
if ((digest = rpmfiFDigest(fi, &algo, &diglen))) {
|
2008-05-29 20:48:40 +08:00
|
|
|
unsigned char fdigest[diglen];
|
|
|
|
if (!rpmDoDigest(algo, fn, 0, fdigest, NULL) &&
|
|
|
|
memcmp(digest, fdigest, diglen)) {
|
|
|
|
fi->actions[i] = FA_BACKUP;
|
|
|
|
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
|
|
|
{
|
2008-01-30 22:04:40 +08:00
|
|
|
rpmsenseFlags reqFlags = (RPMSENSE_LESS | RPMSENSE_EQUAL);
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmds req;
|
2001-11-11 03:24:19 +08:00
|
|
|
int rc;
|
|
|
|
|
|
|
|
if (p == NULL || h == NULL)
|
|
|
|
return 1;
|
|
|
|
|
2008-04-24 19:56:27 +08:00
|
|
|
req = rpmdsSingle(RPMTAG_REQUIRENAME, rpmteN(p), rpmteEVR(p), 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);
|
2007-12-15 01:52:11 +08:00
|
|
|
char * altNEVR = headerGetNEVRA(h, NULL);
|
2002-05-20 02:42:25 +08:00
|
|
|
rpmpsAppend(ps, RPMPROB_OLDPACKAGE,
|
2007-10-24 15:31:42 +08:00
|
|
|
rpmteNEVRA(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
|
|
|
{
|
2008-02-05 18:12:31 +08:00
|
|
|
rpm_color_t tscolor = rpmtsColor(ts);
|
|
|
|
rpm_color_t 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);
|
2008-04-18 02:56:54 +08:00
|
|
|
ARGV_t netsharedPaths = NULL;
|
|
|
|
ARGV_t languages = NULL;
|
2001-04-04 04:41:09 +08:00
|
|
|
const char * dn, * bn;
|
2007-12-14 17:38:20 +08:00
|
|
|
size_t dnlen, bnlen;
|
2007-12-15 01:52:11 +08:00
|
|
|
char * s;
|
2001-04-03 21:41:56 +08:00
|
|
|
int * drc;
|
|
|
|
char * dff;
|
2001-11-16 08:26:30 +08:00
|
|
|
int dc;
|
2007-12-14 17:38:20 +08:00
|
|
|
int i, j, ix;
|
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
|
|
|
|
2007-12-15 01:52:11 +08:00
|
|
|
{ char *tmpPath = rpmExpand("%{_netsharedpath}", NULL);
|
2008-04-18 02:56:54 +08:00
|
|
|
if (tmpPath && *tmpPath != '%') {
|
|
|
|
argvSplit(&netsharedPaths, 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) {
|
2008-04-18 02:56:54 +08:00
|
|
|
argvSplit(&languages, 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);
|
2008-04-25 19:34:36 +08:00
|
|
|
drc = xcalloc(dc, sizeof(*drc));
|
|
|
|
dff = xcalloc(dc, sizeof(*dff));
|
2001-11-16 08:26:30 +08:00
|
|
|
|
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++) {
|
2007-12-14 17:38:20 +08:00
|
|
|
size_t 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]) {
|
2007-12-19 20:13:34 +08:00
|
|
|
const char *l, *le;
|
|
|
|
char **lang;
|
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;
|
2008-02-05 18:31:32 +08:00
|
|
|
rpm_mode_t 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;
|
2008-03-07 15:47:51 +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
|
|
|
|
2008-04-18 02:56:54 +08:00
|
|
|
if (netsharedPaths) argvFree(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
|
2008-04-18 02:56:54 +08:00
|
|
|
if (languages) argvFree(languages);
|
2008-04-25 19:34:36 +08:00
|
|
|
free(drc);
|
|
|
|
free(dff);
|
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;
|
|
|
|
}
|
|
|
|
|
2008-03-17 22:03:51 +08:00
|
|
|
/*
|
|
|
|
* Run pre/post transaction scripts for transaction set
|
|
|
|
* param ts Transaction set
|
|
|
|
* param stag RPMTAG_PRETRANS or RPMTAG_POSTTRANS
|
|
|
|
* return 0 on success, -1 on error (invalid script tag)
|
|
|
|
*/
|
|
|
|
static int runTransScripts(rpmts ts, rpmTag stag)
|
|
|
|
{
|
|
|
|
rpmtsi pi;
|
|
|
|
rpmte p;
|
|
|
|
rpmfi fi;
|
|
|
|
rpmpsm psm;
|
|
|
|
int xx;
|
|
|
|
|
|
|
|
pi = rpmtsiInit(ts);
|
|
|
|
while ((p = rpmtsiNext(pi, TR_ADDED)) != NULL) {
|
|
|
|
const char * script = NULL, * scriptprog = NULL;
|
|
|
|
rpmTag progtag = RPMTAG_NOT_FOUND;
|
|
|
|
|
|
|
|
if ((fi = rpmtsiFi(pi)) == NULL)
|
|
|
|
continue; /* XXX can't happen */
|
|
|
|
|
|
|
|
switch (stag) {
|
|
|
|
case RPMTAG_PRETRANS:
|
|
|
|
script = fi->pretrans;
|
|
|
|
scriptprog = fi->pretransprog;
|
|
|
|
progtag = RPMTAG_PRETRANSPROG;
|
|
|
|
break;
|
|
|
|
case RPMTAG_POSTTRANS:
|
|
|
|
script = fi->posttrans;
|
|
|
|
scriptprog = fi->posttransprog;
|
|
|
|
progtag = RPMTAG_POSTTRANSPROG;
|
|
|
|
p->fi = rpmfiFree(p->fi);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* programmer error, blow up */
|
|
|
|
assert(progtag != RPMTAG_NOT_FOUND);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If no pre/post-transaction script, then don't bother. */
|
|
|
|
if (script == NULL)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
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:
|
|
|
|
/* FIX: notify annotations */
|
|
|
|
p->fd = ts->notify(p->h, RPMCALLBACK_INST_CLOSE_FILE,
|
|
|
|
0, 0, rpmteKey(p), ts->notifyData);
|
|
|
|
p->fd = NULL;
|
|
|
|
break;
|
|
|
|
case RPMRC_NOTTRUSTED:
|
|
|
|
case RPMRC_NOKEY:
|
|
|
|
case RPMRC_OK:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rpmteFd(p) != NULL) {
|
|
|
|
fi = rpmfiNew(ts, p->h, RPMTAG_BASENAMES, 1);
|
|
|
|
if (fi != NULL) { /* XXX can't happen */
|
|
|
|
if (stag == RPMTAG_PRETRANS) {
|
|
|
|
fi->te = p;
|
|
|
|
p->fi = fi;
|
|
|
|
} else {
|
2008-05-15 23:52:18 +08:00
|
|
|
p->fi = fi;
|
2008-03-17 22:03:51 +08:00
|
|
|
p->fi->te = p;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
psm = rpmpsmNew(ts, p, p->fi);
|
|
|
|
assert(psm != NULL);
|
|
|
|
xx = rpmpsmScriptStage(psm, stag, progtag);
|
|
|
|
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);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
{
|
2008-02-05 18:12:31 +08:00
|
|
|
rpm_color_t tscolor = rpmtsColor(ts);
|
2004-03-27 01:27:57 +08:00
|
|
|
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;
|
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-10-10 03:40:09 +08:00
|
|
|
/* If we are in test mode, then there's no need for transaction lock. */
|
2008-03-17 18:04:39 +08:00
|
|
|
if (!(rpmtsFlags(ts) & RPMTRANS_FLAG_TEST)) {
|
2004-04-08 07:50:35 +08:00
|
|
|
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-12-15 16:39:15 +08:00
|
|
|
char *fn = rpmGetPath("%{?_install_file_context_path}", NULL);
|
2007-09-03 19:42:42 +08:00
|
|
|
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;
|
2008-04-04 14:53:17 +08:00
|
|
|
{ char * currDir = rpmGetCwd();
|
2004-03-27 01:27:57 +08:00
|
|
|
rpmtsSetCurrDir(ts, currDir);
|
|
|
|
currDir = _free(currDir);
|
|
|
|
}
|
|
|
|
|
|
|
|
(void) rpmtsSetChrootDone(ts, 0);
|
2003-04-07 20:05:35 +08:00
|
|
|
|
2008-02-05 21:29:37 +08:00
|
|
|
{ rpm_tid_t tid = (rpm_tid_t) time(NULL);
|
2004-03-27 01:27:57 +08:00
|
|
|
(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
|
|
|
|
2008-03-07 15:47:51 +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
|
|
|
|
2008-05-02 16:48:27 +08:00
|
|
|
if (!(rpmtsFilterFlags(ts) & RPMPROB_FILTER_IGNOREARCH))
|
2004-03-27 01:27:57 +08:00
|
|
|
if (!archOkay(rpmteA(p)))
|
|
|
|
rpmpsAppend(ps, RPMPROB_BADARCH,
|
2007-10-24 15:31:42 +08:00
|
|
|
rpmteNEVRA(p), rpmteKey(p),
|
2004-03-27 01:27:57 +08:00
|
|
|
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,
|
2007-10-24 15:31:42 +08:00
|
|
|
rpmteNEVRA(p), rpmteKey(p),
|
2004-03-27 01:27:57 +08:00
|
|
|
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,
|
2007-10-24 15:31:42 +08:00
|
|
|
rpmteNEVRA(p), rpmteKey(p),
|
2004-03-27 01:27:57 +08:00
|
|
|
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))))) {
|
2008-03-07 15:47:51 +08:00
|
|
|
rpmlog(RPMLOG_DEBUG, "running pre-transaction scripts\n");
|
2008-03-17 22:03:51 +08:00
|
|
|
runTransScripts(ts, RPMTAG_PRETRANS);
|
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.
|
|
|
|
*/
|
2008-03-07 15:47:51 +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);
|
2008-04-24 18:23:22 +08:00
|
|
|
if (chroot(rootDir) == -1) {
|
|
|
|
rpmlog(RPMLOG_ERR, _("Unable to change root directory: %m\n"));
|
|
|
|
return -1;
|
|
|
|
}
|
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
|
|
|
*/
|
2008-03-07 15:47:51 +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) {
|
2008-02-05 18:31:32 +08:00
|
|
|
rpm_mode_t mode;
|
2007-04-16 20:26:12 +08:00
|
|
|
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
|
|
|
/* ===============================================
|
|
|
|
* 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;
|
2007-12-17 20:58:02 +08:00
|
|
|
int gotfd, async;
|
2004-03-27 01:27:57 +08:00
|
|
|
|
|
|
|
gotfd = 0;
|
|
|
|
if ((fi = rpmtsiFi(pi)) == NULL)
|
|
|
|
continue; /* XXX can't happen */
|
|
|
|
|
|
|
|
psm = rpmpsmNew(ts, p, fi);
|
2007-12-17 20:58:02 +08:00
|
|
|
async = (rpmtsiOc(pi) >= rpmtsUnorderedSuccessors(ts, -1) ? 1 : 0);
|
|
|
|
rpmpsmSetAsync(psm, async);
|
2004-03-27 01:27:57 +08:00
|
|
|
|
|
|
|
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++;
|
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.
|
|
|
|
*/
|
2007-12-17 20:58:02 +08:00
|
|
|
rpmpsmSetFI(psm, NULL);
|
2004-03-27 01:27:57 +08:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
2007-12-17 20:58:02 +08:00
|
|
|
rpmpsmSetFI(psm, p->fi);
|
2004-03-27 01:27:57 +08:00
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
ourrc++;
|
|
|
|
lastFailKey = pkgKey;
|
|
|
|
}
|
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++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
(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
|
|
|
|
2007-05-16 21:22:01 +08:00
|
|
|
if (!(rpmtsFlags(ts) & RPMTRANS_FLAG_TEST)) {
|
2008-03-07 15:47:51 +08:00
|
|
|
rpmlog(RPMLOG_DEBUG, "running post-transaction scripts\n");
|
2008-03-17 22:03:51 +08:00
|
|
|
runTransScripts(ts, RPMTAG_POSTTRANS);
|
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
|
|
|
}
|