pastebin - collaborative debugging tool
rovema.kpaste.net RSS

Difference between
modified post 31751d by Anonymous on Mon 2nd May 2022 13:03
original post d056 by Anonymous on Mon 2nd May 2022 12:55
Download diff
Show old version | new version | both versions

    
11
#!/usr/bin/ksh93
22
33
#
44
# xorg_proc_package_list.ksh - get list of packages used by Xorg process
55
#
66
#
77
#
88
99
set -o xtrace
1010
set -o errexit
1111
set -o nounset
1212
1313
#
1414
# builtins&vars
1515
#
1616
builtin cat
1717
typeset s1
1818
typeset s2
1919
2020
compound c=(
2121
	integer xorg_pid
2222
	typeset -a mapped_files_ar
2323
	typeset -A package_list
2424
)
2525
2626
c.xorg_pid="$(pgrep Xorg)"
2727
2828
c.mapped_files_ar=(
2929
	$(
3030
		cat "/proc/${c.xorg_pid}/maps" | \
3131
		sed -r 's/[[:xdigit:]]+?-[[:xdigit:]]+? [rwxp-]+ [[:xdigit:]]+? .+? (\/.+?$)/\1/' | \
3232
		egrep '^/' |
3333
		sort -u
3434
	)
3535
)
3636
3737
for s1 in "${c.mapped_files_ar[@]}" ; do
3838
	s2="$(apt-file search "$s1" 2>'/dev/null' || true)"
3939
	[[ $s2 != '' ]] || continue
4040
41+
	# extract package name
4142
	s2="${s2/~(El)(.+?):.+/\1}"
4243
4344
	# add result, use package name as index to eliminate duplicates
4445
	c.package_list["$s2"]="$s2"
4546
done
4647
4748
#
4849
# debug data
4950
#
5051
print -v c
5152
5253
#
5354
# print results
5455
#
5556
printf "# Package list:\n"
5657
printf "%s\n" "${c.package_list[@]}"
5758
5859
# EOF.
5960

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