diff --git a/debugsubpkg.diff b/debugsubpkg.diff index 30dde08..21bb36d 100644 --- a/debugsubpkg.diff +++ b/debugsubpkg.diff @@ -1,7 +1,9 @@ Create a debuginfo package for each subpackage. ---- ./build/files.c.orig 2016-10-21 09:44:00.300962089 +0000 -+++ ./build/files.c 2017-01-19 13:01:34.731859805 +0000 +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 @@ -21,6 +21,10 @@ #include #include @@ -13,7 +15,7 @@ Create a debuginfo package for each subpackage. #include "rpmio/rpmio_internal.h" /* XXX rpmioSlurp */ #include "misc/fts.h" #include "lib/rpmfi_internal.h" /* XXX fi->apath */ -@@ -2156,13 +2160,238 @@ exit: +@@ -2155,13 +2159,298 @@ exit: return rc; } @@ -22,7 +24,7 @@ Create a debuginfo package for each subpackage. + allocated *build_id array of size *build_id_size. Returns -1 on + error. */ + -+int ++static int +getELFBuildId (const char *name, + unsigned char **id, size_t *id_size) +{ @@ -70,8 +72,9 @@ Create a debuginfo package for each subpackage. + Elf_Data src = dst; + + gelf_getshdr (s, &shdr); -+ if (shdr.sh_type != SHT_NOTE -+ || !(shdr.sh_flags & SHF_ALLOC)) ++ /* LD creates .note.gnu.build-id with SHF_ALLOC but the DWZ ++ common debuginfo only file only has non-allocated sections. */ ++ if (shdr.sh_type != SHT_NOTE) + continue; + + /* Look for a build-ID note here. */ @@ -139,15 +142,49 @@ Create a debuginfo package for each subpackage. + 0 +}; + -+static void addDebuginfoPackage(rpmSpec spec, Package pkg, char *buildroot) ++/* Add a new debuginfo package based on PKG with FILES. */ ++ ++static Package addDebuginfoPackage(rpmSpec spec, Package pkg, ARGV_t files) +{ ++ const char *name; ++ char tmp[1024]; ++ Package dbg = newPackage(NULL, spec->pool, &spec->packages); ++ name = headerGetString(pkg->header, RPMTAG_NAME); ++ /* Set name, summary and group. */ ++ snprintf(tmp, 1024, "%s-debuginfo", name); ++ headerPutString(dbg->header, RPMTAG_NAME, tmp); ++ snprintf(tmp, 1024, "Debug information for package %s", name); ++ headerPutString(dbg->header, RPMTAG_SUMMARY, tmp); ++ snprintf(tmp, 1024, "This package provides debug information for package %s.\n" ++ "Debug information is useful when developing applications that use this\n" ++ "package or when debugging this package.", name); ++ headerPutString(dbg->header, RPMTAG_DESCRIPTION, tmp); ++ headerPutString(dbg->header, RPMTAG_GROUP, "Development/Debug"); ++ /* Inherit other tags from parent. */ ++ headerCopyTags(spec->packages->header, ++ dbg->header, copyTagsForDebug); ++ ++ /* Add self-provides */ ++ dbg->ds = rpmdsThis(dbg->header, RPMTAG_REQUIRENAME, RPMSENSE_EQUAL); ++ addPackageProvides(dbg); ++ ++ /* Build up the files list. */ ++ dbg->fileList = files; ++ return dbg; ++} ++ ++/* Process the filelist of PKG and see to eventually create a debuginfo ++ packge for it. */ ++ ++static Package processDebuginfo(rpmSpec spec, Package pkg, char *buildroot) ++{ ++ static int handled_dwz = 1; + const char *a; + + elf_version(EV_CURRENT); + a = headerGetString(pkg->header, RPMTAG_ARCH); + if (strcmp(a, "noarch") != 0) + { -+ Package dbg; + rpmfi fi = rpmfilesIter(pkg->cpioList, RPMFI_ITER_FWD); + char tmp[1024]; + const char *name; @@ -195,7 +232,49 @@ Create a debuginfo package for each subpackage. + /* If we see build-id links for the first time add the + directory. */ + if (!seen_build_id) -+ argvAdd(&files, "%dir /usr/lib/debug/.build-id"); ++ { ++ 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 + to the debug information file and the binary. */ @@ -213,30 +292,9 @@ Create a debuginfo package for each subpackage. + /* If there are debuginfo files for this package add a + new debuginfo package. */ + if (files) -+ { -+ dbg = newPackage(NULL, spec->pool, &spec->packages); -+ headerNVR(pkg->header, &name, NULL, NULL); -+ /* Set name, summary and group. */ -+ snprintf(tmp, 1024, "%s-debuginfo", name); -+ headerPutString(dbg->header, RPMTAG_NAME, tmp); -+ snprintf(tmp, 1024, "Debug information for package %s", name); -+ headerPutString(dbg->header, RPMTAG_SUMMARY, tmp); -+ snprintf(tmp, 1024, "This package provides debug information for package %s.\n" -+ "Debug information is useful when developing applications that use this\n" -+ "package or when debugging this package.", name); -+ headerPutString(dbg->header, RPMTAG_DESCRIPTION, tmp); -+ headerPutString(dbg->header, RPMTAG_GROUP, "Development/Debug"); -+ /* Inherit other tags from parent. */ -+ headerCopyTags(pkg->header, dbg->header, copyTagsForDebug); -+ -+ /* Add self-provides */ -+ dbg->ds = rpmdsThis(dbg->header, RPMTAG_REQUIRENAME, RPMSENSE_EQUAL); -+ addPackageProvides(dbg); -+ -+ /* Build up the files list. */ -+ dbg->fileList = files; -+ } ++ return addDebuginfoPackage (spec, pkg, files); + } ++ return NULL; +} +#endif + @@ -246,29 +304,122 @@ Create a debuginfo package for each subpackage. Package pkg; rpmRC rc = RPMRC_OK; + char *buildroot; ++ Package first_dbg = NULL, dwz_dbg = NULL; ++ int processing_dbg = 0; ++ int main_pkg_got_dbg = 0; ++ char dwz_dbg_buildid[41] = { '\0' } ; check_fileList = newStringBuf(); + buildroot = rpmGenPath(spec->rootDir, spec->buildRoot, NULL); genSourceRpmName(spec); for (pkg = spec->packages; pkg != NULL; pkg = pkg->next) { -@@ -2180,8 +2409,12 @@ rpmRC processBinaryFiles(rpmSpec spec, r +@@ -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 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 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; ++ dwz_dbg = pkg; ++ } ++ else ++ 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 -+ addDebuginfoPackage(spec, pkg, buildroot); ++ if (! processing_dbg) ++ { ++ Package dbg = processDebuginfo(spec, pkg, buildroot); ++ if (dbg && ! first_dbg) ++ { ++ first_dbg = dbg; ++ if (pkg == spec->packages) ++ 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) ++ addReqProv(pkg, RPMTAG_REQUIRENAME, ++ "debuginfo(build-id)", dwz_dbg_buildid, RPMSENSE_EQUAL, 0); +#endif + if ((rc = rpmfcGenerateDepends(spec, pkg)) != RPMRC_OK) goto exit; a = headerGetString(pkg->header, RPMTAG_ARCH); ---- ./build/parseSpec.c.orig 2017-01-19 13:01:28.985876261 +0000 -+++ ./build/parseSpec.c 2017-01-19 13:01:34.732859802 +0000 +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 @@ -564,7 +564,7 @@ static void initSourceHeader(rpmSpec spe } @@ -278,8 +429,10 @@ Create a debuginfo package for each subpackage. { const char *arch, *name; char *evr, *isaprov; ---- ./build/rpmbuild_internal.h.orig 2016-10-13 07:12:21.364778540 +0000 -+++ ./build/rpmbuild_internal.h 2017-01-19 13:01:34.732859802 +0000 +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 @@ -442,6 +442,13 @@ int addReqProv(Package pkg, rpmTagVal ta @@ -294,8 +447,10 @@ Create a debuginfo package for each subpackage. * Add rpmlib feature dependency. * @param pkg package * @param feature rpm feature name (i.e. "rpmlib(Foo)" for feature Foo) ---- ./macros.in.orig 2017-01-19 13:01:28.988876252 +0000 -+++ ./macros.in 2017-01-19 13:01:34.733859800 +0000 +Index: macros.in +=================================================================== +--- macros.in.orig 2017-02-21 12:39:50.060450696 +0100 ++++ macros.in 2017-02-21 15:39:02.817639317 +0100 @@ -186,24 +186,10 @@ # Template for debug information sub-package. %debug_package \ @@ -321,8 +476,10 @@ Create a debuginfo package for each subpackage. %description debugsource\ This package provides debug sources for package %{name}.\ Debug sources are useful when developing applications that use this\ ---- ./scripts/find-debuginfo.sh.orig 2017-01-19 13:01:28.983876267 +0000 -+++ ./scripts/find-debuginfo.sh 2017-01-19 13:01:34.733859800 +0000 +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 @@ -220,6 +220,11 @@ debug_link() # Provide .2, .3, ... symlinks to all filename instances of this build-id. make_id_dup_link() @@ -360,3 +517,4 @@ Create a debuginfo package for each subpackage. if [ -s "$SOURCEFILE" ]; then mkdir -p "${RPM_BUILD_ROOT}/usr/src/debug" + diff --git a/macrosin.diff b/macrosin.diff index 1b37ddc..111967d 100644 --- a/macrosin.diff +++ b/macrosin.diff @@ -1,5 +1,7 @@ ---- ./macros.in.orig 2016-10-21 09:47:06.238886221 +0000 -+++ ./macros.in 2017-01-19 12:48:15.414136831 +0000 +Index: macros.in +=================================================================== +--- macros.in.orig 2017-02-16 10:40:09.908649457 +0100 ++++ macros.in 2017-03-06 13:35:44.504200409 +0100 @@ -185,22 +185,22 @@ # Template for debug information sub-package. @@ -45,7 +47,27 @@ # Algorithm to use for generating file checksum digests on build. # If not specified or 0, MD5 is used. -@@ -459,16 +460,22 @@ package or when debugging this package.\ +@@ -448,6 +449,19 @@ package or when debugging this package.\ + # + #%_include_minidebuginfo 1 + ++# Number of debugging information entries (DIEs) above which ++# dwz will stop considering file for multifile optimizations ++# and enter a low memory mode, in which it will optimize ++# in about half the memory needed otherwise. ++%_dwz_low_mem_die_limit 10000000 ++# Number of DIEs above which dwz will stop processing ++# a file altogether. ++%_dwz_max_die_limit 50000000 ++ ++%_find_debuginfo_dwz_opts --run-dwz\\\ ++ --dwz-low-mem-die-limit %{_dwz_low_mem_die_limit}\\\ ++ --dwz-max-die-limit %{_dwz_max_die_limit} ++ + # + # Use internal dependency generator rather than external helpers? + %_use_internal_dependency_generator 1 +@@ -459,16 +473,22 @@ package or when debugging this package.\ # Directories whose contents should be considered as documentation. %__docdir_path %{_datadir}/doc:%{_datadir}/man:%{_datadir}/info:%{_datadir}/gtk-doc/html:%{?_docdir}:%{?_mandir}:%{?_infodir}:%{?_javadocdir}:/usr/doc:/usr/man:/usr/info:/usr/X11R6/man @@ -70,7 +92,7 @@ # # Path to file attribute classifications for automatic dependency -@@ -538,10 +545,10 @@ package or when debugging this package.\ +@@ -538,10 +558,10 @@ package or when debugging this package.\ # Misc BDB tuning options %__dbi_other mp_mmapsize=128Mb mp_size=1Mb @@ -83,7 +105,7 @@ #============================================================================== # ---- GPG/PGP/PGP5 signature macros. -@@ -840,7 +847,7 @@ package or when debugging this package.\ +@@ -840,7 +860,7 @@ package or when debugging this package.\ %_build_vendor %{_host_vendor} %_build_os %{_host_os} %_host @host@ @@ -92,7 +114,7 @@ %_host_cpu @host_cpu@ %_host_vendor @host_vendor@ %_host_os @host_os@ -@@ -1009,6 +1016,183 @@ done \ +@@ -1009,6 +1029,183 @@ done \ %python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; import sys; sys.stdout.write(get_python_lib(1))") %python_version %(%{__python} -c "import sys; sys.stdout.write(sys.version[:3])") @@ -276,7 +298,7 @@ #------------------------------------------------------------------------------ # arch macro for all Intel i?86 compatibile processors # (Note: This macro (and it's analogues) will probably be obsoleted when -@@ -1019,7 +1203,9 @@ done \ +@@ -1019,7 +1216,9 @@ done \ #------------------------------------------------------------------------------ # arch macro for all supported ARM processors @@ -287,7 +309,7 @@ #------------------------------------------------------------------------------ # arch macro for 32-bit MIPS processors -@@ -1174,3 +1360,24 @@ end} +@@ -1174,3 +1373,24 @@ end} # \endverbatim #*/ diff --git a/rpm.changes b/rpm.changes index 14f6798..c688697 100644 --- a/rpm.changes +++ b/rpm.changes @@ -1,3 +1,11 @@ +------------------------------------------------------------------- +Mon Mar 6 12:37:48 UTC 2017 - rguenther@suse.com + +- Tweak debugsubpkg.diff to no longer use obsoleted RPM interfaces + and add support for debuginfo compressed by DWZ. +- Add %_find_debuginfo_dwz_opts and DWZ limits to macrosin.diff. +- Add dwz requires to rpm-build. [fate#322957] + ------------------------------------------------------------------- Wed Mar 1 13:55:51 CET 2017 - mls@suse.de diff --git a/rpm.spec b/rpm.spec index 3e12211..6a354fc 100644 --- a/rpm.spec +++ b/rpm.spec @@ -184,6 +184,7 @@ Requires: binutils Requires: bzip2 Requires: coreutils Requires: diffutils +Requires: dwz Requires: file Requires: findutils Requires: gawk