From 18243ddb211f50bdeb17f269e5f6d8b1d59b86d5 Mon Sep 17 00:00:00 2001 From: "biao716.wang" Date: Tue, 21 Mar 2023 15:08:48 +0900 Subject: [PATCH] Fix build error: Ignore rewrite "%package debuginfo" section in spec file Change-Id: I4ecc81988f64c395aef10b4f7c089fba1cc9e614 Signed-off-by: biao716.wang --- build/parsePreamble.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/build/parsePreamble.c b/build/parsePreamble.c index 96bf9c0..70c528a 100644 --- a/build/parsePreamble.c +++ b/build/parsePreamble.c @@ -702,8 +702,9 @@ int addLangTag(rpmSpec spec, Header h, rpmTagVal tag, if (haveLangTag(h, tag, lang)) { /* Turn this into an error eventually */ - rpmlog(RPMLOG_WARNING, _("line %d: second %s\n"), + rpmlog(RPMLOG_WARNING, _("line %d: second %s, please remove it\n"), spec->lineNum, rpmTagGetName(tag)); + return 0; } if (!*lang) { @@ -1126,6 +1127,30 @@ int parsePreamble(rpmSpec spec, int initialPackage) // goto exit; if (!lookupPackage(spec, name, flag, NULL)) { + //exist %package debuginfo, need to ignore it, because there has been + //debuginfo package created by %debug_package macro. + if (0 == strncmp(name, "debuginfo", 9)) + { + rpmlog(RPMLOG_WARNING, _("debuginfo package has been in spec file, Don't write again this %s"), spec->line); + if ((rc = readLine(spec, STRIP_TRAILINGSPACE | STRIP_COMMENTS)) > 0) { + nextPart = PART_NONE; + } else if (rc < 0) { + free(name); + goto exit; + } else { + while (! (nextPart = isPart(spec->line))) { + if ((rc = readLine(spec, STRIP_TRAILINGSPACE | STRIP_COMMENTS)) > 0) { + nextPart = PART_NONE; + break; + } + if (rc) { + free(name); + goto exit; + } + } + } + res = nextPart; + } free(name); goto exit; } -- 2.7.4