- python: memory leaks in headerLoad/headerunload bindings.
- python: retrofit sha1 digest using RPMTAG_SHA1RHN.
- python: change rhnUnload bindings.
CVS patchset: 5032
CVS date: 2001/08/27 18:39:17
- verify perms (but not mode) on %ghost files.
- headers without RPMTAG_NAME are skipped when retrieved.
- within a region, entries sort by address; added drips sort by tag.
+ - fix: error message on failed package installs resurrected.
+ - python: memory leaks in headerLoad/headerunload bindings.
+ - python: retrofit sha1 digest using RPMTAG_SHA1RHN.
+ - python: change rhnUnload bindings.
4.0 -> 4.0.[12]
- add doxygen and lclint annotations most everywhere.
if (headerWrite(fd, h, HEADER_MAGIC_YES)) {
rc = RPMERR_NOSPACE;
- rpmError(RPMERR_NOSPACE, _("Unable to write %s header\n"), "temp");
+ rpmError(RPMERR_NOSPACE, _("Unable to write temp header\n"));
} else { /* Write the archive and get the size */
if (csa->cpioList != NULL) {
rc = cpio_doio(fd, h, csa, rpmio_flags);
fdInitSHA1(fd, 0);
if (headerWrite(fd, h, HEADER_MAGIC_NO)) {
rc = RPMERR_NOSPACE;
- rpmError(RPMERR_NOSPACE, _("Unable to write %s header\n"), "final");
+ rpmError(RPMERR_NOSPACE, _("Unable to write final header\n"));
}
(void) Fflush(fd);
fdFiniSHA1(fd, (void **)&sha1, NULL, 1);
sig = headerReload(sig, RPMTAG_HEADERSIGNATURES);
if (sig == NULL) { /* XXX can't happen */
rc = RPMERR_RELOAD;
- rpmError(RPMERR_RELOAD, _("Unable to reload %s header.\n"), "signature");
+ rpmError(RPMERR_RELOAD, _("Unable to reload signature header.\n"));
goto exit;
}
unsigned int * archiveSize, const char ** failedFile)
{
size_t pos = 0;
- int rc;
+ int rc, ec = 0;
fsm->goal = goal;
if (cfd) {
sprintf(fsm->sufbuf, ";%08x", (unsigned)ts->id);
}
- rc = fsm->rc = 0;
+ ec = fsm->rc = 0;
rc = fsmStage(fsm, FSM_CREATE);
+ if (rc && !ec) ec = rc;
rc = fsmStage(fsm, fsm->goal);
+ if (rc && !ec) ec = rc;
- if (fsm->archiveSize && rc == 0)
+ if (fsm->archiveSize && ec == 0)
*fsm->archiveSize = (fdGetCpioPos(fsm->cfd) - pos);
- return rc;
+ return ec;
}
int fsmTeardown(FSM_t fsm) {
/* Notify on success. */
(void) fsmStage(fsm, FSM_NOTIFY);
- if (fsmStage(fsm, FSM_FINI))
+ rc = fsmStage(fsm, FSM_FINI);
+ if (rc) {
/*@loopbreak@*/ break;
+ }
}
break;
case FSM_PKGERASE:
/* XXX common error message. */
rpmError(
- (strict_erasures ? RPMERR_RMDIR : RPMWARN_RMDIR),
+ (strict_erasures ? RPMERR_RMDIR : RPMDEBUG_RMDIR),
_("%s rmdir of %s failed: Directory not empty\n"),
fiTypeString(fi), fsm->path);
break;
default:
rpmError(
- (strict_erasures ? RPMERR_RMDIR : RPMWARN_RMDIR),
+ (strict_erasures ? RPMERR_RMDIR : RPMDEBUG_RMDIR),
_("%s rmdir of %s failed: %s\n"),
fiTypeString(fi), fsm->path, strerror(errno));
break;
if (!rc) break;
if (!(errno == ENOENT && (fsm->fflags & RPMFILE_MISSINGOK)))
rpmError(
- (strict_erasures ? RPMERR_UNLINK : RPMWARN_UNLINK),
+ (strict_erasures ? RPMERR_UNLINK : RPMDEBUG_UNLINK),
_("%s unlink of %s failed: %s\n"),
fiTypeString(fi), fsm->path, strerror(errno));
}
/* Notify on success. */
if (!rc) rc = fsmStage(fsm, FSM_NOTIFY);
+ else if (fsm->failedFile && *fsm->failedFile == NULL) {
+ *fsm->failedFile = fsm->path;
+ fsm->path = NULL;
+ }
break;
case FSM_DESTROY:
fsm->path = _free(fsm->path);
if (!rc) {
rpmMessage(RPMMESS_VERBOSE, _("Wrote: %s\n"),
(psm->pkgURL ? psm->pkgURL : "???"));
- } else {
- if (psm->failedFile)
- rpmError(RPMERR_CPIO,
- _("create archive failed on file %s: %s\n"),
- psm->failedFile, cpioStrerror(rc));
- else
- rpmError(RPMERR_CPIO, _("create archive failed: %s\n"),
- cpioStrerror(rc));
}
}
+ if (rc) {
+ if (psm->failedFile)
+ rpmError(RPMERR_CPIO,
+ _("%s failed on file %s: %s\n"),
+ psm->stepName, psm->failedFile, cpioStrerror(rc));
+ else
+ rpmError(RPMERR_CPIO, _("%s failed: %s\n"),
+ psm->stepName, cpioStrerror(rc));
+ }
+
if (fi->h && (psm->goal == PSM_PKGERASE || psm->goal == PSM_PKGSAVE))
fi->h = headerFree(fi->h);
psm->oh = headerFree(psm->oh);
fi->fuser = hfd(fi->fuser, -1);
fi->apath = _free(fi->apath);
fi->fstates = _free(fi->fstates);
-
break;
case PSM_PKGINSTALL:
RPMTAG_MULTILIBS = 1127,
RPMTAG_INSTALLTID = 1128,
RPMTAG_REMOVETID = 1129,
+ RPMTAG_SHA1RHN = 1130, /*!< internal */
/*@-enummemuse@*/
RPMTAG_FIRSTFREE_TAG /*!< internal */
/*@=enummemuse@*/
int ec = 0; /* assume no problems */
/* Retrieve header digest. */
- if (!hge(h, RPMTAG_SHA1HEADER, &hdt, (void **) &hdigest, NULL)) {
+ if (!hge(h, RPMTAG_SHA1HEADER, &hdt, (void **) &hdigest, NULL)
+ && !hge(h, RPMTAG_SHA1RHN, &hdt, (void **) &hdigest, NULL))
+ {
if (hge(h, RPMTAG_BADSHA1HEADER, &hdt, (void **) &hdigest, NULL))
flags |= (RPMDIGEST_REVERSE|RPMDIGEST_BCSWAP);
else
#define PY_POPT_VERSION "0.2"
-static const char *rcs_id = "$Id: poptmodule.c,v 1.4 2001/07/21 19:44:22 jbj Exp $";
+static const char *rcs_id = "$Id: poptmodule.c,v 1.5 2001/08/27 18:39:17 jbj Exp $";
static char *module_doc = "Python bindings for the popt library\n\
\n\
/* Methods for the popt module */
static struct PyMethodDef poptModuleMethods[] = {
- {"getContext", (PyCFunction)getContext},
- {"strerror", (PyCFunction)_strerror},
+ {"getContext", (PyCFunction)getContext, METH_VARARGS, NULL},
+ {"strerror", (PyCFunction)_strerror, METH_VARARGS, NULL},
{NULL, NULL}
};
#include "rpmcli.h" /* XXX for rpmCheckSig */
#include "misc.h"
#include "rpmio_internal.h"
+#include "header_internal.h"
#include "upgrade.h"
extern int _rpmio_debug;
+/*@unused@*/ static inline Header headerAllocated(Header h) {
+ h->flags |= HEADERFLAG_ALLOCATED;
+ return 0;
+}
+
#ifdef __LCLINT__
#undef PyObject_HEAD
#define PyObject_HEAD int _PyObjectHead
free((void *)fileNames);
}
+/**
+ */
+static PyObject * rhnUnload(PyObject * self, PyObject * args) {
+ int len;
+ char * uh;
+ PyObject * rc;
+ hdrObject *s;
+ Header h;
+
+ if (!PyArg_ParseTuple(args, ""))
+ return NULL;
+
+ h = headerLink(s->h);
+
+ /* Legacy headers are forced into immutable region. */
+ if (!headerIsEntry(h, RPMTAG_HEADERIMMUTABLE)) {
+ Header nh = headerReload(h, RPMTAG_HEADERIMMUTABLE);
+ /* XXX Another unload/load cycle to "seal" the immutable region. */
+ uh = headerUnload(nh);
+ headerFree(nh);
+ h = headerLoad(uh);
+ headerAllocated(h);
+ }
+
+ /* All headers have SHA1 digest, compute and add if necessary. */
+ if (!headerIsEntry(h, RPMTAG_SHA1HEADER)) {
+ int_32 uht, uhc;
+ const char * digest;
+ size_t digestlen;
+ DIGEST_CTX ctx;
+
+ headerGetEntry(h, RPMTAG_HEADERIMMUTABLE, &uht, (void **)&uh, &uhc);
+
+ ctx = rpmDigestInit(RPMDIGEST_SHA1);
+ rpmDigestUpdate(ctx, uh, uhc);
+ rpmDigestFinal(ctx, (void **)&digest, &digestlen, 1);
+
+ headerAddEntry(h, RPMTAG_SHA1RHN, RPM_STRING_TYPE, digest, 1);
+
+ uh = headerFreeData(uh, uht);
+ digest = _free(digest);
+ }
+
+ len = headerSizeof(h, 0);
+ uh = headerUnload(h);
+ headerFree(h);
+
+ rc = PyString_FromStringAndSize(uh, len);
+ free(uh);
+
+ return rc;
+}
+
/** \ingroup python
*/
static PyObject * hdrFullFilelist(hdrObject * s, PyObject * args) {
{"expandFilelist", (PyCFunction) hdrExpandFilelist, 1 },
{"compressFilelist", (PyCFunction) hdrCompressFilelist, 1 },
{"fullFilelist", (PyCFunction) hdrFullFilelist, 1 },
+ {"rhnUnload", (PyCFunction) rhnUnload, 1 },
{NULL, NULL} /* sentinel */
};
PyErr_SetString(pyrpmError, "bad header");
return NULL;
}
+ headerAllocated(hdr);
compressFilelist (hdr);
providePackageNVR (hdr);
PyErr_SetString(pyrpmError, "bad header");
return NULL;
}
+ headerAllocated(hdr);
if (!headerIsEntry(hdr, RPMTAG_HEADERIMMUTABLE)) {
PyErr_SetString(pyrpmError, "bad header, not immutable");
return (PyObject *) h;
}
-/**
- */
-static PyObject * rhnUnload(PyObject * self, PyObject * args) {
- int len;
- char * uh;
- PyObject * rc;
- hdrObject *s;
- Header h;
- if (!PyArg_ParseTuple(args, "O!", &hdrType, &s))
- return NULL;
-
- h = headerLink(s->h);
-
- /* Legacy headers are forced into immutable region. */
- if (!headerIsEntry(h, RPMTAG_HEADERIMMUTABLE)) {
- Header nh = headerReload(h, RPMTAG_HEADERIMMUTABLE);
- /* XXX Another unload/load cycle to "seal" the immutable region. */
- uh = headerUnload(nh);
- headerFree(nh);
- h = headerLoad(uh);
- }
-
- /* All headers have SHA1 digest, compute and add if necessary. */
- if (!headerIsEntry(h, RPMTAG_SHA1HEADER)) {
- int_32 uht, uhc;
- const char * digest;
- size_t digestlen;
- DIGEST_CTX ctx;
-
- headerGetEntry(h, RPMTAG_HEADERIMMUTABLE, &uht, (void **)&uh, &uhc);
-
- ctx = rpmDigestInit(RPMDIGEST_SHA1);
- rpmDigestUpdate(ctx, uh, uhc);
- rpmDigestFinal(ctx, (void **)&digest, &digestlen, 1);
-
- headerAddEntry(h, RPMTAG_SHA1HEADER, RPM_STRING_TYPE, digest, 1);
-
- uh = headerFreeData(uh, uht);
- digest = _free(digest);
- }
-
- len = headerSizeof(h, 0);
- uh = headerUnload(h);
- headerFree(h);
-
- rc = PyString_FromStringAndSize(uh, len);
- free(uh);
-
- return rc;
-}
-
/**
*/
static PyObject * rpmInitDB(PyObject * self, PyObject * args) {
{ "findUpgradeSet", (PyCFunction) findUpgradeSet, METH_VARARGS, NULL },
{ "headerFromPackage", (PyCFunction) rpmHeaderFromPackage, METH_VARARGS, NULL },
{ "headerLoad", (PyCFunction) hdrLoad, METH_VARARGS, NULL },
- { "rhnUnload", (PyCFunction) rhnUnload, METH_VARARGS, NULL },
{ "rhnLoad", (PyCFunction) rhnLoad, METH_VARARGS, NULL },
{ "initdb", (PyCFunction) rpmInitDB, METH_VARARGS, NULL },
{ "opendb", (PyCFunction) rpmOpenDB, METH_VARARGS, NULL },
RPMERR_SIGGEN = _em(201), /*!< Error generating signature */
RPMERR_SIGVFY = _nm(202), /*!< */
- RPMWARN_UNLINK = _wm(512u+16), /*!< unlink(2) failed */
- RPMWARN_RMDIR = _wm(512u+17), /*!< rmdir(2) failed */
- RPMWARN_FLOCK = _wm(512u+27) /*!< locking the database failed */
+ RPMDEBUG_UNLINK = _dm(512u+16), /*!< unlink(2) failed */
+ RPMDEBUG_RMDIR = _dm(512u+17), /*!< rmdir(2) failed */
+ RPMWARN_FLOCK = _wm(512u+27) /*!< locking the database failed */
} rpmerrCode;
/*@=typeuse @*/