Advertisement
sakuya-inu-izayoi

installsources.bash

Aug 27th, 2015
390
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.05 KB | None | 0 0
  1. #!/usr/bin/env bash
  2. # vim: set et sw=4 sts=4 :
  3.  
  4. if [ x$INSTALL_SOURCES = x ]
  5. then
  6.   exit 0
  7. fi
  8.  
  9. echo "Running installsources"
  10.  
  11. touch /tmp/installsources
  12.  
  13. save_elf_sources() {
  14.     local binary=$1
  15.     local sources_dir=/usr/src/debug/${CATEGORY}/${PF}
  16.  
  17.     debugedit -b "${WORKDIR}" -d "${sources_dir}" \
  18.         -l "${T}"/debug.sources "${binary}"
  19.     if [[ -s ${T}/debug.sources ]] ; then
  20.         [[ -d ${D}${sources_dir} ]] || mkdir -p "${D}${sources_dir}"
  21.         grep -zv '/<built-in>$' "${T}"/debug.sources | \
  22.             (cd "${WORKDIR}"; LANG=C sort -z -u | \
  23.             rsync -rtL0 --files-from=- "${WORKDIR}/" "${D}${sources_dir}/" 2>/dev/null )
  24.     fi
  25. }
  26.  
  27. for binary in \
  28.     $(scanelf -yqRBF '#k%F' -k '.symtab' "${D}")
  29. do
  30.     ftype=$(file "${binary}") || continue
  31.     [[ -z ${ftype} ]] && continue
  32.  
  33.     if [[ ${ftype} == *"SB executable"*
  34.         || ${ftype} == *"SB shared object"*
  35.         || ${ftype} == *"SB relocatable"* ]] ;
  36.     then
  37.         echo "   ${binary:${#D}}"
  38.         save_elf_sources "${binary}"
  39.     fi
  40. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement