2020-10-15 16:36:07 +00:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# shim-find-debuginfo.sh
|
|
|
|
# Copyright (C) 2017 Peter Jones <Peter Jones@random>
|
|
|
|
#
|
|
|
|
# Distributed under terms of the GPLv3 license.
|
|
|
|
#
|
|
|
|
set -e
|
|
|
|
set -u
|
|
|
|
|
|
|
|
mainarch=$1 && shift
|
|
|
|
if [ $# == 1 ]; then
|
|
|
|
altarch=$1 && shift
|
|
|
|
fi
|
|
|
|
if ! [ -v RPM_BUILD_ROOT ]; then
|
|
|
|
echo "RPM_BUILD_ROOT must be set" 1>&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
findsource()
|
|
|
|
{
|
|
|
|
(
|
2021-08-06 19:33:22 +00:00
|
|
|
cd "${RPM_BUILD_ROOT}"
|
|
|
|
find usr/src/debug/ -type d | sed -e "s,^,%dir /," | sort -u | tac
|
|
|
|
find usr/src/debug/ -type f | sed -e "s,^,/," | sort -u | tac
|
2020-10-15 16:36:07 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
finddebug()
|
|
|
|
{
|
|
|
|
arch=$1 && shift
|
|
|
|
declare -a dirs=()
|
|
|
|
declare -a files=()
|
|
|
|
declare -a excludes=()
|
2021-08-06 19:33:22 +00:00
|
|
|
declare -a tmp=()
|
2020-10-15 16:36:07 +00:00
|
|
|
|
2021-08-06 19:33:22 +00:00
|
|
|
pushd "${RPM_BUILD_ROOT}" >/dev/null 2>&1
|
|
|
|
|
|
|
|
mapfile -t tmp < <(find usr/lib/debug/ -type f -iname "*.efi.debug")
|
|
|
|
for x in "${tmp[@]}" ; do
|
2020-10-15 16:36:07 +00:00
|
|
|
if ! [ -e "${x}" ]; then
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
if [[ ${x} =~ ${arch}\.efi\.debug$ ]]; then
|
|
|
|
files[${#files[@]}]=${x}
|
|
|
|
else
|
|
|
|
excludes[${#excludes[@]}]=${x}
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
for x in usr/lib/debug/.build-id/*/*.debug ; do
|
|
|
|
if ! [ -e "${x}" ]; then
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
link=$(readlink "${x}")
|
|
|
|
if [[ ${link} =~ ${arch}\.efi\.debug$ ]]; then
|
|
|
|
files[${#files[@]}]=${x}
|
|
|
|
files[${#files[@]}]=${x%%.debug}
|
|
|
|
else
|
|
|
|
excludes[${#excludes[@]}]=${x}
|
|
|
|
excludes[${#excludes[@]}]=${x%%.debug}
|
|
|
|
fi
|
|
|
|
done
|
2021-08-06 19:33:22 +00:00
|
|
|
for x in "${files[@]}" ; do
|
|
|
|
declare name
|
|
|
|
|
|
|
|
name=$(dirname "/${x}")
|
2020-10-15 16:36:07 +00:00
|
|
|
while [ "${name}" != "/" ]; do
|
|
|
|
case "${name}" in
|
|
|
|
"/usr/lib/debug"|"/usr/lib"|"/usr")
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
dirs[${#dirs[@]}]=${name}
|
|
|
|
;;
|
|
|
|
esac
|
2021-08-06 19:33:22 +00:00
|
|
|
name=$(dirname "${name}")
|
2020-10-15 16:36:07 +00:00
|
|
|
done
|
|
|
|
done
|
|
|
|
|
|
|
|
popd >/dev/null 2>&1
|
2021-08-06 19:33:22 +00:00
|
|
|
for x in "${dirs[@]}" ; do
|
2020-10-15 16:36:07 +00:00
|
|
|
echo "%dir ${x}"
|
|
|
|
done | sort | uniq
|
2021-08-06 19:33:22 +00:00
|
|
|
for x in "${files[@]}" ; do
|
2020-10-15 16:36:07 +00:00
|
|
|
echo "/${x}"
|
|
|
|
done | sort | uniq
|
2021-08-06 19:33:22 +00:00
|
|
|
for x in "${excludes[@]}" ; do
|
2020-10-15 16:36:07 +00:00
|
|
|
echo "%exclude /${x}"
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2021-08-06 19:33:22 +00:00
|
|
|
findsource > "build-${mainarch}/debugsource.list"
|
|
|
|
finddebug "${mainarch}" > "build-${mainarch}/debugfiles.list"
|
2020-10-15 16:36:07 +00:00
|
|
|
if [ -v altarch ]; then
|
2021-08-06 19:33:22 +00:00
|
|
|
finddebug "${altarch}" > "build-${altarch}/debugfiles.list"
|
2020-10-15 16:36:07 +00:00
|
|
|
fi
|