Move open + close of files during install to separate functions
- internal rpmteOpen() and rpmteClose() functions replacing copy-paste slop between rpmtsRun() and runTransScripts() - eliminates bunch of rpmte privacy violations - rpmtsRun() doesn't need the file descriptor for anything, might as well keep it hidden
This commit is contained in:
parent
0b0fe33d3c
commit
ee59836299
43
lib/rpmte.c
43
lib/rpmte.c
|
@ -606,3 +606,46 @@ rpmte rpmtsiNext(rpmtsi tsi, rpmElementType type)
|
||||||
}
|
}
|
||||||
return te;
|
return te;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int rpmteOpen(rpmte te, rpmts ts)
|
||||||
|
{
|
||||||
|
int rc = 0;
|
||||||
|
if (te == NULL || ts == NULL)
|
||||||
|
goto exit;
|
||||||
|
|
||||||
|
te->h = NULL;
|
||||||
|
te->fd = rpmtsNotify(ts, te, RPMCALLBACK_INST_OPEN_FILE, 0, 0);
|
||||||
|
if (te->fd != NULL) {
|
||||||
|
rpmVSFlags ovsflags;
|
||||||
|
rpmRC pkgrc;
|
||||||
|
|
||||||
|
ovsflags = rpmtsSetVSFlags(ts, rpmtsVSFlags(ts) | RPMVSF_NEEDPAYLOAD);
|
||||||
|
pkgrc = rpmReadPackageFile(ts, rpmteFd(te), rpmteNEVRA(te), &te->h);
|
||||||
|
rpmtsSetVSFlags(ts, ovsflags);
|
||||||
|
switch (pkgrc) {
|
||||||
|
default:
|
||||||
|
rpmteClose(te, ts);
|
||||||
|
break;
|
||||||
|
case RPMRC_NOTTRUSTED:
|
||||||
|
case RPMRC_NOKEY:
|
||||||
|
case RPMRC_OK:
|
||||||
|
rc = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
exit:
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
int rpmteClose(rpmte te, rpmts ts)
|
||||||
|
{
|
||||||
|
int rc = 0;
|
||||||
|
if (te != NULL && ts != NULL) {
|
||||||
|
rpmtsNotify(ts, te, RPMCALLBACK_INST_CLOSE_FILE, 0, 0);
|
||||||
|
te->fd = NULL;
|
||||||
|
te->h = headerFree(te->h);
|
||||||
|
rc = 1;
|
||||||
|
}
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
|
@ -75,5 +75,11 @@ struct rpmtsi_s {
|
||||||
int oc; /*!< iterator index. */
|
int oc; /*!< iterator index. */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
RPM_GNUC_INTERNAL
|
||||||
|
int rpmteOpen(rpmte te, rpmts ts);
|
||||||
|
|
||||||
|
RPM_GNUC_INTERNAL
|
||||||
|
int rpmteClose(rpmte te, rpmts ts);
|
||||||
|
|
||||||
#endif /* _RPMTE_INTERNAL_H */
|
#endif /* _RPMTE_INTERNAL_H */
|
||||||
|
|
||||||
|
|
|
@ -755,30 +755,7 @@ static int runTransScripts(rpmts ts, rpmTag stag)
|
||||||
if (!havescript)
|
if (!havescript)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
p->fd = rpmtsNotify(ts, p, RPMCALLBACK_INST_OPEN_FILE, 0, 0);
|
if (rpmteOpen(p, ts)) {
|
||||||
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 = rpmtsNotify(ts, p, RPMCALLBACK_INST_CLOSE_FILE, 0, 0);
|
|
||||||
p->fd = NULL;
|
|
||||||
break;
|
|
||||||
case RPMRC_NOTTRUSTED:
|
|
||||||
case RPMRC_NOKEY:
|
|
||||||
case RPMRC_OK:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rpmteFd(p) != NULL) {
|
|
||||||
p->fi = rpmfiFree(p->fi);
|
p->fi = rpmfiFree(p->fi);
|
||||||
fi = rpmfiNew(ts, p->h, RPMTAG_BASENAMES, RPMFI_KEEPHEADER);
|
fi = rpmfiNew(ts, p->h, RPMTAG_BASENAMES, RPMFI_KEEPHEADER);
|
||||||
if (fi != NULL) { /* XXX can't happen */
|
if (fi != NULL) { /* XXX can't happen */
|
||||||
|
@ -791,13 +768,10 @@ static int runTransScripts(rpmts ts, rpmTag stag)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
psm = rpmpsmNew(ts, p, p->fi);
|
psm = rpmpsmNew(ts, p, p->fi);
|
||||||
assert(psm != NULL);
|
|
||||||
xx = rpmpsmScriptStage(psm, stag, progtag);
|
xx = rpmpsmScriptStage(psm, stag, progtag);
|
||||||
psm = rpmpsmFree(psm);
|
psm = rpmpsmFree(psm);
|
||||||
|
|
||||||
(void) rpmtsNotify(ts, p, RPMCALLBACK_INST_CLOSE_FILE, 0, 0);
|
rpmteClose(p, ts);
|
||||||
p->fd = NULL;
|
|
||||||
p->h = headerFree(p->h);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pi = rpmtsiFree(pi);
|
pi = rpmtsiFree(pi);
|
||||||
|
@ -1271,9 +1245,8 @@ int rpmtsRun(rpmts ts, rpmps okProbs, rpmprobFilterFlags ignoreSet)
|
||||||
/* FIX: fi reload needs work */
|
/* FIX: fi reload needs work */
|
||||||
while ((p = rpmtsiNext(pi, 0)) != NULL) {
|
while ((p = rpmtsiNext(pi, 0)) != NULL) {
|
||||||
rpmalKey pkgKey;
|
rpmalKey pkgKey;
|
||||||
int gotfd, async;
|
int async;
|
||||||
|
|
||||||
gotfd = 0;
|
|
||||||
if ((fi = rpmtsiFi(pi)) == NULL)
|
if ((fi = rpmtsiFi(pi)) == NULL)
|
||||||
continue; /* XXX can't happen */
|
continue; /* XXX can't happen */
|
||||||
|
|
||||||
|
@ -1290,38 +1263,8 @@ int rpmtsRun(rpmts ts, rpmps okProbs, rpmprobFilterFlags ignoreSet)
|
||||||
rpmlog(RPMLOG_DEBUG, "========== +++ %s %s-%s 0x%x\n",
|
rpmlog(RPMLOG_DEBUG, "========== +++ %s %s-%s 0x%x\n",
|
||||||
rpmteNEVR(p), rpmteA(p), rpmteO(p), rpmteColor(p));
|
rpmteNEVR(p), rpmteA(p), rpmteO(p), rpmteColor(p));
|
||||||
|
|
||||||
p->h = NULL;
|
|
||||||
/* FIX: rpmte not opaque */
|
|
||||||
{
|
|
||||||
p->fd = rpmtsNotify(ts, p, RPMCALLBACK_INST_OPEN_FILE, 0, 0);
|
|
||||||
if (rpmteFd(p) != NULL) {
|
|
||||||
rpmVSFlags ovsflags = rpmtsVSFlags(ts);
|
|
||||||
rpmVSFlags vsflags = ovsflags | RPMVSF_NEEDPAYLOAD;
|
|
||||||
rpmRC rpmrc;
|
|
||||||
|
|
||||||
ovsflags = rpmtsSetVSFlags(ts, vsflags);
|
if (rpmteOpen(p, ts)) {
|
||||||
rpmrc = rpmReadPackageFile(ts, rpmteFd(p),
|
|
||||||
rpmteNEVR(p), &p->h);
|
|
||||||
vsflags = rpmtsSetVSFlags(ts, ovsflags);
|
|
||||||
|
|
||||||
switch (rpmrc) {
|
|
||||||
default:
|
|
||||||
/* FIX: notify annotations */
|
|
||||||
p->fd = rpmtsNotify(ts, p, RPMCALLBACK_INST_CLOSE_FILE,
|
|
||||||
0, 0);
|
|
||||||
p->fd = NULL;
|
|
||||||
ourrc++;
|
|
||||||
break;
|
|
||||||
case RPMRC_NOTTRUSTED:
|
|
||||||
case RPMRC_NOKEY:
|
|
||||||
case RPMRC_OK:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (rpmteFd(p) != NULL) gotfd = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rpmteFd(p) != NULL) {
|
|
||||||
/*
|
/*
|
||||||
* XXX Sludge necessary to tranfer existing fstates/actions
|
* XXX Sludge necessary to tranfer existing fstates/actions
|
||||||
* XXX around a recreated file info set.
|
* XXX around a recreated file info set.
|
||||||
|
@ -1374,20 +1317,12 @@ int rpmtsRun(rpmts ts, rpmps okProbs, rpmprobFilterFlags ignoreSet)
|
||||||
ourrc++;
|
ourrc++;
|
||||||
lastFailKey = pkgKey;
|
lastFailKey = pkgKey;
|
||||||
}
|
}
|
||||||
|
rpmteClose(p, ts);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
ourrc++;
|
ourrc++;
|
||||||
lastFailKey = pkgKey;
|
lastFailKey = pkgKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gotfd) {
|
|
||||||
/* FIX: check rc */
|
|
||||||
(void) rpmtsNotify(ts, p, RPMCALLBACK_INST_CLOSE_FILE, 0, 0);
|
|
||||||
p->fd = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
p->h = headerFree(p->h);
|
|
||||||
|
|
||||||
(void) rpmswExit(rpmtsOp(ts, RPMTS_OP_INSTALL), 0);
|
(void) rpmswExit(rpmtsOp(ts, RPMTS_OP_INSTALL), 0);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue