- Fix non-working combination of %lang and %doc directive

- Resolves: #1254483
This commit is contained in:
Lubos Kardos 2016-04-06 11:36:13 +02:00
parent 0b025ec5a1
commit 20901a7b46
2 changed files with 199 additions and 1 deletions

View File

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

View File

@ -29,7 +29,7 @@
Summary: The RPM package management system
Name: rpm
Version: %{rpmver}
Release: %{?snapver:0.%{snapver}.}27%{?dist}
Release: %{?snapver:0.%{snapver}.}28%{?dist}
Group: System Environment/Base
Url: http://www.rpm.org/
Source0: http://rpm.org/releases/rpm-4.12.x/%{name}-%{srcver}.tar.bz2
@ -73,6 +73,7 @@ Patch117: rpm-4.13.0-add-mipsr6-support.patch
Patch118: rpm-4.13.0-Use-pkg-dpaths-during-dependency-generation.patch
Patch119: rpm-4.13.0-Noarch-ExclusiveArch.patch
Patch120: rpm-4.13.0-redirect2null.patch
Patch121: rpm-4.13.0-lang-doc-directives.patch
# These are not yet upstream
Patch302: rpm-4.7.1-geode-i686.patch
@ -584,6 +585,9 @@ exit 0
%doc doc/librpm/html/*
%changelog
* Wed Apr 06 2016 Lubos Kardos <lkardos@redhat.com> 4.13.0-0.rc1.28
- Fix non-working combination of %%lang and %%doc directive (#1254483)
* Thu Mar 10 2016 Lubos Kardos <lkardos@redhat.com> 4.13.0-0.rc1.27
- Add posix.redirect2null (#1287918)