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
|
|
|
|
2008-02-03 22:24:07 +08:00
|
|
|
#include <rpm/header.h>
|
2007-12-08 20:02:32 +08:00
|
|
|
#include <rpm/rpmbuild.h>
|
|
|
|
#include <rpm/rpmlog.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
|
|
|
extern int noLang;
|
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 */
|
2007-09-12 05:03:27 +08:00
|
|
|
static const char *name = NULL;
|
|
|
|
static const char *lang = NULL;
|
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
|
|
|
};
|
|
|
|
|
2007-09-21 20:23:02 +08:00
|
|
|
int parseDescription(rpmSpec spec)
|
1998-01-13 05:31:29 +08:00
|
|
|
{
|
2007-12-07 16:43:53 +08:00
|
|
|
int nextPart = RPMRC_FAIL; /* assume error */
|
1998-01-13 05:31:29 +08:00
|
|
|
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
|
|
|
|
|
|
|
name = NULL;
|
|
|
|
lang = RPMBUILD_DEFAULT_LANG;
|
1998-01-13 05:31:29 +08:00
|
|
|
|
|
|
|
if ((rc = poptParseArgvString(spec->line, &argc, &argv))) {
|
2007-11-19 22:25:24 +08:00
|
|
|
rpmlog(RPMLOG_ERR, _("line %d: Error parsing %%description: %s\n"),
|
1998-01-13 05:31:29 +08:00
|
|
|
spec->lineNum, poptStrerror(rc));
|
2007-12-07 16:43:53 +08:00
|
|
|
return RPMRC_FAIL;
|
1998-01-13 05:31:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
optCon = poptGetContext(NULL, argc, argv, optionsTable, 0);
|
|
|
|
while ((arg = poptGetNextOpt(optCon)) > 0) {
|
|
|
|
if (arg == 'n') {
|
|
|
|
flag = PART_NAME;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (arg < -1) {
|
2007-11-19 22:25:24 +08:00
|
|
|
rpmlog(RPMLOG_ERR, _("line %d: Bad option %s: %s\n"),
|
1998-01-13 05:31:29 +08:00
|
|
|
spec->lineNum,
|
|
|
|
poptBadOption(optCon, POPT_BADOPTION_NOALIAS),
|
|
|
|
spec->line);
|
2003-04-17 06:13:18 +08:00
|
|
|
goto exit;
|
1998-01-13 05:31:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (poptPeekArg(optCon)) {
|
1999-10-28 07:18:10 +08:00
|
|
|
if (name == NULL)
|
1998-01-13 05:31:29 +08:00
|
|
|
name = poptGetArg(optCon);
|
|
|
|
if (poptPeekArg(optCon)) {
|
2007-11-19 22:25:24 +08:00
|
|
|
rpmlog(RPMLOG_ERR, _("line %d: Too many names: %s\n"),
|
1998-01-13 05:31:29 +08:00
|
|
|
spec->lineNum,
|
|
|
|
spec->line);
|
2003-04-17 06:13:18 +08:00
|
|
|
goto exit;
|
1998-01-13 05:31:29 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lookupPackage(spec, name, flag, &pkg)) {
|
2007-11-19 22:25:24 +08:00
|
|
|
rpmlog(RPMLOG_ERR, _("line %d: Package does not exist: %s\n"),
|
1998-01-13 05:31:29 +08:00
|
|
|
spec->lineNum, spec->line);
|
2003-04-17 06:13:18 +08:00
|
|
|
goto exit;
|
1998-01-13 05:31:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************/
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
if (headerIsEntry(pkg->header, RPMTAG_DESCRIPTION)) {
|
2007-11-19 22:25:24 +08:00
|
|
|
rpmlog(RPMLOG_ERR, _("line %d: Second description\n"),
|
2001-01-16 07:09:42 +08:00
|
|
|
spec->lineNum);
|
2003-04-17 06:13:18 +08:00
|
|
|
goto exit;
|
1998-01-13 05:31:29 +08:00
|
|
|
}
|
|
|
|
#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) {
|
2007-12-07 16:43:53 +08:00
|
|
|
nextPart = RPMRC_FAIL;
|
2003-04-17 06:13:18 +08:00
|
|
|
goto exit;
|
1998-05-21 01:05:26 +08:00
|
|
|
}
|
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 =
|
2003-04-17 06:13:18 +08:00
|
|
|
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) {
|
2007-12-07 16:43:53 +08:00
|
|
|
nextPart = RPMRC_FAIL;
|
2003-04-17 06:13:18 +08:00
|
|
|
goto exit;
|
1998-05-21 01:05:26 +08:00
|
|
|
}
|
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
|
|
|
|
2003-04-17 06:13:18 +08:00
|
|
|
exit:
|
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;
|
|
|
|
}
|