rpm5.org: fixup various places in rpmbuild from rpmerr.h elimination

This commit is contained in:
Panu Matilainen 2007-12-07 09:28:39 +02:00
parent 79fed162ac
commit 2a9c146f31
6 changed files with 69 additions and 66 deletions

View File

@ -47,7 +47,7 @@ static void doRmSource(rpmSpec spec)
/*
* @todo Single use by %%doc in files.c prevents static.
*/
int doScript(rpmSpec spec, rpmBuildFlags what, const char *name, StringBuf sb, int test)
rpmRC doScript(rpmSpec spec, rpmBuildFlags what, const char *name, StringBuf sb, int test)
{
const char * rootURL = spec->rootURL;
const char * rootDir;
@ -67,9 +67,10 @@ int doScript(rpmSpec spec, rpmBuildFlags what, const char *name, StringBuf sb, i
FD_t fd;
FD_t xfd;
pid_t pid;
pid_t child;
pid_t status;
int rc;
int status;
rpmRC rc;
switch (what) {
case RPMBUILD_PREP:
@ -124,13 +125,13 @@ int doScript(rpmSpec spec, rpmBuildFlags what, const char *name, StringBuf sb, i
name = "???";
if ((what != RPMBUILD_RMBUILD) && sb == NULL) {
rc = 0;
rc = RPMRC_OK;
goto exit;
}
if (rpmMkTempFile(rootURL, &scriptName, &fd) || fd == NULL || Ferror(fd)) {
rpmlog(RPMLOG_ERR, _("Unable to open temp file.\n"));
rc = RPMLOG_ERR;
rc = RPMRC_FAIL;
goto exit;
}
@ -140,7 +141,7 @@ int doScript(rpmSpec spec, rpmBuildFlags what, const char *name, StringBuf sb, i
xfd = fd;
if ((fp = fdGetFILE(xfd)) == NULL) {
rc = RPMLOG_ERR;
rc = RPMRC_FAIL;
goto exit;
}
@ -168,7 +169,7 @@ int doScript(rpmSpec spec, rpmBuildFlags what, const char *name, StringBuf sb, i
(void) Fclose(xfd);
if (test) {
rc = 0;
rc = RPMRC_OK;
goto exit;
}
@ -176,7 +177,7 @@ if (_build_debug)
fprintf(stderr, "*** rootURL %s buildDirURL %s\n", rootURL, buildDirURL);
if (buildDirURL && buildDirURL[0] != '/' &&
(urlSplit(buildDirURL, &u) != 0)) {
rc = RPMLOG_ERR;
rc = RPMRC_FAIL;
goto exit;
}
if (u != NULL) {
@ -220,13 +221,13 @@ fprintf(stderr, "*** addMacros\n");
if (!WIFEXITED(status) || WEXITSTATUS(status)) {
rpmlog(RPMLOG_ERR, _("Bad exit status from %s (%s)\n"),
scriptName, name);
rc = RPMLOG_ERR;
rc = RPMRC_FAIL;
} else
rc = 0;
rc = RPMRC_OK;
exit:
if (scriptName) {
if (!rc)
if (rc == RPMRC_OK)
(void) unlink(scriptName);
scriptName = _free(scriptName);
}
@ -260,9 +261,9 @@ fprintf(stderr, "*** delMacros\n");
return rc;
}
int buildSpec(rpmts ts, rpmSpec spec, int what, int test)
rpmRC buildSpec(rpmts ts, rpmSpec spec, int what, int test)
{
int rc = 0;
rpmRC rc = RPMRC_OK;
if (!spec->recursing && spec->BACount) {
int x;
@ -327,7 +328,7 @@ int buildSpec(rpmts ts, rpmSpec spec, int what, int test)
(void) unlink(spec->specFile);
exit:
if (rc && rpmlogGetNrecs() > 0) {
if (rc != RPMRC_OK && rpmlogGetNrecs() > 0) {
rpmlog(RPMLOG_NOTICE, _("\n\nRPM build errors:\n"));
rpmlogPrint(NULL);
}

View File

@ -28,9 +28,9 @@ typedef struct cpioSourceArchive_s {
* @retval specp spec structure to carry package header (or NULL)
* @retval sigs package signature
* @param csa
* @return 0 on success
* @return RPMRC_OK on success
*/
int readRPM(const char * fileName,
rpmRC readRPM(const char * fileName,
rpmSpec * specp,
Header * sigs,
CSA_t csa);
@ -47,9 +47,9 @@ int readRPM(const char * fileName,
* @param csa
* @param passPhrase
* @retval cookie generated cookie (i.e build host/time)
* @return 0 on success
* @return RPMRC_OK on success
*/
int writeRPM(Header * hdrp, unsigned char ** pkgidp,
rpmRC writeRPM(Header * hdrp, unsigned char ** pkgidp,
const char * fileName,
CSA_t csa,
char * passPhrase,

View File

@ -1941,11 +1941,11 @@ static int processPackageFiles(rpmSpec spec, Package pkg,
if (installSpecialDoc) {
int _missing_doc_files_terminate_build =
rpmExpandNumeric("%{?_missing_doc_files_terminate_build}");
int rc;
rpmRC rc;
rc = doScript(spec, RPMBUILD_STRINGBUF, "%doc", pkg->specialDoc, test);
if (rc && _missing_doc_files_terminate_build)
fl.processingFailed = rc;
if (rc != RPMRC_OK && _missing_doc_files_terminate_build)
fl.processingFailed = 1;
}
/* Reset for %doc */

View File

@ -43,14 +43,15 @@ static inline int genSourceRpmName(rpmSpec spec)
/**
* @todo Create transaction set *much* earlier.
*/
static int cpio_doio(FD_t fdo, Header h, CSA_t csa,
static rpmRC cpio_doio(FD_t fdo, Header h, CSA_t csa,
const char * fmodeMacro)
{
rpmts ts = rpmtsCreate();
rpmfi fi = csa->cpioList;
const char *failedFile = NULL;
FD_t cfd;
int rc, ec;
rpmRC rc = RPMRC_OK;
int xx;
{ const char *fmode = rpmExpand(fmodeMacro, NULL);
if (!(fmode && fmode[0] == 'w'))
@ -60,13 +61,15 @@ static int cpio_doio(FD_t fdo, Header h, CSA_t csa,
fmode = _free(fmode);
}
if (cfd == NULL)
return 1;
return RPMRC_FAIL;
rc = fsmSetup(fi->fsm, FSM_PKGBUILD, ts, fi, cfd,
xx = fsmSetup(fi->fsm, FSM_PKGBUILD, ts, fi, cfd,
&csa->cpioArchiveSize, &failedFile);
if (xx)
rc = RPMRC_FAIL;
(void) Fclose(cfd);
ec = fsmTeardown(fi->fsm);
if (!rc) rc = ec;
xx = fsmTeardown(fi->fsm);
if (rc == RPMRC_OK && xx) rc = RPMRC_FAIL;
if (rc) {
if (failedFile)
@ -75,7 +78,7 @@ static int cpio_doio(FD_t fdo, Header h, CSA_t csa,
else
rpmlog(RPMLOG_ERR, _("create archive failed: %s\n"),
cpioStrerror(rc));
rc = 1;
rc = RPMRC_FAIL;
}
failedFile = _free(failedFile);
@ -86,7 +89,7 @@ static int cpio_doio(FD_t fdo, Header h, CSA_t csa,
/**
*/
static int cpio_copy(FD_t fdo, CSA_t csa)
static rpmRC cpio_copy(FD_t fdo, CSA_t csa)
{
char buf[BUFSIZ];
size_t nb;
@ -95,16 +98,16 @@ static int cpio_copy(FD_t fdo, CSA_t csa)
if (Fwrite(buf, sizeof(buf[0]), nb, fdo) != nb) {
rpmlog(RPMLOG_ERR, _("cpio_copy write failed: %s\n"),
Fstrerror(fdo));
return 1;
return RPMRC_FAIL;
}
csa->cpioArchiveSize += nb;
}
if (Ferror(csa->cpioFdIn)) {
rpmlog(RPMLOG_ERR, _("cpio_copy read failed: %s\n"),
Fstrerror(csa->cpioFdIn));
return 1;
return RPMRC_FAIL;
}
return 0;
return RPMRC_OK;
}
/**
@ -262,7 +265,7 @@ static int processScriptFiles(rpmSpec spec, Package pkg)
return 0;
}
int readRPM(const char *fileName, rpmSpec *specp,
rpmRC readRPM(const char *fileName, rpmSpec *specp,
Header *sigs, CSA_t csa)
{
FD_t fdi;
@ -278,14 +281,14 @@ int readRPM(const char *fileName, rpmSpec *specp,
(fileName ? fileName : "<stdin>"),
Fstrerror(fdi));
if (fdi) (void) Fclose(fdi);
return RPMLOG_ERR;
return RPMRC_FAIL;
}
/* XXX FIXME: EPIPE on <stdin> */
if (Fseek(fdi, 0, SEEK_SET) == -1) {
rpmlog(RPMLOG_ERR, _("%s: Fseek failed: %s\n"),
(fileName ? fileName : "<stdin>"), Fstrerror(fdi));
return RPMLOG_ERR;
return RPMRC_FAIL;
}
/* Reallocate build data structures */
@ -335,10 +338,10 @@ int readRPM(const char *fileName, rpmSpec *specp,
else
(void) Fclose(fdi);
return 0;
return RPMRC_OK;
}
int writeRPM(Header *hdrp, unsigned char ** pkgidp, const char *fileName,
rpmRC writeRPM(Header *hdrp, unsigned char ** pkgidp, const char *fileName,
CSA_t csa, char *passPhrase, const char **cookie)
{
FD_t fd = NULL;
@ -351,7 +354,8 @@ int writeRPM(Header *hdrp, unsigned char ** pkgidp, const char *fileName,
char buf[BUFSIZ];
Header h;
Header sig = NULL;
int rc = 0, isSource;
int isSource, xx;
rpmRC rc = RPMRC_OK;
/* Transfer header reference form *hdrp to h. */
h = headerLink(*hdrp);
@ -402,7 +406,7 @@ int writeRPM(Header *hdrp, unsigned char ** pkgidp, const char *fileName,
/* Reallocate the header into one contiguous region. */
h = headerReload(h, RPMTAG_HEADERIMMUTABLE);
if (h == NULL) { /* XXX can't happen */
rc = RPMLOG_ERR;
rc = RPMRC_FAIL;
rpmlog(RPMLOG_ERR, _("Unable to create immutable header region.\n"));
goto exit;
}
@ -414,14 +418,14 @@ int writeRPM(Header *hdrp, unsigned char ** pkgidp, const char *fileName,
* archive (after compression) can be added to the header.
*/
if (rpmMkTempFile(NULL, &sigtarget, &fd)) {
rc = RPMLOG_ERR;
rc = RPMRC_FAIL;
rpmlog(RPMLOG_ERR, _("Unable to open temp file.\n"));
goto exit;
}
fdInitDigest(fd, PGPHASHALGO_SHA1, 0);
if (headerWrite(fd, h, HEADER_MAGIC_YES)) {
rc = RPMLOG_ERR;
rc = RPMRC_FAIL;
rpmlog(RPMLOG_ERR, _("Unable to write temp header\n"));
} else { /* Write the archive and get the size */
(void) Fflush(fd);
@ -431,22 +435,19 @@ int writeRPM(Header *hdrp, unsigned char ** pkgidp, const char *fileName,
} else if (Fileno(csa->cpioFdIn) >= 0) {
rc = cpio_copy(fd, csa);
} else {
rc = RPMLOG_ERR;
rc = RPMRC_FAIL;
rpmlog(RPMLOG_ERR, _("Bad CSA data\n"));
}
}
rpmio_flags = _free(rpmio_flags);
if (rc)
if (rc != RPMRC_OK)
goto exit;
(void) Fclose(fd);
fd = NULL;
(void) unlink(fileName);
if (rc)
goto exit;
/* Generate the signature */
(void) fflush(stdout);
sig = rpmNewSignature();
@ -471,7 +472,7 @@ int writeRPM(Header *hdrp, unsigned char ** pkgidp, const char *fileName,
/* Reallocate the signature into one contiguous region. */
sig = headerReload(sig, RPMTAG_HEADERSIGNATURES);
if (sig == NULL) { /* XXX can't happen */
rc = RPMLOG_ERR;
rc = RPMRC_FAIL;
rpmlog(RPMLOG_ERR, _("Unable to reload signature header.\n"));
goto exit;
}
@ -479,7 +480,7 @@ int writeRPM(Header *hdrp, unsigned char ** pkgidp, const char *fileName,
/* Open the output file */
fd = Fopen(fileName, "w.ufdio");
if (fd == NULL || Ferror(fd)) {
rc = RPMLOG_ERR;
rc = RPMRC_FAIL;
rpmlog(RPMLOG_ERR, _("Could not open %s: %s\n"),
fileName, Fstrerror(fd));
goto exit;
@ -488,10 +489,10 @@ int writeRPM(Header *hdrp, unsigned char ** pkgidp, const char *fileName,
/* Write the lead section into the package. */
{
rpmlead lead = rpmLeadFromHeader(h);
int rc = rpmLeadWrite(fd, lead);
rc = rpmLeadWrite(fd, lead);
lead = rpmLeadFree(lead);
if (rc != RPMRC_OK) {
rc = RPMLOG_ERR;
rc = RPMRC_FAIL;
rpmlog(RPMLOG_ERR, _("Unable to write package: %s\n"),
Fstrerror(fd));
goto exit;
@ -499,14 +500,15 @@ int writeRPM(Header *hdrp, unsigned char ** pkgidp, const char *fileName,
}
/* Write the signature section into the package. */
rc = rpmWriteSignature(fd, sig);
if (rc)
if (rpmWriteSignature(fd, sig)) {
rc = RPMRC_FAIL;
goto exit;
}
/* Append the header and archive */
ifd = Fopen(sigtarget, "r.ufdio");
if (ifd == NULL || Ferror(ifd)) {
rc = RPMLOG_ERR;
rc = RPMRC_FAIL;
rpmlog(RPMLOG_ERR, _("Unable to open sigtarget %s: %s\n"),
sigtarget, Fstrerror(ifd));
goto exit;
@ -517,7 +519,7 @@ int writeRPM(Header *hdrp, unsigned char ** pkgidp, const char *fileName,
{ Header nh = headerRead(ifd, HEADER_MAGIC_YES);
if (nh == NULL) {
rc = RPMLOG_ERR;
rc = RPMRC_FAIL;
rpmlog(RPMLOG_ERR, _("Unable to read header from %s: %s\n"),
sigtarget, Fstrerror(ifd));
goto exit;
@ -527,11 +529,11 @@ int writeRPM(Header *hdrp, unsigned char ** pkgidp, const char *fileName,
(void) headerMergeLegacySigs(nh, sig);
#endif
rc = headerWrite(fd, nh, HEADER_MAGIC_YES);
xx = headerWrite(fd, nh, HEADER_MAGIC_YES);
nh = headerFree(nh);
if (rc) {
rc = RPMLOG_ERR;
if (xx) {
rc = RPMRC_FAIL;
rpmlog(RPMLOG_ERR, _("Unable to write header to %s: %s\n"),
fileName, Fstrerror(fd));
goto exit;
@ -541,19 +543,19 @@ int writeRPM(Header *hdrp, unsigned char ** pkgidp, const char *fileName,
/* Write the payload into the package. */
while ((count = Fread(buf, sizeof(buf[0]), sizeof(buf), ifd)) > 0) {
if (count == -1) {
rc = RPMLOG_ERR;
rc = RPMRC_FAIL;
rpmlog(RPMLOG_ERR, _("Unable to read payload from %s: %s\n"),
sigtarget, Fstrerror(ifd));
goto exit;
}
if (Fwrite(buf, sizeof(buf[0]), count, fd) != count) {
rc = RPMLOG_ERR;
rc = RPMRC_FAIL;
rpmlog(RPMLOG_ERR, _("Unable to write payload to %s: %s\n"),
fileName, Fstrerror(fd));
goto exit;
}
}
rc = 0;
rc = RPMRC_OK;
exit:
SHA1 = _free(SHA1);
@ -584,7 +586,7 @@ exit:
sigtarget = _free(sigtarget);
}
if (rc == 0)
if (rc == RPMRC_OK)
rpmlog(RPMLOG_NOTICE, _("Wrote: %s\n"), fileName);
else
(void) unlink(fileName);

View File

@ -272,9 +272,9 @@ char * parseExpressionString(rpmSpec spec, const char * expr);
* @param name name of scriptlet section
* @param sb lines that compose script body
* @param test don't execute scripts or package if testing
* @return 0 on success, RPMERR_SCRIPT on failure
* @return RPMRC_OK on success
*/
int doScript(rpmSpec spec, rpmBuildFlags what, const char * name,
rpmRC doScript(rpmSpec spec, rpmBuildFlags what, const char * name,
StringBuf sb, int test);
/** \ingroup rpmbuild
@ -382,9 +382,9 @@ int parseSpec(rpmts ts, const char * specFile,
* @param spec spec file control structure
* @param what bit(s) to enable stages of build
* @param test don't execute scripts or package if testing
* @return 0 on success
* @return RPMRC_OK on success
*/
int buildSpec(rpmts ts, rpmSpec spec, int what, int test);
rpmRC buildSpec(rpmts ts, rpmSpec spec, int what, int test);
/** \ingroup rpmbuild
* Generate binary package(s).

View File

@ -403,7 +403,7 @@ static int makePGPSignature(const char * file, int32_t * sigTagp,
}
rpmlog(RPMLOG_ERR, _("Could not exec %s: %s\n"), "pgp",
strerror(errno));
_exit(RPMLOG_ERR);
_exit(EXIT_FAILURE);
}
delMacro(NULL, "__plaintext_filename");