View Single Post
Old 12th June 2019
brudan brudan is offline
Fdisk Soldier
 
Join Date: Dec 2018
Posts: 82
Default

I wrote a little shell script that tells me why a particular package was installed (manual vs. automatic) and which other packages depend on it, if any. Here it is in case it is of use to anyone:

Code:
#!/bin/sh

cd /var/db/pkg

grep -q '@option manual-installation' ${1}-*/+CONTENTS 2>/dev/null
result=$?
case $result in
	0)	echo "Manually installed." ;;
	1)	echo "Automatically installed." ;;
	2)	echo "Not installed."; exit ;;
esac

if grep -q -r "@depend .*:${1}-" *; then
	echo "The following packages depend on it:"
	grep -r "@depend .*:${1}-" * | awk -F'/' '{print $1}' | uniq
else
	echo "No packages depend on it."
fi
To use it, save the script somewhere in your PATH, name it why and make it executable. Here is an example run:

Code:
bruno@thinkpad:~$ why ffmpeg
Manually installed.
The following packages depend on it:
mplayer-20190330p0
mpv-0.29.1
I choose ffmpeg as an example on purpuse: It shows the unusual situation where a manually-installed package also happens to be a dependency of other packages.

Last edited by brudan; 18th June 2019 at 06:28 PM.
Reply With Quote