Add debugsource recommends to debuginfo packages.

Debuginfo packages are useful without debugsource files. But it is often
useful to also have the debugsource 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).

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 <mark@klomp.org>
This commit is contained in:
Mark Wielaard 2017-09-21 17:01:50 +02:00 committed by Panu Matilainen
parent 8a2eed2211
commit ec0d4d80d8
2 changed files with 76 additions and 3 deletions

View File

@ -2773,6 +2773,9 @@ static void patchDebugPackageString(Package dbg, rpmTag tag, Package pkg, Packag
_free(newsubst);
}
/* Early prototype for use in filterDebuginfoPackage. */
static void addPackageDeps(Package from, Package to, enum rpmTag_e tag);
/* create a new debuginfo subpackage for package pkg from the
* main debuginfo package */
static Package cloneDebuginfoPackage(rpmSpec spec, Package pkg, Package maindbg)
@ -2805,7 +2808,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 +2918,9 @@ 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). */
addPackageDeps(dbg, dbgsrc ? dbgsrc : maindbg,
RPMTAG_RECOMMENDNAME);
}
}
}
@ -2976,6 +2983,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)
@ -3009,6 +3026,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);
@ -3039,6 +3059,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)
addPackageDeps(dbgpkg, dbgsrcpkg, RPMTAG_RECOMMENDNAME);
}
for (pkg = spec->packages; pkg != NULL; pkg = pkg->next) {
@ -3056,6 +3082,8 @@ rpmRC processBinaryFiles(rpmSpec spec, rpmBuildPkgFlags pkgFlags,
deplink = extradbg;
if (addDebugSrc(extradbg, buildroot))
deplink = extradbg;
if (dbgsrcpkg != NULL)
addPackageDeps(extradbg, dbgsrcpkg, RPMTAG_RECOMMENDNAME);
maindbg = NULL; /* all normal packages processed */
}
@ -3072,7 +3100,8 @@ 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)
addPackageDeps(pkg, deplink, RPMTAG_REQUIRENAME);

View File

@ -896,15 +896,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
@ -1036,6 +1041,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
@ -1049,12 +1059,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
@ -1110,6 +1127,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
@ -1123,12 +1145,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
@ -1170,6 +1199,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
@ -1184,6 +1217,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
@ -1197,12 +1234,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