Yank rpmfi state update out of rpmtsRun()

- stuff it into internal rpmfiUpdateState() function to get it out of
  sight for now, the mechanism needs some...
This commit is contained in:
Panu Matilainen 2008-11-14 17:16:42 +02:00
parent ee59836299
commit 2835e091ae
3 changed files with 47 additions and 40 deletions

View File

@ -1405,3 +1405,46 @@ fprintf(stderr, "*** fi %p\t%s[%d]\n", fi, Type, (fi ? fi->fc : 0));
/* FIX: rpmfi null annotations */
return rpmfiLink(fi, (fi ? fi->Type : NULL));
}
rpmfi rpmfiUpdateState(rpmfi fi, rpmts ts, rpmte p)
{
char * fstates = fi->fstates;
rpmFileAction * actions = fi->actions;
sharedFileInfo replaced = fi->replaced;
rpmte savep;
int numShared = 0;
if (replaced != NULL) {
for (; replaced->otherPkg; replaced++) {
numShared++;
}
if (numShared > 0) {
replaced = xcalloc(numShared + 1, sizeof(*fi->replaced));
memcpy(replaced, fi->replaced,
sizeof(*fi->replaced) * (numShared + 1));
}
}
fi->fstates = NULL;
fi->actions = NULL;
fi->replaced = NULL;
/* FIX: fi->actions is NULL */
fi = rpmfiFree(fi);
savep = rpmtsSetRelocateElement(ts, p);
fi = rpmfiNew(ts, p->h, RPMTAG_BASENAMES, RPMFI_KEEPHEADER);
(void) rpmtsSetRelocateElement(ts, savep);
if (fi != NULL) { /* XXX can't happen */
fi->te = p;
free(fi->fstates);
fi->fstates = fstates;
free(fi->actions);
fi->actions = actions;
if (replaced != NULL)
fi->replaced = replaced;
p->fi = fi;
}
return fi;
}

View File

@ -113,5 +113,8 @@ struct rpmfi_s {
int nrefs; /*!< Reference count. */
};
RPM_GNUC_INTERNAL
rpmfi rpmfiUpdateState(rpmfi fi, rpmts ts, rpmte p);
#endif /* _RPMFI_INTERNAL_H */

View File

@ -1270,46 +1270,7 @@ int rpmtsRun(rpmts ts, rpmps okProbs, rpmprobFilterFlags ignoreSet)
* XXX around a recreated file info set.
*/
rpmpsmSetFI(psm, NULL);
{
char * fstates = fi->fstates;
rpmFileAction * actions = fi->actions;
sharedFileInfo replaced = fi->replaced;
rpmte savep;
int numShared = 0;
if (replaced != NULL) {
for (; replaced->otherPkg; replaced++) {
numShared++;
}
if (numShared > 0) {
replaced = xcalloc(numShared + 1,
sizeof(*fi->replaced));
memcpy(replaced, fi->replaced,
sizeof(*fi->replaced) * (numShared + 1));
}
}
fi->fstates = NULL;
fi->actions = NULL;
fi->replaced = NULL;
/* FIX: fi->actions is NULL */
fi = rpmfiFree(fi);
savep = rpmtsSetRelocateElement(ts, p);
fi = rpmfiNew(ts, p->h, RPMTAG_BASENAMES, RPMFI_KEEPHEADER);
(void) rpmtsSetRelocateElement(ts, savep);
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;
if (replaced != NULL)
fi->replaced = replaced;
p->fi = fi;
}
}
fi = rpmfiUpdateState(fi, ts, p);
rpmpsmSetFI(psm, p->fi);
/* FIX: psm->fi may be NULL */