epm-packages 1.86 KB
Newer Older
Danil Mikhailov's avatar
Danil Mikhailov committed
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
Danil Mikhailov's avatar
Danil Mikhailov committed
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.
Danil Mikhailov's avatar
Danil Mikhailov committed
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/>.
Danil Mikhailov's avatar
Danil Mikhailov committed
18 19
#

Danil Mikhailov's avatar
Danil Mikhailov committed
20
epm_packages()
Danil Mikhailov's avatar
Danil Mikhailov committed
21
{
22
	local CMD
Danil Mikhailov's avatar
Danil Mikhailov committed
23

Vitaly Lipatov's avatar
Vitaly Lipatov committed
24 25
case $PMTYPE in
	apt-rpm)
26
		CMD="rpm -qa $pkg_filenames"
27
		[ -n "$short" ] && CMD="rpm -qa --queryformat %{name}\n $pkg_filenames"
Danil Mikhailov's avatar
Danil Mikhailov committed
28
		;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
29
	apt-dpkg)
30
		CMD="dpkg -l $pkg_filenames"
31
		[ -n "$short" ] && CMD="dpkg-query -W --showformat=\${Package}\n $pkg_filenames"
Danil Mikhailov's avatar
Danil Mikhailov committed
32
		;;
33
	yum-rpm|urpm-rpm|zypper-rpm|dnf-rpm)
34
		CMD="rpm -qa $pkg_filenames"
35
		[ -n "$short" ] && CMD="rpm -qa --queryformat %{name}\n $pkg_filenames"
Danil Mikhailov's avatar
Danil Mikhailov committed
36
		;;
37
# Note: dnf has dnf list command
38 39 40
	emerge)
		CMD="qlist -I"
		;;
41
	pkgsrc)
42 43
		CMD="pkg_info"
		;;
44
	pacman)
45 46 47 48 49
		CMD="pacman -Qs $pkg_filenames"
		if [ -n "$short" ] ; then
			docmd $CMD | sed -e "s| .*||g" -e "s|.*/||g" | grep -v "^$"
			return
		fi
50
		;;
51
	npackd)
Vitaly Lipatov's avatar
Vitaly Lipatov committed
52 53
		CMD="npackdcl list --status=installed"
		# TODO: use search if pkg_filenames is not empty
54
		;;
55 56 57
#	chocolatey)
#		CMD="chocolatey list"
#		;;
58
	slackpkg)
59
		CMD="ls -1 /var/log/packages/"
Vitaly Lipatov's avatar
Vitaly Lipatov committed
60 61 62 63
		if [ -n "$short" ] ; then
			docmd ls -1 /var/log/packages/ | sed -e "s|-[0-9].*||g"
			return
		fi
64
		;;
65 66 67 68 69 70
	homebrew)
		CMD="brew $pkg_filenames"
		;;
	ipkg)
		CMD="ipkg list"
		;;
Danil Mikhailov's avatar
Danil Mikhailov committed
71
	*)
Vitaly Lipatov's avatar
Vitaly Lipatov committed
72
		fatal "Do not known query command for $PMTYPE"
Danil Mikhailov's avatar
Danil Mikhailov committed
73 74 75 76 77 78
		;;
esac

docmd $CMD

}