diff --git a/0001-Make-sure-that-debugsourcefiles.list-is-generated-in.patch b/0001-Make-sure-that-debugsourcefiles.list-is-generated-in.patch deleted file mode 100644 index 5361611..0000000 --- a/0001-Make-sure-that-debugsourcefiles.list-is-generated-in.patch +++ /dev/null @@ -1,32 +0,0 @@ -From 64c70fcdd9751cf1e8d25f1240fa7a0ea4e353fc Mon Sep 17 00:00:00 2001 -From: Mark Wielaard -Date: Wed, 26 Jul 2017 02:37:17 +0200 -Subject: [PATCH] Make sure that debugsourcefiles.list is generated in the - build dir. - -The %_debugsource_template expects the debugsourcefiles.list file -to be in the (current) build dir. Make sure that is always the case -even if find-debuginfo.sh was invoked in a different (sub) directory -by adding the build dir path as explicit argument to -S. - -Signed-off-by: Mark Wielaard ---- - macros.in | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/macros.in b/macros.in -index f71fcc103..d882fa794 100644 ---- a/macros.in -+++ b/macros.in -@@ -185,7 +185,7 @@ - %{?_unique_debug_srcs:--unique-debug-src-base "%{name}-%{VERSION}-%{RELEASE}.%{_arch}"} \\\ - %{?_find_debuginfo_dwz_opts} \\\ - %{?_find_debuginfo_opts} \\\ -- %{?_debugsource_packages:-S debugsourcefiles.list} \\\ -+ %{?_debugsource_packages:-S "%{_builddir}/%{?buildsubdir}/debugsourcefiles.list"} \\\ - "%{_builddir}/%{?buildsubdir}"\ - %{nil} - --- -2.13.3 - diff --git a/0001-remove-duplicated-call-to-strlen.patch b/0001-remove-duplicated-call-to-strlen.patch new file mode 100644 index 0000000..0eb8dab --- /dev/null +++ b/0001-remove-duplicated-call-to-strlen.patch @@ -0,0 +1,24 @@ +From 726e2bb66c16e3a70664185b246de910dc5b9010 Mon Sep 17 00:00:00 2001 +From: Igor Gnatenko +Date: Fri, 28 Jul 2017 14:32:20 +0200 +Subject: [PATCH] remove duplicated call to strlen() + +It is already done few lines above. + +Signed-off-by: Igor Gnatenko +--- + build/files.c | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/build/files.c b/build/files.c +index 9b1d2cd98..2238c2453 100644 +--- a/build/files.c ++++ b/build/files.c +@@ -2764,7 +2764,6 @@ static void filterDebuginfoPackage(rpmSpec spec, Package pkg, + int namel = strlen(name); + + /* strip trailing .debug like in find-debuginfo.sh */ +- namel = strlen(name); + if (namel > 6 && !strcmp(name + namel - 6, ".debug")) + namel -= 6; + diff --git a/0002-store-path-of-excluded-files.patch b/0002-store-path-of-excluded-files.patch new file mode 100644 index 0000000..fca1b27 --- /dev/null +++ b/0002-store-path-of-excluded-files.patch @@ -0,0 +1,64 @@ +From 90007b550cf585c9cb9427e1fd0b2d8f56c9c2b5 Mon Sep 17 00:00:00 2001 +From: Igor Gnatenko +Date: Fri, 28 Jul 2017 14:33:29 +0200 +Subject: [PATCH] store path of excluded files + +We will need this in next commit so we know which files +were excluded and we will exclude respective debug files. + +Signed-off-by: Igor Gnatenko +--- + build/files.c | 6 +++++- + build/rpmbuild_internal.h | 1 + + build/spec.c | 2 ++ + 3 files changed, 8 insertions(+), 1 deletion(-) + +diff --git a/build/files.c b/build/files.c +index 2238c2453..988b3b315 100644 +--- a/build/files.c ++++ b/build/files.c +@@ -1060,7 +1060,11 @@ static void genCpioListAndHeader(FileList fl, Package pkg, int isSrc) + } + + /* Skip files that were marked with %exclude. */ +- if (flp->flags & RPMFILE_EXCLUDE) continue; ++ if (flp->flags & RPMFILE_EXCLUDE) ++ { ++ argvAdd(&pkg->fileExcludeList, flp->diskPath); ++ continue; ++ } + + /* Collect on-disk paths for archive creation */ + pkg->dpaths[npaths++] = xstrdup(flp->diskPath); +diff --git a/build/rpmbuild_internal.h b/build/rpmbuild_internal.h +index 1c3332faf..5978a6d32 100644 +--- a/build/rpmbuild_internal.h ++++ b/build/rpmbuild_internal.h +@@ -118,6 +118,7 @@ struct Package_s { + + ARGV_t fileFile; + ARGV_t fileList; /* If NULL, package will not be written */ ++ ARGV_t fileExcludeList; + ARGV_t removePostfixes; + ARGV_t policyList; + +diff --git a/build/spec.c b/build/spec.c +index 7cb264abd..c33cde7eb 100644 +--- a/build/spec.c ++++ b/build/spec.c +@@ -101,6 +101,7 @@ Package newPackage(const char *name, rpmstrPool pool, Package *pkglist) + p->autoProv = 1; + p->autoReq = 1; + p->fileList = NULL; ++ p->fileExcludeList = NULL; + p->fileFile = NULL; + p->policyList = NULL; + p->pool = rpmstrPoolLink(pool); +@@ -143,6 +144,7 @@ static Package freePackage(Package pkg) + } + + pkg->fileList = argvFree(pkg->fileList); ++ pkg->fileExcludeList = argvFree(pkg->fileExcludeList); + pkg->fileFile = argvFree(pkg->fileFile); + pkg->policyList = argvFree(pkg->policyList); + pkg->removePostfixes = argvFree(pkg->removePostfixes); diff --git a/0003-exclude-respective-debug-files-for-files-which-are-e.patch b/0003-exclude-respective-debug-files-for-files-which-are-e.patch new file mode 100644 index 0000000..ef90f73 --- /dev/null +++ b/0003-exclude-respective-debug-files-for-files-which-are-e.patch @@ -0,0 +1,46 @@ +From 651d9355f6db9f4d1305c25af5a953289dc8ef47 Mon Sep 17 00:00:00 2001 +From: Igor Gnatenko +Date: Fri, 28 Jul 2017 15:21:00 +0200 +Subject: [PATCH] exclude respective debug files for files which are excluded + +Closes: https://github.com/rpm-software-management/rpm/issues/284 +Signed-off-by: Igor Gnatenko +--- + build/files.c | 17 ++++++++++++++++- + 1 file changed, 16 insertions(+), 1 deletion(-) + +diff --git a/build/files.c b/build/files.c +index 988b3b315..a29730998 100644 +--- a/build/files.c ++++ b/build/files.c +@@ -1062,7 +1062,7 @@ static void genCpioListAndHeader(FileList fl, Package pkg, int isSrc) + /* Skip files that were marked with %exclude. */ + if (flp->flags & RPMFILE_EXCLUDE) + { +- argvAdd(&pkg->fileExcludeList, flp->diskPath); ++ argvAdd(&pkg->fileExcludeList, flp->cpioPath); + continue; + } + +@@ -2802,6 +2802,21 @@ static void filterDebuginfoPackage(rpmSpec spec, Package pkg, + } + path = _free(path); + } ++ /* Exclude debug files for files which were excluded in respective non-debug package */ ++ for (ARGV_const_t excl = pkg->fileExcludeList; excl && *excl; excl++) { ++ const char *name = *excl; ++ ++ /* generate path */ ++ rasprintf(&path, "%s%s%s%s.debug", buildroot, DEBUG_LIB_DIR, name, uniquearch); ++ /* Exclude only debuginfo files which actually exist */ ++ if (access(path, F_OK) == 0) { ++ char *line = NULL; ++ rasprintf(&line, "%%exclude %s", path + buildrootlen); ++ argvAdd(&files, line); ++ _free(line); ++ } ++ path = _free(path); ++ } + + /* add collected directories to file list */ + if (dirs) { diff --git a/0004-store-mapping-for-renamed-files.patch b/0004-store-mapping-for-renamed-files.patch new file mode 100644 index 0000000..6350fcf --- /dev/null +++ b/0004-store-mapping-for-renamed-files.patch @@ -0,0 +1,125 @@ +From f1e03904fc7173c772cb5795f6df30591f790b01 Mon Sep 17 00:00:00 2001 +From: Igor Gnatenko +Date: Fri, 28 Jul 2017 18:30:37 +0200 +Subject: [PATCH] store mapping for renamed files + +We will need this in next commit so we know which original name +files had, so we can reference appropriate debug file. + +Signed-off-by: Igor Gnatenko +--- + build/files.c | 40 +++++++++++++++++++++++++++++----------- + build/rpmbuild_internal.h | 12 ++++++++++++ + build/spec.c | 2 ++ + 3 files changed, 43 insertions(+), 11 deletions(-) + +diff --git a/build/files.c b/build/files.c +index a29730998..2387a2e5b 100644 +--- a/build/files.c ++++ b/build/files.c +@@ -50,6 +50,17 @@ + #define DEBUG_ID_DIR "/usr/lib/debug/.build-id" + #define DEBUG_DWZ_DIR "/usr/lib/debug/.dwz" + ++#undef HASHTYPE ++#undef HTKEYTYPE ++#undef HTDATATYPE ++#define HASHTYPE fileRenameHash ++#define HTKEYTYPE const char * ++#define HTDATATYPE char * ++#include "lib/rpmhash.C" ++#undef HASHTYPE ++#undef HTKEYTYPE ++#undef HTDATATYPE ++ + /** + */ + enum specfFlags_e { +@@ -982,19 +993,26 @@ static void genCpioListAndHeader(FileList fl, Package pkg, int isSrc) + } + + /* Adjust paths if needed */ +- if (!isSrc && pkg->removePostfixes) +- for (i = 0, flp = fl->files.recs; i < fl->files.used; i++, flp++) { +- char * cpiopath = flp->cpioPath; +- +- for (ARGV_const_t postfix_p = pkg->removePostfixes; *postfix_p; postfix_p++) { +- int len = strlen(*postfix_p); +- int plen = strlen(cpiopath); +- if (len <= plen && !strncmp(cpiopath+plen-len, *postfix_p, len)) { +- cpiopath[plen-len] = '\0'; +- if (plen-len > 0 && cpiopath[plen-len-1] == '/') { +- cpiopath[plen-len-1] = '\0'; ++ if (!isSrc && pkg->removePostfixes) { ++ pkg->fileRenameMap = fileRenameHashCreate(fl->files.used, ++ rstrhash, strcmp, ++ (fileRenameHashFreeKey)rfree, (fileRenameHashFreeData)rfree); ++ for (i = 0, flp = fl->files.recs; i < fl->files.used; i++, flp++) { ++ char * cpiopath = flp->cpioPath; ++ char * cpiopath_orig = xstrdup(cpiopath); ++ ++ for (ARGV_const_t postfix_p = pkg->removePostfixes; *postfix_p; postfix_p++) { ++ int len = strlen(*postfix_p); ++ int plen = strlen(cpiopath); ++ if (len <= plen && !strncmp(cpiopath+plen-len, *postfix_p, len)) { ++ cpiopath[plen-len] = '\0'; ++ if (plen-len > 0 && cpiopath[plen-len-1] == '/') { ++ cpiopath[plen-len-1] = '\0'; ++ } + } + } ++ if (strcmp(cpiopath_orig, cpiopath)) ++ fileRenameHashAddEntry(pkg->fileRenameMap, xstrdup(cpiopath), cpiopath_orig); + } + } + +diff --git a/build/rpmbuild_internal.h b/build/rpmbuild_internal.h +index 5978a6d32..b4247ae61 100644 +--- a/build/rpmbuild_internal.h ++++ b/build/rpmbuild_internal.h +@@ -6,6 +6,17 @@ + #include + #include "build/rpmbuild_misc.h" + ++#undef HASHTYPE ++#undef HTKEYTYPE ++#undef HTDATATYPE ++#define HASHTYPE fileRenameHash ++#define HTKEYTYPE const char * ++#define HTDATATYPE char * ++#include "lib/rpmhash.H" ++#undef HASHTYPE ++#undef HTKEYTYPE ++#undef HTDATATYPE ++ + struct TriggerFileEntry { + int index; + char * fileName; +@@ -120,6 +131,7 @@ struct Package_s { + ARGV_t fileList; /* If NULL, package will not be written */ + ARGV_t fileExcludeList; + ARGV_t removePostfixes; ++ fileRenameHash fileRenameMap; + ARGV_t policyList; + + Package next; +diff --git a/build/spec.c b/build/spec.c +index c33cde7eb..eaa5dce61 100644 +--- a/build/spec.c ++++ b/build/spec.c +@@ -104,6 +104,7 @@ Package newPackage(const char *name, rpmstrPool pool, Package *pkglist) + p->fileExcludeList = NULL; + p->fileFile = NULL; + p->policyList = NULL; ++ p->fileRenameMap = NULL; + p->pool = rpmstrPoolLink(pool); + p->dpaths = NULL; + +@@ -148,6 +149,7 @@ static Package freePackage(Package pkg) + pkg->fileFile = argvFree(pkg->fileFile); + pkg->policyList = argvFree(pkg->policyList); + pkg->removePostfixes = argvFree(pkg->removePostfixes); ++ pkg->fileRenameMap = fileRenameHashFree(pkg->fileRenameMap); + pkg->cpioList = rpmfilesFree(pkg->cpioList); + pkg->dpaths = argvFree(pkg->dpaths); + diff --git a/0005-reference-proper-debug-files-whenever-RemovePathPost.patch b/0005-reference-proper-debug-files-whenever-RemovePathPost.patch new file mode 100644 index 0000000..d6dbb52 --- /dev/null +++ b/0005-reference-proper-debug-files-whenever-RemovePathPost.patch @@ -0,0 +1,36 @@ +From d145899932ed040cdaaed70a7ce2ea0f11757ab6 Mon Sep 17 00:00:00 2001 +From: Igor Gnatenko +Date: Fri, 28 Jul 2017 18:32:06 +0200 +Subject: [PATCH] reference proper debug files whenever RemovePathPostfixes is + used + +Closes: https://github.com/rpm-software-management/rpm/issues/280 +Signed-off-by: Igor Gnatenko +--- + build/files.c | 13 +++++++++++++ + 1 file changed, 13 insertions(+) + +diff --git a/build/files.c b/build/files.c +index 2387a2e5b..a4b5cd6e8 100644 +--- a/build/files.c ++++ b/build/files.c +@@ -2788,6 +2788,19 @@ static void filterDebuginfoPackage(rpmSpec spec, Package pkg, + /* strip trailing .debug like in find-debuginfo.sh */ + if (namel > 6 && !strcmp(name + namel - 6, ".debug")) + namel -= 6; ++ ++ /* fileRenameMap doesn't necessarily have to be initialized */ ++ if (pkg->fileRenameMap) { ++ char **names = NULL; ++ int namec = 0; ++ fileRenameHashGetEntry(pkg->fileRenameMap, name, &names, &namec, NULL); ++ if (namec) { ++ if (namec > 1) ++ rpmlog(RPMLOG_WARNING, _("%s was mapped to multiple filenames"), name); ++ name = *names; ++ namel = strlen(name); ++ } ++ } + + /* generate path */ + rasprintf(&path, "%s%s%.*s%s.debug", buildroot, DEBUG_LIB_DIR, namel, name, uniquearch); diff --git a/0061-find-debuginfo.sh-make-sure-that-debugsourcefiles.li.patch b/0061-find-debuginfo.sh-make-sure-that-debugsourcefiles.li.patch new file mode 100644 index 0000000..db0ee77 --- /dev/null +++ b/0061-find-debuginfo.sh-make-sure-that-debugsourcefiles.li.patch @@ -0,0 +1,32 @@ +From 56c2885d708bc3485cad2b14205224e082ff2d01 Mon Sep 17 00:00:00 2001 +From: Igor Gnatenko +Date: Fri, 28 Jul 2017 07:42:38 +0200 +Subject: [PATCH] find-debuginfo.sh: make sure that debugsourcefiles.list is + generated under the builddir + +The %_debugsource_template expects the debugsourcefiles.list file +to be in the (current) build dir. Make sure that is always the case +even if find-debuginfo.sh was invoked in a different (sub) directory +by prepending $BUILDDIR to the output file as written in description +"All file names in switches are relative to builddir (. if not given).". + +Closes: https://github.com/rpm-software-management/rpm/issues/279 +Based-on-patch-by: Mark Wielaard +Signed-off-by: Igor Gnatenko +(cherry picked from commit 436b6ce0ddf33f90f8efd967f0457efce23bd71f) +--- + scripts/find-debuginfo.sh | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/scripts/find-debuginfo.sh b/scripts/find-debuginfo.sh +index b83e4c6db..af065cd23 100644 +--- a/scripts/find-debuginfo.sh ++++ b/scripts/find-debuginfo.sh +@@ -566,6 +566,7 @@ if [ -d "${RPM_BUILD_ROOT}/usr/lib" -o -d "${RPM_BUILD_ROOT}/usr/src" ]; then + fi + + if [ -n "$srcout" ]; then ++ srcout="$BUILDDIR/$srcout" + > "$srcout" + if [ -d "${RPM_BUILD_ROOT}/usr/src/debug" ]; then + (cd "${RPM_BUILD_ROOT}/usr" diff --git a/0062-Avoid-redundant-processing-for-RemovePathPostfixes.patch b/0062-Avoid-redundant-processing-for-RemovePathPostfixes.patch new file mode 100644 index 0000000..aa8a4ac --- /dev/null +++ b/0062-Avoid-redundant-processing-for-RemovePathPostfixes.patch @@ -0,0 +1,50 @@ +From c32af0184db82f74bf506873ec9a69970299dd18 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?P=C3=A1draig=20Brady?= +Date: Thu, 19 Nov 2015 13:38:19 +0000 +Subject: [PATCH] Avoid redundant processing for RemovePathPostfixes + +Only iterate over the file list if RemovePathPostfixes: has been specified. +Also don't bother reallocating the paths as the existing path modified in +place will suffice. + +(cherry picked from commit 8e8571a7f33d1ecc5a0c0b62196fd79b26a6052e) +--- + build/files.c | 11 ++--------- + 1 file changed, 2 insertions(+), 9 deletions(-) + +diff --git a/build/files.c b/build/files.c +index 29274926c..9b1d2cd98 100644 +--- a/build/files.c ++++ b/build/files.c +@@ -980,29 +980,22 @@ static void genCpioListAndHeader(FileList fl, Package pkg, int isSrc) + digestalgo); + digestalgo = defaultalgo; + } +- ++ + /* Adjust paths if needed */ ++ if (!isSrc && pkg->removePostfixes) + for (i = 0, flp = fl->files.recs; i < fl->files.used; i++, flp++) { +- int changed = 0; + char * cpiopath = flp->cpioPath; + +- if (!isSrc && pkg->removePostfixes) + for (ARGV_const_t postfix_p = pkg->removePostfixes; *postfix_p; postfix_p++) { + int len = strlen(*postfix_p); + int plen = strlen(cpiopath); + if (len <= plen && !strncmp(cpiopath+plen-len, *postfix_p, len)) { + cpiopath[plen-len] = '\0'; +- changed = 1; + if (plen-len > 0 && cpiopath[plen-len-1] == '/') { + cpiopath[plen-len-1] = '\0'; + } + } + } +- if (changed) { +- char * tmp = xstrdup(cpiopath); +- _free(flp->cpioPath); +- flp->cpioPath = tmp; +- } + } + + /* Sort the big list */ diff --git a/rpm.spec b/rpm.spec index 7c5d09b..56af5fa 100644 --- a/rpm.spec +++ b/rpm.spec @@ -29,7 +29,7 @@ Summary: The RPM package management system Name: rpm Version: %{rpmver} -Release: %{?snapver:0.%{snapver}.}38%{?dist} +Release: %{?snapver:0.%{snapver}.}39%{?dist} Group: System Environment/Base Url: http://www.rpm.org/ Source0: http://ftp.rpm.org/releases/%{srcdir}/%{name}-%{srcver}.tar.bz2 @@ -155,14 +155,24 @@ Patch335: 0059-Fix-error-handling-in-rpmio-Python-binding-test-case.patch # Finally make sure that test results are not ignored ;) Patch340: 0060-Return-error-exit-status-when-make-check-is-failed.patch +# Fix for generation of debugsourcefiles.list in subdirectory +Patch341: 0061-find-debuginfo.sh-make-sure-that-debugsourcefiles.li.patch + +# Trivial improvement for RemovePathPostfixes +Patch342: 0062-Avoid-redundant-processing-for-RemovePathPostfixes.patch + # These are not yet upstream # Enable debugsource and debuginfo subpackages by default Patch900: 0001-macros-enable-debugsource-and-debuginfo-subpkgs-by-d.patch -# Fixes for debugsource/debuginfo-ubspackages -Patch901: 0001-Make-sure-that-debugsourcefiles.list-is-generated-in.patch -Patch902: rpm-4.7.1-geode-i686.patch +# debuginfo_subpackages fixes +Patch901: 0001-remove-duplicated-call-to-strlen.patch +Patch902: 0002-store-path-of-excluded-files.patch +Patch903: 0003-exclude-respective-debug-files-for-files-which-are-e.patch +Patch904: 0004-store-mapping-for-renamed-files.patch +Patch905: 0005-reference-proper-debug-files-whenever-RemovePathPost.patch +Patch906: rpm-4.7.1-geode-i686.patch # Probably to be upstreamed in slightly different form -Patch904: rpm-4.13.90-ldflags.patch +Patch907: rpm-4.13.90-ldflags.patch # Partially GPL/LGPL dual-licensed and some bits with BSD # SourceLicense: (GPLv2+ and LGPLv2+ with exceptions) and BSD @@ -657,6 +667,9 @@ exit 0 %doc doc/librpm/html/* %changelog +* Fri Jul 28 2017 Igor Gnatenko - 4.13.0.1-39 +- Backport fixes for debuginfo subpackages + * Wed Jul 26 2017 Igor Gnatenko - 4.13.0.1-38 - Backport trivial fix for debugsourcefiles.list ending up in random dir