| 1 | #!/usr/bin/env bash |
|---|
| 2 | # vim: set et sw=4 sts=4 : |
|---|
| 3 | |
|---|
| 4 | echo "Running installsources" |
|---|
| 5 | |
|---|
| 6 | touch /tmp/installsources |
|---|
| 7 | |
|---|
| 8 | save_elf_sources() { |
|---|
| 9 | local binary=$1 |
|---|
| 10 | local sources_dir=/usr/src/debug/${CATEGORY}/${PF} |
|---|
| 11 | |
|---|
| 12 | debugedit -b "${WORKDIR}" -d "${sources_dir}" \ |
|---|
| 13 | -l "${T}"/debug.sources "${binary}" |
|---|
| 14 | if [[ -s ${T}/debug.sources ]] ; then |
|---|
| 15 | [[ -d ${D}${sources_dir} ]] || mkdir -p "${D}${sources_dir}" |
|---|
| 16 | grep -zv '/<built-in>$' "${T}"/debug.sources | \ |
|---|
| 17 | (cd "${WORKDIR}"; LANG=C sort -z -u | \ |
|---|
| 18 | rsync -rtL0 --files-from=- "${WORKDIR}/" "${D}${sources_dir}/" ) |
|---|
| 19 | fi |
|---|
| 20 | } |
|---|
| 21 | |
|---|
| 22 | for binary in \ |
|---|
| 23 | $(scanelf -yqRBF '#k%F' -k '.symtab' "${D}") |
|---|
| 24 | do |
|---|
| 25 | ftype=$(file "${binary}") || continue |
|---|
| 26 | [[ -z ${ftype} ]] && continue |
|---|
| 27 | |
|---|
| 28 | if [[ ${ftype} == *"SB executable"* |
|---|
| 29 | || ${ftype} == *"SB shared object"* |
|---|
| 30 | || ${ftype} == *"SB relocatable"* ]] ; |
|---|
| 31 | then |
|---|
| 32 | echo " ${binary:${#D}}" |
|---|
| 33 | save_elf_sources "${binary}" |
|---|
| 34 | fi |
|---|
| 35 | done |
|---|