pastebin - collaborative debugging tool
rovema.kpaste.net RSS


Xorg: print Debian packages used by Xorg process
Posted by Anonymous on Mon 2nd May 2022 13:03
raw | new post
view followups (newest first): Xorg: print Debian packages used by Xorg process by Anonymous
modification of post by Anonymous (view diff)

  1. #!/usr/bin/ksh93
  2.  
  3. #
  4. # xorg_proc_package_list.ksh - get list of packages used by Xorg process
  5. #
  6. #
  7. #
  8.  
  9. set -o xtrace
  10. set -o errexit
  11. set -o nounset
  12.  
  13. #
  14. # builtins&vars
  15. #
  16. builtin cat
  17. typeset s1
  18. typeset s2
  19.  
  20. compound c=(
  21.         integer xorg_pid
  22.         typeset -a mapped_files_ar
  23.         typeset -A package_list
  24. )
  25.  
  26. c.xorg_pid="$(pgrep Xorg)"
  27.  
  28. c.mapped_files_ar=(
  29.         $(
  30.                 cat "/proc/${c.xorg_pid}/maps" | \
  31.                 sed -r 's/[[:xdigit:]]+?-[[:xdigit:]]+? [rwxp-]+ [[:xdigit:]]+? .+? (\/.+?$)/\1/' | \
  32.                 egrep '^/' |
  33.                 sort -u
  34.         )
  35. )
  36.  
  37. for s1 in "${c.mapped_files_ar[@]}" ; do
  38.         s2="$(apt-file search "$s1" 2>'/dev/null' || true)"
  39.         [[ $s2 != '' ]] || continue
  40.        
  41.         # extract package name
  42.         s2="${s2/~(El)(.+?):.+/\1}"
  43.  
  44.         # add result, use package name as index to eliminate duplicates
  45.         c.package_list["$s2"]="$s2"
  46. done
  47.  
  48. #
  49. # debug data
  50. #
  51. print -v c
  52.  
  53. #
  54. # print results
  55. #
  56. printf "# Package list:\n"
  57. printf "%s\n" "${c.package_list[@]}"
  58.  
  59. # EOF.

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}




All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at