epm-search_file 2.17 KB
Newer Older
1 2
#!/bin/sh
#
3 4
# Copyright (C) 2012, 2016  Etersoft
# Copyright (C) 2012, 2016  Vitaly Lipatov <lav@etersoft.ru>
5
#
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
__alt_local_content_search()
22
{
23 24
    load_helper epm-sh-altlinux

25
    info "Locate contents index file(s) ..."
26
    local CI="$(get_local_alt_contents_index)"
Vitaly Lipatov's avatar
Vitaly Lipatov committed
27
    # TODO use something like
Vitaly Lipatov's avatar
Vitaly Lipatov committed
28
    [ -n "$CI" ] || fatal "Have no local contents index"
29 30 31 32

    info "Searching in"
    echo "$CI"
    echo "for $1... "
33
    #[ -n "$USETTY" ] || OUTCMD="cat"
34
#    OUTCMD="cat"
35

36
#    {
37
        # note! tabulation below!
38 39
        __local_ercat $CI | grep -h -- ".*$1.*	" | sed -e "s|\(.*\)\t\(.*\)|\2: \1|g"
#    } | $OUTCMD
40 41
}

42 43
epm_search_file()
{
44
	local CMD
Vitaly Lipatov's avatar
Vitaly Lipatov committed
45
	[ -n "$pkg_filenames" ] || fatal "Search file: missing file name(s)"
46 47

case $PMTYPE in
48
	apt-rpm)
49
		__alt_local_content_search $pkg_filenames
50
		return ;;
Vitaly Lipatov's avatar
Vitaly Lipatov committed
51
	apt-dpkg|aptitude-dpkg)
52
		assure_exists apt-file
53
		sudocmd apt-file update
54 55 56
		docmd apt-file search $pkg_filenames
		return ;;
	yum-rpm)
Vitaly Lipatov's avatar
Vitaly Lipatov committed
57
		# TODO
58
		info "Search by full packages list is not implemented yet"
59
		CMD="yum provides"
60
		;;
61
	dnf-rpm)
Vitaly Lipatov's avatar
Vitaly Lipatov committed
62
		# TODO
63
		info "Search by full packages list i snot implemented yet"
64 65
		CMD="dnf provides"
		;;
66 67 68
	urpm-rpm)
		CMD="urpmf"
		;;
69
	zypper-rpm)
70 71
		CMD="zypper wp vi"
		;;
72 73 74
	pacman)
		CMD="pacman -Qo"
		;;
75
	slackpkg)
76
		CMD="/usr/sbin/slackpkg file-search"
77
		;;
78 79 80
	ipkg)
		CMD="ipkg search"
		;;
81 82 83
	xbps)
		CMD="xbps-query -Ro"
		;;
84 85 86 87
	aptcyg)
		docmd apt-cyg searchall $(echo " $pkg_filenames" | sed -e "s| /| |g")
		return
		;;
88
	*)
89
		fatal "Have no suitable search file command for $PMTYPE"
90 91 92 93 94 95
		;;
esac

docmd $CMD $pkg_filenames

}