2000-08-28 03:18:25 +08:00
|
|
|
/** \ingroup rpmbuild
|
|
|
|
* \file build/parseDescription.c
|
2000-01-25 04:02:32 +08:00
|
|
|
* Parse %description section from spec file.
|
|
|
|
*/
|
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
#include "system.h"
|
1998-01-13 05:31:29 +08:00
|
|
|
|
1998-07-31 06:09:42 +08:00
|
|
|
#include "rpmbuild.h"
|
2000-12-13 04:03:45 +08:00
|
|
|
#include "debug.h"
|
1998-07-31 06:09:42 +08:00
|
|
|
|
2001-06-04 21:55:58 +08:00
|
|
|
/*@-exportheadervar@*/
|
2001-10-15 11:22:10 +08:00
|
|
|
/*@unchecked@*/
|
2001-06-04 21:55:58 +08:00
|
|
|
extern int noLang;
|
|
|
|
/*@=exportheadervar@*/
|
1998-08-12 02:24:48 +08:00
|
|
|
|
1998-03-05 00:51:06 +08:00
|
|
|
/* These have to be global scope to make up for *stupid* compilers */
|
2001-10-15 11:22:10 +08:00
|
|
|
/*@unchecked@*/
|
1999-10-28 07:18:10 +08:00
|
|
|
/*@observer@*/ /*@null@*/ static const char *name = NULL;
|
2001-10-15 11:22:10 +08:00
|
|
|
/*@unchecked@*/
|
1999-10-28 07:18:10 +08:00
|
|
|
/*@observer@*/ /*@null@*/ static const char *lang = NULL;
|
1998-03-05 00:51:06 +08:00
|
|
|
|
2001-10-15 11:22:10 +08:00
|
|
|
/*@unchecked@*/
|
1998-03-05 00:51:06 +08:00
|
|
|
static struct poptOption optionsTable[] = {
|
1998-11-20 03:10:23 +08:00
|
|
|
{ NULL, 'n', POPT_ARG_STRING, &name, 'n', NULL, NULL},
|
|
|
|
{ NULL, 'l', POPT_ARG_STRING, &lang, 'l', NULL, NULL},
|
|
|
|
{ 0, 0, 0, 0, 0, NULL, NULL}
|
1998-03-05 00:51:06 +08:00
|
|
|
};
|
|
|
|
|
1998-01-13 05:31:29 +08:00
|
|
|
int parseDescription(Spec spec)
|
|
|
|
{
|
|
|
|
int nextPart;
|
|
|
|
StringBuf sb;
|
|
|
|
int flag = PART_SUBNAME;
|
|
|
|
Package pkg;
|
|
|
|
int rc, argc;
|
1998-04-03 02:31:12 +08:00
|
|
|
int arg;
|
1999-10-28 07:18:10 +08:00
|
|
|
const char **argv = NULL;
|
1998-01-13 05:31:29 +08:00
|
|
|
poptContext optCon = NULL;
|
2001-05-07 03:17:14 +08:00
|
|
|
spectag t = NULL;
|
1998-03-05 00:51:06 +08:00
|
|
|
|
2001-10-18 00:43:36 +08:00
|
|
|
/*@-mods@*/
|
1998-03-05 00:51:06 +08:00
|
|
|
name = NULL;
|
|
|
|
lang = RPMBUILD_DEFAULT_LANG;
|
2001-10-18 00:43:36 +08:00
|
|
|
/*@=mods@*/
|
1998-01-13 05:31:29 +08:00
|
|
|
|
|
|
|
if ((rc = poptParseArgvString(spec->line, &argc, &argv))) {
|
2001-01-16 07:09:42 +08:00
|
|
|
rpmError(RPMERR_BADSPEC, _("line %d: Error parsing %%description: %s\n"),
|
1998-01-13 05:31:29 +08:00
|
|
|
spec->lineNum, poptStrerror(rc));
|
|
|
|
return RPMERR_BADSPEC;
|
|
|
|
}
|
|
|
|
|
|
|
|
optCon = poptGetContext(NULL, argc, argv, optionsTable, 0);
|
|
|
|
while ((arg = poptGetNextOpt(optCon)) > 0) {
|
|
|
|
if (arg == 'n') {
|
|
|
|
flag = PART_NAME;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (arg < -1) {
|
2001-01-16 07:09:42 +08:00
|
|
|
rpmError(RPMERR_BADSPEC, _("line %d: Bad option %s: %s\n"),
|
1998-01-13 05:31:29 +08:00
|
|
|
spec->lineNum,
|
|
|
|
poptBadOption(optCon, POPT_BADOPTION_NOALIAS),
|
|
|
|
spec->line);
|
2001-04-29 09:05:43 +08:00
|
|
|
argv = _free(argv);
|
2001-05-06 03:28:32 +08:00
|
|
|
optCon = poptFreeContext(optCon);
|
1998-01-13 05:31:29 +08:00
|
|
|
return RPMERR_BADSPEC;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (poptPeekArg(optCon)) {
|
2001-10-18 00:43:36 +08:00
|
|
|
/*@-mods@*/
|
1999-10-28 07:18:10 +08:00
|
|
|
if (name == NULL)
|
1998-01-13 05:31:29 +08:00
|
|
|
name = poptGetArg(optCon);
|
2001-10-18 00:43:36 +08:00
|
|
|
/*@=mods@*/
|
1998-01-13 05:31:29 +08:00
|
|
|
if (poptPeekArg(optCon)) {
|
2001-01-16 07:09:42 +08:00
|
|
|
rpmError(RPMERR_BADSPEC, _("line %d: Too many names: %s\n"),
|
1998-01-13 05:31:29 +08:00
|
|
|
spec->lineNum,
|
|
|
|
spec->line);
|
2001-04-29 09:05:43 +08:00
|
|
|
argv = _free(argv);
|
2001-05-06 03:28:32 +08:00
|
|
|
optCon = poptFreeContext(optCon);
|
1998-01-13 05:31:29 +08:00
|
|
|
return RPMERR_BADSPEC;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lookupPackage(spec, name, flag, &pkg)) {
|
2001-01-16 07:09:42 +08:00
|
|
|
rpmError(RPMERR_BADSPEC, _("line %d: Package does not exist: %s\n"),
|
1998-01-13 05:31:29 +08:00
|
|
|
spec->lineNum, spec->line);
|
2001-04-29 09:05:43 +08:00
|
|
|
argv = _free(argv);
|
2001-05-06 03:28:32 +08:00
|
|
|
optCon = poptFreeContext(optCon);
|
1998-01-13 05:31:29 +08:00
|
|
|
return RPMERR_BADSPEC;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************/
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
if (headerIsEntry(pkg->header, RPMTAG_DESCRIPTION)) {
|
2001-01-16 07:09:42 +08:00
|
|
|
rpmError(RPMERR_BADSPEC, _("line %d: Second description\n"),
|
|
|
|
spec->lineNum);
|
2001-04-29 09:05:43 +08:00
|
|
|
argv = _free(argv);
|
2001-05-06 03:28:32 +08:00
|
|
|
optCon = poptFreeContext(optCon);
|
1998-01-13 05:31:29 +08:00
|
|
|
return RPMERR_BADSPEC;
|
|
|
|
}
|
|
|
|
#endif
|
1999-02-23 01:44:57 +08:00
|
|
|
|
|
|
|
t = stashSt(spec, pkg->header, RPMTAG_DESCRIPTION, lang);
|
1998-01-13 05:31:29 +08:00
|
|
|
|
|
|
|
sb = newStringBuf();
|
|
|
|
|
1998-05-21 01:05:26 +08:00
|
|
|
if ((rc = readLine(spec, STRIP_TRAILINGSPACE | STRIP_COMMENTS)) > 0) {
|
1998-01-13 05:31:29 +08:00
|
|
|
nextPart = PART_NONE;
|
|
|
|
} else {
|
1998-05-21 01:05:26 +08:00
|
|
|
if (rc) {
|
|
|
|
return rc;
|
|
|
|
}
|
1998-01-13 05:31:29 +08:00
|
|
|
while (! (nextPart = isPart(spec->line))) {
|
|
|
|
appendLineStringBuf(sb, spec->line);
|
1999-02-23 01:44:57 +08:00
|
|
|
if (t) t->t_nlines++;
|
1998-05-21 01:05:26 +08:00
|
|
|
if ((rc =
|
|
|
|
readLine(spec, STRIP_TRAILINGSPACE | STRIP_COMMENTS)) > 0) {
|
1998-01-13 05:31:29 +08:00
|
|
|
nextPart = PART_NONE;
|
|
|
|
break;
|
|
|
|
}
|
1998-05-21 01:05:26 +08:00
|
|
|
if (rc) {
|
|
|
|
return rc;
|
|
|
|
}
|
1998-01-13 05:31:29 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
stripTrailingBlanksStringBuf(sb);
|
1998-08-12 02:24:48 +08:00
|
|
|
if (!(noLang && strcmp(lang, RPMBUILD_DEFAULT_LANG))) {
|
2001-05-01 06:32:22 +08:00
|
|
|
(void) headerAddI18NString(pkg->header, RPMTAG_DESCRIPTION,
|
1998-01-13 05:31:29 +08:00
|
|
|
getStringBuf(sb), lang);
|
1998-08-12 02:24:48 +08:00
|
|
|
}
|
1998-01-13 05:31:29 +08:00
|
|
|
|
2001-05-06 03:28:32 +08:00
|
|
|
sb = freeStringBuf(sb);
|
1998-01-13 05:31:29 +08:00
|
|
|
|
2001-04-29 09:05:43 +08:00
|
|
|
argv = _free(argv);
|
2001-05-06 03:28:32 +08:00
|
|
|
optCon = poptFreeContext(optCon);
|
1998-01-13 05:31:29 +08:00
|
|
|
|
|
|
|
return nextPart;
|
|
|
|
}
|