From b02893092594b868296c5b3f58ab631e368bae1a Mon Sep 17 00:00:00 2001 From: Jindrich Novy Date: Tue, 23 Jun 2009 11:05:06 +0200 Subject: [PATCH] Teach %files to accept multiple filelists (ticket #70, rhbz#475359) --- build/files.c | 40 +++++++++++++++++++--------------------- build/parseFiles.c | 16 +++++++--------- build/rpmspec.h | 2 +- build/spec.c | 2 +- 4 files changed, 28 insertions(+), 32 deletions(-) diff --git a/build/files.c b/build/files.c index 98abedd..dfbd675 100644 --- a/build/files.c +++ b/build/files.c @@ -1744,35 +1744,33 @@ static rpmRC processPackageFiles(rpmSpec spec, Package pkg, if (pkg->fileFile) { char *ffn; + ARGV_t filelists; FILE *fd; - /* XXX W2DO? urlPath might be useful here. */ - if (*pkg->fileFile == '/') { - ffn = rpmGetPath(pkg->fileFile, NULL); - } else { - /* XXX FIXME: add %{buildsubdir} */ + argvSplit(&filelists, getStringBuf(pkg->fileFile), "\n"); + for (fp = filelists; *fp != NULL; fp++) { ffn = rpmGetPath("%{_builddir}/", (spec->buildSubdir ? spec->buildSubdir : "") , - "/", pkg->fileFile, NULL); - } - fd = fopen(ffn, "r"); - - if (fd == NULL || ferror(fd)) { - rpmlog(RPMLOG_ERR, _("Could not open %%files file %s: %m\n"), ffn); - return RPMRC_FAIL; - } - ffn = _free(ffn); + "/", *fp, NULL); + fd = fopen(ffn, "r"); - while (fgets(buf, sizeof(buf), fd)) { - handleComments(buf); - if (expandMacros(spec, spec->macros, buf, sizeof(buf))) { - rpmlog(RPMLOG_ERR, _("line: %s\n"), buf); - fclose(fd); + if (fd == NULL || ferror(fd)) { + rpmlog(RPMLOG_ERR, _("Could not open %%files file %s: %m\n"), ffn); return RPMRC_FAIL; } - appendStringBuf(pkg->fileList, buf); + ffn = _free(ffn); + + while (fgets(buf, sizeof(buf), fd)) { + handleComments(buf); + if (expandMacros(spec, spec->macros, buf, sizeof(buf))) { + rpmlog(RPMLOG_ERR, _("line: %s\n"), buf); + fclose(fd); + return RPMRC_FAIL; + } + appendStringBuf(pkg->fileList, buf); + } + (void) fclose(fd); } - (void) fclose(fd); } /* Init the file list structure */ diff --git a/build/parseFiles.c b/build/parseFiles.c index 96e6429..b6ceb4c 100644 --- a/build/parseFiles.c +++ b/build/parseFiles.c @@ -65,15 +65,13 @@ int parseFiles(rpmSpec spec) goto exit; } - if (pkg->fileList != NULL) { - rpmlog(RPMLOG_ERR, _("line %d: Second %%files list\n"), - spec->lineNum); - goto exit; - } - - if (file) { - /* XXX not necessary as readline has expanded already, but won't hurt. */ - pkg->fileFile = rpmGetPath(file, NULL); + for (arg=1; argfileFile) pkg->fileFile = newStringBuf(); + appendLineStringBuf(pkg->fileFile, file); + free(file); + } } pkg->fileList = newStringBuf(); diff --git a/build/rpmspec.h b/build/rpmspec.h index 3b115f6..eb94118 100644 --- a/build/rpmspec.h +++ b/build/rpmspec.h @@ -169,7 +169,7 @@ struct Package_s { struct TriggerFileEntry * triggerFiles; - char * fileFile; + StringBuf fileFile; StringBuf fileList; /* If NULL, package will not be written */ Package next; diff --git a/build/spec.c b/build/spec.c index 76b22a2..ca97107 100644 --- a/build/spec.c +++ b/build/spec.c @@ -157,7 +157,7 @@ Package freePackage(Package pkg) pkg->header = headerFree(pkg->header); pkg->ds = rpmdsFree(pkg->ds); pkg->fileList = freeStringBuf(pkg->fileList); - pkg->fileFile = _free(pkg->fileFile); + pkg->fileFile = freeStringBuf(pkg->fileFile); if (pkg->cpioList) { rpmfi fi = pkg->cpioList; pkg->cpioList = NULL; -- 2.7.4