Debuginfo packages are useful without debugsource files. But it is often useful to also have the debugsourc files. So make debuginfo packages that don't contain sources recommend the debugsource package (or the main debuginfo one if the sources are not in a separate debugsource package).
Rename addPackageRequires to addPackageRequiresRecommends with an argument to indicate whether the package is required or recommended. Move up so it can be used with filterDebuginfoPackage. Add Package dbgsrc as argument to filterDebuginfoPackage so it can be added as recommendation. Add a new function findDebugsourcePackage. Use it to add a requires to the main debuginfo file and/or the debuginfo subpackages. Extend the various rpmbuild.at tests that create debugsource and/or debuginfo subpackages to check the debugsource (or main debuginfo) package is recommended. Signed-off-by: Mark Wielaard <m...@klomp.org> --- build/files.c | 59 ++++++++++++++++++++++++++++++++++++++++--------------- tests/rpmbuild.at | 46 ++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 88 insertions(+), 17 deletions(-) diff --git a/build/files.c b/build/files.c index 5e84532..86ec80a 100644 --- a/build/files.c +++ b/build/files.c @@ -2773,6 +2773,21 @@ static void patchDebugPackageString(Package dbg, rpmTag tag, Package pkg, Packag _free(newsubst); } +/* add a requires or recommends for package "to" into package "from". */ +static void addPackageRequiresRecommends(Package from, Package to, + bool recommends) +{ + const char *name; + char *evr, *isaprov; + enum rpmTag_e tag = recommends ? RPMTAG_RECOMMENDNAME : RPMTAG_REQUIRENAME; + name = headerGetString(to->header, RPMTAG_NAME); + evr = headerGetAsString(to->header, RPMTAG_EVR); + isaprov = rpmExpand(name, "%{?_isa}", NULL); + addReqProv(from, tag, isaprov, evr, RPMSENSE_EQUAL, 0); + free(isaprov); + free(evr); +} + /* create a new debuginfo subpackage for package pkg from the * main debuginfo package */ static Package cloneDebuginfoPackage(rpmSpec spec, Package pkg, Package maindbg) @@ -2805,7 +2820,8 @@ static Package cloneDebuginfoPackage(rpmSpec spec, Package pkg, Package maindbg) /* collect the debug files for package pkg and put them into * a (possibly new) debuginfo subpackage */ static void filterDebuginfoPackage(rpmSpec spec, Package pkg, - Package maindbg, char *buildroot, char *uniquearch) + Package maindbg, Package dbgsrc, + char *buildroot, char *uniquearch) { rpmfi fi; ARGV_t files = NULL; @@ -2914,6 +2930,8 @@ static void filterDebuginfoPackage(rpmSpec spec, Package pkg, else { Package dbg = cloneDebuginfoPackage(spec, pkg, maindbg); dbg->fileList = files; + /* Recommend the debugsource package (or the main debuginfo). */ + addPackageRequiresRecommends(dbg, dbgsrc ?: maindbg, true); } } } @@ -2976,6 +2994,16 @@ static int addDebugSrc(Package pkg, char *buildroot) return ret; } +/* find the debugsource package, if it has been created. + * We do this simply by searching for a package with the right name. */ +static Package findDebugsourcePackage(rpmSpec spec) +{ + Package pkg = NULL; + if (lookupPackage(spec, "debugsource", PART_SUBNAME|PART_QUIET, &pkg)) + return NULL; + return pkg && pkg->fileList ? pkg : NULL; +} + /* find the main debuginfo package. We do this simply by * searching for a package with the right name. */ static Package findDebuginfoPackage(rpmSpec spec) @@ -2986,19 +3014,6 @@ static Package findDebuginfoPackage(rpmSpec spec) return pkg && pkg->fileList ? pkg : NULL; } -/* add a requires for package "to" into package "from". */ -static void addPackageRequires(Package from, Package to) -{ - const char *name; - char *evr, *isaprov; - name = headerGetString(to->header, RPMTAG_NAME); - evr = headerGetAsString(to->header, RPMTAG_EVR); - isaprov = rpmExpand(name, "%{?_isa}", NULL); - addReqProv(from, RPMTAG_REQUIRENAME, isaprov, evr, RPMSENSE_EQUAL, 0); - free(isaprov); - free(evr); -} - rpmRC processBinaryFiles(rpmSpec spec, rpmBuildPkgFlags pkgFlags, int didInstall, int test) { @@ -3008,6 +3023,9 @@ rpmRC processBinaryFiles(rpmSpec spec, rpmBuildPkgFlags pkgFlags, char *uniquearch = NULL; Package maindbg = NULL; /* the (existing) main debuginfo package */ Package deplink = NULL; /* create requires to this package */ + /* The debugsource package, if it exists, that the debuginfo package(s) + should Recommend. */ + Package dbgsrcpkg = findDebugsourcePackage(spec); #if HAVE_LIBDW elf_version (EV_CURRENT); @@ -3038,6 +3056,12 @@ rpmRC processBinaryFiles(rpmSpec spec, rpmBuildPkgFlags pkgFlags, if (rpmExpandNumeric("%{?_unique_debug_names}")) uniquearch = rpmExpand("-%{VERSION}-%{RELEASE}.%{_arch}", NULL); } + } else if (dbgsrcpkg != NULL) { + /* We have a debugsource package, but no debuginfo subpackages. + The main debuginfo package should recommend the debugsource one. */ + Package dbgpkg = findDebuginfoPackage(spec); + if (dbgpkg) + addPackageRequiresRecommends(dbgpkg, dbgsrcpkg, true); } for (pkg = spec->packages; pkg != NULL; pkg = pkg->next) { @@ -3055,6 +3079,8 @@ rpmRC processBinaryFiles(rpmSpec spec, rpmBuildPkgFlags pkgFlags, deplink = extradbg; if (addDebugSrc(extradbg, buildroot)) deplink = extradbg; + if (dbgsrcpkg != NULL) + addPackageRequiresRecommends(extradbg, dbgsrcpkg, true); maindbg = NULL; /* all normal packages processed */ } @@ -3071,9 +3097,10 @@ rpmRC processBinaryFiles(rpmSpec spec, rpmBuildPkgFlags pkgFlags, goto exit; if (maindbg) - filterDebuginfoPackage(spec, pkg, maindbg, buildroot, uniquearch); + filterDebuginfoPackage(spec, pkg, maindbg, dbgsrcpkg, + buildroot, uniquearch); else if (deplink && pkg != deplink) - addPackageRequires(pkg, deplink); + addPackageRequiresRecommends(pkg, deplink, false); if ((rc = rpmfcGenerateDepends(spec, pkg)) != RPMRC_OK) goto exit; diff --git a/tests/rpmbuild.at b/tests/rpmbuild.at index 25d9167..fe49b2b 100644 --- a/tests/rpmbuild.at +++ b/tests/rpmbuild.at @@ -856,15 +856,20 @@ run rpmbuild --quiet \ --define "_debugsource_packages 1" \ -ba "${abs_srcdir}"/data/SPECS/hello2.spec -# Unpack the debuginfo rpms so we can check the sources are there. +# Unpack the debugsource rpm so we can check the sources are there. rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello2-debugsource-1.0-1.*.rpm \ | cpio -diu --quiet # Check that hello.c is there. ls ./usr/src/debug/hello2-1.0*/ + +# The debuginfo package should recommend the debugsource package (ignore arch). +echo -n "Recommends: " +rpm -qp --recommends ${abs_builddir}/testing/build/RPMS/*/hello2-debuginfo-1.0-1.*.rpm | sed -E 's/([[-.a-z0-9]]+)\(.*\) = ([[-.0-9]]+)/\1\(ignore-arch\) = \2/' ], [0], [hello.c +Recommends: hello2-debugsource(ignore-arch) = 1.0-1 ], [ignore]) AT_CLEANUP @@ -996,6 +1001,11 @@ else echo "No hello2: $debug_name" fi +# No debugsource package, so sources are in the main debuginfo package. +# Make sure it is recommended. +echo -n "Recommends: " +rpm -qp --recommends ${abs_builddir}/testing/build/RPMS/*/test-test2-debuginfo-1.0-1.*.rpm | sed -E 's/([[-.a-z0-9]]+)\(.*\) = ([[-.0-9]]+)/\1\(ignore-arch\) = \2/' + # Third contains hello3.debug rpm2cpio ${abs_builddir}/testing/build/RPMS/*/test-test3-1.0-1.*.rpm \ | cpio -diu --quiet @@ -1009,12 +1019,19 @@ if test -f ./usr/lib/debug/bin/$debug_name; then else echo "No hello3: $debug_name" fi + +# No debugsource package, so sources are in the main debuginfo package. +# Make sure it is recommended. +echo -n "Recommends: " +rpm -qp --recommends ${abs_builddir}/testing/build/RPMS/*/test-test3-debuginfo-1.0-1.*.rpm | sed -E 's/([[-.a-z0-9]]+)\(.*\) = ([[-.0-9]]+)/\1\(ignore-arch\) = \2/' ], [0], [3 hello debug exists hello2 debug exists +Recommends: test-debuginfo(ignore-arch) = 1.0-1 hello3 debug exists +Recommends: test-debuginfo(ignore-arch) = 1.0-1 ], [ignore]) AT_CLEANUP @@ -1070,6 +1087,11 @@ else echo "No hello2: $debug_name" fi +# No debugsource package, so sources are in the main debuginfo package. +# Make sure it is recommended. +echo -n "Recommends: " +rpm -qp --recommends ${abs_builddir}/testing/build/RPMS/*/test-test2-debuginfo-1.0-1.*.rpm | sed -E 's/([[-.a-z0-9]]+)\(.*\) = ([[-.0-9]]+)/\1\(ignore-arch\) = \2/' + # Third contains hello3.debug rpm2cpio ${abs_builddir}/testing/build/RPMS/*/test-test3-1.0-1.*.rpm \ | cpio -diu --quiet @@ -1083,12 +1105,19 @@ if test -f ./usr/lib/debug/bin/$debug_name; then else echo "No hello3: $debug_name" fi + +# No debugsource package, so sources are in the main debuginfo package. +# Make sure it is recommended. +echo -n "Recommends: " +rpm -qp --recommends ${abs_builddir}/testing/build/RPMS/*/test-test3-debuginfo-1.0-1.*.rpm | sed -E 's/([[-.a-z0-9]]+)\(.*\) = ([[-.0-9]]+)/\1\(ignore-arch\) = \2/' ], [0], [3 hello debug exists hello2 debug exists +Recommends: test-debuginfo(ignore-arch) = 1.0-1 hello3 debug exists +Recommends: test-debuginfo(ignore-arch) = 1.0-1 ], [ignore]) AT_CLEANUP @@ -1130,6 +1159,10 @@ else echo "No hello: $debug_name" fi +# Sources are in debugsource package. Make sure it is recommended. +echo -n "Recommends: " +rpm -qp --recommends ${abs_builddir}/testing/build/RPMS/*/test-debuginfo-1.0-1.*.rpm | sed -E 's/([[-.a-z0-9]]+)\(.*\) = ([[-.0-9]]+)/\1\(ignore-arch\) = \2/' + # Second contains hello2.debug rpm2cpio ${abs_builddir}/testing/build/RPMS/*/test-test2-1.0-1.*.rpm \ | cpio -diu --quiet @@ -1144,6 +1177,10 @@ else echo "No hello2: $debug_name" fi +# Sources are in debugsource package. Make sure it is recommended. +echo -n "Recommends: " +rpm -qp --recommends ${abs_builddir}/testing/build/RPMS/*/test-test2-debuginfo-1.0-1.*.rpm | sed -E 's/([[-.a-z0-9]]+)\(.*\) = ([[-.0-9]]+)/\1\(ignore-arch\) = \2/' + # Third contains hello3.debug rpm2cpio ${abs_builddir}/testing/build/RPMS/*/test-test3-1.0-1.*.rpm \ | cpio -diu --quiet @@ -1157,12 +1194,19 @@ if test -f ./usr/lib/debug/bin/$debug_name; then else echo "No hello3: $debug_name" fi + +# Sources are in debugsource package. Make sure it is recommended. +echo -n "Recommends: " +rpm -qp --recommends ${abs_builddir}/testing/build/RPMS/*/test-test3-debuginfo-1.0-1.*.rpm | sed -E 's/([[-.a-z0-9]]+)\(.*\) = ([[-.0-9]]+)/\1\(ignore-arch\) = \2/' ], [0], [3 hello debug exists +Recommends: test-debugsource(ignore-arch) = 1.0-1 hello2 debug exists +Recommends: test-debugsource(ignore-arch) = 1.0-1 hello3 debug exists +Recommends: test-debugsource(ignore-arch) = 1.0-1 ], [ignore]) AT_CLEANUP -- 1.8.3.1 _______________________________________________ Rpm-maint mailing list Rpm-maint@lists.rpm.org http://lists.rpm.org/mailman/listinfo/rpm-maint