csomh / source-git / rpm

Forked from source-git/rpm 4 years ago
Clone
2ff057
# rpmbuildid.at: test rpmbuild buildid symlink support
2ff057
#
2ff057
# This file is part of RPM, the RPM Package Manager.
2ff057
# Copyright (C) 2016 Mark J. Wielaard <mjw@redhat.com>
2ff057
#
2ff057
# This file is free software; you can redistribute it and/or modify
2ff057
# it under the terms of the GNU General Public License as published by
2ff057
# the Free Software Foundation; either version 2 of the License, or
2ff057
# (at your option) any later version.
2ff057
#
2ff057
# RPM is distributed in the hope that it will be useful, but
2ff057
# WITHOUT ANY WARRANTY; without even the implied warranty of
2ff057
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
2ff057
# GNU General Public License for more details.
2ff057
#
2ff057
# You should have received a copy of the GNU General Public License
2ff057
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
2ff057
2ff057
AT_BANNER([RPM buildid tests])
2ff057
2ff057
# ------------------------------
2ff057
# Check if rpmbuild "none" doesn't generates buildid symlinks for hello program
2ff057
AT_SETUP([rpmbuild buildid none])
2ff057
AT_KEYWORDS([build] [debuginfo] [buildid])
2ff057
AT_CHECK([
2ff057
rm -rf ${TOPDIR}
2ff057
AS_MKDIR_P(${TOPDIR}/SOURCES)
2ff057
2ff057
# Setup sources
2ff057
cp "${abs_srcdir}"/data/SOURCES/hello-1.0.tar.gz "${abs_srcdir}"/data/SOURCES/hello-1.0-modernize.patch ${TOPDIR}/SOURCES
2ff057
2ff057
# Build, contains one ELF which should have a buildid.
2ff057
rundebug rpmbuild \
2ff057
  --define="_build_id_links none" \
2ff057
  --quiet -ba "${abs_srcdir}"/data/SPECS/hello.spec
2ff057
2ff057
# There should be zero build-id files in both the main and debuginfo package
2ff057
echo -n "hello build-id files: "
2ff057
run rpm -ql -p "${TOPDIR}"/RPMS/*/hello-1.0-1.*.rpm \
2ff057
  | grep /.build-id/ | wc --lines
2ff057
2ff057
echo -n "hello debuginfo build-id files: "
2ff057
run rpm -ql -p "${TOPDIR}"/RPMS/*/hello-debuginfo-1.0-1.*.rpm \
2ff057
  | grep /.build-id/ | wc --lines
2ff057
2ff057
],
2ff057
[0],
2ff057
[hello build-id files: 0
2ff057
hello debuginfo build-id files: 0
2ff057
],
2ff057
[ignore])
2ff057
AT_CLEANUP
2ff057
2ff057
# ------------------------------
2ff057
# Check if rpmbuild "alldebug" generates debuginfo buildid symlinks.
2ff057
# Without unique debug file names.
2ff057
AT_SETUP([rpmbuild buildid alldebug])
2ff057
AT_KEYWORDS([build] [debuginfo] [buildid])
2ff057
AT_CHECK([
2ff057
rm -rf ${TOPDIR}
2ff057
AS_MKDIR_P(${TOPDIR}/SOURCES)
2ff057
2ff057
# Setup sources
2ff057
cp "${abs_srcdir}"/data/SOURCES/hello-1.0.tar.gz "${abs_srcdir}"/data/SOURCES/hello-1.0-modernize.patch ${TOPDIR}/SOURCES
2ff057
2ff057
# Build, contains one ELF which should have a buildid.
2ff057
rundebug rpmbuild \
2ff057
  --define="_build_id_links alldebug" \
2ff057
  --undefine "_unique_debug_names" \
2ff057
  --undefine "_unique_debug_srcs" \
2ff057
  --quiet -ba "${abs_srcdir}"/data/SPECS/hello.spec
2ff057
2ff057
# There should be zero build-id files in the main package
2ff057
# Main and debug should be in the debuginfo package,
2ff057
# plus the .build-id/xx subdir, 3 in total.
2ff057
echo -n "hello build-id files: "
2ff057
run rpm -ql -p "${TOPDIR}"/RPMS/*/hello-1.0-1.*.rpm \
2ff057
  | grep /.build-id/ | wc --lines
2ff057
2ff057
echo -n "hello debuginfo build-id files: "
2ff057
run rpm -ql -p "${TOPDIR}"/RPMS/*/hello-debuginfo-1.0-1.*.rpm \
2ff057
  | grep /.build-id/ | wc --lines
2ff057
2ff057
# Extract the both packages to check the build-id files link to the
2ff057
# main and .debug files.
2ff057
rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello-1.0-1.*.rpm \
2ff057
  | cpio -diu
2ff057
rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello-debuginfo-1.0-1.*.rpm \
2ff057
  | cpio -diu
2ff057
2ff057
# Check there is a build-id symlink for the main file.
2ff057
main_file=./usr/local/bin/hello
2ff057
test -f "${main_file}" || echo "No main file ${main_file}"
2ff057
2ff057
# Extract the build-id from the main file
2ff057
id_main=$(file $main_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
2ff057
2ff057
id_main_file="./usr/lib/debug/.build-id/${id_main:0:2}/${id_main:2}"
2ff057
test -L "$id_main_file" || echo "No build-id file $id_main_file"
2ff057
2ff057
canon_main_file=$(readlink -f ${main_file})
2ff057
2ff057
test -f "$canon_main_file" \
2ff057
  || echo "Cannot resolve main file ${main_file} -> ${canon_main_file}"
2ff057
2ff057
canon_main_id_file=$(readlink -f ${id_main_file})
2ff057
2ff057
test -f "$canon_main_id_file" \
2ff057
  || echo "Cannot resolve main build-id file ${id_main_file} -> ${canon_main_id_file}"
2ff057
2ff057
test "$canon_main_file" = "$canon_main_id_file" \
2ff057
  || echo "main and build-id file not linked"
2ff057
2ff057
# And check the same for the debug file.
2ff057
debug_file=./usr/lib/debug/usr/local/bin/hello.debug
2ff057
test -f ${debug_file} || echo "No debug file ${debug_file}"
2ff057
2ff057
# Extract the build-id from the .debug file
2ff057
id_debug=$(file $debug_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
2ff057
2ff057
test ${id_main} = ${id_debug} || echo "unequal main and debug id"
2ff057
2ff057
id_debug_file="./usr/lib/debug/.build-id/${id_debug:0:2}/${id_debug:2}.debug"
2ff057
test -L "$id_debug_file" || echo "No build-id file $id_debug_file"
2ff057
2ff057
canon_debug_file=$(readlink -f ${debug_file})
2ff057
2ff057
test -f "$canon_debug_file" \
2ff057
  || echo "Cannot resolve debug file ${debug_file} -> ${canon_debug_file}"
2ff057
2ff057
canon_debug_id_file=$(readlink -f ${id_debug_file})
2ff057
2ff057
test -f "$canon_debug_id_file" \
2ff057
  || echo "Cannot resolve debug build-id file ${id_debug_file} -> ${canon_debug_id_file}"
2ff057
2ff057
test "$canon_debug_file" = "$canon_debug_id_file" \
2ff057
  || echo "debug and build-id not linked"
2ff057
],
2ff057
[0],
2ff057
[hello build-id files: 0
2ff057
hello debuginfo build-id files: 3
2ff057
],
2ff057
[ignore])
2ff057
AT_CLEANUP
2ff057
2ff057
# ------------------------------
2ff057
# Check if rpmbuild "alldebug" generates debuginfo buildid symlinks.
2ff057
# With unique debug file names.
2ff057
AT_SETUP([rpmbuild buildid alldebug unique debug names])
2ff057
AT_KEYWORDS([build] [debuginfo] [buildid])
2ff057
AT_CHECK([
2ff057
rm -rf ${TOPDIR}
2ff057
AS_MKDIR_P(${TOPDIR}/SOURCES)
2ff057
2ff057
# Setup sources
2ff057
cp "${abs_srcdir}"/data/SOURCES/hello-1.0.tar.gz "${abs_srcdir}"/data/SOURCES/hello-1.0-modernize.patch ${TOPDIR}/SOURCES
2ff057
2ff057
# Build, contains one ELF which should have a buildid.
2ff057
rundebug rpmbuild \
2ff057
  --define="_build_id_links alldebug" \
2ff057
  --define="_unique_debug_names 1" \
2ff057
  --quiet -ba "${abs_srcdir}"/data/SPECS/hello.spec
2ff057
2ff057
# There should be zero build-id files in the main package
2ff057
# Main and debug should be in the debuginfo package,
2ff057
# plus the .build-id/xx subdir, 3 in total.
2ff057
echo -n "hello build-id files: "
2ff057
run rpm -ql -p "${TOPDIR}"/RPMS/*/hello-1.0-1.*.rpm \
2ff057
  | grep /.build-id/ | wc --lines
2ff057
2ff057
echo -n "hello debuginfo build-id files: "
2ff057
run rpm -ql -p "${TOPDIR}"/RPMS/*/hello-debuginfo-1.0-1.*.rpm \
2ff057
  | grep /.build-id/ | wc --lines
2ff057
2ff057
# Extract the both packages to check the build-id files link to the
2ff057
# main and .debug files.
2ff057
rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello-1.0-1.*.rpm \
2ff057
  | cpio -diu
2ff057
rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello-debuginfo-1.0-1.*.rpm \
2ff057
  | cpio -diu
2ff057
2ff057
# Check there is a build-id symlink for the main file.
2ff057
main_file=./usr/local/bin/hello
2ff057
test -f "${main_file}" || echo "No main file ${main_file}"
2ff057
2ff057
# Extract the build-id from the main file
2ff057
id_main=$(file $main_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
2ff057
2ff057
id_main_file="./usr/lib/debug/.build-id/${id_main:0:2}/${id_main:2}"
2ff057
test -L "$id_main_file" || echo "No build-id file $id_main_file"
2ff057
2ff057
canon_main_file=$(readlink -f ${main_file})
2ff057
2ff057
test -f "$canon_main_file" \
2ff057
  || echo "Cannot resolve main file ${main_file} -> ${canon_main_file}"
2ff057
2ff057
canon_main_id_file=$(readlink -f ${id_main_file})
2ff057
2ff057
test -f "$canon_main_id_file" \
2ff057
  || echo "Cannot resolve main build-id file ${id_main_file} -> ${canon_main_id_file}"
2ff057
2ff057
test "$canon_main_file" = "$canon_main_id_file" \
2ff057
  || echo "main and build-id file not linked"
2ff057
2ff057
# And check the same for the debug file.
2ff057
debug_file=./usr/lib/debug/usr/local/bin/hello-*.debug
2ff057
test -f ${debug_file} || echo "No debug file ${debug_file}"
2ff057
2ff057
# Extract the build-id from the .debug file
2ff057
id_debug=$(file $debug_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
2ff057
2ff057
test ${id_main} = ${id_debug} || echo "unequal main and debug id"
2ff057
2ff057
id_debug_file="./usr/lib/debug/.build-id/${id_debug:0:2}/${id_debug:2}.debug"
2ff057
test -L "$id_debug_file" || echo "No build-id file $id_debug_file"
2ff057
2ff057
canon_debug_file=$(readlink -f ${debug_file})
2ff057
2ff057
test -f "$canon_debug_file" \
2ff057
  || echo "Cannot resolve debug file ${debug_file} -> ${canon_debug_file}"
2ff057
2ff057
canon_debug_id_file=$(readlink -f ${id_debug_file})
2ff057
2ff057
test -f "$canon_debug_id_file" \
2ff057
  || echo "Cannot resolve debug build-id file ${id_debug_file} -> ${canon_debug_id_file}"
2ff057
2ff057
test "$canon_debug_file" = "$canon_debug_id_file" \
2ff057
  || echo "debug and build-id not linked"
2ff057
],
2ff057
[0],
2ff057
[hello build-id files: 0
2ff057
hello debuginfo build-id files: 3
2ff057
],
2ff057
[ignore])
2ff057
AT_CLEANUP
2ff057
2ff057
# ------------------------------
2ff057
# Check if rpmbuild "separate" generates main and debuginfo buildid symlinks
2ff057
# Without unique debug file names
2ff057
AT_SETUP([rpmbuild buildid separate])
2ff057
AT_KEYWORDS([build] [debuginfo] [buildid])
2ff057
AT_CHECK([
2ff057
rm -rf ${TOPDIR}
2ff057
AS_MKDIR_P(${TOPDIR}/SOURCES)
2ff057
2ff057
# Setup sources
2ff057
cp "${abs_srcdir}"/data/SOURCES/hello-1.0.tar.gz "${abs_srcdir}"/data/SOURCES/hello-1.0-modernize.patch ${TOPDIR}/SOURCES
2ff057
2ff057
# Build, contains one ELF which should have a buildid.
2ff057
rundebug rpmbuild \
2ff057
  --define="_build_id_links separate" \
2ff057
  --undefine "_unique_debug_names" \
2ff057
  --undefine "_unique_debug_srcs" \
2ff057
  --quiet -ba "${abs_srcdir}"/data/SPECS/hello.spec
2ff057
2ff057
# There should be one build-id files in the main and debuginfo package
2ff057
# plus the .build-id/xx subdir, 2 in total.
2ff057
echo -n "hello build-id files: "
2ff057
run rpm -ql -p "${TOPDIR}"/RPMS/*/hello-1.0-1.*.rpm \
2ff057
  | grep /.build-id/ | wc --lines
2ff057
2ff057
echo -n "hello debuginfo build-id files: "
2ff057
run rpm -ql -p "${TOPDIR}"/RPMS/*/hello-debuginfo-1.0-1.*.rpm \
2ff057
  | grep /.build-id/ | wc --lines
2ff057
2ff057
# Extract the both packages to check the build-id files link to the
2ff057
# main and .debug files.
2ff057
rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello-1.0-1.*.rpm \
2ff057
  | cpio -diu
2ff057
rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello-debuginfo-1.0-1.*.rpm \
2ff057
  | cpio -diu
2ff057
2ff057
# Check there is a build-id symlink for the main file.
2ff057
main_file=./usr/local/bin/hello
2ff057
test -f "${main_file}" || echo "No main file ${main_file}"
2ff057
2ff057
# Extract the build-id from the main file
2ff057
id_main=$(file $main_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
2ff057
2ff057
id_main_file="./usr/lib/.build-id/${id_main:0:2}/${id_main:2}"
2ff057
test -L "$id_main_file" || echo "No build-id file $id_main_file"
2ff057
2ff057
canon_main_file=$(readlink -f ${main_file})
2ff057
2ff057
test -f "$canon_main_file" \
2ff057
  || echo "Cannot resolve main file ${main_file} -> ${canon_main_file}"
2ff057
2ff057
canon_main_id_file=$(readlink -f ${id_main_file})
2ff057
2ff057
test -f "$canon_main_id_file" \
2ff057
  || echo "Cannot resolve main build-id file ${id_main_file} -> ${canon_main_id_file}"
2ff057
2ff057
test "$canon_main_file" = "$canon_main_id_file" \
2ff057
  || echo "main and build-id file not linked"
2ff057
2ff057
# And check the same for the debug file.
2ff057
debug_file=./usr/lib/debug/usr/local/bin/hello.debug
2ff057
test -f ${debug_file} || echo "No debug file ${debug_file}"
2ff057
2ff057
# Extract the build-id from the .debug file
2ff057
id_debug=$(file $debug_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
2ff057
2ff057
test ${id_main} = ${id_debug} || echo "unequal main and debug id"
2ff057
2ff057
id_debug_file="./usr/lib/debug/.build-id/${id_debug:0:2}/${id_debug:2}.debug"
2ff057
test -L "$id_debug_file" || echo "No build-id file $id_debug_file"
2ff057
2ff057
canon_debug_file=$(readlink -f ${debug_file})
2ff057
2ff057
test -f "$canon_debug_file" \
2ff057
  || echo "Cannot resolve debug file ${debug_file} -> ${canon_debug_file}"
2ff057
2ff057
canon_debug_id_file=$(readlink -f ${id_debug_file})
2ff057
2ff057
test -f "$canon_debug_id_file" \
2ff057
  || echo "Cannot resolve debug build-id file ${id_debug_file} -> ${canon_debug_id_file}"
2ff057
2ff057
test "$canon_debug_file" = "$canon_debug_id_file" \
2ff057
  || echo "debug and build-id not linked"
2ff057
],
2ff057
[0],
2ff057
[hello build-id files: 2
2ff057
hello debuginfo build-id files: 2
2ff057
],
2ff057
[ignore])
2ff057
AT_CLEANUP
2ff057
2ff057
# ------------------------------
2ff057
# Check if rpmbuild "separate" generates main and debuginfo buildid symlinks
2ff057
# With unique debug file names
2ff057
AT_SETUP([rpmbuild buildid separate unique debug names])
2ff057
AT_KEYWORDS([build] [debuginfo] [buildid])
2ff057
AT_CHECK([
2ff057
rm -rf ${TOPDIR}
2ff057
AS_MKDIR_P(${TOPDIR}/SOURCES)
2ff057
2ff057
# Setup sources
2ff057
cp "${abs_srcdir}"/data/SOURCES/hello-1.0.tar.gz "${abs_srcdir}"/data/SOURCES/hello-1.0-modernize.patch ${TOPDIR}/SOURCES
2ff057
2ff057
# Build, contains one ELF which should have a buildid.
2ff057
rundebug rpmbuild \
2ff057
  --define="_build_id_links separate" \
2ff057
  --define="_unique_debug_names 1" \
2ff057
  --quiet -ba "${abs_srcdir}"/data/SPECS/hello.spec
2ff057
2ff057
# There should be one build-id files in the main and debuginfo package
2ff057
# plus the .build-id/xx subdir, 2 in total.
2ff057
echo -n "hello build-id files: "
2ff057
run rpm -ql -p "${TOPDIR}"/RPMS/*/hello-1.0-1.*.rpm \
2ff057
  | grep /.build-id/ | wc --lines
2ff057
2ff057
echo -n "hello debuginfo build-id files: "
2ff057
run rpm -ql -p "${TOPDIR}"/RPMS/*/hello-debuginfo-1.0-1.*.rpm \
2ff057
  | grep /.build-id/ | wc --lines
2ff057
2ff057
# Extract the both packages to check the build-id files link to the
2ff057
# main and .debug files.
2ff057
rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello-1.0-1.*.rpm \
2ff057
  | cpio -diu
2ff057
rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello-debuginfo-1.0-1.*.rpm \
2ff057
  | cpio -diu
2ff057
2ff057
# Check there is a build-id symlink for the main file.
2ff057
main_file=./usr/local/bin/hello
2ff057
test -f "${main_file}" || echo "No main file ${main_file}"
2ff057
2ff057
# Extract the build-id from the main file
2ff057
id_main=$(file $main_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
2ff057
2ff057
id_main_file="./usr/lib/.build-id/${id_main:0:2}/${id_main:2}"
2ff057
test -L "$id_main_file" || echo "No build-id file $id_main_file"
2ff057
2ff057
canon_main_file=$(readlink -f ${main_file})
2ff057
2ff057
test -f "$canon_main_file" \
2ff057
  || echo "Cannot resolve main file ${main_file} -> ${canon_main_file}"
2ff057
2ff057
canon_main_id_file=$(readlink -f ${id_main_file})
2ff057
2ff057
test -f "$canon_main_id_file" \
2ff057
  || echo "Cannot resolve main build-id file ${id_main_file} -> ${canon_main_id_file}"
2ff057
2ff057
test "$canon_main_file" = "$canon_main_id_file" \
2ff057
  || echo "main and build-id file not linked"
2ff057
2ff057
# And check the same for the debug file.
2ff057
debug_file=./usr/lib/debug/usr/local/bin/hello-*.debug
2ff057
test -f ${debug_file} || echo "No debug file ${debug_file}"
2ff057
2ff057
# Extract the build-id from the .debug file
2ff057
id_debug=$(file $debug_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
2ff057
2ff057
test ${id_main} = ${id_debug} || echo "unequal main and debug id"
2ff057
2ff057
id_debug_file="./usr/lib/debug/.build-id/${id_debug:0:2}/${id_debug:2}.debug"
2ff057
test -L "$id_debug_file" || echo "No build-id file $id_debug_file"
2ff057
2ff057
canon_debug_file=$(readlink -f ${debug_file})
2ff057
2ff057
test -f "$canon_debug_file" \
2ff057
  || echo "Cannot resolve debug file ${debug_file} -> ${canon_debug_file}"
2ff057
2ff057
canon_debug_id_file=$(readlink -f ${id_debug_file})
2ff057
2ff057
test -f "$canon_debug_id_file" \
2ff057
  || echo "Cannot resolve debug build-id file ${id_debug_file} -> ${canon_debug_id_file}"
2ff057
2ff057
test "$canon_debug_file" = "$canon_debug_id_file" \
2ff057
  || echo "debug and build-id not linked"
2ff057
],
2ff057
[0],
2ff057
[hello build-id files: 2
2ff057
hello debuginfo build-id files: 2
2ff057
],
2ff057
[ignore])
2ff057
AT_CLEANUP
2ff057
2ff057
# ------------------------------
2ff057
# Check if rpmbuild "compat" generates main and debuginfo buildid symlinks
2ff057
# Without unique debug file names
2ff057
AT_SETUP([rpmbuild buildid compat])
2ff057
AT_KEYWORDS([build] [debuginfo] [buildid])
2ff057
AT_CHECK([
2ff057
rm -rf ${TOPDIR}
2ff057
AS_MKDIR_P(${TOPDIR}/SOURCES)
2ff057
2ff057
# Setup sources
2ff057
cp "${abs_srcdir}"/data/SOURCES/hello-1.0.tar.gz "${abs_srcdir}"/data/SOURCES/hello-1.0-modernize.patch ${TOPDIR}/SOURCES
2ff057
2ff057
# Build, contains one ELF which should have a buildid.
2ff057
rundebug rpmbuild \
2ff057
  --define="_build_id_links compat" \
2ff057
  --undefine "_unique_debug_names" \
2ff057
  --undefine "_unique_debug_srcs" \
2ff057
  --quiet -ba "${abs_srcdir}"/data/SPECS/hello.spec
2ff057
2ff057
# There should be one build-id files in the main and debuginfo package.
2ff057
# the debuginfo package has one extra main build-id compat symlink
2ff057
# plus the .build-id/xx subdir, 2 in total in main, 3 in total in debug
2ff057
echo -n "hello build-id files: "
2ff057
run rpm -ql -p "${TOPDIR}"/RPMS/*/hello-1.0-1.*.rpm \
2ff057
  | grep /.build-id/ | wc --lines
2ff057
2ff057
echo -n "hello debuginfo build-id files: "
2ff057
run rpm -ql -p "${TOPDIR}"/RPMS/*/hello-debuginfo-1.0-1.*.rpm \
2ff057
  | grep /.build-id/ | wc --lines
2ff057
2ff057
# Extract the both packages to check the build-id files link to the
2ff057
# main and .debug files.
2ff057
rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello-1.0-1.*.rpm \
2ff057
  | cpio -diu
2ff057
rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello-debuginfo-1.0-1.*.rpm \
2ff057
  | cpio -diu
2ff057
2ff057
# Check there is a build-id symlink for the main file.
2ff057
main_file=./usr/local/bin/hello
2ff057
test -f "${main_file}" || echo "No main file ${main_file}"
2ff057
2ff057
# Extract the build-id from the main file
2ff057
id_main=$(file $main_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
2ff057
2ff057
id_main_file="./usr/lib/.build-id/${id_main:0:2}/${id_main:2}"
2ff057
test -L "$id_main_file" || echo "No build-id file $id_main_file"
2ff057
2ff057
canon_main_file=$(readlink -f ${main_file})
2ff057
2ff057
test -f "$canon_main_file" \
2ff057
  || echo "Cannot resolve main file ${main_file} -> ${canon_main_file}"
2ff057
2ff057
canon_main_id_file=$(readlink -f ${id_main_file})
2ff057
2ff057
test -f "$canon_main_id_file" \
2ff057
  || echo "Cannot resolve main build-id file ${id_main_file} -> ${canon_main_id_file}"
2ff057
2ff057
test "$canon_main_file" = "$canon_main_id_file" \
2ff057
  || echo "main and build-id file not linked"
2ff057
2ff057
# And check the same for the debug file.
2ff057
debug_file=./usr/lib/debug/usr/local/bin/hello.debug
2ff057
test -f ${debug_file} || echo "No debug file ${debug_file}"
2ff057
2ff057
# Extract the build-id from the .debug file
2ff057
id_debug=$(file $debug_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
2ff057
2ff057
test ${id_main} = ${id_debug} || echo "unequal main and debug id"
2ff057
2ff057
id_debug_file="./usr/lib/debug/.build-id/${id_debug:0:2}/${id_debug:2}.debug"
2ff057
test -L "$id_debug_file" || echo "No build-id file $id_debug_file"
2ff057
2ff057
canon_debug_file=$(readlink -f ${debug_file})
2ff057
2ff057
test -f "$canon_debug_file" \
2ff057
  || echo "Cannot resolve debug file ${debug_file} -> ${canon_debug_file}"
2ff057
2ff057
canon_debug_id_file=$(readlink -f ${id_debug_file})
2ff057
2ff057
test -f "$canon_debug_id_file" \
2ff057
  || echo "Cannot resolve debug build-id file ${id_debug_file} -> ${canon_debug_id_file}"
2ff057
2ff057
test "$canon_debug_file" = "$canon_debug_id_file" \
2ff057
  || echo "debug and build-id not linked"
2ff057
2ff057
# The compat link should also point to the same (indirectly).
2ff057
id_compat_file="./usr/lib/debug/.build-id/${id_main:0:2}/${id_main:2}"
2ff057
test -L "$id_compat_file" || echo "No build-id compat file $id_compat_file"
2ff057
2ff057
canon_compat_file=$(readlink -f ${id_compat_file})
2ff057
2ff057
test -f "$canon_compat_file" \
2ff057
  || echo "Cannot resolve compat file ${id_compat_file} -> ${canon_compat_file}"
2ff057
2ff057
test "$canon_compat_file" = "$canon_main_file" \
2ff057
  || echo "compat and build-id not linked"
2ff057
],
2ff057
[0],
2ff057
[hello build-id files: 2
2ff057
hello debuginfo build-id files: 3
2ff057
],
2ff057
[ignore])
2ff057
AT_CLEANUP
2ff057
2ff057
# ------------------------------
2ff057
# Check if rpmbuild "compat" generates main and debuginfo buildid symlinks
2ff057
# With unique debug file names
2ff057
AT_SETUP([rpmbuild buildid compat unique debug names])
2ff057
AT_KEYWORDS([build] [debuginfo] [buildid])
2ff057
AT_CHECK([
2ff057
rm -rf ${TOPDIR}
2ff057
AS_MKDIR_P(${TOPDIR}/SOURCES)
2ff057
2ff057
# Setup sources
2ff057
cp "${abs_srcdir}"/data/SOURCES/hello-1.0.tar.gz "${abs_srcdir}"/data/SOURCES/hello-1.0-modernize.patch ${TOPDIR}/SOURCES
2ff057
2ff057
# Build, contains one ELF which should have a buildid.
2ff057
rundebug rpmbuild \
2ff057
  --define="_build_id_links compat" \
2ff057
  --define="_unique_debug_names 1" \
2ff057
  --quiet -ba "${abs_srcdir}"/data/SPECS/hello.spec
2ff057
2ff057
# There should be one build-id files in the main and debuginfo package.
2ff057
# the debuginfo package has one extra main build-id compat symlink
2ff057
# plus the .build-id/xx subdir, 2 in total in main, 3 in total in debug
2ff057
echo -n "hello build-id files: "
2ff057
run rpm -ql -p "${TOPDIR}"/RPMS/*/hello-1.0-1.*.rpm \
2ff057
  | grep /.build-id/ | wc --lines
2ff057
2ff057
echo -n "hello debuginfo build-id files: "
2ff057
run rpm -ql -p "${TOPDIR}"/RPMS/*/hello-debuginfo-1.0-1.*.rpm \
2ff057
  | grep /.build-id/ | wc --lines
2ff057
2ff057
# Extract the both packages to check the build-id files link to the
2ff057
# main and .debug files.
2ff057
rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello-1.0-1.*.rpm \
2ff057
  | cpio -diu
2ff057
rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello-debuginfo-1.0-1.*.rpm \
2ff057
  | cpio -diu
2ff057
2ff057
# Check there is a build-id symlink for the main file.
2ff057
main_file=./usr/local/bin/hello
2ff057
test -f "${main_file}" || echo "No main file ${main_file}"
2ff057
2ff057
# Extract the build-id from the main file
2ff057
id_main=$(file $main_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
2ff057
2ff057
id_main_file="./usr/lib/.build-id/${id_main:0:2}/${id_main:2}"
2ff057
test -L "$id_main_file" || echo "No build-id file $id_main_file"
2ff057
2ff057
canon_main_file=$(readlink -f ${main_file})
2ff057
2ff057
test -f "$canon_main_file" \
2ff057
  || echo "Cannot resolve main file ${main_file} -> ${canon_main_file}"
2ff057
2ff057
canon_main_id_file=$(readlink -f ${id_main_file})
2ff057
2ff057
test -f "$canon_main_id_file" \
2ff057
  || echo "Cannot resolve main build-id file ${id_main_file} -> ${canon_main_id_file}"
2ff057
2ff057
test "$canon_main_file" = "$canon_main_id_file" \
2ff057
  || echo "main and build-id file not linked"
2ff057
2ff057
# And check the same for the debug file.
2ff057
debug_file=./usr/lib/debug/usr/local/bin/hello-*debug
2ff057
test -f ${debug_file} || echo "No debug file ${debug_file}"
2ff057
2ff057
# Extract the build-id from the .debug file
2ff057
id_debug=$(file $debug_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
2ff057
2ff057
test ${id_main} = ${id_debug} || echo "unequal main and debug id"
2ff057
2ff057
id_debug_file="./usr/lib/debug/.build-id/${id_debug:0:2}/${id_debug:2}.debug"
2ff057
test -L "$id_debug_file" || echo "No build-id file $id_debug_file"
2ff057
2ff057
canon_debug_file=$(readlink -f ${debug_file})
2ff057
2ff057
test -f "$canon_debug_file" \
2ff057
  || echo "Cannot resolve debug file ${debug_file} -> ${canon_debug_file}"
2ff057
2ff057
canon_debug_id_file=$(readlink -f ${id_debug_file})
2ff057
2ff057
test -f "$canon_debug_id_file" \
2ff057
  || echo "Cannot resolve debug build-id file ${id_debug_file} -> ${canon_debug_id_file}"
2ff057
2ff057
test "$canon_debug_file" = "$canon_debug_id_file" \
2ff057
  || echo "debug and build-id not linked"
2ff057
2ff057
# The compat link should also point to the same (indirectly).
2ff057
id_compat_file="./usr/lib/debug/.build-id/${id_main:0:2}/${id_main:2}"
2ff057
test -L "$id_compat_file" || echo "No build-id compat file $id_compat_file"
2ff057
2ff057
canon_compat_file=$(readlink -f ${id_compat_file})
2ff057
2ff057
test -f "$canon_compat_file" \
2ff057
  || echo "Cannot resolve compat file ${id_compat_file} -> ${canon_compat_file}"
2ff057
2ff057
test "$canon_compat_file" = "$canon_main_file" \
2ff057
  || echo "compat and build-id not linked"
2ff057
],
2ff057
[0],
2ff057
[hello build-id files: 2
2ff057
hello debuginfo build-id files: 3
2ff057
],
2ff057
[ignore])
2ff057
AT_CLEANUP
2ff057
2ff057
# ------------------------------
2ff057
# Check that (copied) files with duplicate build-ids are handled correctly.
2ff057
# This should create "numbered" build-id files.
2ff057
# This is simply the hello example with one binary copied.
2ff057
AT_SETUP([rpmbuild buildid duplicate alldebug])
2ff057
AT_KEYWORDS([build] [debuginfo] [buildid])
2ff057
AT_CHECK([
2ff057
rm -rf ${TOPDIR}
2ff057
AS_MKDIR_P(${TOPDIR}/SOURCES)
2ff057
2ff057
cp "${abs_srcdir}"/data/SOURCES/hello-1.0.tar.gz "${abs_srcdir}"/data/SOURCES/hello-1.0-modernize.patch ${TOPDIR}/SOURCES
2ff057
2ff057
# Should create two warnings
2ff057
rundebug rpmbuild --quiet \
2ff057
  --define="_build_id_links alldebug" \
2ff057
  -ba "${abs_srcdir}"/data/SPECS/hello2cp.spec 2>&1 | grep "^warning: " \
2ff057
  | cut -f1-3 -d' '
2ff057
2ff057
rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello2-1.0-1.*.rpm \
2ff057
  | cpio -diu --quiet
2ff057
2ff057
hello_file=./usr/local/bin/hello
2ff057
2ff057
# Extract the build-id from the main file
2ff057
id=$(file $hello_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
2ff057
2ff057
# alldebug not here...
2ff057
id_file="./usr/lib/debug/.build-id/${id:0:2}/${id:2}"
2ff057
test -L "$id_file" && echo "main id in main package"
2ff057
id_dup_file="./usr/lib/debug/.build-id/${id:0:2}/${id:2}.1"
2ff057
test -L "$id_dup_file" && echo "main dup id in main package"
2ff057
2ff057
rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello2-debuginfo-1.0-1.*.rpm \
2ff057
  | cpio -diu --quiet
2ff057
2ff057
# alldebug, so they are all here
2ff057
test -L "$id_file" && echo "main id in debug package"
2ff057
test -L "$id_dup_file" && echo "main dup id in debug package"
2ff057
2ff057
debug_id_file="./usr/lib/debug/.build-id/${id:0:2}/${id:2}.debug"
2ff057
test -L "$debug_id_file" && echo "debug id in debug package"
2ff057
debug_dup_file="./usr/lib/debug/.build-id/${id:0:2}/${id:2}.1.debug"
2ff057
test -L "$debug_dup_file" && echo "debug dup id in debug package"
2ff057
2ff057
# We don't know which points to which, but we do know they point
2ff057
# to different files.
2ff057
canon_id_file=$(readlink -f ${id_file})
2ff057
canon_dup_file=$(readlink -f ${id_dup_file})
2ff057
test "$canon_id_file" != "$canon_dup_file" \
2ff057
  || echo "id and dup same"
2ff057
2ff057
canon_debug_id_file=$(readlink -f ${debug_id_file})
2ff057
canon_debug_dup_file=$(readlink -f ${debug_dup_file})
2ff057
test "$canon_debug_id_file" != "$canon_debug_dup_file" \
2ff057
  || echo "debug id and dup same"
2ff057
],
2ff057
[0],
2ff057
[warning: Duplicate build-ids
2ff057
warning: Duplicate build-ids
2ff057
main id in debug package
2ff057
main dup id in debug package
2ff057
debug id in debug package
2ff057
debug dup id in debug package
2ff057
],
2ff057
[])
2ff057
AT_CLEANUP
2ff057
2ff057
# ------------------------------
2ff057
# Check that hard linked files are handled correctly.
2ff057
# Since the hard linked files have duplicate build-ids,
2ff057
# it should create "numbered" build-id files.
2ff057
# This is simply the hello example with one binary hard linked.
2ff057
AT_SETUP([rpmbuild buildid hardlink alldebug])
2ff057
AT_KEYWORDS([build] [debuginfo] [buildid])
2ff057
AT_CHECK([
2ff057
rm -rf ${TOPDIR}
2ff057
AS_MKDIR_P(${TOPDIR}/SOURCES)
2ff057
2ff057
cp "${abs_srcdir}"/data/SOURCES/hello-1.0.tar.gz "${abs_srcdir}"/data/SOURCES/hello-1.0-modernize.patch ${TOPDIR}/SOURCES
2ff057
2ff057
# No warnings for hard links
2ff057
rundebug rpmbuild --quiet \
2ff057
  --define="_build_id_links alldebug" \
2ff057
  -ba "${abs_srcdir}"/data/SPECS/hello2ln.spec 2>&1 | grep "^warning: " \
2ff057
  | cut -f1-3 -d' '
2ff057
2ff057
rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello2-1.0-1.*.rpm \
2ff057
  | cpio -diu --quiet
2ff057
2ff057
hello_file=./usr/local/bin/hello
2ff057
2ff057
# Extract the build-id from the main file
2ff057
id=$(file $hello_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
2ff057
2ff057
# alldebug not here...
2ff057
id_file="./usr/lib/debug/.build-id/${id:0:2}/${id:2}"
2ff057
test -L "$id_file" && echo "main id in main package"
2ff057
id_dup_file="./usr/lib/debug/.build-id/${id:0:2}/${id:2}.1"
2ff057
test -L "$id_dup_file" && echo "main dup id in main package"
2ff057
2ff057
rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello2-debuginfo-1.0-1.*.rpm \
2ff057
  | cpio -diu --quiet
2ff057
2ff057
# alldebug, so they are all here
2ff057
test -L "$id_file" && echo "main id in debug package"
2ff057
test -L "$id_dup_file" && echo "main dup id in debug package"
2ff057
2ff057
debug_id_file="./usr/lib/debug/.build-id/${id:0:2}/${id:2}.debug"
2ff057
test -L "$debug_id_file" && echo "debug id in debug package"
2ff057
debug_dup_file="./usr/lib/debug/.build-id/${id:0:2}/${id:2}.1.debug"
2ff057
test -L "$debug_dup_file" && echo "debug dup id in debug package"
2ff057
2ff057
# We don't know which points to which, but we do know they point
2ff057
# to different files.
2ff057
canon_id_file=$(readlink -f ${id_file})
2ff057
canon_dup_file=$(readlink -f ${id_dup_file})
2ff057
test "$canon_id_file" != "$canon_dup_file" \
2ff057
  || echo "id and dup same"
2ff057
2ff057
canon_debug_id_file=$(readlink -f ${debug_id_file})
2ff057
canon_debug_dup_file=$(readlink -f ${debug_dup_file})
2ff057
test "$canon_debug_id_file" != "$canon_debug_dup_file" \
2ff057
  || echo "debug id and dup same"
2ff057
],
2ff057
[0],
2ff057
[main id in debug package
2ff057
main dup id in debug package
2ff057
debug id in debug package
2ff057
debug dup id in debug package
2ff057
],
2ff057
[])
2ff057
AT_CLEANUP
2ff057
2ff057
# ------------------------------
2ff057
# Check that (copied) files with duplicate build-ids are handled correctly.
2ff057
# This should create "numbered" build-id files.
2ff057
# This is simply the hello example with one binary copied.
2ff057
AT_SETUP([rpmbuild buildid duplicate separate])
2ff057
AT_KEYWORDS([build] [debuginfo] [buildid])
2ff057
AT_CHECK([
2ff057
rm -rf ${TOPDIR}
2ff057
AS_MKDIR_P(${TOPDIR}/SOURCES)
2ff057
2ff057
cp "${abs_srcdir}"/data/SOURCES/hello-1.0.tar.gz "${abs_srcdir}"/data/SOURCES/hello-1.0-modernize.patch ${TOPDIR}/SOURCES
2ff057
2ff057
# Should create two warnings
2ff057
rundebug rpmbuild --quiet \
2ff057
  --define="_build_id_links separate" \
2ff057
  -ba "${abs_srcdir}"/data/SPECS/hello2cp.spec 2>&1 | grep "^warning: " \
2ff057
  | cut -f1-3 -d' '
2ff057
2ff057
rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello2-1.0-1.*.rpm \
2ff057
  | cpio -diu --quiet
2ff057
2ff057
hello_file=./usr/local/bin/hello
2ff057
2ff057
# Extract the build-id from the main file
2ff057
id=$(file $hello_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
2ff057
2ff057
# separate build-ids split...
2ff057
id_file="./usr/lib/.build-id/${id:0:2}/${id:2}"
2ff057
test -L "$id_file" && echo "main id in main package"
2ff057
id_dup_file="./usr/lib/.build-id/${id:0:2}/${id:2}.1"
2ff057
test -L "$id_dup_file" && echo "main dup id in main package"
2ff057
2ff057
rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello2-debuginfo-1.0-1.*.rpm \
2ff057
  | cpio -diu --quiet
2ff057
2ff057
# separate, so debug ids are here
2ff057
debug_id_file="./usr/lib/debug/.build-id/${id:0:2}/${id:2}.debug"
2ff057
test -L "$debug_id_file" && echo "debug id in debug package"
2ff057
debug_dup_file="./usr/lib/debug/.build-id/${id:0:2}/${id:2}.1.debug"
2ff057
test -L "$debug_dup_file" && echo "debug dup id in debug package"
2ff057
2ff057
# We don't know which points to which, but we do know they point
2ff057
# to different files.
2ff057
canon_id_file=$(readlink -f ${id_file})
2ff057
canon_dup_file=$(readlink -f ${id_dup_file})
2ff057
test "$canon_id_file" != "$canon_dup_file" \
2ff057
  || echo "id and dup same"
2ff057
2ff057
canon_debug_id_file=$(readlink -f ${debug_id_file})
2ff057
canon_debug_dup_file=$(readlink -f ${debug_dup_file})
2ff057
test "$canon_debug_id_file" != "$canon_debug_dup_file" \
2ff057
  || echo "debug id and dup same"
2ff057
],
2ff057
[0],
2ff057
[warning: Duplicate build-ids
2ff057
warning: Duplicate build-ids
2ff057
main id in main package
2ff057
main dup id in main package
2ff057
debug id in debug package
2ff057
debug dup id in debug package
2ff057
],
2ff057
[])
2ff057
AT_CLEANUP
2ff057
2ff057
# ------------------------------
2ff057
# Check that hard linked files are handled correctly.
2ff057
# Since the hard linked files have duplicate build-ids,
2ff057
# it should create "numbered" build-id files.
2ff057
# This is simply the hello example with one binary hard linked.
2ff057
AT_SETUP([rpmbuild buildid hardlink separate])
2ff057
AT_KEYWORDS([build] [debuginfo] [buildid])
2ff057
AT_CHECK([
2ff057
rm -rf ${TOPDIR}
2ff057
AS_MKDIR_P(${TOPDIR}/SOURCES)
2ff057
2ff057
cp "${abs_srcdir}"/data/SOURCES/hello-1.0.tar.gz "${abs_srcdir}"/data/SOURCES/hello-1.0-modernize.patch ${TOPDIR}/SOURCES
2ff057
2ff057
# No warnings for hard links
2ff057
rundebug rpmbuild --quiet \
2ff057
  --define="_build_id_links separate" \
2ff057
  -ba "${abs_srcdir}"/data/SPECS/hello2ln.spec 2>&1 | grep "^warning: " \
2ff057
  | cut -f1-3 -d' '
2ff057
2ff057
rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello2-1.0-1.*.rpm \
2ff057
  | cpio -diu --quiet
2ff057
2ff057
hello_file=./usr/local/bin/hello
2ff057
2ff057
# Extract the build-id from the main file
2ff057
id=$(file $hello_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
2ff057
2ff057
# separate build-ids split...
2ff057
id_file="./usr/lib/.build-id/${id:0:2}/${id:2}"
2ff057
test -L "$id_file" && echo "main id in main package"
2ff057
id_dup_file="./usr/lib/.build-id/${id:0:2}/${id:2}.1"
2ff057
test -L "$id_dup_file" && echo "main dup id in main package"
2ff057
2ff057
rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello2-debuginfo-1.0-1.*.rpm \
2ff057
  | cpio -diu --quiet
2ff057
2ff057
# separate, so debug ids are here
2ff057
debug_id_file="./usr/lib/debug/.build-id/${id:0:2}/${id:2}.debug"
2ff057
test -L "$debug_id_file" && echo "debug id in debug package"
2ff057
debug_dup_file="./usr/lib/debug/.build-id/${id:0:2}/${id:2}.1.debug"
2ff057
test -L "$debug_dup_file" && echo "debug dup id in debug package"
2ff057
2ff057
# We don't know which points to which, but we do know they point
2ff057
# to different files.
2ff057
canon_id_file=$(readlink -f ${id_file})
2ff057
canon_dup_file=$(readlink -f ${id_dup_file})
2ff057
test "$canon_id_file" != "$canon_dup_file" \
2ff057
  || echo "id and dup same"
2ff057
2ff057
canon_debug_id_file=$(readlink -f ${debug_id_file})
2ff057
canon_debug_dup_file=$(readlink -f ${debug_dup_file})
2ff057
test "$canon_debug_id_file" != "$canon_debug_dup_file" \
2ff057
  || echo "debug id and dup same"
2ff057
],
2ff057
[0],
2ff057
[main id in main package
2ff057
main dup id in main package
2ff057
debug id in debug package
2ff057
debug dup id in debug package
2ff057
],
2ff057
[])
2ff057
AT_CLEANUP
2ff057
2ff057
# ------------------------------
2ff057
# Check that (copied) files with duplicate build-ids are handled correctly.
2ff057
# This should create "numbered" build-id files.
2ff057
# This is simply the hello example with one binary copied.
2ff057
AT_SETUP([rpmbuild buildid duplicate compat])
2ff057
AT_KEYWORDS([build] [debuginfo] [buildid])
2ff057
AT_CHECK([
2ff057
rm -rf ${TOPDIR}
2ff057
AS_MKDIR_P(${TOPDIR}/SOURCES)
2ff057
2ff057
cp "${abs_srcdir}"/data/SOURCES/hello-1.0.tar.gz "${abs_srcdir}"/data/SOURCES/hello-1.0-modernize.patch ${TOPDIR}/SOURCES
2ff057
2ff057
# Should create two warnings
2ff057
rundebug rpmbuild --quiet \
2ff057
  --define="_build_id_links compat" \
2ff057
  -ba "${abs_srcdir}"/data/SPECS/hello2cp.spec 2>&1 | grep "^warning: " \
2ff057
  | cut -f1-3 -d' '
2ff057
2ff057
rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello2-1.0-1.*.rpm \
2ff057
  | cpio -diu --quiet
2ff057
2ff057
hello_file=./usr/local/bin/hello
2ff057
2ff057
# Extract the build-id from the main file
2ff057
id=$(file $hello_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
2ff057
2ff057
# compat build-ids split...
2ff057
id_file="./usr/lib/.build-id/${id:0:2}/${id:2}"
2ff057
test -L "$id_file" && echo "main id in main package"
2ff057
id_dup_file="./usr/lib/.build-id/${id:0:2}/${id:2}.1"
2ff057
test -L "$id_dup_file" && echo "main dup id in main package"
2ff057
2ff057
rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello2-debuginfo-1.0-1.*.rpm \
2ff057
  | cpio -diu --quiet
2ff057
2ff057
# compat, so main (and debug) ids are (also) here
2ff057
compat_file="./usr/lib/debug/.build-id/${id:0:2}/${id:2}"
2ff057
test -L "$compat_file" && echo "compat id in debug package"
2ff057
compat_dup_file="./usr/lib/debug/.build-id/${id:0:2}/${id:2}.1"
2ff057
test -L "$compat_dup_file" && echo "compat dup id in debug package"
2ff057
2ff057
debug_id_file="./usr/lib/debug/.build-id/${id:0:2}/${id:2}.debug"
2ff057
test -L "$debug_id_file" && echo "debug id in debug package"
2ff057
debug_dup_file="./usr/lib/debug/.build-id/${id:0:2}/${id:2}.1.debug"
2ff057
test -L "$debug_dup_file" && echo "debug dup id in debug package"
2ff057
2ff057
# We don't know which points to which, but we do know they point
2ff057
# to different files.
2ff057
canon_id_file=$(readlink -f ${id_file})
2ff057
canon_dup_file=$(readlink -f ${id_dup_file})
2ff057
test "$canon_id_file" != "$canon_dup_file" \
2ff057
  || echo "id and dup same"
2ff057
2ff057
canon_debug_id_file=$(readlink -f ${debug_id_file})
2ff057
canon_debug_dup_file=$(readlink -f ${debug_dup_file})
2ff057
test "$canon_debug_id_file" != "$canon_debug_dup_file" \
2ff057
  || echo "debug id and dup same"
2ff057
2ff057
canon_compat_file=$(readlink -f ${compat_file})
2ff057
canon_compat_dup_file=$(readlink -f ${compat_dup_file})
2ff057
test "$canon_compat_file" != "$canon_compat_dup_file" \
2ff057
  || echo "compat id and dup same"
2ff057
],
2ff057
[0],
2ff057
[warning: Duplicate build-ids
2ff057
warning: Duplicate build-ids
2ff057
main id in main package
2ff057
main dup id in main package
2ff057
compat id in debug package
2ff057
compat dup id in debug package
2ff057
debug id in debug package
2ff057
debug dup id in debug package
2ff057
],
2ff057
[])
2ff057
AT_CLEANUP
2ff057
2ff057
# ------------------------------
2ff057
# Check that hard linked files are handled correctly.
2ff057
# Since the hard linked files have duplicate build-ids,
2ff057
# it should create "numbered" build-id files.
2ff057
# This is simply the hello example with one binary hard linked.
2ff057
AT_SETUP([rpmbuild buildid hardlink compat])
2ff057
AT_KEYWORDS([build] [debuginfo] [buildid])
2ff057
AT_CHECK([
2ff057
rm -rf ${TOPDIR}
2ff057
AS_MKDIR_P(${TOPDIR}/SOURCES)
2ff057
2ff057
cp "${abs_srcdir}"/data/SOURCES/hello-1.0.tar.gz "${abs_srcdir}"/data/SOURCES/hello-1.0-modernize.patch ${TOPDIR}/SOURCES
2ff057
2ff057
# No warnings for hard links
2ff057
rundebug rpmbuild --quiet \
2ff057
  --define="_build_id_links compat" \
2ff057
  -ba "${abs_srcdir}"/data/SPECS/hello2ln.spec 2>&1 | grep "^warning: " \
2ff057
  | cut -f1-3 -d' '
2ff057
2ff057
rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello2-1.0-1.*.rpm \
2ff057
  | cpio -diu --quiet
2ff057
2ff057
hello_file=./usr/local/bin/hello
2ff057
2ff057
# Extract the build-id from the main file
2ff057
id=$(file $hello_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
2ff057
2ff057
# compat build-ids split...
2ff057
id_file="./usr/lib/.build-id/${id:0:2}/${id:2}"
2ff057
test -L "$id_file" && echo "main id in main package"
2ff057
id_dup_file="./usr/lib/.build-id/${id:0:2}/${id:2}.1"
2ff057
test -L "$id_dup_file" && echo "main dup id in main package"
2ff057
2ff057
rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello2-debuginfo-1.0-1.*.rpm \
2ff057
  | cpio -diu --quiet
2ff057
2ff057
# compat, so main (and debug) ids are (also) here
2ff057
compat_file="./usr/lib/debug/.build-id/${id:0:2}/${id:2}"
2ff057
test -L "$compat_file" && echo "compat id in debug package"
2ff057
compat_dup_file="./usr/lib/debug/.build-id/${id:0:2}/${id:2}.1"
2ff057
test -L "$compat_dup_file" && echo "compat dup id in debug package"
2ff057
2ff057
debug_id_file="./usr/lib/debug/.build-id/${id:0:2}/${id:2}.debug"
2ff057
test -L "$debug_id_file" && echo "debug id in debug package"
2ff057
debug_dup_file="./usr/lib/debug/.build-id/${id:0:2}/${id:2}.1.debug"
2ff057
test -L "$debug_dup_file" && echo "debug dup id in debug package"
2ff057
2ff057
# We don't know which points to which, but we do know they point
2ff057
# to different files.
2ff057
canon_id_file=$(readlink -f ${id_file})
2ff057
canon_dup_file=$(readlink -f ${id_dup_file})
2ff057
test "$canon_id_file" != "$canon_dup_file" \
2ff057
  || echo "id and dup same"
2ff057
2ff057
canon_debug_id_file=$(readlink -f ${debug_id_file})
2ff057
canon_debug_dup_file=$(readlink -f ${debug_dup_file})
2ff057
test "$canon_debug_id_file" != "$canon_debug_dup_file" \
2ff057
  || echo "debug id and dup same"
2ff057
2ff057
canon_compat_file=$(readlink -f ${compat_file})
2ff057
canon_compat_dup_file=$(readlink -f ${compat_dup_file})
2ff057
test "$canon_compat_file" != "$canon_compat_dup_file" \
2ff057
  || echo "compat id and dup same"
2ff057
],
2ff057
[0],
2ff057
[main id in main package
2ff057
main dup id in main package
2ff057
compat id in debug package
2ff057
compat dup id in debug package
2ff057
debug id in debug package
2ff057
debug dup id in debug package
2ff057
],
2ff057
[])
2ff057
AT_CLEANUP
2ff057
2ff057
# ------------------------------
2ff057
# Check build-ids are recomputed with unique_build_ids,
2ff057
# but not with _no_recompute_build_ids
2ff057
AT_SETUP([rpmbuild buildid recompute])
2ff057
AT_KEYWORDS([build] [debuginfo] [buildid])
2ff057
AT_CHECK([
2ff057
rm -rf ${TOPDIR}
2ff057
AS_MKDIR_P(${TOPDIR}/SOURCES)
2ff057
2ff057
cp "${abs_srcdir}"/data/SOURCES/hello-1.0.tar.gz "${abs_srcdir}"/data/SOURCES/hello-1.0-modernize.patch ${TOPDIR}/SOURCES
2ff057
2ff057
# Make sure we get debuginfo
2ff057
export CFLAGS="-g"
2ff057
2ff057
# Unique 1
2ff057
rundebug rpmbuild --quiet \
2ff057
  --define="_unique_build_ids 1" \
2ff057
  --undefine="_no_recompute_build_ids" \
2ff057
  -ba "${abs_srcdir}"/data/SPECS/hello.spec
2ff057
2ff057
rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello-1.0-1.*.rpm \
2ff057
  | cpio -diu --quiet
2ff057
2ff057
hello_file=./usr/local/bin/hello
2ff057
2ff057
# Extract the build-id from the main file
2ff057
test -f $hello_file || echo "No $hello_file"
2ff057
id1=$(file $hello_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
2ff057
2ff057
# Make sure we generate a new one
2ff057
rm $hello_file
2ff057
2ff057
# Unique 2
2ff057
# Build the "next" release, which has no changes except for the release update.
2ff057
rundebug rpmbuild --quiet \
2ff057
  --define="_unique_build_ids 1" \
2ff057
  --undefine="_no_recompute_build_ids" \
2ff057
  -ba "${abs_srcdir}"/data/SPECS/hello-r2.spec
2ff057
2ff057
rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello-1.0-2.*.rpm \
2ff057
  | cpio -diu --quiet
2ff057
2ff057
# Extract the build-id from the main file
2ff057
test -f $hello_file || echo "No $hello_file"
2ff057
id2=$(file $hello_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
2ff057
2ff057
# Two unique builds should not be equal
2ff057
if test "$id1" == "$id2"; then
2ff057
  echo "uniques equal";
2ff057
else
2ff057
  echo "uniques unequal";
2ff057
fi
2ff057
2ff057
# Make sure we generate a new one
2ff057
rm $hello_file
2ff057
2ff057
# no-recompute 1
2ff057
rundebug rpmbuild --quiet \
2ff057
  --undefine="_unique_build_ids" \
2ff057
  --undefine="_unique_debug_names" \
2ff057
  --undefine="_unique_debug_srcs" \
2ff057
  --define="_no_recompute_build_ids 1" \
2ff057
  -ba "${abs_srcdir}"/data/SPECS/hello.spec
2ff057
2ff057
rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello-1.0-1.*.rpm \
2ff057
  | cpio -diu --quiet
2ff057
2ff057
hello_file=./usr/local/bin/hello
2ff057
2ff057
# Extract the build-id from the main file
2ff057
test -f $hello_file || echo "No $hello_file"
2ff057
id3=$(file $hello_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
2ff057
2ff057
# An unique and no-recompute build should be unequal
2ff057
if test "$id2" == "$id3"; then
2ff057
  echo "no-recompute unique equal";
2ff057
else
2ff057
  echo "no-recompute unique unequal";
2ff057
fi
2ff057
2ff057
# Make sure we generate a new one
2ff057
rm $hello_file
2ff057
2ff057
# no-recompute 2
2ff057
# Build the "next" release, which has no changes except for the release update.
2ff057
rundebug rpmbuild --quiet \
2ff057
  --undefine="_unique_build_ids" \
2ff057
  --undefine="_unique_debug_names" \
2ff057
  --undefine="_unique_debug_srcs" \
2ff057
  --define="_no_recompute_build_ids 1" \
2ff057
  -ba "${abs_srcdir}"/data/SPECS/hello-r2.spec
2ff057
2ff057
rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello-1.0-2.*.rpm \
2ff057
  | cpio -diu --quiet
2ff057
2ff057
# Extract the build-id from the main file
2ff057
test -f $hello_file || echo "No $hello_file"
2ff057
id4=$(file $hello_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
2ff057
2ff057
# Two no-recompute builds should be equal. Even for different "releases".
2ff057
if test "$id3" == "$id4"; then
2ff057
  echo "no-recomputes equal";
2ff057
else
2ff057
  echo "no-recomputes unequal";
2ff057
fi
2ff057
],
2ff057
[0],
2ff057
[uniques unequal
2ff057
no-recompute unique unequal
2ff057
no-recomputes equal
2ff057
],
2ff057
[ignore])
2ff057
AT_CLEANUP
2ff057
2ff057
# ------------------------------
2ff057
# Check build-ids are unique between versions/releases
2ff057
# with _unique_build_ids defined.
2ff057
AT_SETUP([rpmbuild buildid unique r1 r2])
2ff057
AT_KEYWORDS([build] [debuginfo] [buildid])
2ff057
AT_CHECK([
2ff057
rm -rf ${TOPDIR}
2ff057
AS_MKDIR_P(${TOPDIR}/SOURCES)
2ff057
2ff057
cp "${abs_srcdir}"/data/SOURCES/hello-1.0.tar.gz "${abs_srcdir}"/data/SOURCES/hello-1.0-modernize.patch ${TOPDIR}/SOURCES
2ff057
2ff057
# No warnings for hard links
2ff057
rundebug rpmbuild --quiet \
2ff057
  --define="_unique_build_ids 1" \
2ff057
  -ba "${abs_srcdir}"/data/SPECS/hello.spec
2ff057
2ff057
rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello-1.0-1.*.rpm \
2ff057
  | cpio -diu --quiet
2ff057
2ff057
hello_file=./usr/local/bin/hello
2ff057
2ff057
# Extract the build-id from the main file
2ff057
test -f $hello_file || echo "No $hello_file"
2ff057
id1=$(file $hello_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
2ff057
2ff057
# Make sure we generate a new one
2ff057
rm $hello_file
2ff057
2ff057
# Build the "next" release, which has no changes except for the release update.
2ff057
rundebug rpmbuild --quiet \
2ff057
  --define="_unique_build_ids 1" \
2ff057
  -ba "${abs_srcdir}"/data/SPECS/hello-r2.spec
2ff057
2ff057
rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello-1.0-2.*.rpm \
2ff057
  | cpio -diu --quiet
2ff057
2ff057
# Extract the build-id from the main file
2ff057
test -f $hello_file || echo "No $hello_file"
2ff057
id2=$(file $hello_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
2ff057
2ff057
if test "$id1" == "$id2"; then echo "equal $id1"; else echo "unequal"; fi
2ff057
],
2ff057
[0],
2ff057
[unequal
2ff057
],
2ff057
[ignore])
2ff057
AT_CLEANUP
2ff057
2ff057
# ------------------------------
2ff057
# Check build-ids are non-unique between versions/releases
2ff057
# with _unique_build_ids undefined (and exact same sources).
2ff057
AT_SETUP([rpmbuild buildid non-unique r1 r2])
2ff057
AT_KEYWORDS([build] [debuginfo] [buildid])
2ff057
AT_CHECK([
2ff057
rm -rf ${TOPDIR}
2ff057
AS_MKDIR_P(${TOPDIR}/SOURCES)
2ff057
2ff057
cp "${abs_srcdir}"/data/SOURCES/hello-1.0.tar.gz "${abs_srcdir}"/data/SOURCES/hello-1.0-modernize.patch ${TOPDIR}/SOURCES
2ff057
2ff057
# No warnings for hard links
2ff057
rundebug rpmbuild --quiet \
2ff057
  --undefine="_unique_build_ids" \
2ff057
  --undefine="_unique_debug_names" \
2ff057
  --undefine="_unique_debug_srcs" \
2ff057
  -ba "${abs_srcdir}"/data/SPECS/hello.spec
2ff057
2ff057
rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello-1.0-1.*.rpm \
2ff057
  | cpio -diu --quiet
2ff057
2ff057
hello_file=./usr/local/bin/hello
2ff057
2ff057
# Extract the build-id from the main file
2ff057
test -f $hello_file || echo "No $hello_file"
2ff057
id1=$(file $hello_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
2ff057
2ff057
# Make sure we generate a new one
2ff057
rm $hello_file
2ff057
2ff057
# Build the "next" release, which has no changes except for the release update.
2ff057
rundebug rpmbuild --quiet \
2ff057
  --undefine="_unique_build_ids" \
2ff057
  --undefine="_unique_debug_names" \
2ff057
  --undefine="_unique_debug_srcs" \
2ff057
  -ba "${abs_srcdir}"/data/SPECS/hello-r2.spec
2ff057
2ff057
rpm2cpio ${abs_builddir}/testing/build/RPMS/*/hello-1.0-2.*.rpm \
2ff057
  | cpio -diu --quiet
2ff057
2ff057
# Extract the build-id from the main file
2ff057
test -f $hello_file || echo "No $hello_file"
2ff057
id2=$(file $hello_file | sed 's/.*, BuildID\[[.*\]]=\([[0-9a-f]]*\),.*/\1/')
2ff057
2ff057
if test "$id1" == "$id2"; then echo "equal"; else echo "unequal $id1 $id2"; fi
2ff057
],
2ff057
[0],
2ff057
[equal
2ff057
],
2ff057
[ignore])
2ff057
AT_CLEANUP
2ff057
2ff057
# ------------------------------
2ff057
# Check that build-id directories are created with the right permissions
2ff057
# even if the spec file sets attrs explicitly.
2ff057
AT_SETUP([rpmbuild buildid attrs])
2ff057
AT_KEYWORDS([build] [debuginfo] [buildid])
2ff057
AT_CHECK([
2ff057
rm -rf ${TOPDIR}
2ff057
AS_MKDIR_P(${TOPDIR}/SOURCES)
2ff057
2ff057
# Setup sources
2ff057
cp "${abs_srcdir}"/data/SOURCES/hello.c ${TOPDIR}/SOURCES
2ff057
2ff057
# Build, contains one ELF which should have a buildid.
2ff057
rundebug rpmbuild \
2ff057
  --define="_build_id_links compat" \
2ff057
  --define "_unique_debug_names 1" \
2ff057
  --define "_unique_debug_srcs 1" \
2ff057
  --quiet -ba "${abs_srcdir}"/data/SPECS/hello-attr-buildid.spec
2ff057
2ff057
run rpm -qp --qf "[[%{filenames} %{filemodes:perms}\n]]" \
2ff057
        ${abs_builddir}/testing/build/RPMS/*/test-1.0-1*rpm \
2ff057
	| grep "build-id d"
2ff057
2ff057
run rpm -qp --qf "[[%{filenames} %{filemodes:perms}\n]]" \
2ff057
        ${abs_builddir}/testing/build/RPMS/*/test-debuginfo-1.0-1*rpm \
2ff057
	| grep "build-id d"
2ff057
],
2ff057
[0],
2ff057
[/usr/lib/.build-id drwxr-xr-x
2ff057
/usr/lib/debug/.build-id drwxr-xr-x
2ff057
],
2ff057
[ignore])
2ff057
AT_CLEANUP
2ff057
2ff057
# ------------------------------
2ff057
# Check that build-id directories are created with the right attributes
2ff057
# even if the spec file sets config explicitly.
2ff057
AT_SETUP([rpmbuild buildid config attrs])
2ff057
AT_KEYWORDS([build] [debuginfo] [buildid])
2ff057
AT_CHECK([
2ff057
rm -rf ${TOPDIR}
2ff057
AS_MKDIR_P(${TOPDIR}/SOURCES)
2ff057
2ff057
# Setup sources
2ff057
cp "${abs_srcdir}"/data/SOURCES/hello.c ${TOPDIR}/SOURCES
2ff057
2ff057
# Build, contains one ELF which should have a buildid.
2ff057
rundebug rpmbuild \
2ff057
  --define="_build_id_links compat" \
2ff057
  --define "_unique_debug_names 1" \
2ff057
  --define "_unique_debug_srcs 1" \
2ff057
  --quiet -ba "${abs_srcdir}"/data/SPECS/hello-config-buildid.spec
2ff057
2ff057
# Should contain one config file.
2ff057
run rpm -c -qp ${abs_builddir}/testing/build/RPMS/*/test-1.0-1*rpm
2ff057
# Should not contain config files.
2ff057
run rpm -c -qp ${abs_builddir}/testing/build/RPMS/*/test-debuginfo-1.0-1*rpm
2ff057
],
2ff057
[0],
2ff057
[/etc/config.file
2ff057
],
2ff057
[ignore])
2ff057
AT_CLEANUP