From cf340dff995f8e590b88cf1f8b8c985aaa5cee96 Mon Sep 17 00:00:00 2001 From: "biao716.wang" Date: Thu, 30 Mar 2023 15:50:29 +0900 Subject: Fix vd build error with rpm 4.14 for writing %files debuginfo This patch is compatible with old writing way in spec file for vd projects. in some vd project, there is such section: %file debuginfo XXXXX In current logic, there is no need to write this way in rpm 4.14, it will check if there is XXX.debug kind of files, if there is none, no debuginfo package is generated. But in vd projects' spec, it put some files which is not XXX.debug files to debuginfo package, this is not allowed in rpm 4.14. Change-Id: I735bed46de8b6c67fb0730476544075d332b46b4 Signed-off-by: biao716.wang --- build/files.c | 20 ++++++++++++++++++-- build/parseFiles.c | 5 +++++ lib/rpmtag.h | 9 +++++---- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/build/files.c b/build/files.c index 67268d41d..c641528a4 100644 --- a/build/files.c +++ b/build/files.c @@ -130,6 +130,9 @@ typedef struct AttrRec_s { /* list of files */ static StringBuf check_fileList = NULL; +/*backup of maindb->fileList*/ +ARGV_t maindb_fileList_bakup = NULL; + typedef struct FileEntry_s { rpmfileAttrs attrFlags; specfFlags specdFlags; @@ -2934,8 +2937,11 @@ static void filterDebuginfoPackage(rpmSpec spec, Package pkg, /* we have collected some files. Now put them in a debuginfo * package. If this is not the main package, clone the main * debuginfo package */ - if (pkg == spec->packages) + if (pkg == spec->packages) { maindbg->fileList = files; + /*free maindb_fileList_bakup and set to NULL*/ + maindb_fileList_bakup = argvFree(maindb_fileList_bakup); + } else { Package dbg = cloneDebuginfoPackage(spec, pkg, maindbg); dbg->fileList = files; @@ -2943,6 +2949,14 @@ static void filterDebuginfoPackage(rpmSpec spec, Package pkg, addPackageDeps(dbg, dbgsrc ? dbgsrc : maindbg, RPMTAG_RECOMMENDNAME); } + } else { + /*To allow generate debuginfo package which is written in spec file, even there is no .debug files*/ + if (pkg == spec->packages && headerGetString(maindbg->header,RPMTAG_MULTIFILELIST)) { + rpmlog(RPMLOG_WARNING, "user rewrite %%file debuginfo to pack something\n"); + maindbg->fileList = maindb_fileList_bakup; + maindb_fileList_bakup = NULL; + headerDel(maindbg->header,RPMTAG_MULTIFILELIST); + } } } @@ -3075,8 +3089,10 @@ rpmRC processBinaryFiles(rpmSpec spec, rpmBuildPkgFlags pkgFlags, *pp = maindbg; } /* delete unsplit file list, we will re-add files back later */ + /*backup maindb fileList before free*/ + maindb_fileList_bakup = maindbg->fileList; maindbg->fileFile = argvFree(maindbg->fileFile); - maindbg->fileList = argvFree(maindbg->fileList); + maindbg->fileList = NULL; if (rpmExpandNumeric("%{?_unique_debug_names}")) uniquearch = rpmExpand("-%{VERSION}-%{RELEASE}.%{_arch}", NULL); } diff --git a/build/parseFiles.c b/build/parseFiles.c index 5ccc94509..29fd637e9 100644 --- a/build/parseFiles.c +++ b/build/parseFiles.c @@ -72,6 +72,11 @@ int parseFiles(rpmSpec spec) if (pkg->fileList != NULL) { rpmlog(RPMLOG_WARNING, _("line %d: multiple %%files for package '%s'\n"), spec->lineNum, rpmstrPoolStr(pkg->pool, pkg->name)); + if (0 == strncmp(name, "debuginfo", 9)) + { + char* multifilelist_flag = "1"; + headerPutString(pkg->header, RPMTAG_MULTIFILELIST, multifilelist_flag); + } pkg->fileList = argvFree(pkg->fileList); } diff --git a/lib/rpmtag.h b/lib/rpmtag.h index 276df7a23..4491aa9a4 100644 --- a/lib/rpmtag.h +++ b/lib/rpmtag.h @@ -269,8 +269,9 @@ typedef enum rpmTag_e { RPMTAG_BUILDOBSOLETES = 1194, /* internal (unimplemented) */ RPMTAG_DBINSTANCE = 1195, /* i extension */ RPMTAG_NVRA = 1196, /* s extension */ + RPMTAG_MULTIFILELIST = 1197, /* s */ - /* tags 1997-4999 reserved */ + /* tags 1998-4999 reserved */ RPMTAG_FILENAMES = 5000, /* s[] extension */ RPMTAG_FILEPROVIDE = 5001, /* s[] extension */ RPMTAG_FILEREQUIRE = 5002, /* s[] extension */ @@ -368,10 +369,10 @@ typedef enum rpmTag_e { RPMTAG_FILESIGNATURELENGTH = 5091, /* i */ RPMTAG_PAYLOADDIGEST = 5092, /* s[] */ RPMTAG_PAYLOADDIGESTALGO = 5093, /* i */ - /* Skip numbers which might be used in new RPM versions */ - RPMTAG_BUILDINFO = 7000, /* s[] information about build */ + /* Skip numbers which might be used in new RPM versions */ + RPMTAG_BUILDINFO = 7000, /* s[] information about build */ - RPMTAG_FIRSTFREE_TAG /*!< internal */ + RPMTAG_FIRSTFREE_TAG, /*!< internal */ } rpmTag; #define RPMTAG_EXTERNAL_TAG 1000000 -- cgit v1.2.3