epm-search_file 1.99 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)
Vitaly Lipatov's avatar
Vitaly Lipatov committed
52 53
		# TODO
		info "Search by full packages list does not realized"
54
		CMD="yum provides"
55
		;;
56
	dnf-rpm)
Vitaly Lipatov's avatar
Vitaly Lipatov committed
57 58
		# TODO
		info "Search by full packages list does not realized"
59 60
		CMD="dnf provides"
		;;
61 62 63
	urpm-rpm)
		CMD="urpmf"
		;;
64
	zypper-rpm)
65 66
		CMD="zypper wp vi"
		;;
67 68 69
	pacman)
		CMD="pacman -Qo"
		;;
70
	slackpkg)
71
		CMD="/usr/sbin/slackpkg file-search"
72
		;;
73 74 75
	ipkg)
		CMD="ipkg search"
		;;
76 77 78 79
	aptcyg)
		docmd apt-cyg searchall $(echo " $pkg_filenames" | sed -e "s| /| |g")
		return
		;;
80
	*)
81
		fatal "Have no suitable search file command for $PMTYPE"
82 83 84 85 86 87
		;;
esac

docmd $CMD $pkg_filenames

}