epm-requires 1.48 KB
Newer Older
1 2 3 4 5
#!/bin/sh
#
# Copyright (C) 2012  Etersoft
# Copyright (C) 2012  Vitaly Lipatov <lav@etersoft.ru>
#
6 7 8
# 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
9 10 11 12 13
# (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
14
# GNU Affero General Public License for more details.
15
#
16 17
# 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/>.
18 19 20 21
#

epm_requires()
{
22 23
	local CMD
	[ -n "$pkg_filenames" ] || fatal "Run query without names"
24

25
# by package file
26 27 28 29 30 31
case $PMTYPE in
	apt-rpm|urpm-rpm|zypper-rpm|yum-rpm)
		CMD="rpm -q --requires -p"
		;;
	apt-dpkg)
		showcmd dpkg -s $pkg_files
Vitaly Lipatov's avatar
Vitaly Lipatov committed
32
		a= dpkg -s $pkg_names | grep "^Depends:" | sed "s|^Depends:||g"
33 34 35 36 37 38 39 40 41
		return
		;;
	*)
		fatal "Do not known command for $PMTYPE"
		;;
esac

[ -n "$pkg_files" ] && docmd $CMD $pkg_files

42
# by package name
43 44 45 46 47 48 49 50
case $PMTYPE in
	apt-rpm|urpm-rpm|zypper-rpm)
		# FIXME: use hi level commands
		CMD="rpm -q --requires"
		;;
	yum-rpm)
		CMD="yum deplist"
		;;
51 52 53
	pacman)
		CMD="pactree"
		;;
54 55 56 57 58 59 60 61 62 63 64 65
	apt-dpkg)
		CMD="apt-cache depends"
		;;
	*)
		fatal "Do not known command for $PMTYPE"
		;;
esac


[ -n "$pkg_names" ] && docmd $CMD $pkg_names

}