epm-search_file 1.77 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
__alt_local_content_search()
21
{
22 23 24
    load_helper epm-sh-altlinux

    local CI="$(get_local_alt_contents_index)"
25

26 27 28
    #local OUTCMD="less"
    #[ -n "$USETTY" ] || OUTCMD="cat"
    OUTCMD="cat"
29 30

    {
31
        [ -n "$USETTY" ] && echo "Search in $CI for $1..."
32 33
        # note! tabulation below!
        grep -h -- ".*$1.*	" $CI | sed -e "s|\(.*\)\t\(.*\)|\2: \1|g"
34 35 36
    } | $OUTCMD
}

37 38
epm_search_file()
{
39
	local CMD
Vitaly Lipatov's avatar
Vitaly Lipatov committed
40
	[ -n "$pkg_filenames" ] || fatal "Search file: missing file name(s)"
41 42

case $PMTYPE in
43
	apt-rpm)
44
		__alt_local_content_search $pkg_filenames
45
		return ;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
46
	apt-dpkg|aptitude-dpkg)
47
		assure_exists apt-file
48
		sudocmd apt-file update
49 50 51
		docmd apt-file search $pkg_filenames
		return ;;
	yum-rpm)
52
		CMD="yum provides"
53
		;;
54 55 56
	dnf-rpm)
		CMD="dnf provides"
		;;
57 58 59
	urpm-rpm)
		CMD="urpmf"
		;;
60
	zypper-rpm)
61 62
		CMD="zypper wp vi"
		;;
63 64 65
	pacman)
		CMD="pacman -Qo"
		;;
66
	slackpkg)
67
		CMD="/usr/sbin/slackpkg file-search"
68
		;;
69 70 71
	ipkg)
		CMD="ipkg search"
		;;
72
	*)
73
		fatal "Have no suitable search file command for $PMTYPE"
74 75 76 77 78 79
		;;
esac

docmd $CMD $pkg_filenames

}