From 3b630e456581ad1969337749eec24a421a3c6a8ead2f87d7782a92470e1f1f90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Schr=C3=B6der?= Date: Wed, 22 Mar 2017 11:56:38 +0000 Subject: [PATCH] Update debugsubpkg.diff OBS-URL: https://build.opensuse.org/package/show/Base:System/rpm?expand=0&rev=386 --- debugsubpkg.diff | 219 +++++++++++++++++------------------------------ 1 file changed, 80 insertions(+), 139 deletions(-) diff --git a/debugsubpkg.diff b/debugsubpkg.diff index 21bb36d..19e20bb 100644 --- a/debugsubpkg.diff +++ b/debugsubpkg.diff @@ -1,9 +1,7 @@ Create a debuginfo package for each subpackage. -Index: build/files.c -=================================================================== ---- build/files.c.orig 2017-02-16 10:52:49.292092380 +0100 -+++ build/files.c 2017-02-22 15:17:39.066161045 +0100 +--- ./build/files.c.orig 2017-02-16 09:52:49.292092380 +0000 ++++ ./build/files.c 2017-03-22 11:55:13.814882170 +0000 @@ -21,6 +21,10 @@ #include #include @@ -15,7 +13,7 @@ Index: build/files.c #include "rpmio/rpmio_internal.h" /* XXX rpmioSlurp */ #include "misc/fts.h" #include "lib/rpmfi_internal.h" /* XXX fi->apath */ -@@ -2155,13 +2159,298 @@ exit: +@@ -2155,13 +2159,301 @@ exit: return rc; } @@ -178,7 +176,6 @@ Index: build/files.c + +static Package processDebuginfo(rpmSpec spec, Package pkg, char *buildroot) +{ -+ static int handled_dwz = 1; + const char *a; + + elf_version(EV_CURRENT); @@ -233,47 +230,8 @@ Index: build/files.c + directory. */ + if (!seen_build_id) + { ++ seen_build_id = 1; + argvAdd(&files, "%dir /usr/lib/debug/.build-id"); -+ if (!handled_dwz) -+ { -+ handled_dwz = 1; -+ /* For now put the shared data from .dwz into the -+ first package we process. -+ ??? Ideally we do this in a postprocessing -+ step after building all -debuginfo packages. */ -+ snprintf(tmp, 1024, "%s%s", buildroot, -+ "/usr/lib/debug/.dwz"); -+ if (lstat(tmp, &sbuf) == 0 && S_ISDIR(sbuf.st_mode)) -+ { -+ DIR *d; -+ struct dirent *de; -+ argvAdd(&files, "/usr/lib/debug/.dwz"); -+ d = opendir (tmp); -+ while ((de = readdir (d))) -+ { -+ unsigned char *build_id2 = NULL; -+ size_t build_id_size2 = 0; -+ snprintf(tmp, 1024, -+ "%s/usr/lib/debug/.dwz/%s", -+ buildroot, de->d_name); -+ if (lstat(tmp, &sbuf) == -1 -+ || ! S_ISREG(sbuf.st_mode)) -+ continue; -+ if (getELFBuildId(tmp, &build_id2, -+ &build_id_size2) == -1) -+ continue; -+ snprintf(tmp, 1024, -+ "/usr/lib/debug/.build-id/%02x/", -+ build_id2[0]); -+ for (i = 1; i < build_id_size2; ++i) -+ sprintf(tmp + strlen(tmp), "%02x", build_id2[i]); -+ sprintf(tmp + strlen(tmp), ".debug"); -+ argvAdd(&files, tmp); -+ free (build_id2); -+ } -+ closedir (d); -+ } -+ } + } + + /* From the build-id construct the two links pointing back @@ -296,6 +254,49 @@ Index: build/files.c + } + return NULL; +} ++ ++ ++static char *addDebugDWZ(ARGV_t *filesp, char *buildroot) ++{ ++ char tmp[1024]; ++ struct stat sbuf; ++ char *dwz_dbg_buildid = NULL; ++ DIR *d; ++ struct dirent *de; ++ ++ snprintf(tmp, 1024, "%s%s", buildroot, "/usr/lib/debug/.dwz"); ++ if (lstat(tmp, &sbuf) == 0 && S_ISDIR(sbuf.st_mode)) ++ return NULL; ++ d = opendir(tmp); ++ if (!d) ++ return NULL; ++ ++ argvAdd(filesp, "/usr/lib/debug/.dwz"); ++ while ((de = readdir (d))) { ++ unsigned char *build_id = NULL; ++ size_t build_id_size = 0; ++ ++ snprintf(tmp, 1024, "%s/usr/lib/debug/.dwz/%s", buildroot, de->d_name); ++ if (lstat(tmp, &sbuf) == -1 || !S_ISREG(sbuf.st_mode)) ++ continue; ++ if (getELFBuildId(tmp, &build_id, &build_id_size) == -1) ++ continue; ++ snprintf(tmp, 1024, "/usr/lib/debug/.build-id/%02x/", build_id[0]); ++ for (i = 1; i < build_id_size; ++i) ++ sprintf(tmp + strlen(tmp), "%02x", build_id[i]); ++ sprintf(tmp + strlen(tmp), ".debug"); ++ argvAdd(filesp, tmp); ++ if (!dwz_dbg_buildid) { ++ for (i = 0; i < build_id_size; ++i) ++ sprintf(tmp + 2 * i, "%02x", build_id[i]); ++ dwz_dbg_buildid = xstrdup(tmp); ++ } ++ free(build_id); ++ } ++ closedir(d); ++ return dwz_dbg_buildid; ++} ++ +#endif + rpmRC processBinaryFiles(rpmSpec spec, rpmBuildPkgFlags pkgFlags, @@ -307,108 +308,49 @@ Index: build/files.c + Package first_dbg = NULL, dwz_dbg = NULL; + int processing_dbg = 0; + int main_pkg_got_dbg = 0; -+ char dwz_dbg_buildid[41] = { '\0' } ; ++ char *dwz_dbg_buildid = NULL; check_fileList = newStringBuf(); + buildroot = rpmGenPath(spec->rootDir, spec->buildRoot, NULL); genSourceRpmName(spec); for (pkg = spec->packages; pkg != NULL; pkg = pkg->next) { -@@ -2171,7 +2460,7 @@ rpmRC processBinaryFiles(rpmSpec spec, r - int arch_color; - - if (pkg->fileList == NULL) -- continue; -+ continue; - - headerPutString(pkg->header, RPMTAG_SOURCERPM, spec->sourceRpmName); - -@@ -2179,8 +2468,90 @@ rpmRC processBinaryFiles(rpmSpec spec, r +@@ -2179,8 +2471,40 @@ rpmRC processBinaryFiles(rpmSpec spec, r rpmlog(RPMLOG_NOTICE, _("Processing files: %s\n"), nvr); free(nvr); - if ((rc = processPackageFiles(spec, pkgFlags, pkg, installSpecialDoc, test)) != RPMRC_OK || - (rc = rpmfcGenerateDepends(spec, pkg)) != RPMRC_OK) +#if HAVE_GELF_H && HAVE_LIBELF -+ if (pkg == first_dbg) -+ { -+ char tmp[1024]; -+ struct stat sbuf; -+ int i; -+ ARGV_t files = NULL; ++ if (pkg == first_dbg) { + /* If we have multiple debug packages then we put + DWZ generated files into %name-debuginfo which + may already exist. Otherwise put the DWZ data + into the only debug package. */ -+ if (! first_dbg->next -+ || main_pkg_got_dbg) -+ files = first_dbg->fileList; -+ + processing_dbg = 1; -+ -+ snprintf(tmp, 1024, "%s%s", buildroot, -+ "/usr/lib/debug/.dwz"); -+ if (lstat(tmp, &sbuf) == 0 && S_ISDIR(sbuf.st_mode)) -+ { -+ DIR *d; -+ struct dirent *de; -+ argvAdd(&files, "/usr/lib/debug/.dwz"); -+ d = opendir (tmp); -+ while ((de = readdir (d))) -+ { -+ unsigned char *build_id = NULL; -+ size_t build_id_size = 0; -+ snprintf(tmp, 1024, -+ "%s/usr/lib/debug/.dwz/%s", -+ buildroot, de->d_name); -+ if (lstat(tmp, &sbuf) == -1 -+ || ! S_ISREG(sbuf.st_mode)) -+ continue; -+ if (getELFBuildId(tmp, &build_id, -+ &build_id_size) == -1) -+ continue; -+ snprintf(tmp, 1024, -+ "/usr/lib/debug/.build-id/%02x/", -+ build_id[0]); -+ sprintf(dwz_dbg_buildid, "%02x", build_id[0]); -+ for (i = 1; i < build_id_size; ++i) -+ { -+ sprintf(tmp + strlen(tmp), "%02x", build_id[i]); -+ sprintf(dwz_dbg_buildid + strlen(dwz_dbg_buildid), -+ "%02x", build_id[i]); -+ } -+ sprintf(tmp + strlen(tmp), ".debug"); -+ argvAdd(&files, tmp); -+ free (build_id); -+ } -+ closedir (d); -+ } -+ if (! first_dbg->next -+ || main_pkg_got_dbg) -+ { -+ first_dbg->fileList = files; ++ if (!first_dbg->next || main_pkg_got_dbg) { ++ dwz_dbg_buildid = addDebugDWZ(&first_dbg->fileList, buildroot); + dwz_dbg = pkg; -+ } -+ else -+ dwz_dbg = addDebuginfoPackage (spec, spec->packages, files); -+ } ++ } else { ++ ARGV_t files = NULL; ++ dwz_dbg_buildid = addDebugDWZ(&files, buildroot); ++ dwz_dbg = addDebuginfoPackage(spec, spec->packages, files); ++ } ++ } +#endif + if ((rc = processPackageFiles(spec, pkgFlags, pkg, installSpecialDoc, test)) != RPMRC_OK) + goto exit; +#if HAVE_GELF_H && HAVE_LIBELF -+ if (! processing_dbg) -+ { ++ if (!processing_dbg) { + Package dbg = processDebuginfo(spec, pkg, buildroot); -+ if (dbg && ! first_dbg) -+ { ++ if (dbg && !first_dbg) { + first_dbg = dbg; + if (pkg == spec->packages) -+ main_pkg_got_dbg = 1; -+ } -+ } ++ main_pkg_got_dbg = 1; ++ } ++ } + /* If we have DWZ info and it is not in PKG then add a requires. */ -+ else if (dwz_dbg_buildid[0] -+ && pkg != dwz_dbg) ++ if (dwz_dbg_buildid && pkg != dwz_dbg) + addReqProv(pkg, RPMTAG_REQUIRENAME, + "debuginfo(build-id)", dwz_dbg_buildid, RPMSENSE_EQUAL, 0); +#endif @@ -416,10 +358,16 @@ Index: build/files.c goto exit; a = headerGetString(pkg->header, RPMTAG_ARCH); -Index: build/parseSpec.c -=================================================================== ---- build/parseSpec.c.orig 2017-02-21 12:39:50.036450319 +0100 -+++ build/parseSpec.c 2017-02-21 12:39:50.072450885 +0100 +@@ -2215,6 +2539,7 @@ rpmRC processBinaryFiles(rpmSpec spec, r + } + exit: + check_fileList = freeStringBuf(check_fileList); ++ _free(dwz_dbg_buildid); + + return rc; + } +--- ./build/parseSpec.c.orig 2017-03-22 11:52:02.332400093 +0000 ++++ ./build/parseSpec.c 2017-03-22 11:52:43.249280459 +0000 @@ -564,7 +564,7 @@ static void initSourceHeader(rpmSpec spe } @@ -429,10 +377,8 @@ Index: build/parseSpec.c { const char *arch, *name; char *evr, *isaprov; -Index: build/rpmbuild_internal.h -=================================================================== ---- build/rpmbuild_internal.h.orig 2017-02-16 10:40:09.788649545 +0100 -+++ build/rpmbuild_internal.h 2017-02-21 12:39:50.072450885 +0100 +--- ./build/rpmbuild_internal.h.orig 2017-02-16 09:40:09.788649545 +0000 ++++ ./build/rpmbuild_internal.h 2017-03-22 11:52:43.249280459 +0000 @@ -442,6 +442,13 @@ int addReqProv(Package pkg, rpmTagVal ta @@ -447,10 +393,8 @@ Index: build/rpmbuild_internal.h * Add rpmlib feature dependency. * @param pkg package * @param feature rpm feature name (i.e. "rpmlib(Foo)" for feature Foo) -Index: macros.in -=================================================================== ---- macros.in.orig 2017-02-21 12:39:50.060450696 +0100 -+++ macros.in 2017-02-21 15:39:02.817639317 +0100 +--- ./macros.in.orig 2017-03-22 11:52:02.335400084 +0000 ++++ ./macros.in 2017-03-22 11:52:43.250280456 +0000 @@ -186,24 +186,10 @@ # Template for debug information sub-package. %debug_package \ @@ -476,10 +420,8 @@ Index: macros.in %description debugsource\ This package provides debug sources for package %{name}.\ Debug sources are useful when developing applications that use this\ -Index: scripts/find-debuginfo.sh -=================================================================== ---- scripts/find-debuginfo.sh.orig 2017-02-21 12:39:50.016450005 +0100 -+++ scripts/find-debuginfo.sh 2017-02-21 15:39:03.265646371 +0100 +--- ./scripts/find-debuginfo.sh.orig 2017-03-22 11:52:02.331400096 +0000 ++++ ./scripts/find-debuginfo.sh 2017-03-22 11:52:43.250280456 +0000 @@ -220,6 +220,11 @@ debug_link() # Provide .2, .3, ... symlinks to all filename instances of this build-id. make_id_dup_link() @@ -517,4 +459,3 @@ Index: scripts/find-debuginfo.sh if [ -s "$SOURCEFILE" ]; then mkdir -p "${RPM_BUILD_ROOT}/usr/src/debug" -