- #!/usr/bin/ksh93
- #
- # xorg_proc_package_list.ksh - get list of packages used by Xorg process
- #
- #
- #
- set -o xtrace
- set -o errexit
- set -o nounset
- #
- # builtins&vars
- #
- builtin cat
- typeset s1
- typeset s2
- typeset -a a1
- compound c=(
- integer xorg_pid
- typeset -a mapped_files_ar
- typeset -A package_list
- )
- c.xorg_pid="$(pgrep Xorg)"
- c.mapped_files_ar=(
- $(
- cat "/proc/${c.xorg_pid}/maps" | \
- sed -r 's/[[:xdigit:]]+?-[[:xdigit:]]+? [rwxp-]+ [[:xdigit:]]+? .+? (\/.+?$)/\1/' | \
- egrep '^/' |
- sort -u
- )
- )
- for s1 in "${c.mapped_files_ar[@]}" ; do
- s1="$(apt-file search "$s1" 2>'/dev/null' || true)"
- [[ $s1 != '' ]] || continue
- # apt-file can return multiple results, one per line
- # we stuff them into the array a1 here and then
- # process them one-by-one
- IFS=$'\n'
- a1=( $s1 )
- IFS=$' \t\n' # restore
- printf $"# apt-file %d results\n" "${#a1[@]}"
- for s2 in "${a1[@]}" ; do
- # extract package name
- s2="${s2/~(El)(.+?):.+/\1}"
- # add result, use package name as index to eliminate duplicates
- c.package_list["$s2"]="$s2"
- done
- done
- #
- # debug data
- #
- print -v c
- #
- # print results
- #
- printf "# Package list:\n"
- printf "%s\n" "${c.package_list[@]}"
- # EOF.
Xorg: print Debian packages used by Xorg process
Posted by Anonymous on Mon 2nd May 2022 17:39
raw | new post
modification of post by Anonymous (view diff)
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.