epm-search_file 2.05 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
# TODO: port or rewrite apt-file
21 22 23 24 25 26 27 28 29 30
# https://bugzilla.altlinux.org/show_bug.cgi?id=14449
local_content_search()
{
    local SYSARCH
    SYSARCH=$(uname -m)
    [ "$SYSARCH" = "x86_64" ] || SYSARCH=i586

    local REPODIR=/var/ftp/pub/ALTLinux/Sisyphus
    local CI=$REPODIR/$SYSARCH/base/contents_index
    local CINOA=$REPODIR/noarch/base/contents_index
31 32 33
    #local OUTCMD="less"
    #[ -n "$USETTY" ] || OUTCMD="cat"
    OUTCMD="cat"
34 35 36 37 38

    test -r $CI && test -r $CINOA || fatal "Can't locate $CI or $CINOA"

    {
        [ -n "$USETTY" ] && echo "Search in $CI and $CINOA for $1..."
39
        grep -h -- ".*$1.*\t" $CI $CINOA | sed -e "s|\(.*\)\t\(.*\)|\2: \1|g"
40 41 42
    } | $OUTCMD
}

43 44
epm_search_file()
{
45 46
	local CMD
	[ -n "$pkg_filenames" ] || fatal "Run search without names"
47 48

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

docmd $CMD $pkg_filenames

}