diff options
author | Mark Wielaard <mjw@redhat.com> | 2016-06-14 17:07:12 +0200 |
---|---|---|
committer | Florian Festi <ffesti@redhat.com> | 2016-07-29 18:28:53 +0200 |
commit | bbfe1f86b2e4b5c0bd499d9f3dd9de9c9c20fff2 (patch) | |
tree | 7e6c7e85d9c9edcd9a6bef4e0ec9d1cb4108d4b1 /tests | |
parent | 4ec7c396fb9464a3fcff006408871f8175ab169b (diff) | |
download | rpm-bbfe1f86b2e4b5c0bd499d9f3dd9de9c9c20fff2.tar.gz |
Add build-id links to rpm for all ELF files.
This patch moves the main ELF file build-id symlinks from the
debuginfo package into the main package. And uses different
base directories for the main ELF file build-id symlink.
For the main build-id use /usr/lib/.build-id and for the debug
build-id use /usr/lib/debug/.build-id.
There are two reasons for doing this. The main package and the
debuginfo package might get out of sync, or the debuginfo package
might not be installed at all. In which case finding the main ELF
file through the build-id symlink becomes impossible. Secondly by
moving the main ELF build-id symlink in its own directory the
/usr/lib/debug directory gets populated with only debuginfo files
which is convenient if the user might want to have that directory
populated through a network mountpoint.
To support the new logic the symlink code has been moved from
find-debuginfo.sh to build/files.c.
This also includes support for a new config %_build_id_links that
defaults to compat. The other settings are none, alldebug (the old
style) and separate. compat is like separate, but adds a compatibility
link under /usr/lib/debug/.build-id for the main build-id symlink.
There are several new testcases added to test the various settings
using the new keyword "buildid".
Signed-off-by: Mark Wielaard <mjw@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Makefile.am | 1 | ||||
-rw-r--r-- | tests/data/SPECS/hello2cp.spec | 64 | ||||
-rw-r--r-- | tests/data/SPECS/hello2ln.spec | 63 | ||||
-rw-r--r-- | tests/rpmbuildid.at | 761 | ||||
-rw-r--r-- | tests/rpmtests.at | 1 |
5 files changed, 890 insertions, 0 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am index 779b92fb3..96c05ff44 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -19,6 +19,7 @@ TESTSUITE_AT += rpmquery.at TESTSUITE_AT += rpmverify.at TESTSUITE_AT += rpmdb.at TESTSUITE_AT += rpmbuild.at +TESTSUITE_AT += rpmbuildid.at TESTSUITE_AT += rpmi.at TESTSUITE_AT += rpmvercmp.at TESTSUITE_AT += rpmdeps.at diff --git a/tests/data/SPECS/hello2cp.spec b/tests/data/SPECS/hello2cp.spec new file mode 100644 index 000000000..33d8dc260 --- /dev/null +++ b/tests/data/SPECS/hello2cp.spec @@ -0,0 +1,64 @@ +Summary: hello2 -- double hello, world rpm +Name: hello2 +Version: 1.0 +Release: 1 +Group: Utilities +License: GPL +Distribution: RPM test suite. +Vendor: Red Hat Software +Packager: Red Hat Software <bugs@redhat.com> +URL: http://www.redhat.com +Source0: hello-1.0.tar.gz +Patch0: hello-1.0-modernize.patch +Excludearch: lsi +Excludeos: cpm +Provides: hi +Conflicts: goodbye +Obsoletes: howdy +Prefix: /usr + +%description +Simple rpm demonstration. + +%prep +%setup -q -n hello-1.0 +%patch0 -p1 -b .modernize + +%build +make CFLAGS="-g -O1" +cp hello hello2 + +%install +rm -rf $RPM_BUILD_ROOT +mkdir -p $RPM_BUILD_ROOT/usr/local/bin +make DESTDIR=$RPM_BUILD_ROOT install +cp hello2 $RPM_BUILD_ROOT/usr/local/bin/ + +%clean +rm -rf $RPM_BUILD_ROOT + +%pre + +%post + +%preun + +%postun + +%files +%defattr(-,root,root) +%doc FAQ +#%readme README +#%license COPYING +%attr(0751,root,root) /usr/local/bin/hello +%attr(0751,root,root) /usr/local/bin/hello2 + +%changelog +* Mon Jun 6 2016 Mark Wielaard <mjw@redhat.com> +- Copy hello to hello2 for duplicate build-id testing. + +* Wed May 18 2016 Mark Wielaard <mjw@redhat.com> +- Add hello2 for dwz testing support. + +* Tue Oct 20 1998 Jeff Johnson <jbj@redhat.com> +- create. diff --git a/tests/data/SPECS/hello2ln.spec b/tests/data/SPECS/hello2ln.spec new file mode 100644 index 000000000..2c40dcc32 --- /dev/null +++ b/tests/data/SPECS/hello2ln.spec @@ -0,0 +1,63 @@ +Summary: hello2 -- double hello, world rpm +Name: hello2 +Version: 1.0 +Release: 1 +Group: Utilities +License: GPL +Distribution: RPM test suite. +Vendor: Red Hat Software +Packager: Red Hat Software <bugs@redhat.com> +URL: http://www.redhat.com +Source0: hello-1.0.tar.gz +Patch0: hello-1.0-modernize.patch +Excludearch: lsi +Excludeos: cpm +Provides: hi +Conflicts: goodbye +Obsoletes: howdy +Prefix: /usr + +%description +Simple rpm demonstration. + +%prep +%setup -q -n hello-1.0 +%patch0 -p1 -b .modernize + +%build +make CFLAGS="-g -O1" + +%install +rm -rf $RPM_BUILD_ROOT +mkdir -p $RPM_BUILD_ROOT/usr/local/bin +make DESTDIR=$RPM_BUILD_ROOT install +ln $RPM_BUILD_ROOT/usr/local/bin/hello $RPM_BUILD_ROOT/usr/local/bin/hello2 + +%clean +rm -rf $RPM_BUILD_ROOT + +%pre + +%post + +%preun + +%postun + +%files +%defattr(-,root,root) +%doc FAQ +#%readme README +#%license COPYING +%attr(0751,root,root) /usr/local/bin/hello +%attr(0751,root,root) /usr/local/bin/hello2 + +%changelog +* Mon Jun 6 2016 Mark Wielaard <mjw@redhat.com> +- Hard link hello to hello2 for duplicate build-id testing. + +* Wed May 18 2016 Mark Wielaard <mjw@redhat.com> +- Add hello2 for dwz testing support. + +* Tue Oct 20 1998 Jeff Johnson <jbj@redhat.com> +- create. diff --git a/tests/rpmbuildid.at b/tests/rpmbuildid.at new file mode 100644 index 000000000..eddca969b --- /dev/null +++ b/tests/rpmbuildid.at @@ -0,0 +1,761 @@ +# rpmbuildid.at: test rpmbuild buildid symlink support +# +# This file is part of RPM, the RPM Package Manager. +# Copyright (C) 2016 Mark J. Wielaard <mjw@redhat.com> +# +# This file is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# RPM is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +AT_BANNER([RPM buildid tests]) + +# ------------------------------ +# Check if rpmbuild "none" doesn't generates buildid symlinks for hello program +AT_SETUP([rpmbuild buildid none]) +AT_KEYWORDS([build] [debuginfo] [buildid]) +AT_CHECK([ +rm -rf ${TOPDIR} +AS_MKDIR_P(${TOPDIR}/SOURCES) + +# Setup sources +cp "${abs_srcdir}"/data/SOURCES/hello-1.0.tar.gz "${abs_srcdir}"/data/SOURCES/hello-1.0-modernize.patch ${TOPDIR}/SOURCES + +# Build, contains one ELF which should have a buildid. +run rpmbuild \ + --macros=${abs_top_builddir}/macros:${abs_top_builddir}/tests/testing/usr/local/lib/rpm/platform/%{_target_cpu}-%{_target_os}/macros:${top_srcdir}/macros.debug \ + --rcfile=${abs_top_builddir}/rpmrc \ + --define="_build_id_links none" \ + --quiet -ba "${abs_srcdir}"/data/SPECS/hello.spec + +# There should be zero build-id files in both the main and debuginfo package +echo -n "hello build-id files: " +run rpm -ql -p "${TOPDIR}"/RPMS/*/hello-1.0-1.*.rpm \ + | grep /.build-id/ | wc --lines + +echo -n "hello debuginfo build-id files: " +run rpm -ql -p "${TOPDIR}"/RPMS/*/hello-debuginfo-1.0-1.*.rpm \ + | grep /.build-id/ | wc --lines + +], +[0], +[hello build-id files: 0 +hello debuginfo build-id files: 0 +], +[ignore]) +AT_CLEANUP + +# ------------------------------ +# Check if rpmbuild "alldebug" generates debuginfo buildid symlinks +AT_SETUP([rpmbuild buildid alldebug]) +AT_KEYWORDS([build] [debuginfo] [buildid]) +AT_CHECK([ +rm -rf ${TOPDIR} +AS_MKDIR_P(${TOPDIR}/SOURCES) + +# Setup sources +cp "${abs_srcdir}"/data/SOURCES/hello-1.0.tar.gz "${abs_srcdir}"/data/SOURCES/hello-1.0-modernize.patch ${TOPDIR}/SOURCES + +# Build, contains one ELF which should have a buildid. +run rpmbuild \ + --macros=${abs_top_builddir}/macros:${abs_top_builddir}/tests/testing/usr/local/lib/rpm/platform/%{_target_cpu}-%{_target_os}/macros:${top_srcdir}/macros.debug \ + --rcfile=${abs_top_builddir}/rpmrc \ + --define="_build_id_links alldebug" \ + --quiet -ba "${abs_srcdir}"/data/SPECS/hello.spec + +# There should be zero build-id files in the main package +# Main and debug should be in the debuginfo package, +# plus the .build-id/xx subdir, 3 in total. +echo -n "hello build-id files: " +run rpm -ql -p "${TOPDIR}"/RPMS/*/hello-1.0-1.*.rpm \ + | grep /.build-id/ | wc --lines + +echo -n "hello debuginfo build-id files: " +run rpm -ql -p "${TOPDIR}"/RPMS/*/hello-debuginfo-1.0-1.*.rpm \ + | grep /.build-id/ | wc --lines + +# Extract the both packages to check the build-id files link to the +# main and .debug files. +rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello-1.0-1.*.rpm \ + | cpio -diu +rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello-debuginfo-1.0-1.*.rpm \ + | cpio -diu + +# Check there is a build-id symlink for the main file. +main_file=./usr/local/bin/hello +test -f "${main_file}" || echo "No main file ${main_file}" + +# Extract the build-id from the main file +id_main=$(file $main_file | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/') + +id_main_file="./usr/lib/debug/.build-id/${id_main:0:2}/${id_main:2}" +test -L "$id_main_file" || echo "No build-id file $id_main_file" + +canon_main_file=$(readlink -f ${main_file}) + +test -f "$canon_main_file" \ + || echo "Cannot resolve main file ${main_file} -> ${canon_main_file}" + +canon_main_id_file=$(readlink -f ${id_main_file}) + +test -f "$canon_main_id_file" \ + || echo "Cannot resolve main build-id file ${id_main_file} -> ${canon_main_id_file}" + +test "$canon_main_file" = "$canon_main_id_file" \ + || echo "main and build-id file not linked" + +# And check the same for the debug file. +debug_file=./usr/lib/debug/usr/local/bin/hello.debug +test -f "${debug_file}" || echo "No debug file ${debug_file}" + +# Extract the build-id from the .debug file +id_debug=$(file $debug_file | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/') + +test ${id_main} = ${id_debug} || echo "unequal main and debug id" + +id_debug_file="./usr/lib/debug/.build-id/${id_debug:0:2}/${id_debug:2}.debug" +test -L "$id_debug_file" || echo "No build-id file $id_debug_file" + +canon_debug_file=$(readlink -f ${debug_file}) + +test -f "$canon_debug_file" \ + || echo "Cannot resolve debug file ${debug_file} -> ${canon_debug_file}" + +canon_debug_id_file=$(readlink -f ${id_debug_file}) + +test -f "$canon_debug_id_file" \ + || echo "Cannot resolve debug build-id file ${id_debug_file} -> ${canon_debug_id_file}" + +test "$canon_debug_file" = "$canon_debug_id_file" \ + || echo "debug and build-id not linked" +], +[0], +[hello build-id files: 0 +hello debuginfo build-id files: 3 +], +[ignore]) +AT_CLEANUP + +# ------------------------------ +# Check if rpmbuild "separate" generates main and debuginfo buildid symlinks +AT_SETUP([rpmbuild buildid separate]) +AT_KEYWORDS([build] [debuginfo] [buildid]) +AT_CHECK([ +rm -rf ${TOPDIR} +AS_MKDIR_P(${TOPDIR}/SOURCES) + +# Setup sources +cp "${abs_srcdir}"/data/SOURCES/hello-1.0.tar.gz "${abs_srcdir}"/data/SOURCES/hello-1.0-modernize.patch ${TOPDIR}/SOURCES + +# Build, contains one ELF which should have a buildid. +run rpmbuild \ + --macros=${abs_top_builddir}/macros:${abs_top_builddir}/tests/testing/usr/local/lib/rpm/platform/%{_target_cpu}-%{_target_os}/macros:${top_srcdir}/macros.debug \ + --rcfile=${abs_top_builddir}/rpmrc \ + --define="_build_id_links separate" \ + --quiet -ba "${abs_srcdir}"/data/SPECS/hello.spec + +# There should be one build-id files in the main and debuginfo package +# plus the .build-id/xx subdir, 2 in total. +echo -n "hello build-id files: " +run rpm -ql -p "${TOPDIR}"/RPMS/*/hello-1.0-1.*.rpm \ + | grep /.build-id/ | wc --lines + +echo -n "hello debuginfo build-id files: " +run rpm -ql -p "${TOPDIR}"/RPMS/*/hello-debuginfo-1.0-1.*.rpm \ + | grep /.build-id/ | wc --lines + +# Extract the both packages to check the build-id files link to the +# main and .debug files. +rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello-1.0-1.*.rpm \ + | cpio -diu +rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello-debuginfo-1.0-1.*.rpm \ + | cpio -diu + +# Check there is a build-id symlink for the main file. +main_file=./usr/local/bin/hello +test -f "${main_file}" || echo "No main file ${main_file}" + +# Extract the build-id from the main file +id_main=$(file $main_file | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/') + +id_main_file="./usr/lib/.build-id/${id_main:0:2}/${id_main:2}" +test -L "$id_main_file" || echo "No build-id file $id_main_file" + +canon_main_file=$(readlink -f ${main_file}) + +test -f "$canon_main_file" \ + || echo "Cannot resolve main file ${main_file} -> ${canon_main_file}" + +canon_main_id_file=$(readlink -f ${id_main_file}) + +test -f "$canon_main_id_file" \ + || echo "Cannot resolve main build-id file ${id_main_file} -> ${canon_main_id_file}" + +test "$canon_main_file" = "$canon_main_id_file" \ + || echo "main and build-id file not linked" + +# And check the same for the debug file. +debug_file=./usr/lib/debug/usr/local/bin/hello.debug +test -f "${debug_file}" || echo "No debug file ${debug_file}" + +# Extract the build-id from the .debug file +id_debug=$(file $debug_file | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/') + +test ${id_main} = ${id_debug} || echo "unequal main and debug id" + +id_debug_file="./usr/lib/debug/.build-id/${id_debug:0:2}/${id_debug:2}.debug" +test -L "$id_debug_file" || echo "No build-id file $id_debug_file" + +canon_debug_file=$(readlink -f ${debug_file}) + +test -f "$canon_debug_file" \ + || echo "Cannot resolve debug file ${debug_file} -> ${canon_debug_file}" + +canon_debug_id_file=$(readlink -f ${id_debug_file}) + +test -f "$canon_debug_id_file" \ + || echo "Cannot resolve debug build-id file ${id_debug_file} -> ${canon_debug_id_file}" + +test "$canon_debug_file" = "$canon_debug_id_file" \ + || echo "debug and build-id not linked" +], +[0], +[hello build-id files: 2 +hello debuginfo build-id files: 2 +], +[ignore]) +AT_CLEANUP + +# ------------------------------ +# Check if rpmbuild "compat" generates main and debuginfo buildid symlinks +AT_SETUP([rpmbuild buildid compat]) +AT_KEYWORDS([build] [debuginfo] [buildid]) +AT_CHECK([ +rm -rf ${TOPDIR} +AS_MKDIR_P(${TOPDIR}/SOURCES) + +# Setup sources +cp "${abs_srcdir}"/data/SOURCES/hello-1.0.tar.gz "${abs_srcdir}"/data/SOURCES/hello-1.0-modernize.patch ${TOPDIR}/SOURCES + +# Build, contains one ELF which should have a buildid. +run rpmbuild \ + --macros=${abs_top_builddir}/macros:${abs_top_builddir}/tests/testing/usr/local/lib/rpm/platform/%{_target_cpu}-%{_target_os}/macros:${top_srcdir}/macros.debug \ + --rcfile=${abs_top_builddir}/rpmrc \ + --define="_build_id_links compat" \ + --quiet -ba "${abs_srcdir}"/data/SPECS/hello.spec + +# There should be one build-id files in the main and debuginfo package. +# the debuginfo package has one extra main build-id compat symlink +# plus the .build-id/xx subdir, 2 in total in main, 3 in total in debug +echo -n "hello build-id files: " +run rpm -ql -p "${TOPDIR}"/RPMS/*/hello-1.0-1.*.rpm \ + | grep /.build-id/ | wc --lines + +echo -n "hello debuginfo build-id files: " +run rpm -ql -p "${TOPDIR}"/RPMS/*/hello-debuginfo-1.0-1.*.rpm \ + | grep /.build-id/ | wc --lines + +# Extract the both packages to check the build-id files link to the +# main and .debug files. +rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello-1.0-1.*.rpm \ + | cpio -diu +rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello-debuginfo-1.0-1.*.rpm \ + | cpio -diu + +# Check there is a build-id symlink for the main file. +main_file=./usr/local/bin/hello +test -f "${main_file}" || echo "No main file ${main_file}" + +# Extract the build-id from the main file +id_main=$(file $main_file | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/') + +id_main_file="./usr/lib/.build-id/${id_main:0:2}/${id_main:2}" +test -L "$id_main_file" || echo "No build-id file $id_main_file" + +canon_main_file=$(readlink -f ${main_file}) + +test -f "$canon_main_file" \ + || echo "Cannot resolve main file ${main_file} -> ${canon_main_file}" + +canon_main_id_file=$(readlink -f ${id_main_file}) + +test -f "$canon_main_id_file" \ + || echo "Cannot resolve main build-id file ${id_main_file} -> ${canon_main_id_file}" + +test "$canon_main_file" = "$canon_main_id_file" \ + || echo "main and build-id file not linked" + +# And check the same for the debug file. +debug_file=./usr/lib/debug/usr/local/bin/hello.debug +test -f "${debug_file}" || echo "No debug file ${debug_file}" + +# Extract the build-id from the .debug file +id_debug=$(file $debug_file | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/') + +test ${id_main} = ${id_debug} || echo "unequal main and debug id" + +id_debug_file="./usr/lib/debug/.build-id/${id_debug:0:2}/${id_debug:2}.debug" +test -L "$id_debug_file" || echo "No build-id file $id_debug_file" + +canon_debug_file=$(readlink -f ${debug_file}) + +test -f "$canon_debug_file" \ + || echo "Cannot resolve debug file ${debug_file} -> ${canon_debug_file}" + +canon_debug_id_file=$(readlink -f ${id_debug_file}) + +test -f "$canon_debug_id_file" \ + || echo "Cannot resolve debug build-id file ${id_debug_file} -> ${canon_debug_id_file}" + +test "$canon_debug_file" = "$canon_debug_id_file" \ + || echo "debug and build-id not linked" + +# The compat link should also point to the same (indirectly). +id_compat_file="./usr/lib/debug/.build-id/${id_main:0:2}/${id_main:2}" +test -L "$id_compat_file" || echo "No build-id compat file $id_compat_file" + +canon_compat_file=$(readlink -f ${id_compat_file}) + +test -f "$canon_compat_file" \ + || echo "Cannot resolve compat file ${id_compat_file} -> ${canon_compat_file}" + +test "$canon_compat_file" = "$canon_main_file" \ + || echo "compat and build-id not linked" +], +[0], +[hello build-id files: 2 +hello debuginfo build-id files: 3 +], +[ignore]) +AT_CLEANUP + +# ------------------------------ +# Check that (copied) files with duplicate build-ids are handled correctly. +# This should create "numbered" build-id files. +# This is simply the hello example with one binary copied. +AT_SETUP([rpmbuild buildid duplicate alldebug]) +AT_KEYWORDS([build] [debuginfo] [buildid]) +AT_CHECK([ +rm -rf ${TOPDIR} +AS_MKDIR_P(${TOPDIR}/SOURCES) + +cp "${abs_srcdir}"/data/SOURCES/hello-1.0.tar.gz "${abs_srcdir}"/data/SOURCES/hello-1.0-modernize.patch ${TOPDIR}/SOURCES + +# Should create two warnings +run rpmbuild --quiet \ + --macros=${abs_top_builddir}/macros:${abs_top_builddir}/tests/testing/usr/local/lib/rpm/platform/%{_target_cpu}-%{_target_os}/macros:${top_srcdir}/macros.debug \ + --rcfile=${abs_top_builddir}/rpmrc \ + --define="_build_id_links alldebug" \ + -ba "${abs_srcdir}"/data/SPECS/hello2cp.spec 2>&1 | grep "^warning: " \ + | cut -f1-3 -d' ' + +rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello2-1.0-1.*.rpm \ + | cpio -diu --quiet + +hello_file=./usr/local/bin/hello + +# Extract the build-id from the main file +id=$(file $hello_file | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/') + +# alldebug not here... +id_file="./usr/lib/debug/.build-id/${id:0:2}/${id:2}" +test -L "$id_file" && echo "main id in main package" +id_dup_file="./usr/lib/debug/.build-id/${id:0:2}/${id:2}.1" +test -L "$id_dup_file" && echo "main dup id in main package" + +rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello2-debuginfo-1.0-1.*.rpm \ + | cpio -diu --quiet + +# alldebug, so they are all here +test -L "$id_file" && echo "main id in debug package" +test -L "$id_dup_file" && echo "main dup id in debug package" + +debug_id_file="./usr/lib/debug/.build-id/${id:0:2}/${id:2}.debug" +test -L "$debug_id_file" && echo "debug id in debug package" +debug_dup_file="./usr/lib/debug/.build-id/${id:0:2}/${id:2}.1.debug" +test -L "$debug_dup_file" && echo "debug dup id in debug package" + +# We don't know which points to which, but we do know they point +# to different files. +canon_id_file=$(readlink -f ${id_file}) +canon_dup_file=$(readlink -f ${id_dup_file}) +test "$canon_id_file" != "$canon_dup_file" \ + || echo "id and dup same" + +canon_debug_id_file=$(readlink -f ${debug_id_file}) +canon_debug_dup_file=$(readlink -f ${debug_dup_file}) +test "$canon_debug_id_file" != "$canon_debug_dup_file" \ + || echo "debug id and dup same" +], +[0], +[warning: Duplicate build-ids +warning: Duplicate build-ids +main id in debug package +main dup id in debug package +debug id in debug package +debug dup id in debug package +], +[]) +AT_CLEANUP + +# ------------------------------ +# Check that hard linked files are handled correctly. +# Since the hard linked files have duplicate build-ids, +# it should create "numbered" build-id files. +# This is simply the hello example with one binary hard linked. +AT_SETUP([rpmbuild buildid hardlink alldebug]) +AT_KEYWORDS([build] [debuginfo] [buildid]) +AT_CHECK([ +rm -rf ${TOPDIR} +AS_MKDIR_P(${TOPDIR}/SOURCES) + +cp "${abs_srcdir}"/data/SOURCES/hello-1.0.tar.gz "${abs_srcdir}"/data/SOURCES/hello-1.0-modernize.patch ${TOPDIR}/SOURCES + +# No warnings for hard links +run rpmbuild --quiet \ + --macros=${abs_top_builddir}/macros:${abs_top_builddir}/tests/testing/usr/local/lib/rpm/platform/%{_target_cpu}-%{_target_os}/macros:${top_srcdir}/macros.debug \ + --rcfile=${abs_top_builddir}/rpmrc \ + --define="_build_id_links alldebug" \ + -ba "${abs_srcdir}"/data/SPECS/hello2ln.spec 2>&1 | grep "^warning: " \ + | cut -f1-3 -d' ' + +rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello2-1.0-1.*.rpm \ + | cpio -diu --quiet + +hello_file=./usr/local/bin/hello + +# Extract the build-id from the main file +id=$(file $hello_file | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/') + +# alldebug not here... +id_file="./usr/lib/debug/.build-id/${id:0:2}/${id:2}" +test -L "$id_file" && echo "main id in main package" +id_dup_file="./usr/lib/debug/.build-id/${id:0:2}/${id:2}.1" +test -L "$id_dup_file" && echo "main dup id in main package" + +rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello2-debuginfo-1.0-1.*.rpm \ + | cpio -diu --quiet + +# alldebug, so they are all here +test -L "$id_file" && echo "main id in debug package" +test -L "$id_dup_file" && echo "main dup id in debug package" + +debug_id_file="./usr/lib/debug/.build-id/${id:0:2}/${id:2}.debug" +test -L "$debug_id_file" && echo "debug id in debug package" +debug_dup_file="./usr/lib/debug/.build-id/${id:0:2}/${id:2}.1.debug" +test -L "$debug_dup_file" && echo "debug dup id in debug package" + +# We don't know which points to which, but we do know they point +# to different files. +canon_id_file=$(readlink -f ${id_file}) +canon_dup_file=$(readlink -f ${id_dup_file}) +test "$canon_id_file" != "$canon_dup_file" \ + || echo "id and dup same" + +canon_debug_id_file=$(readlink -f ${debug_id_file}) +canon_debug_dup_file=$(readlink -f ${debug_dup_file}) +test "$canon_debug_id_file" != "$canon_debug_dup_file" \ + || echo "debug id and dup same" +], +[0], +[main id in debug package +main dup id in debug package +debug id in debug package +debug dup id in debug package +], +[]) +AT_CLEANUP + +# ------------------------------ +# Check that (copied) files with duplicate build-ids are handled correctly. +# This should create "numbered" build-id files. +# This is simply the hello example with one binary copied. +AT_SETUP([rpmbuild buildid duplicate separate]) +AT_KEYWORDS([build] [debuginfo] [buildid]) +AT_CHECK([ +rm -rf ${TOPDIR} +AS_MKDIR_P(${TOPDIR}/SOURCES) + +cp "${abs_srcdir}"/data/SOURCES/hello-1.0.tar.gz "${abs_srcdir}"/data/SOURCES/hello-1.0-modernize.patch ${TOPDIR}/SOURCES + +# Should create two warnings +run rpmbuild --quiet \ + --macros=${abs_top_builddir}/macros:${abs_top_builddir}/tests/testing/usr/local/lib/rpm/platform/%{_target_cpu}-%{_target_os}/macros:${top_srcdir}/macros.debug \ + --rcfile=${abs_top_builddir}/rpmrc \ + --define="_build_id_links separate" \ + -ba "${abs_srcdir}"/data/SPECS/hello2cp.spec 2>&1 | grep "^warning: " \ + | cut -f1-3 -d' ' + +rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello2-1.0-1.*.rpm \ + | cpio -diu --quiet + +hello_file=./usr/local/bin/hello + +# Extract the build-id from the main file +id=$(file $hello_file | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/') + +# separate build-ids split... +id_file="./usr/lib/.build-id/${id:0:2}/${id:2}" +test -L "$id_file" && echo "main id in main package" +id_dup_file="./usr/lib/.build-id/${id:0:2}/${id:2}.1" +test -L "$id_dup_file" && echo "main dup id in main package" + +rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello2-debuginfo-1.0-1.*.rpm \ + | cpio -diu --quiet + +# seperate, so debug ids are here +debug_id_file="./usr/lib/debug/.build-id/${id:0:2}/${id:2}.debug" +test -L "$debug_id_file" && echo "debug id in debug package" +debug_dup_file="./usr/lib/debug/.build-id/${id:0:2}/${id:2}.1.debug" +test -L "$debug_dup_file" && echo "debug dup id in debug package" + +# We don't know which points to which, but we do know they point +# to different files. +canon_id_file=$(readlink -f ${id_file}) +canon_dup_file=$(readlink -f ${id_dup_file}) +test "$canon_id_file" != "$canon_dup_file" \ + || echo "id and dup same" + +canon_debug_id_file=$(readlink -f ${debug_id_file}) +canon_debug_dup_file=$(readlink -f ${debug_dup_file}) +test "$canon_debug_id_file" != "$canon_debug_dup_file" \ + || echo "debug id and dup same" +], +[0], +[warning: Duplicate build-ids +warning: Duplicate build-ids +main id in main package +main dup id in main package +debug id in debug package +debug dup id in debug package +], +[]) +AT_CLEANUP + +# ------------------------------ +# Check that hard linked files are handled correctly. +# Since the hard linked files have duplicate build-ids, +# it should create "numbered" build-id files. +# This is simply the hello example with one binary hard linked. +AT_SETUP([rpmbuild buildid hardlink separate]) +AT_KEYWORDS([build] [debuginfo] [buildid]) +AT_CHECK([ +rm -rf ${TOPDIR} +AS_MKDIR_P(${TOPDIR}/SOURCES) + +cp "${abs_srcdir}"/data/SOURCES/hello-1.0.tar.gz "${abs_srcdir}"/data/SOURCES/hello-1.0-modernize.patch ${TOPDIR}/SOURCES + +# No warnings for hard links +run rpmbuild --quiet \ + --macros=${abs_top_builddir}/macros:${abs_top_builddir}/tests/testing/usr/local/lib/rpm/platform/%{_target_cpu}-%{_target_os}/macros:${top_srcdir}/macros.debug \ + --rcfile=${abs_top_builddir}/rpmrc \ + --define="_build_id_links separate" \ + -ba "${abs_srcdir}"/data/SPECS/hello2ln.spec 2>&1 | grep "^warning: " \ + | cut -f1-3 -d' ' + +rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello2-1.0-1.*.rpm \ + | cpio -diu --quiet + +hello_file=./usr/local/bin/hello + +# Extract the build-id from the main file +id=$(file $hello_file | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/') + +# separate build-ids split... +id_file="./usr/lib/.build-id/${id:0:2}/${id:2}" +test -L "$id_file" && echo "main id in main package" +id_dup_file="./usr/lib/.build-id/${id:0:2}/${id:2}.1" +test -L "$id_dup_file" && echo "main dup id in main package" + +rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello2-debuginfo-1.0-1.*.rpm \ + | cpio -diu --quiet + +# separate, so debug ids are here +debug_id_file="./usr/lib/debug/.build-id/${id:0:2}/${id:2}.debug" +test -L "$debug_id_file" && echo "debug id in debug package" +debug_dup_file="./usr/lib/debug/.build-id/${id:0:2}/${id:2}.1.debug" +test -L "$debug_dup_file" && echo "debug dup id in debug package" + +# We don't know which points to which, but we do know they point +# to different files. +canon_id_file=$(readlink -f ${id_file}) +canon_dup_file=$(readlink -f ${id_dup_file}) +test "$canon_id_file" != "$canon_dup_file" \ + || echo "id and dup same" + +canon_debug_id_file=$(readlink -f ${debug_id_file}) +canon_debug_dup_file=$(readlink -f ${debug_dup_file}) +test "$canon_debug_id_file" != "$canon_debug_dup_file" \ + || echo "debug id and dup same" +], +[0], +[main id in main package +main dup id in main package +debug id in debug package +debug dup id in debug package +], +[]) +AT_CLEANUP + +# ------------------------------ +# Check that (copied) files with duplicate build-ids are handled correctly. +# This should create "numbered" build-id files. +# This is simply the hello example with one binary copied. +AT_SETUP([rpmbuild buildid duplicate compat]) +AT_KEYWORDS([build] [debuginfo] [buildid]) +AT_CHECK([ +rm -rf ${TOPDIR} +AS_MKDIR_P(${TOPDIR}/SOURCES) + +cp "${abs_srcdir}"/data/SOURCES/hello-1.0.tar.gz "${abs_srcdir}"/data/SOURCES/hello-1.0-modernize.patch ${TOPDIR}/SOURCES + +# Should create two warnings +run rpmbuild --quiet \ + --macros=${abs_top_builddir}/macros:${abs_top_builddir}/tests/testing/usr/local/lib/rpm/platform/%{_target_cpu}-%{_target_os}/macros:${top_srcdir}/macros.debug \ + --rcfile=${abs_top_builddir}/rpmrc \ + --define="_build_id_links compat" \ + -ba "${abs_srcdir}"/data/SPECS/hello2cp.spec 2>&1 | grep "^warning: " \ + | cut -f1-3 -d' ' + +rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello2-1.0-1.*.rpm \ + | cpio -diu --quiet + +hello_file=./usr/local/bin/hello + +# Extract the build-id from the main file +id=$(file $hello_file | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/') + +# compat build-ids split... +id_file="./usr/lib/.build-id/${id:0:2}/${id:2}" +test -L "$id_file" && echo "main id in main package" +id_dup_file="./usr/lib/.build-id/${id:0:2}/${id:2}.1" +test -L "$id_dup_file" && echo "main dup id in main package" + +rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello2-debuginfo-1.0-1.*.rpm \ + | cpio -diu --quiet + +# compat, so main (and debug) ids are (also) here +compat_file="./usr/lib/debug/.build-id/${id:0:2}/${id:2}" +test -L "$compat_file" && echo "compat id in debug package" +compat_dup_file="./usr/lib/debug/.build-id/${id:0:2}/${id:2}.1" +test -L "$compat_dup_file" && echo "compat dup id in debug package" + +debug_id_file="./usr/lib/debug/.build-id/${id:0:2}/${id:2}.debug" +test -L "$debug_id_file" && echo "debug id in debug package" +debug_dup_file="./usr/lib/debug/.build-id/${id:0:2}/${id:2}.1.debug" +test -L "$debug_dup_file" && echo "debug dup id in debug package" + +# We don't know which points to which, but we do know they point +# to different files. +canon_id_file=$(readlink -f ${id_file}) +canon_dup_file=$(readlink -f ${id_dup_file}) +test "$canon_id_file" != "$canon_dup_file" \ + || echo "id and dup same" + +canon_debug_id_file=$(readlink -f ${debug_id_file}) +canon_debug_dup_file=$(readlink -f ${debug_dup_file}) +test "$canon_debug_id_file" != "$canon_debug_dup_file" \ + || echo "debug id and dup same" + +canon_compat_file=$(readlink -f ${compat_file}) +canon_compat_dup_file=$(readlink -f ${compat_dup_file}) +test "$canon_compat_file" != "$canon_compat_dup_file" \ + || echo "compat id and dup same" +], +[0], +[warning: Duplicate build-ids +warning: Duplicate build-ids +main id in main package +main dup id in main package +compat id in debug package +compat dup id in debug package +debug id in debug package +debug dup id in debug package +], +[]) +AT_CLEANUP + +# ------------------------------ +# Check that hard linked files are handled correctly. +# Since the hard linked files have duplicate build-ids, +# it should create "numbered" build-id files. +# This is simply the hello example with one binary hard linked. +AT_SETUP([rpmbuild buildid hardlink compat]) +AT_KEYWORDS([build] [debuginfo] [buildid]) +AT_CHECK([ +rm -rf ${TOPDIR} +AS_MKDIR_P(${TOPDIR}/SOURCES) + +cp "${abs_srcdir}"/data/SOURCES/hello-1.0.tar.gz "${abs_srcdir}"/data/SOURCES/hello-1.0-modernize.patch ${TOPDIR}/SOURCES + +# No warnings for hard links +run rpmbuild --quiet \ + --macros=${abs_top_builddir}/macros:${abs_top_builddir}/tests/testing/usr/local/lib/rpm/platform/%{_target_cpu}-%{_target_os}/macros:${top_srcdir}/macros.debug \ + --rcfile=${abs_top_builddir}/rpmrc \ + --define="_build_id_links compat" \ + -ba "${abs_srcdir}"/data/SPECS/hello2ln.spec 2>&1 | grep "^warning: " \ + | cut -f1-3 -d' ' + +rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello2-1.0-1.*.rpm \ + | cpio -diu --quiet + +hello_file=./usr/local/bin/hello + +# Extract the build-id from the main file +id=$(file $hello_file | sed 's/.*, BuildID[.*]=\(.*\),.*/\1/') + +# compat build-ids split... +id_file="./usr/lib/.build-id/${id:0:2}/${id:2}" +test -L "$id_file" && echo "main id in main package" +id_dup_file="./usr/lib/.build-id/${id:0:2}/${id:2}.1" +test -L "$id_dup_file" && echo "main dup id in main package" + +rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello2-debuginfo-1.0-1.*.rpm \ + | cpio -diu --quiet + +# compat, so main (and debug) ids are (also) here +compat_file="./usr/lib/debug/.build-id/${id:0:2}/${id:2}" +test -L "$compat_file" && echo "compat id in debug package" +compat_dup_file="./usr/lib/debug/.build-id/${id:0:2}/${id:2}.1" +test -L "$compat_dup_file" && echo "compat dup id in debug package" + +debug_id_file="./usr/lib/debug/.build-id/${id:0:2}/${id:2}.debug" +test -L "$debug_id_file" && echo "debug id in debug package" +debug_dup_file="./usr/lib/debug/.build-id/${id:0:2}/${id:2}.1.debug" +test -L "$debug_dup_file" && echo "debug dup id in debug package" + +# We don't know which points to which, but we do know they point +# to different files. +canon_id_file=$(readlink -f ${id_file}) +canon_dup_file=$(readlink -f ${id_dup_file}) +test "$canon_id_file" != "$canon_dup_file" \ + || echo "id and dup same" + +canon_debug_id_file=$(readlink -f ${debug_id_file}) +canon_debug_dup_file=$(readlink -f ${debug_dup_file}) +test "$canon_debug_id_file" != "$canon_debug_dup_file" \ + || echo "debug id and dup same" + +canon_compat_file=$(readlink -f ${compat_file}) +canon_compat_dup_file=$(readlink -f ${compat_dup_file}) +test "$canon_compat_file" != "$canon_compat_dup_file" \ + || echo "compat id and dup same" +], +[0], +[main id in main package +main dup id in main package +compat id in debug package +compat dup id in debug package +debug id in debug package +debug dup id in debug package +], +[]) +AT_CLEANUP
\ No newline at end of file diff --git a/tests/rpmtests.at b/tests/rpmtests.at index b51266a2d..5495cced1 100644 --- a/tests/rpmtests.at +++ b/tests/rpmtests.at @@ -4,6 +4,7 @@ m4_include([rpmverify.at]) m4_include([rpmdb.at]) m4_include([rpmi.at]) m4_include([rpmbuild.at]) +m4_include([rpmbuildid.at]) m4_include([rpmscript.at]) m4_include([rpmvercmp.at]) m4_include([rpmdeps.at]) |