epm-whatdepends 1.92 KB
Newer Older
1 2
#!/bin/sh
#
Vitaly Lipatov's avatar
Vitaly Lipatov committed
3 4
# Copyright (C) 2013, 2016, 2018  Etersoft
# Copyright (C) 2013, 2016, 2018  Vitaly Lipatov <lav@etersoft.ru>
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

20 21
# TODO: will it has local only mode?

22 23
load_helper epm-print

24 25 26
epm_whatdepends()
{
	local CMD
27 28 29
	[ -n "$pkg_files" ] && fatal "whatdepends do not handle files"
	[ -n "$pkg_names" ] || fatal "whatdepends: missing package(s) name"
	local pkg=$(print_name $pkg_names)
30 31 32

# by package name
case $PMTYPE in
33
	apt-rpm)
34 35 36 37 38
		if [ -n "$short" ] ; then
			showcmd apt-cache whatdepends $pkg
			a= apt-cache whatdepends $pkg | grep "^  [^ ]" | sed -e "s|[0-9]*:||" | grep -E -v "(i586-|-debuginfo)"
			return
		fi
39
		CMD="apt-cache whatdepends"
40
		;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
41
	apt-dpkg|aptitude-dpkg)
42 43
		CMD="apt-cache rdepends"
		;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
44 45 46
	aptitude-dpkg)
		CMD="aptitude why"
		;;
47 48 49
	packagekit-*)
		CMD="pkcon depends-on"
		;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
50 51 52
	yum-rpm)
		CMD="repoquery --whatrequires"
		;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
53 54 55
	urpm-rpm)
		CMD="urpmq --whatrequires"
		;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
56
	dnf-rpm)
57
		# check command: dnf repoquery --whatrequires
Vitaly Lipatov's avatar
Vitaly Lipatov committed
58 59
		CMD="repoquery --whatrequires"
		;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
60
	emerge)
61
		assure_exists equery
Vitaly Lipatov's avatar
Vitaly Lipatov committed
62 63
		CMD="equery depends -a"
		;;
64 65 66
	homebrew)
		CMD="brew uses"
		;;
67 68 69
	pkgng)
		CMD="pkg info -r"
		;;
70 71 72
	aptcyg)
		CMD="apt-cyg rdepends"
		;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
73 74 75
	opkg)
		CMD="opkg whatdepends"
		;;
76 77 78
	xbps)
		CMD="xbps-query -X"
		;;
79
	*)
80
		fatal "Have no suitable command for $PMTYPE"
81 82 83
		;;
esac

84
docmd $CMD $pkg
85 86

}