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"
|
2008-12-19 21:05:54 +08:00
|
|
|
#include "lib/rpmfi_internal.h" /* only internal apis */
|
2008-11-27 16:48:22 +08:00
|
|
|
#include "lib/rpmte_internal.h" /* only internal apis */
|
2007-11-23 18:39:29 +08:00
|
|
|
#include "lib/rpmts_internal.h"
|
|
|
|
#include "lib/cpio.h"
|
2009-01-15 16:28:13 +08:00
|
|
|
#include "rpmio/rpmhook.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
|
|
|
|
2009-02-24 15:21:20 +08:00
|
|
|
/* Calculate total number of files involved in transaction */
|
|
|
|
static uint64_t countFiles(rpmts ts)
|
|
|
|
{
|
|
|
|
uint64_t fc = 0;
|
|
|
|
rpmtsi pi = rpmtsiInit(ts);
|
|
|
|
rpmte p;
|
|
|
|
rpmfi fi;
|
|
|
|
while ((p = rpmtsiNext(pi, 0)) != NULL) {
|
|
|
|
if ((fi = rpmteFI(p)) == NULL)
|
|
|
|
continue; /* XXX can't happen */
|
|
|
|
fc += rpmfiFC(fi);
|
|
|
|
}
|
|
|
|
pi = rpmtsiFree(pi);
|
|
|
|
return fc;
|
|
|
|
}
|
|
|
|
|
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 */
|
2008-11-07 17:58:25 +08:00
|
|
|
static int handleInstInstalledFile(const rpmts ts, rpmte p, rpmfi fi,
|
|
|
|
Header otherHeader, rpmfi otherFi,
|
|
|
|
int beingRemoved)
|
1999-07-14 22:36:10 +08:00
|
|
|
{
|
2008-12-03 17:39:48 +08:00
|
|
|
unsigned int fx = rpmfiFX(fi);
|
|
|
|
rpmfs fs = rpmteGetFileStates(p);
|
2009-03-08 23:38:49 +08:00
|
|
|
int isCfgFile = ((rpmfiFFlags(otherFi) | rpmfiFFlags(fi)) & RPMFILE_CONFIG);
|
2002-07-28 08:41:15 +08:00
|
|
|
|
2008-12-03 17:39:48 +08:00
|
|
|
if (XFA_SKIPPING(rpmfsGetAction(fs, fx)))
|
2008-11-07 17:58:25 +08:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (rpmfiCompare(otherFi, fi)) {
|
2009-03-08 23:36:39 +08:00
|
|
|
rpm_color_t tscolor = rpmtsColor(ts);
|
|
|
|
rpm_color_t prefcolor = rpmtsPrefColor(ts);
|
|
|
|
rpm_color_t FColor = rpmfiFColor(fi) & tscolor;
|
|
|
|
rpm_color_t oFColor = rpmfiFColor(otherFi) & tscolor;
|
2008-11-07 17:58:25 +08:00
|
|
|
int rConflicts;
|
|
|
|
|
|
|
|
rConflicts = !(beingRemoved || (rpmtsFilterFlags(ts) & RPMPROB_FILTER_REPLACEOLDFILES));
|
|
|
|
/* Resolve file conflicts to prefer Elf64 (if not forced). */
|
|
|
|
if (tscolor != 0 && FColor != 0 && FColor != oFColor) {
|
|
|
|
if (oFColor & prefcolor) {
|
2008-12-03 17:39:48 +08:00
|
|
|
rpmfsSetAction(fs, fx, FA_SKIPCOLOR);
|
2008-11-07 17:58:25 +08:00
|
|
|
rConflicts = 0;
|
|
|
|
} else if (FColor & prefcolor) {
|
2008-12-03 17:39:48 +08:00
|
|
|
rpmfsSetAction(fs, fx, FA_CREATE);
|
2008-11-07 17:58:25 +08:00
|
|
|
rConflicts = 0;
|
2003-07-10 04:18:54 +08:00
|
|
|
}
|
2008-11-07 17:58:25 +08:00
|
|
|
}
|
2003-07-10 04:18:54 +08:00
|
|
|
|
2008-11-07 17:58:25 +08:00
|
|
|
if (rConflicts) {
|
2009-03-08 23:25:45 +08:00
|
|
|
char *altNEVR = headerGetNEVRA(otherHeader, NULL);
|
2009-03-08 23:28:17 +08:00
|
|
|
rpmps ps = rpmtsProblems(ts);
|
2008-11-07 17:58: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);
|
2009-03-08 23:25:45 +08:00
|
|
|
free(altNEVR);
|
2009-03-08 23:28:17 +08:00
|
|
|
rpmpsFree(ps);
|
1999-08-14 04:05:57 +08:00
|
|
|
}
|
1998-12-19 03:09:38 +08:00
|
|
|
|
2008-11-07 17:58:25 +08:00
|
|
|
/* Save file identifier to mark as state REPLACED. */
|
2008-12-03 17:39:48 +08:00
|
|
|
if ( !(isCfgFile || XFA_SKIPPING(rpmfsGetAction(fs, fx))) ) {
|
2008-11-07 17:58:25 +08:00
|
|
|
if (!beingRemoved)
|
2008-12-02 04:34:59 +08:00
|
|
|
rpmfsAddReplaced(rpmteGetFileStates(p), rpmfiFX(fi),
|
2008-11-07 17:58:25 +08:00
|
|
|
headerGetInstance(otherHeader),
|
|
|
|
rpmfiFX(otherFi));
|
1998-12-19 03:09:38 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-11-07 17:58:25 +08:00
|
|
|
/* Determine config file dispostion, skipping missing files (if any). */
|
|
|
|
if (isCfgFile) {
|
2009-03-08 23:38:49 +08:00
|
|
|
int skipMissing = ((rpmtsFlags(ts) & RPMTRANS_FLAG_ALLFILES) ? 0 : 1);
|
2008-11-07 17:58:25 +08:00
|
|
|
rpmFileAction action = rpmfiDecideFate(otherFi, fi, skipMissing);
|
2008-12-03 17:39:48 +08:00
|
|
|
rpmfsSetAction(fs, fx, action);
|
2008-11-07 17:58:25 +08:00
|
|
|
}
|
|
|
|
rpmfiSetFReplacedSize(fi, rpmfiFSize(otherFi));
|
1998-12-19 03:09:38 +08:00
|
|
|
|
1999-07-14 22:36:10 +08:00
|
|
|
return 0;
|
1998-12-19 03:09:38 +08:00
|
|
|
}
|
|
|
|
|
2000-10-21 00:47:00 +08:00
|
|
|
/**
|
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 */
|
2009-02-24 17:23:25 +08:00
|
|
|
static void handleOverlappedFiles(rpmts ts, rpmFpHash ht, rpmte p, rpmfi fi)
|
1999-07-14 22:36:10 +08:00
|
|
|
{
|
2008-06-12 21:41:31 +08:00
|
|
|
rpm_loff_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;
|
2008-11-13 15:56:52 +08:00
|
|
|
rpm_color_t tscolor = rpmtsColor(ts);
|
|
|
|
rpm_color_t prefcolor = rpmtsPrefColor(ts);
|
2008-12-03 17:39:48 +08:00
|
|
|
rpmfs fs = rpmteGetFileStates(p);
|
|
|
|
rpmfs otherFs;
|
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 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-11-27 16:22:45 +08:00
|
|
|
rpmte otherTe;
|
2008-02-05 21:15:41 +08:00
|
|
|
rpmfileAttrs FFlags;
|
2008-02-05 18:31:32 +08:00
|
|
|
rpm_mode_t FMode;
|
2008-10-21 21:45:09 +08:00
|
|
|
struct rpmffi_s * recs;
|
1999-08-15 04:01:38 +08:00
|
|
|
int numRecs;
|
|
|
|
|
2008-12-03 17:39:48 +08:00
|
|
|
if (XFA_SKIPPING(rpmfsGetAction(fs, 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);
|
2008-12-19 21:04:51 +08:00
|
|
|
fiFps = rpmfiFpsIndex(fi, 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.
|
|
|
|
*/
|
2009-02-24 17:23:25 +08:00
|
|
|
(void) rpmFpHashGetEntry(ht, fiFps, &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. */
|
2008-11-26 23:29:55 +08:00
|
|
|
for (j = 0; j < numRecs && recs[j].p != p; 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;
|
2008-11-27 16:22:45 +08:00
|
|
|
otherTe = NULL;
|
2008-12-03 17:39:48 +08:00
|
|
|
otherFs = NULL;
|
2008-10-21 21:45:09 +08:00
|
|
|
|
1999-08-14 04:05:57 +08:00
|
|
|
for (otherPkgNum = j - 1; otherPkgNum >= 0; otherPkgNum--) {
|
2008-11-27 16:22:45 +08:00
|
|
|
otherTe = recs[otherPkgNum].p;
|
|
|
|
otherFi = rpmteFI(otherTe);
|
2008-10-21 21:45:09 +08:00
|
|
|
otherFileNum = recs[otherPkgNum].fileno;
|
2008-12-03 17:39:48 +08:00
|
|
|
otherFs = rpmteGetFileStates(otherTe);
|
2001-11-16 02:22:33 +08:00
|
|
|
|
1999-08-18 07:05:24 +08:00
|
|
|
/* Added packages need only look at other added packages. */
|
2008-11-27 16:22:45 +08:00
|
|
|
if (rpmteType(p) == TR_ADDED && rpmteType(otherTe) != TR_ADDED)
|
2007-09-12 01:07:39 +08:00
|
|
|
continue;
|
1999-08-14 04:05:57 +08:00
|
|
|
|
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. */
|
2008-12-03 17:39:48 +08:00
|
|
|
if (rpmfsGetAction(otherFs, 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? */
|
2008-11-12 04:32:23 +08:00
|
|
|
rpmFileAction action;
|
2008-12-03 17:39:48 +08:00
|
|
|
if (rpmfsGetAction(fs, 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. */
|
2008-11-12 04:32:23 +08:00
|
|
|
action = (FFlags & RPMFILE_NOREPLACE) ?
|
|
|
|
FA_ALTNAME : FA_BACKUP;
|
1999-08-17 06:10:27 +08:00
|
|
|
} else {
|
2008-11-12 04:32:23 +08:00
|
|
|
action = FA_CREATE;
|
1999-08-17 06:10:27 +08:00
|
|
|
}
|
2008-12-03 17:39:48 +08:00
|
|
|
rpmfsSetAction(fs, i, action);
|
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 ... */
|
2009-06-15 20:21:27 +08:00
|
|
|
if (!XFA_SKIPPING(rpmfsGetAction(fs, i)))
|
|
|
|
rpmfsSetAction(otherFs, otherFileNum, FA_SKIPCOLOR);
|
2008-12-03 17:39:48 +08:00
|
|
|
rpmfsSetAction(fs, 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 ... */
|
2008-12-03 17:39:48 +08:00
|
|
|
if (XFA_SKIPPING(rpmfsGetAction(fs, i)))
|
|
|
|
rpmfsSetAction(otherFs, otherFileNum, FA_CREATE);
|
|
|
|
rpmfsSetAction(fs, i, FA_SKIPCOLOR);
|
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,
|
2008-11-27 16:22:45 +08:00
|
|
|
rpmteNEVRA(otherTe),
|
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. */
|
2008-11-12 04:32:23 +08:00
|
|
|
rpmFileAction action;
|
|
|
|
action = (FFlags & RPMFILE_NOREPLACE) ? FA_ALTNAME : FA_SKIP;
|
2008-12-03 17:39:48 +08:00
|
|
|
rpmfsSetAction(fs, i, action);
|
1999-08-17 06:10:27 +08:00
|
|
|
} else {
|
2003-07-10 04:18:54 +08:00
|
|
|
if (!done)
|
2008-12-03 17:39:48 +08:00
|
|
|
rpmfsSetAction(fs, 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) {
|
2008-12-03 17:39:48 +08:00
|
|
|
assert(otherFi != NULL);
|
|
|
|
/* Here is an overlapped added file we don't want to nuke. */
|
|
|
|
if (rpmfsGetAction(otherFs, otherFileNum) != FA_ERASE) {
|
1999-08-17 06:10:27 +08:00
|
|
|
/* On updates, don't remove files. */
|
2008-12-03 17:39:48 +08:00
|
|
|
rpmfsSetAction(fs, 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. */
|
2008-12-03 17:39:48 +08:00
|
|
|
rpmfsSetAction(otherFs, otherFileNum, FA_SKIP);
|
1999-08-15 04:01:38 +08:00
|
|
|
}
|
2008-12-03 17:39:48 +08:00
|
|
|
if (XFA_SKIPPING(rpmfsGetAction(fs, 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))) {
|
2008-12-03 17:39:48 +08:00
|
|
|
rpmfsSetAction(fs, 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)) {
|
2008-12-03 17:39:48 +08:00
|
|
|
rpmfsSetAction(fs, i, FA_BACKUP);
|
2008-05-29 20:48:40 +08:00
|
|
|
break;
|
|
|
|
}
|
1999-07-14 22:36:10 +08:00
|
|
|
}
|
1999-01-19 11:01:52 +08:00
|
|
|
}
|
2008-12-03 17:39:48 +08:00
|
|
|
rpmfsSetAction(fs, 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),
|
2008-12-03 17:39:48 +08:00
|
|
|
rpmfiFReplacedSize(fi), fixupSize, rpmfsGetAction(fs, 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 p current transaction element
|
|
|
|
* @param h installed header
|
2009-02-24 16:13:43 +08:00
|
|
|
* @param ps problem set
|
2001-11-11 03:24:19 +08:00
|
|
|
* @return 0 if not newer, 1 if okay
|
2001-09-26 04:51:34 +08:00
|
|
|
*/
|
2009-02-24 16:13:43 +08:00
|
|
|
static int ensureOlder(const rpmte p, const Header h, rpmps ps)
|
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) {
|
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);
|
|
|
|
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
|
|
|
*/
|
2008-12-03 17:39:48 +08:00
|
|
|
static void skipFiles(const rpmts ts, rpmte p)
|
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);
|
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;
|
2008-12-03 17:39:48 +08:00
|
|
|
rpmfi fi = rpmteFI(p);
|
|
|
|
rpmfs fs = rpmteGetFileStates(p);
|
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
|
|
|
|
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);
|
|
|
|
while ((i = rpmfiNext(fi)) >= 0)
|
2001-11-16 08:26:30 +08:00
|
|
|
{
|
2002-12-31 09:23:03 +08:00
|
|
|
char ** nsp;
|
2008-11-20 15:40:46 +08:00
|
|
|
const char *flangs;
|
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 */
|
2008-12-03 17:39:48 +08:00
|
|
|
if (XFA_SKIPPING(rpmfsGetAction(fs, 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;
|
2008-12-03 17:39:48 +08:00
|
|
|
rpmfsSetAction(fs, 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).
|
|
|
|
*/
|
2008-11-30 19:51:32 +08:00
|
|
|
for (nsp = ts->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) {
|
2009-08-31 18:03:53 +08:00
|
|
|
if (!rstreqn(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;
|
2009-08-31 18:03:53 +08:00
|
|
|
if (!rstreqn(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;
|
2009-08-31 18:03:53 +08:00
|
|
|
if (!rstreqn(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;
|
2008-12-03 17:39:48 +08:00
|
|
|
rpmfsSetAction(fs, 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.
|
|
|
|
*/
|
2009-03-09 20:57:46 +08:00
|
|
|
flangs = (ts->installLangs != NULL) ? rpmfiFLangs(fi) : NULL;
|
|
|
|
if (flangs != NULL && *flangs != '\0') {
|
2007-12-19 20:13:34 +08:00
|
|
|
const char *l, *le;
|
|
|
|
char **lang;
|
2008-11-30 20:07:03 +08:00
|
|
|
for (lang = ts->installLangs; *lang != NULL; lang++) {
|
2008-11-20 15:40:46 +08:00
|
|
|
for (l = flangs; *l != '\0'; l = le) {
|
2001-04-29 09:05:43 +08:00
|
|
|
for (le = l; *le != '\0' && *le != '|'; le++)
|
2001-06-06 03:26:22 +08:00
|
|
|
{};
|
2009-08-31 18:03:53 +08:00
|
|
|
if ((le-l) > 0 && rstreqn(*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;
|
2008-12-03 17:39:48 +08:00
|
|
|
rpmfsSetAction(fs, i, FA_SKIPNSTATE);
|
1999-07-14 22:36:10 +08:00
|
|
|
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;
|
2008-12-03 17:39:48 +08:00
|
|
|
rpmfsSetAction(fs, i, FA_SKIPNSTATE);
|
2002-12-25 01:06:35 +08:00
|
|
|
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;
|
2008-12-03 17:39:48 +08:00
|
|
|
rpmfsSetAction(fs, 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. */
|
2008-12-19 21:05:54 +08:00
|
|
|
dn = rpmfiDNIndex(fi, j); dnlen = strlen(dn) - 1;
|
2001-04-03 21:41:56 +08:00
|
|
|
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);
|
|
|
|
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
|
|
|
|
2008-12-03 17:39:48 +08:00
|
|
|
if (XFA_SKIPPING(rpmfsGetAction(fs, 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;
|
2009-08-31 18:03:53 +08:00
|
|
|
if (!rstreqn(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;
|
2009-08-31 18:03:53 +08:00
|
|
|
if (!rstreqn(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);
|
2008-12-03 17:39:48 +08:00
|
|
|
rpmfsSetAction(fs, 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-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
|
|
|
|
2008-11-07 17:58:25 +08:00
|
|
|
#undef HASHTYPE
|
|
|
|
#undef HTKEYTYPE
|
|
|
|
#undef HTDATATYPE
|
|
|
|
|
|
|
|
#define HASHTYPE rpmStringSet
|
|
|
|
#define HTKEYTYPE const char *
|
|
|
|
#include "lib/rpmhash.H"
|
|
|
|
#include "lib/rpmhash.C"
|
|
|
|
|
|
|
|
/* Get a rpmdbMatchIterator containing all files in
|
|
|
|
* the rpmdb that share the basename with one from
|
|
|
|
* the transaction.
|
|
|
|
* @param ts transaction set
|
|
|
|
* @return rpmdbMatchIterator sorted
|
|
|
|
by (package, fileNum)
|
|
|
|
*/
|
|
|
|
static
|
2009-02-24 17:50:23 +08:00
|
|
|
rpmdbMatchIterator rpmFindBaseNamesInDB(rpmts ts, uint64_t fileCount)
|
2008-11-07 17:58:25 +08:00
|
|
|
{
|
|
|
|
rpmtsi pi; rpmte p;
|
|
|
|
rpmfi fi;
|
|
|
|
rpmdbMatchIterator mi;
|
|
|
|
int i, xx;
|
|
|
|
const char * baseName;
|
|
|
|
|
2009-02-24 17:50:23 +08:00
|
|
|
rpmStringSet baseNames = rpmStringSetCreate(fileCount,
|
2009-02-24 15:21:20 +08:00
|
|
|
hashFunctionString, strcmp, NULL);
|
2008-11-07 17:58:25 +08:00
|
|
|
|
|
|
|
mi = rpmdbInitIterator(rpmtsGetRdb(ts), RPMTAG_BASENAMES, NULL, 0);
|
|
|
|
|
|
|
|
pi = rpmtsiInit(ts);
|
|
|
|
while ((p = rpmtsiNext(pi, 0)) != NULL) {
|
|
|
|
(void) rpmdbCheckSignals();
|
|
|
|
|
2008-11-27 16:25:47 +08:00
|
|
|
if ((fi = rpmteFI(p)) == NULL)
|
2008-11-07 17:58:25 +08:00
|
|
|
continue; /* XXX can't happen */
|
|
|
|
rpmtsNotify(ts, NULL, RPMCALLBACK_TRANS_PROGRESS, rpmtsiOc(pi),
|
|
|
|
ts->orderCount);
|
|
|
|
|
|
|
|
/* Gather all installed headers with matching basename's. */
|
|
|
|
fi = rpmfiInit(fi, 0);
|
|
|
|
while ((i = rpmfiNext(fi)) >= 0) {
|
|
|
|
size_t keylen;
|
|
|
|
baseName = rpmfiBN(fi);
|
|
|
|
if (rpmStringSetHasEntry(baseNames, baseName))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
keylen = strlen(baseName);
|
|
|
|
if (keylen == 0)
|
|
|
|
keylen++; /* XXX "/" fixup. */
|
|
|
|
xx = rpmdbExtendIterator(mi, baseName, keylen);
|
|
|
|
rpmStringSetAddEntry(baseNames, baseName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pi = rpmtsiFree(pi);
|
|
|
|
rpmStringSetFree(baseNames);
|
|
|
|
|
|
|
|
rpmdbSortIterator(mi);
|
|
|
|
/* iterator is now sorted by (recnum, filenum) */
|
|
|
|
return mi;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check files in the transactions against the rpmdb
|
|
|
|
* Lookup all files with the same basename in the rpmdb
|
|
|
|
* and then check for matching finger prints
|
|
|
|
* @param ts transaction set
|
|
|
|
* @param fpc global finger print cache
|
|
|
|
*/
|
|
|
|
static
|
2009-02-24 17:50:23 +08:00
|
|
|
void checkInstalledFiles(rpmts ts, uint64_t fileCount, rpmFpHash ht, fingerPrintCache fpc)
|
2008-11-07 17:58:25 +08:00
|
|
|
{
|
|
|
|
rpmte p;
|
2008-11-26 23:29:55 +08:00
|
|
|
rpmfi fi;
|
2008-12-03 17:39:48 +08:00
|
|
|
rpmfs fs;
|
2008-11-07 17:58:25 +08:00
|
|
|
rpmfi otherFi=NULL;
|
|
|
|
int j;
|
|
|
|
int xx;
|
|
|
|
unsigned int fileNum;
|
|
|
|
const char * oldDir;
|
|
|
|
|
|
|
|
rpmdbMatchIterator mi;
|
|
|
|
Header h, newheader;
|
|
|
|
|
|
|
|
int beingRemoved;
|
|
|
|
|
|
|
|
rpmlog(RPMLOG_DEBUG, "computing file dispositions\n");
|
|
|
|
|
2009-02-24 17:50:23 +08:00
|
|
|
mi = rpmFindBaseNamesInDB(ts, fileCount);
|
2008-11-07 17:58:25 +08:00
|
|
|
|
|
|
|
/* For all installed headers with matching basename's ... */
|
|
|
|
if (mi == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (rpmdbGetIteratorCount(mi) == 0) {
|
|
|
|
mi = rpmdbFreeIterator(mi);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Loop over all packages from the rpmdb */
|
|
|
|
h = newheader = rpmdbNextIterator(mi);
|
|
|
|
while (h != NULL) {
|
|
|
|
headerGetFlags hgflags = HEADERGET_MINMEM;
|
|
|
|
struct rpmtd_s bnames, dnames, dindexes, ostates;
|
|
|
|
fingerPrint fp;
|
|
|
|
unsigned int installedPkg;
|
|
|
|
|
|
|
|
/* Is this package being removed? */
|
|
|
|
installedPkg = rpmdbGetIteratorOffset(mi);
|
|
|
|
beingRemoved = 0;
|
|
|
|
if (ts->removedPackages != NULL)
|
|
|
|
for (j = 0; j < ts->numRemovedPackages; j++) {
|
|
|
|
if (ts->removedPackages[j] != installedPkg)
|
|
|
|
continue;
|
|
|
|
beingRemoved = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
h = headerLink(h);
|
|
|
|
headerGet(h, RPMTAG_BASENAMES, &bnames, hgflags);
|
|
|
|
headerGet(h, RPMTAG_DIRNAMES, &dnames, hgflags);
|
|
|
|
headerGet(h, RPMTAG_DIRINDEXES, &dindexes, hgflags);
|
|
|
|
headerGet(h, RPMTAG_FILESTATES, &ostates, hgflags);
|
|
|
|
|
|
|
|
oldDir = NULL;
|
2008-12-03 17:39:48 +08:00
|
|
|
/* loop over all interesting files in that package */
|
2008-11-07 17:58:25 +08:00
|
|
|
do {
|
|
|
|
int gotRecs;
|
|
|
|
struct rpmffi_s * recs;
|
|
|
|
int numRecs;
|
2008-11-25 21:33:11 +08:00
|
|
|
const char * dirName;
|
|
|
|
const char * baseName;
|
|
|
|
|
2008-11-07 17:58:25 +08:00
|
|
|
fileNum = rpmdbGetIteratorFileNum(mi);
|
2008-11-25 21:33:11 +08:00
|
|
|
rpmtdSetIndex(&bnames, fileNum);
|
|
|
|
rpmtdSetIndex(&dindexes, fileNum);
|
|
|
|
rpmtdSetIndex(&dnames, *rpmtdGetUint32(&dindexes));
|
|
|
|
rpmtdSetIndex(&ostates, fileNum);
|
|
|
|
|
|
|
|
dirName = rpmtdGetString(&dnames);
|
|
|
|
baseName = rpmtdGetString(&bnames);
|
|
|
|
|
2008-11-07 17:58:25 +08:00
|
|
|
/* lookup finger print for this file */
|
2008-11-25 21:33:11 +08:00
|
|
|
if ( dirName == oldDir) {
|
2008-11-07 17:58:25 +08:00
|
|
|
/* directory is the same as last round */
|
2008-11-25 21:33:11 +08:00
|
|
|
fp.baseName = baseName;
|
2008-11-07 17:58:25 +08:00
|
|
|
} else {
|
2008-11-25 21:33:11 +08:00
|
|
|
fp = fpLookup(fpc, dirName, baseName, 1);
|
|
|
|
oldDir = dirName;
|
2008-11-07 17:58:25 +08:00
|
|
|
}
|
|
|
|
/* search for files in the transaction with same finger print */
|
2009-02-24 17:23:25 +08:00
|
|
|
gotRecs = rpmFpHashGetEntry(ht, &fp, &recs, &numRecs, NULL);
|
2008-11-07 17:58:25 +08:00
|
|
|
|
|
|
|
for (j=0; (j<numRecs)&&gotRecs; j++) {
|
2008-11-26 23:29:55 +08:00
|
|
|
p = recs[j].p;
|
2008-11-27 16:02:00 +08:00
|
|
|
fi = rpmteFI(p);
|
2008-12-03 17:39:48 +08:00
|
|
|
fs = rpmteGetFileStates(p);
|
2008-11-07 17:58:25 +08:00
|
|
|
|
|
|
|
/* Determine the fate of each file. */
|
|
|
|
switch (rpmteType(p)) {
|
|
|
|
case TR_ADDED:
|
|
|
|
if (!otherFi) {
|
2008-12-09 00:46:36 +08:00
|
|
|
otherFi = rpmfiNew(ts, h, RPMTAG_BASENAMES, RPMFI_KEEPHEADER);
|
2008-11-07 17:58:25 +08:00
|
|
|
}
|
2008-11-26 23:29:55 +08:00
|
|
|
rpmfiSetFX(fi, recs[j].fileno);
|
2008-11-07 17:58:25 +08:00
|
|
|
rpmfiSetFX(otherFi, fileNum);
|
2008-11-26 23:29:55 +08:00
|
|
|
xx = handleInstInstalledFile(ts, p, fi, h, otherFi, beingRemoved);
|
2008-11-07 17:58:25 +08:00
|
|
|
break;
|
|
|
|
case TR_REMOVED:
|
|
|
|
if (!beingRemoved) {
|
2008-11-26 23:29:55 +08:00
|
|
|
rpmfiSetFX(fi, recs[j].fileno);
|
2008-11-25 21:33:11 +08:00
|
|
|
if (*rpmtdGetChar(&ostates) == RPMFILE_STATE_NORMAL)
|
2008-12-03 17:39:48 +08:00
|
|
|
rpmfsSetAction(fs, recs[j].fileno, FA_SKIP);
|
2008-11-07 17:58:25 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
newheader = rpmdbNextIterator(mi);
|
|
|
|
|
|
|
|
} while (newheader==h);
|
|
|
|
|
|
|
|
otherFi = rpmfiFree(otherFi);
|
|
|
|
rpmtdFreeData(&ostates);
|
|
|
|
rpmtdFreeData(&bnames);
|
|
|
|
rpmtdFreeData(&dnames);
|
|
|
|
rpmtdFreeData(&dindexes);
|
|
|
|
headerFree(h);
|
|
|
|
h = newheader;
|
|
|
|
}
|
|
|
|
|
|
|
|
mi = rpmdbFreeIterator(mi);
|
|
|
|
}
|
|
|
|
|
2009-02-24 16:13:43 +08:00
|
|
|
/*
|
|
|
|
* For packages being installed:
|
|
|
|
* - verify package arch/os.
|
|
|
|
* - verify package epoch:version-release is newer.
|
|
|
|
*/
|
|
|
|
static rpmps checkProblems(rpmts ts)
|
|
|
|
{
|
|
|
|
rpm_color_t tscolor = rpmtsColor(ts);
|
|
|
|
rpmps ps = rpmpsCreate();
|
|
|
|
rpmtsi pi = rpmtsiInit(ts);
|
|
|
|
rpmte p;
|
|
|
|
|
|
|
|
/* The ordering doesn't matter here */
|
|
|
|
/* XXX Only added packages need be checked. */
|
|
|
|
rpmlog(RPMLOG_DEBUG, "sanity checking %d elements\n", rpmtsNElements(ts));
|
|
|
|
while ((p = rpmtsiNext(pi, TR_ADDED)) != NULL) {
|
|
|
|
rpmdbMatchIterator mi;
|
2009-07-09 19:01:13 +08:00
|
|
|
rpmpsi psi;
|
2009-02-24 16:13:43 +08:00
|
|
|
|
|
|
|
if (!(rpmtsFilterFlags(ts) & RPMPROB_FILTER_IGNOREARCH))
|
|
|
|
if (!archOkay(rpmteA(p)))
|
|
|
|
rpmpsAppend(ps, RPMPROB_BADARCH,
|
|
|
|
rpmteNEVRA(p), rpmteKey(p),
|
|
|
|
rpmteA(p), NULL,
|
|
|
|
NULL, 0);
|
|
|
|
|
|
|
|
if (!(rpmtsFilterFlags(ts) & RPMPROB_FILTER_IGNOREOS))
|
|
|
|
if (!osOkay(rpmteO(p)))
|
|
|
|
rpmpsAppend(ps, RPMPROB_BADOS,
|
|
|
|
rpmteNEVRA(p), rpmteKey(p),
|
|
|
|
rpmteO(p), NULL,
|
|
|
|
NULL, 0);
|
|
|
|
|
|
|
|
if (!(rpmtsFilterFlags(ts) & RPMPROB_FILTER_OLDPACKAGE)) {
|
|
|
|
Header h;
|
|
|
|
mi = rpmtsInitIterator(ts, RPMTAG_NAME, rpmteN(p), 0);
|
|
|
|
while ((h = rpmdbNextIterator(mi)) != NULL)
|
|
|
|
ensureOlder(p, h, ps);
|
|
|
|
mi = rpmdbFreeIterator(mi);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(rpmtsFilterFlags(ts) & RPMPROB_FILTER_REPLACEPKG)) {
|
|
|
|
mi = rpmtsInitIterator(ts, RPMTAG_NAME, rpmteN(p), 0);
|
|
|
|
rpmdbSetIteratorRE(mi, RPMTAG_EPOCH, RPMMIRE_STRCMP, rpmteE(p));
|
|
|
|
rpmdbSetIteratorRE(mi, RPMTAG_VERSION, RPMMIRE_STRCMP, rpmteV(p));
|
|
|
|
rpmdbSetIteratorRE(mi, RPMTAG_RELEASE, RPMMIRE_STRCMP, rpmteR(p));
|
|
|
|
if (tscolor) {
|
|
|
|
rpmdbSetIteratorRE(mi, RPMTAG_ARCH, RPMMIRE_STRCMP, rpmteA(p));
|
|
|
|
rpmdbSetIteratorRE(mi, RPMTAG_OS, RPMMIRE_STRCMP, rpmteO(p));
|
|
|
|
}
|
|
|
|
|
|
|
|
while (rpmdbNextIterator(mi) != NULL) {
|
|
|
|
rpmpsAppend(ps, RPMPROB_PKG_INSTALLED,
|
|
|
|
rpmteNEVRA(p), rpmteKey(p),
|
|
|
|
NULL, NULL,
|
|
|
|
NULL, 0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
mi = rpmdbFreeIterator(mi);
|
|
|
|
}
|
2009-07-09 19:01:13 +08:00
|
|
|
|
|
|
|
/* XXX rpmte problems can only be relocation problems atm */
|
|
|
|
if (!(rpmtsFilterFlags(ts) & RPMPROB_FILTER_FORCERELOCATE)) {
|
|
|
|
psi = rpmpsInitIterator(rpmteProblems(p));
|
|
|
|
while (rpmpsNextIterator(psi) >= 0) {
|
|
|
|
rpmpsAppendProblem(ps, rpmpsGetProblem(psi));
|
|
|
|
}
|
|
|
|
rpmpsFreeIterator(psi);
|
|
|
|
}
|
2009-02-24 16:13:43 +08:00
|
|
|
}
|
|
|
|
pi = rpmtsiFree(pi);
|
|
|
|
return ps;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
rpmpsm psm;
|
2009-02-24 20:24:40 +08:00
|
|
|
rpmTag progtag = RPMTAG_NOT_FOUND;
|
2008-03-17 22:03:51 +08:00
|
|
|
int xx;
|
|
|
|
|
2009-02-24 20:24:40 +08:00
|
|
|
if (stag == RPMTAG_PRETRANS) {
|
|
|
|
progtag = RPMTAG_PRETRANSPROG;
|
|
|
|
} else if (stag == RPMTAG_POSTTRANS) {
|
|
|
|
progtag = RPMTAG_POSTTRANSPROG;
|
|
|
|
} else {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2008-03-17 22:03:51 +08:00
|
|
|
pi = rpmtsiInit(ts);
|
|
|
|
while ((p = rpmtsiNext(pi, TR_ADDED)) != NULL) {
|
2008-11-27 16:48:22 +08:00
|
|
|
/* If no pre/post-transaction script, then don't bother. */
|
|
|
|
if (!rpmteHaveTransScript(p, stag))
|
|
|
|
continue;
|
2008-03-17 22:03:51 +08:00
|
|
|
|
2008-12-19 20:34:45 +08:00
|
|
|
if (rpmteOpen(p, ts, 0)) {
|
2008-12-19 20:57:37 +08:00
|
|
|
psm = rpmpsmNew(ts, p);
|
2008-03-17 22:03:51 +08:00
|
|
|
xx = rpmpsmScriptStage(psm, stag, progtag);
|
|
|
|
psm = rpmpsmFree(psm);
|
2009-01-15 16:28:13 +08:00
|
|
|
rpmteClose(p, ts, 0);
|
2008-03-17 22:03:51 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
pi = rpmtsiFree(pi);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-02-24 17:15:53 +08:00
|
|
|
/* Add fingerprint for each file not skipped. */
|
2009-02-24 17:50:23 +08:00
|
|
|
static void addFingerprints(rpmts ts, uint64_t fileCount, rpmFpHash ht, fingerPrintCache fpc)
|
2009-02-24 16:40:43 +08:00
|
|
|
{
|
|
|
|
rpmtsi pi;
|
|
|
|
rpmte p;
|
|
|
|
rpmfi fi;
|
2009-02-24 17:15:53 +08:00
|
|
|
int i;
|
|
|
|
|
2009-02-24 17:50:23 +08:00
|
|
|
rpmFpHash symlinks = rpmFpHashCreate(fileCount/16+16, fpHashFunction, fpEqual, NULL, NULL);
|
2009-02-24 17:15:53 +08:00
|
|
|
|
|
|
|
pi = rpmtsiInit(ts);
|
|
|
|
while ((p = rpmtsiNext(pi, 0)) != NULL) {
|
|
|
|
(void) rpmdbCheckSignals();
|
|
|
|
|
|
|
|
if ((fi = rpmteFI(p)) == NULL)
|
|
|
|
continue; /* XXX can't happen */
|
|
|
|
|
|
|
|
(void) rpmswEnter(rpmtsOp(ts, RPMTS_OP_FINGERPRINT), 0);
|
|
|
|
rpmfiFpLookup(fi, fpc);
|
|
|
|
/* collect symbolic links */
|
|
|
|
fi = rpmfiInit(fi, 0);
|
|
|
|
while ((i = rpmfiNext(fi)) >= 0) {
|
|
|
|
struct rpmffi_s ffi;
|
|
|
|
char const *linktarget;
|
|
|
|
linktarget = rpmfiFLink(fi);
|
|
|
|
if (!(linktarget && *linktarget != '\0'))
|
|
|
|
continue;
|
|
|
|
if (XFA_SKIPPING(rpmfsGetAction(rpmteGetFileStates(p), i)))
|
|
|
|
continue;
|
|
|
|
ffi.p = p;
|
|
|
|
ffi.fileno = i;
|
|
|
|
rpmFpHashAddEntry(symlinks, rpmfiFpsIndex(fi, i), ffi);
|
|
|
|
}
|
2009-02-24 18:22:21 +08:00
|
|
|
(void) rpmswExit(rpmtsOp(ts, RPMTS_OP_FINGERPRINT), rpmfiFC(fi));
|
2009-02-24 17:15:53 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
pi = rpmtsiFree(pi);
|
|
|
|
|
|
|
|
/* ===============================================
|
|
|
|
* Check fingerprints if they contain symlinks
|
2009-02-24 17:23:25 +08:00
|
|
|
* and add them to the hash table
|
2009-02-24 17:15:53 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
pi = rpmtsiInit(ts);
|
|
|
|
while ((p = rpmtsiNext(pi, 0)) != NULL) {
|
|
|
|
(void) rpmdbCheckSignals();
|
|
|
|
|
|
|
|
if ((fi = rpmteFI(p)) == NULL)
|
|
|
|
continue; /* XXX can't happen */
|
|
|
|
fi = rpmfiInit(fi, 0);
|
|
|
|
(void) rpmswEnter(rpmtsOp(ts, RPMTS_OP_FINGERPRINT), 0);
|
|
|
|
while ((i = rpmfiNext(fi)) >= 0) {
|
|
|
|
if (XFA_SKIPPING(rpmfsGetAction(rpmteGetFileStates(p), i)))
|
|
|
|
continue;
|
2009-02-24 17:23:25 +08:00
|
|
|
fpLookupSubdir(symlinks, ht, fpc, p, i);
|
2009-02-24 17:15:53 +08:00
|
|
|
}
|
|
|
|
(void) rpmswExit(rpmtsOp(ts, RPMTS_OP_FINGERPRINT), 0);
|
|
|
|
}
|
|
|
|
pi = rpmtsiFree(pi);
|
|
|
|
|
|
|
|
rpmFpHashFree(symlinks);
|
|
|
|
}
|
|
|
|
|
2009-02-24 19:41:18 +08:00
|
|
|
static int rpmtsSetup(rpmts ts, rpmprobFilterFlags ignoreSet)
|
|
|
|
{
|
|
|
|
rpm_tid_t tid = (rpm_tid_t) time(NULL);
|
|
|
|
int dbmode = (rpmtsFlags(ts) & RPMTRANS_FLAG_TEST) ? O_RDONLY : (O_RDWR|O_CREAT);
|
|
|
|
|
|
|
|
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));
|
|
|
|
|
|
|
|
/* 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)) {
|
|
|
|
char *fn = rpmGetPath("%{?_install_file_context_path}", NULL);
|
|
|
|
if (matchpathcon_init(fn) == -1) {
|
|
|
|
rpmtsSetFlags(ts, (rpmtsFlags(ts) | RPMTRANS_FLAG_NOCONTEXTS));
|
|
|
|
}
|
|
|
|
free(fn);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* XXX Make sure the database is open RDWR for package install/erase. */
|
|
|
|
if (rpmtsOpenDB(ts, dbmode)) {
|
|
|
|
return -1; /* XXX W2DO? */
|
|
|
|
}
|
|
|
|
|
|
|
|
ts->ignoreSet = ignoreSet;
|
|
|
|
ts->probs = rpmpsFree(ts->probs);
|
|
|
|
|
|
|
|
{ char * currDir = rpmGetCwd();
|
|
|
|
rpmtsSetCurrDir(ts, currDir);
|
|
|
|
currDir = _free(currDir);
|
|
|
|
}
|
|
|
|
|
|
|
|
(void) rpmtsSetChrootDone(ts, 0);
|
|
|
|
(void) rpmtsSetTid(ts, tid);
|
|
|
|
|
|
|
|
/* Get available space on mounted file systems. */
|
|
|
|
(void) rpmtsInitDSI(ts);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int rpmtsFinish(rpmts ts)
|
|
|
|
{
|
|
|
|
if (!(rpmtsFlags(ts) & RPMTRANS_FLAG_NOCONTEXTS)) {
|
|
|
|
matchpathcon_fini();
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-02-24 18:13:26 +08:00
|
|
|
static int rpmtsPrepare(rpmts ts)
|
2009-02-24 17:15:53 +08:00
|
|
|
{
|
|
|
|
rpmtsi pi;
|
|
|
|
rpmte p;
|
|
|
|
rpmfi fi;
|
2009-02-24 18:13:26 +08:00
|
|
|
int xx, rc = 0;
|
2009-02-24 17:50:23 +08:00
|
|
|
uint64_t fileCount = countFiles(ts);
|
2009-02-24 18:13:26 +08:00
|
|
|
const char * rootDir = rpmtsRootDir(ts);
|
2009-08-31 18:03:53 +08:00
|
|
|
int dochroot = (rootDir != NULL && !rstreq(rootDir, "/") && *rootDir == '/');
|
2009-02-24 17:15:53 +08:00
|
|
|
|
2009-02-24 17:50:23 +08:00
|
|
|
fingerPrintCache fpc = fpCacheCreate(fileCount/2 + 10001);
|
|
|
|
rpmFpHash ht = rpmFpHashCreate(fileCount/2+1, fpHashFunction, fpEqual,
|
2009-02-24 17:15:53 +08:00
|
|
|
NULL, NULL);
|
2009-02-24 16:40:43 +08:00
|
|
|
|
2009-02-24 17:50:23 +08:00
|
|
|
rpmlog(RPMLOG_DEBUG, "computing %" PRIu64 " file fingerprints\n", fileCount);
|
|
|
|
|
|
|
|
/* Skip netshared paths, not our i18n files, and excluded docs */
|
|
|
|
pi = rpmtsiInit(ts);
|
|
|
|
while ((p = rpmtsiNext(pi, TR_ADDED)) != NULL) {
|
|
|
|
if ((fi = rpmteFI(p)) == NULL)
|
|
|
|
continue; /* XXX can't happen */
|
|
|
|
|
|
|
|
if (rpmfiFC(fi) > 0)
|
|
|
|
skipFiles(ts, p);
|
|
|
|
}
|
|
|
|
pi = rpmtsiFree(pi);
|
|
|
|
|
2009-02-24 18:13:26 +08:00
|
|
|
/* Enter chroot for fingerprinting if necessary */
|
|
|
|
if (!rpmtsChrootDone(ts)) {
|
|
|
|
xx = chdir("/");
|
2009-02-24 18:31:22 +08:00
|
|
|
if (dochroot) {
|
2009-02-24 18:13:26 +08:00
|
|
|
/* opening db before chroot not optimal, see rhbz#103852 c#3 */
|
|
|
|
xx = rpmdbOpenAll(ts->rdb);
|
|
|
|
if (chroot(rootDir) == -1) {
|
|
|
|
rpmlog(RPMLOG_ERR, _("Unable to change root directory: %m\n"));
|
|
|
|
rc = -1;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
(void) rpmtsSetChrootDone(ts, 1);
|
|
|
|
}
|
|
|
|
|
2009-02-24 16:40:43 +08:00
|
|
|
rpmtsNotify(ts, NULL, RPMCALLBACK_TRANS_START, 6, ts->orderCount);
|
2009-02-24 17:50:23 +08:00
|
|
|
addFingerprints(ts, fileCount, ht, fpc);
|
2009-02-24 16:40:43 +08:00
|
|
|
/* check against files in the rpmdb */
|
2009-02-24 17:50:23 +08:00
|
|
|
checkInstalledFiles(ts, fileCount, ht, fpc);
|
2009-02-24 16:40:43 +08:00
|
|
|
|
|
|
|
pi = rpmtsiInit(ts);
|
|
|
|
while ((p = rpmtsiNext(pi, 0)) != NULL) {
|
|
|
|
if ((fi = rpmteFI(p)) == NULL)
|
|
|
|
continue; /* XXX can't happen */
|
|
|
|
|
|
|
|
(void) rpmswEnter(rpmtsOp(ts, RPMTS_OP_FINGERPRINT), 0);
|
|
|
|
/* check files in ts against each other and update disk space
|
|
|
|
needs on each partition for this package. */
|
2009-02-24 17:23:25 +08:00
|
|
|
handleOverlappedFiles(ts, ht, p, fi);
|
2009-02-24 16:40:43 +08:00
|
|
|
|
|
|
|
/* Check added package has sufficient space on each partition used. */
|
|
|
|
if (rpmteType(p) == TR_ADDED) {
|
|
|
|
rpmtsCheckDSIProblems(ts, p);
|
|
|
|
}
|
|
|
|
(void) rpmswExit(rpmtsOp(ts, RPMTS_OP_FINGERPRINT), 0);
|
|
|
|
}
|
2009-02-24 17:50:23 +08:00
|
|
|
pi = rpmtsiFree(pi);
|
2009-02-24 16:40:43 +08:00
|
|
|
rpmtsNotify(ts, NULL, RPMCALLBACK_TRANS_STOP, 6, ts->orderCount);
|
2009-02-24 17:15:53 +08:00
|
|
|
|
2009-02-24 18:13:26 +08:00
|
|
|
/* return from chroot if done earlier */
|
|
|
|
if (rpmtsChrootDone(ts)) {
|
|
|
|
const char * currDir = rpmtsCurrDir(ts);
|
2009-02-24 18:31:22 +08:00
|
|
|
if (dochroot)
|
2009-02-24 18:13:26 +08:00
|
|
|
xx = chroot(".");
|
|
|
|
(void) rpmtsSetChrootDone(ts, 0);
|
|
|
|
if (currDir != NULL)
|
|
|
|
xx = chdir(currDir);
|
|
|
|
}
|
|
|
|
|
2009-02-24 17:50:23 +08:00
|
|
|
/* File info sets, fp caches etc not needed beyond here, free 'em up. */
|
|
|
|
pi = rpmtsiInit(ts);
|
|
|
|
while ((p = rpmtsiNext(pi, 0)) != NULL) {
|
|
|
|
rpmteSetFI(p, NULL);
|
|
|
|
}
|
2009-02-24 17:15:53 +08:00
|
|
|
pi = rpmtsiFree(pi);
|
2009-02-24 18:13:26 +08:00
|
|
|
|
|
|
|
exit:
|
2009-02-24 17:23:25 +08:00
|
|
|
ht = rpmFpHashFree(ht);
|
2009-02-24 17:15:53 +08:00
|
|
|
fpc = fpCacheFree(fpc);
|
2009-02-24 18:13:26 +08:00
|
|
|
return rc;
|
2009-02-24 16:40:43 +08:00
|
|
|
}
|
|
|
|
|
2008-11-24 21:31:31 +08:00
|
|
|
/*
|
|
|
|
* Transaction main loop: install and remove packages
|
|
|
|
*/
|
|
|
|
static int rpmtsProcess(rpmts ts)
|
|
|
|
{
|
|
|
|
rpmtsi pi; rpmte p;
|
|
|
|
int rc = 0;
|
|
|
|
|
|
|
|
pi = rpmtsiInit(ts);
|
|
|
|
while ((p = rpmtsiNext(pi, 0)) != NULL) {
|
2008-11-25 18:17:47 +08:00
|
|
|
int failed = 1;
|
2008-11-24 21:39:17 +08:00
|
|
|
rpmElementType tetype = rpmteType(p);
|
|
|
|
rpmtsOpX op = (tetype == TR_ADDED) ? RPMTS_OP_INSTALL : RPMTS_OP_ERASE;
|
2008-11-24 21:31:31 +08:00
|
|
|
|
2008-11-24 21:33:23 +08:00
|
|
|
rpmlog(RPMLOG_DEBUG, "========== +++ %s %s-%s 0x%x\n",
|
|
|
|
rpmteNEVR(p), rpmteA(p), rpmteO(p), rpmteColor(p));
|
|
|
|
|
2008-11-25 18:17:47 +08:00
|
|
|
if (rpmteFailed(p)) {
|
2008-11-25 17:46:20 +08:00
|
|
|
/* XXX this should be a warning, need a better message though */
|
|
|
|
rpmlog(RPMLOG_DEBUG, "element %s marked as failed, skipping\n",
|
|
|
|
rpmteNEVRA(p));
|
|
|
|
rc++;
|
|
|
|
continue;
|
|
|
|
}
|
2008-11-24 21:31:31 +08:00
|
|
|
|
2008-12-19 20:34:45 +08:00
|
|
|
if (rpmteOpen(p, ts, 1)) {
|
2008-11-25 18:17:47 +08:00
|
|
|
rpmpsm psm = NULL;
|
|
|
|
pkgStage stage = PSM_UNKNOWN;
|
|
|
|
int async = (rpmtsiOc(pi) >= rpmtsUnorderedSuccessors(ts, -1)) ?
|
|
|
|
1 : 0;
|
|
|
|
|
|
|
|
switch (tetype) {
|
|
|
|
case TR_ADDED:
|
|
|
|
stage = PSM_PKGINSTALL;
|
|
|
|
break;
|
|
|
|
case TR_REMOVED:
|
|
|
|
stage = PSM_PKGERASE;
|
|
|
|
break;
|
2008-11-24 21:31:31 +08:00
|
|
|
}
|
2008-12-19 20:57:37 +08:00
|
|
|
psm = rpmpsmNew(ts, p);
|
2008-11-25 18:17:47 +08:00
|
|
|
rpmpsmSetAsync(psm, async);
|
|
|
|
|
|
|
|
(void) rpmswEnter(rpmtsOp(ts, op), 0);
|
|
|
|
failed = rpmpsmStage(psm, stage);
|
|
|
|
(void) rpmswExit(rpmtsOp(ts, op), 0);
|
|
|
|
psm = rpmpsmFree(psm);
|
2009-01-15 16:28:13 +08:00
|
|
|
rpmteClose(p, ts, 1);
|
2008-11-24 21:31:31 +08:00
|
|
|
}
|
2008-11-25 17:46:20 +08:00
|
|
|
if (failed) {
|
|
|
|
rpmteMarkFailed(p, ts);
|
|
|
|
rc++;
|
|
|
|
}
|
2008-11-24 21:31:31 +08:00
|
|
|
(void) rpmdbSync(rpmtsGetRdb(ts));
|
|
|
|
}
|
|
|
|
pi = rpmtsiFree(pi);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
int rpmtsRun(rpmts ts, rpmps okProbs, rpmprobFilterFlags ignoreSet)
|
|
|
|
{
|
2009-02-24 19:55:27 +08:00
|
|
|
int rc = -1; /* assume failure */
|
2004-04-08 07:50:35 +08:00
|
|
|
void * lock = NULL;
|
2001-11-12 00:17:57 +08:00
|
|
|
|
2004-03-27 01:27:57 +08:00
|
|
|
/* XXX programmer error segfault avoidance. */
|
2009-02-24 19:55:27 +08:00
|
|
|
if (rpmtsNElements(ts) <= 0) {
|
|
|
|
goto exit;
|
|
|
|
}
|
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)) {
|
2009-02-24 19:55:27 +08:00
|
|
|
if (!(lock = rpmtsAcquireLock(ts))) {
|
|
|
|
goto exit;
|
|
|
|
}
|
2004-04-08 07:50:35 +08:00
|
|
|
}
|
2004-03-27 01:27:57 +08:00
|
|
|
|
2009-02-24 19:41:18 +08:00
|
|
|
/* Setup flags and such, open the DB */
|
|
|
|
if (rpmtsSetup(ts, ignoreSet)) {
|
2009-02-24 19:55:27 +08:00
|
|
|
goto exit;
|
1999-07-14 22:36:10 +08:00
|
|
|
}
|
|
|
|
|
2009-02-24 16:13:43 +08:00
|
|
|
/* Check package set for problems */
|
|
|
|
ts->probs = checkProblems(ts);
|
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
|
2009-01-17 20:15:50 +08:00
|
|
|
* problems up to this point and not disabled otherwise. */
|
|
|
|
if (!((rpmtsFlags(ts) & (RPMTRANS_FLAG_BUILD_PROBS|RPMTRANS_FLAG_TEST|RPMTRANS_FLAG_NOPRE))
|
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
|
|
|
|
2009-02-24 16:40:43 +08:00
|
|
|
/* Compute file disposition for each package in transaction set. */
|
2009-02-24 18:13:26 +08:00
|
|
|
if (rpmtsPrepare(ts)) {
|
2009-02-24 19:55:27 +08:00
|
|
|
goto exit;
|
2004-03-27 01:27:57 +08:00
|
|
|
}
|
2003-11-24 03:50:52 +08:00
|
|
|
|
2009-02-24 18:35:21 +08:00
|
|
|
/* If unfiltered problems exist, free memory and return. */
|
|
|
|
if ((rpmtsFlags(ts) & RPMTRANS_FLAG_BUILD_PROBS) ||
|
|
|
|
(rpmpsNumProblems(ts->probs) &&
|
|
|
|
(okProbs == NULL || rpmpsTrim(ts->probs, okProbs)))) {
|
2009-02-24 19:55:27 +08:00
|
|
|
rc = ts->orderCount;
|
|
|
|
goto exit;
|
2004-03-27 01:27:57 +08:00
|
|
|
}
|
2004-03-06 02:22:25 +08:00
|
|
|
|
2009-02-24 19:55:27 +08:00
|
|
|
/* Actually install and remove packages, get final exit code */
|
|
|
|
rc = rpmtsProcess(ts) ? -1 : 0;
|
2004-03-06 02:22:25 +08:00
|
|
|
|
2009-02-24 19:55:27 +08:00
|
|
|
/* Run post-transaction scripts unless disabled */
|
2009-01-17 20:15:50 +08:00
|
|
|
if (!(rpmtsFlags(ts) & (RPMTRANS_FLAG_TEST|RPMTRANS_FLAG_NOPOST))) {
|
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
|
|
|
}
|
|
|
|
|
2009-02-24 19:41:18 +08:00
|
|
|
/* Finish up... */
|
|
|
|
(void) rpmtsFinish(ts);
|
2008-08-08 18:06:28 +08:00
|
|
|
|
2009-02-24 19:55:27 +08:00
|
|
|
exit:
|
2004-03-27 01:27:57 +08:00
|
|
|
rpmtsFreeLock(lock);
|
2009-02-24 19:55:27 +08:00
|
|
|
return rc;
|
2004-03-06 02:22:25 +08:00
|
|
|
}
|