|
Lubos Kardos |
20901a |
From 877d5b130cbfdfd93ad39c1f0f1505790eba264e Mon Sep 17 00:00:00 2001
|
|
Lubos Kardos |
20901a |
From: Lubos Kardos <lkardos@redhat.com>
|
|
Lubos Kardos |
20901a |
Date: Wed, 16 Mar 2016 17:15:14 +0100
|
|
Lubos Kardos |
20901a |
Subject: [PATCH] Fix non-working combination of %lang and %doc directive
|
|
Lubos Kardos |
20901a |
(rhbz:1254483)
|
|
Lubos Kardos |
20901a |
|
|
Lubos Kardos |
20901a |
---
|
|
Lubos Kardos |
20901a |
build/files.c | 99 +++++++++++++++++++++++++++++++++++++++++++++--------------
|
|
Lubos Kardos |
20901a |
1 file changed, 76 insertions(+), 23 deletions(-)
|
|
Lubos Kardos |
20901a |
|
|
Lubos Kardos |
20901a |
diff --git a/build/files.c b/build/files.c
|
|
Lubos Kardos |
20901a |
index 81bb600..3976fb6 100644
|
|
Lubos Kardos |
20901a |
--- a/build/files.c
|
|
Lubos Kardos |
20901a |
+++ b/build/files.c
|
|
Lubos Kardos |
20901a |
@@ -103,14 +103,6 @@ typedef struct AttrRec_s {
|
|
Lubos Kardos |
20901a |
/* list of files */
|
|
Lubos Kardos |
20901a |
static StringBuf check_fileList = NULL;
|
|
Lubos Kardos |
20901a |
|
|
Lubos Kardos |
20901a |
-typedef struct specialDir_s {
|
|
Lubos Kardos |
20901a |
- char * dirname;
|
|
Lubos Kardos |
20901a |
- ARGV_t files;
|
|
Lubos Kardos |
20901a |
- struct AttrRec_s ar;
|
|
Lubos Kardos |
20901a |
- struct AttrRec_s def_ar;
|
|
Lubos Kardos |
20901a |
- rpmFlags sdtype;
|
|
Lubos Kardos |
20901a |
-} * specialDir;
|
|
Lubos Kardos |
20901a |
-
|
|
Lubos Kardos |
20901a |
typedef struct FileEntry_s {
|
|
Lubos Kardos |
20901a |
rpmfileAttrs attrFlags;
|
|
Lubos Kardos |
20901a |
specfFlags specdFlags;
|
|
Lubos Kardos |
20901a |
@@ -127,6 +119,23 @@ typedef struct FileEntry_s {
|
|
Lubos Kardos |
20901a |
int isDir;
|
|
Lubos Kardos |
20901a |
} * FileEntry;
|
|
Lubos Kardos |
20901a |
|
|
Lubos Kardos |
20901a |
+typedef struct specialDir_s {
|
|
Lubos Kardos |
20901a |
+ char * dirname;
|
|
Lubos Kardos |
20901a |
+ ARGV_t files;
|
|
Lubos Kardos |
20901a |
+ struct AttrRec_s ar;
|
|
Lubos Kardos |
20901a |
+ struct AttrRec_s def_ar;
|
|
Lubos Kardos |
20901a |
+ rpmFlags sdtype;
|
|
Lubos Kardos |
20901a |
+
|
|
Lubos Kardos |
20901a |
+ int entriesCount;
|
|
Lubos Kardos |
20901a |
+ int entriesAlloced;
|
|
Lubos Kardos |
20901a |
+
|
|
Lubos Kardos |
20901a |
+ struct {
|
|
Lubos Kardos |
20901a |
+ struct FileEntry_s defEntry;
|
|
Lubos Kardos |
20901a |
+ struct FileEntry_s curEntry;
|
|
Lubos Kardos |
20901a |
+ } *entries;
|
|
Lubos Kardos |
20901a |
+
|
|
Lubos Kardos |
20901a |
+} * specialDir;
|
|
Lubos Kardos |
20901a |
+
|
|
Lubos Kardos |
20901a |
typedef struct FileRecords_s {
|
|
Lubos Kardos |
20901a |
FileListRec recs;
|
|
Lubos Kardos |
20901a |
int alloced;
|
|
Lubos Kardos |
20901a |
@@ -169,6 +178,22 @@ static void dupAttrRec(const AttrRec oar, AttrRec nar)
|
|
Lubos Kardos |
20901a |
*nar = *oar; /* struct assignment */
|
|
Lubos Kardos |
20901a |
}
|
|
Lubos Kardos |
20901a |
|
|
Lubos Kardos |
20901a |
+static void copyFileEntry(FileEntry src, FileEntry dest)
|
|
Lubos Kardos |
20901a |
+{
|
|
Lubos Kardos |
20901a |
+ /* Copying struct makes just shallow copy */
|
|
Lubos Kardos |
20901a |
+ *dest = *src;
|
|
Lubos Kardos |
20901a |
+
|
|
Lubos Kardos |
20901a |
+ /* Do also deep copying */
|
|
Lubos Kardos |
20901a |
+ if (src->langs != NULL) {
|
|
Lubos Kardos |
20901a |
+ dest->langs = argvNew();
|
|
Lubos Kardos |
20901a |
+ argvAppend(&dest->langs, src->langs);
|
|
Lubos Kardos |
20901a |
+ }
|
|
Lubos Kardos |
20901a |
+
|
|
Lubos Kardos |
20901a |
+ if (src->caps != NULL) {
|
|
Lubos Kardos |
20901a |
+ dest->caps = xstrdup(src->caps);
|
|
Lubos Kardos |
20901a |
+ }
|
|
Lubos Kardos |
20901a |
+}
|
|
Lubos Kardos |
20901a |
+
|
|
Lubos Kardos |
20901a |
static void FileEntryFree(FileEntry entry)
|
|
Lubos Kardos |
20901a |
{
|
|
Lubos Kardos |
20901a |
argvFree(entry->langs);
|
|
Lubos Kardos |
20901a |
@@ -1683,22 +1708,47 @@ static char * getSpecialDocDir(Header h, rpmFlags sdtype)
|
|
Lubos Kardos |
20901a |
return res;
|
|
Lubos Kardos |
20901a |
}
|
|
Lubos Kardos |
20901a |
|
|
Lubos Kardos |
20901a |
-static specialDir specialDirNew(Header h, rpmFlags sdtype,
|
|
Lubos Kardos |
20901a |
- AttrRec ar, AttrRec def_ar)
|
|
Lubos Kardos |
20901a |
+static specialDir specialDirNew(Header h, rpmFlags sdtype)
|
|
Lubos Kardos |
20901a |
{
|
|
Lubos Kardos |
20901a |
specialDir sd = xcalloc(1, sizeof(*sd));
|
|
Lubos Kardos |
20901a |
- dupAttrRec(ar, &(sd->ar));
|
|
Lubos Kardos |
20901a |
- dupAttrRec(def_ar, &(sd->def_ar));
|
|
Lubos Kardos |
20901a |
+
|
|
Lubos Kardos |
20901a |
+ sd->entriesCount = 0;
|
|
Lubos Kardos |
20901a |
+ sd->entriesAlloced = 10;
|
|
Lubos Kardos |
20901a |
+ sd->entries = xcalloc(sd->entriesAlloced, sizeof(sd->entries[0]));
|
|
Lubos Kardos |
20901a |
+
|
|
Lubos Kardos |
20901a |
sd->dirname = getSpecialDocDir(h, sdtype);
|
|
Lubos Kardos |
20901a |
sd->sdtype = sdtype;
|
|
Lubos Kardos |
20901a |
return sd;
|
|
Lubos Kardos |
20901a |
}
|
|
Lubos Kardos |
20901a |
|
|
Lubos Kardos |
20901a |
+static void addSpecialFile(specialDir sd, const char *path, FileEntry cur,
|
|
Lubos Kardos |
20901a |
+ FileEntry def)
|
|
Lubos Kardos |
20901a |
+{
|
|
Lubos Kardos |
20901a |
+ argvAdd(&sd->files, path);
|
|
Lubos Kardos |
20901a |
+
|
|
Lubos Kardos |
20901a |
+ if (sd->entriesCount >= sd->entriesAlloced) {
|
|
Lubos Kardos |
20901a |
+ sd->entriesAlloced <<= 1;
|
|
Lubos Kardos |
20901a |
+ sd->entries = xrealloc(sd->entries, sd->entriesAlloced *
|
|
Lubos Kardos |
20901a |
+ sizeof(sd->entries[0]));
|
|
Lubos Kardos |
20901a |
+ }
|
|
Lubos Kardos |
20901a |
+
|
|
Lubos Kardos |
20901a |
+ copyFileEntry(cur, &sd->entries[sd->entriesCount].curEntry);
|
|
Lubos Kardos |
20901a |
+ copyFileEntry(def, &sd->entries[sd->entriesCount].defEntry);
|
|
Lubos Kardos |
20901a |
+ sd->entriesCount++;
|
|
Lubos Kardos |
20901a |
+}
|
|
Lubos Kardos |
20901a |
+
|
|
Lubos Kardos |
20901a |
static specialDir specialDirFree(specialDir sd)
|
|
Lubos Kardos |
20901a |
{
|
|
Lubos Kardos |
20901a |
+ int i = 0;
|
|
Lubos Kardos |
20901a |
+
|
|
Lubos Kardos |
20901a |
if (sd) {
|
|
Lubos Kardos |
20901a |
argvFree(sd->files);
|
|
Lubos Kardos |
20901a |
free(sd->dirname);
|
|
Lubos Kardos |
20901a |
+ for (i = 0; i < sd->entriesCount; i++) {
|
|
Lubos Kardos |
20901a |
+ FileEntryFree(&sd->entries[i].curEntry);
|
|
Lubos Kardos |
20901a |
+ FileEntryFree(&sd->entries[i].defEntry);
|
|
Lubos Kardos |
20901a |
+ }
|
|
Lubos Kardos |
20901a |
+ free(sd->entries);
|
|
Lubos Kardos |
20901a |
free(sd);
|
|
Lubos Kardos |
20901a |
}
|
|
Lubos Kardos |
20901a |
return NULL;
|
|
Lubos Kardos |
20901a |
@@ -1712,6 +1762,7 @@ static void processSpecialDir(rpmSpec spec, Package pkg, FileList fl,
|
|
Lubos Kardos |
20901a |
char *mkdocdir = rpmExpand("%{__mkdir_p} $", sdenv, NULL);
|
|
Lubos Kardos |
20901a |
StringBuf docScript = newStringBuf();
|
|
Lubos Kardos |
20901a |
char *basepath, **files;
|
|
Lubos Kardos |
20901a |
+ int fi;
|
|
Lubos Kardos |
20901a |
|
|
Lubos Kardos |
20901a |
appendStringBuf(docScript, sdenv);
|
|
Lubos Kardos |
20901a |
appendStringBuf(docScript, "=$RPM_BUILD_ROOT");
|
|
Lubos Kardos |
20901a |
@@ -1739,16 +1790,9 @@ static void processSpecialDir(rpmSpec spec, Package pkg, FileList fl,
|
|
Lubos Kardos |
20901a |
fl->processingFailed = 1;
|
|
Lubos Kardos |
20901a |
}
|
|
Lubos Kardos |
20901a |
|
|
Lubos Kardos |
20901a |
- /* Reset for %doc */
|
|
Lubos Kardos |
20901a |
- FileEntryFree(&fl->cur);
|
|
Lubos Kardos |
20901a |
-
|
|
Lubos Kardos |
20901a |
- fl->cur.attrFlags |= sd->sdtype;
|
|
Lubos Kardos |
20901a |
- fl->cur.verifyFlags = fl->def.verifyFlags;
|
|
Lubos Kardos |
20901a |
- dupAttrRec(&(sd->ar), &(fl->cur.ar));
|
|
Lubos Kardos |
20901a |
- dupAttrRec(&(sd->def_ar), &(fl->def.ar));
|
|
Lubos Kardos |
20901a |
-
|
|
Lubos Kardos |
20901a |
basepath = rpmGenPath(spec->rootDir, "%{_builddir}", spec->buildSubdir);
|
|
Lubos Kardos |
20901a |
files = sd->files;
|
|
Lubos Kardos |
20901a |
+ fi = 0;
|
|
Lubos Kardos |
20901a |
while (*files != NULL) {
|
|
Lubos Kardos |
20901a |
char *origfile = rpmGenPath(basepath, *files, NULL);
|
|
Lubos Kardos |
20901a |
char *eorigfile = rpmEscapeSpaces(origfile);
|
|
Lubos Kardos |
20901a |
@@ -1756,6 +1800,12 @@ static void processSpecialDir(rpmSpec spec, Package pkg, FileList fl,
|
|
Lubos Kardos |
20901a |
int globFilesCount, i;
|
|
Lubos Kardos |
20901a |
char *newfile;
|
|
Lubos Kardos |
20901a |
|
|
Lubos Kardos |
20901a |
+ FileEntryFree(&fl->cur);
|
|
Lubos Kardos |
20901a |
+ FileEntryFree(&fl->def);
|
|
Lubos Kardos |
20901a |
+ copyFileEntry(&sd->entries[fi].curEntry, &fl->cur);
|
|
Lubos Kardos |
20901a |
+ copyFileEntry(&sd->entries[fi].defEntry, &fl->def);
|
|
Lubos Kardos |
20901a |
+ fi++;
|
|
Lubos Kardos |
20901a |
+
|
|
Lubos Kardos |
20901a |
if (rpmGlob(eorigfile, &globFilesCount, &globFiles) == 0) {
|
|
Lubos Kardos |
20901a |
for (i = 0; i < globFilesCount; i++) {
|
|
Lubos Kardos |
20901a |
rasprintf(&newfile, "%s/%s", sd->dirname, basename(globFiles[i]));
|
|
Lubos Kardos |
20901a |
@@ -1773,6 +1823,10 @@ static void processSpecialDir(rpmSpec spec, Package pkg, FileList fl,
|
|
Lubos Kardos |
20901a |
}
|
|
Lubos Kardos |
20901a |
free(basepath);
|
|
Lubos Kardos |
20901a |
|
|
Lubos Kardos |
20901a |
+ FileEntryFree(&fl->cur);
|
|
Lubos Kardos |
20901a |
+ FileEntryFree(&fl->def);
|
|
Lubos Kardos |
20901a |
+ copyFileEntry(&sd->entries[0].defEntry, &fl->def);
|
|
Lubos Kardos |
20901a |
+ copyFileEntry(&sd->entries[0].defEntry, &fl->cur);
|
|
Lubos Kardos |
20901a |
fl->cur.isDir = 1;
|
|
Lubos Kardos |
20901a |
(void) processBinaryFile(pkg, fl, sd->dirname);
|
|
Lubos Kardos |
20901a |
|
|
Lubos Kardos |
20901a |
@@ -1867,10 +1921,9 @@ static rpmRC processPackageFiles(rpmSpec spec, rpmBuildPkgFlags pkgFlags,
|
|
Lubos Kardos |
20901a |
|
|
Lubos Kardos |
20901a |
/* save attributes on first special doc/license for later use */
|
|
Lubos Kardos |
20901a |
if (*sdp == NULL) {
|
|
Lubos Kardos |
20901a |
- *sdp = specialDirNew(pkg->header, oattrs,
|
|
Lubos Kardos |
20901a |
- &fl.cur.ar, &fl.def.ar);
|
|
Lubos Kardos |
20901a |
+ *sdp = specialDirNew(pkg->header, oattrs);
|
|
Lubos Kardos |
20901a |
}
|
|
Lubos Kardos |
20901a |
- argvAdd(&(*sdp)->files, *fn);
|
|
Lubos Kardos |
20901a |
+ addSpecialFile(*sdp, *fn, &fl.cur, &fl.def);
|
|
Lubos Kardos |
20901a |
continue;
|
|
Lubos Kardos |
20901a |
}
|
|
Lubos Kardos |
20901a |
|
|
Lubos Kardos |
20901a |
--
|
|
Lubos Kardos |
20901a |
1.9.3
|
|
Lubos Kardos |
20901a |
|