epm-whatdepends 2.24 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
Vitaly Lipatov's avatar
Vitaly Lipatov committed
27
	[ -n "$pkg_files" ] && fatal "whatdepends does not handle files"
Vitaly Lipatov's avatar
Vitaly Lipatov committed
28
	[ -n "$pkg_names" ] || fatal "whatdepends: package name is missed"
29
	local pkg=$(print_name $pkg_names)
30 31 32

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

91
docmd $CMD $pkg
92 93

}